Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

Here's a "generic" version of a simple test plan I just wrote for testing one wizard in a GUI software application my team is currently developing. I wrote this for one specific wizard, then realized that many of these tests are generically-applicable to all wizards.

Without any further introduction, here is my sample test plan. Feel free to use it as a template for creating your own test plans.

I get the following error messages some times when running JRuby scripts:

For some reason I didn't work w/ the Mac much until last year. Actually, to be fair to myself, a lot of that probably had to do with unpleasant experiences with earlier versions of the Mac OS.

But as I was talking to a co-worker this morning I realized that it was a mistake not to spend some quality time with Mac OS X when it came out. Having worked with it for over a year now I've come to take many things for granted that it can do. The discussion this morning had to do with the power of scripting native Mac applications with AppleScript.

Here's a sample Ruby mail program that I created that finds and prints all of the unique email addresses in my IMAP inbox. Hopefully the source code is readable enough that it doesn't need much description. The only hard part is trying to figure out how to get the email address from the Envelope, and that's only because the documentation is hard to find.

Ruby mail program

Here's my Ruby IMAP mail program source code:

Here's a Ruby "read file" example program that shows how to read a file as one string. You just have to pass a file name in to the get_file_as_string method, and this Ruby method will read in all the records from the file, and return the contents of the file as a string.

Writing software is a funny thing. You do something one day and you think it's really cool, then come back another day and go "WTF was I thinking?", so you tear it apart and rewrite it.

Today I ran the JRat Java profiler (Runtime Analysis Toolkit) on some code I wrote about 10 days ago, and it showed that I was looking for a pixel 10,000,000+ times on a 1024x768 resolution image.

Linux wget command FAQ: Can you share an example of a wget command used in a Linux shell script?

Here's a Unix/Linux shell script that I created to download a specific URL on the internet every day using the wget command. Note that I also use the date command to create a dynamic filename, which I'll describe shortly.

Cygwin crontab FAQ: How do I get the crontab system started when using Cygwin?

I can't remember where I found it, but using this series of commands from the Cygwin prompt got the Cygwin crontab system enabled for me. First this command:

cygrunsrv -I cron -p /usr/sbin/cron -a -D

followed by:

net start cron

I haven't used this cygwin feature before, so it feels weird knowing that crontab is running on my Windows system under cygwin.

The grand experiment has begun. The problem: I've been on a project developing a very deep application for four years now, and lately it's become so complex and intertwined that things are starting to break. Developers have been known to say "The application is smarter than I am." I'm just a wee bit concerned about our software quality.

Throughout all of this I started to notice that many of these bugs could be found if we had ... (drumroll) ... automated GUI tests.

I still have a lot to learn about Ruby, but here's a Ruby script that runs a series of system commands (Kernel.system()), which in my case means calling a series of JRuby scripts. I send all of the output from this script and from the system calls to a file by (a) writing directly to the file using Ruby and (b) redirecting STDOUT when making each system() call. I think this is a hack, but I can't find a better way to redirect STDOUT.

I'm doing some crazy things at the moment, basically calling JRuby from a Ruby script on a Windows 2000 system. I'm doing this because there are a bunch of JRuby scripts that I want to run sequentially, and I also want to check for errors after each run, so what better way to invoke them and look for resulting errors than with Ruby, especially on a Windows system? :)

Here's some sample JRuby code that I just used to take a screenshot of my desktop. It uses the Toolkit and Robot classes from Java to make it all happen. It could probably be a little shorter, but I don't know much about JRuby yet. I also had a problem getting the Java File class to work properly, and referencing it as shown was the only way I could get it to work.

Here's some sample code that demonstrates how to use the Java JOptionPane showConfirmDialog method. I've included the method call in the context of a real containing method (doExitAction()) so you can see how it might be used in real-world code.

Here's another one of those postings that are just here to help my bad memory. I currently travel a fair amount, work on different systems and projects, and can't remember the Java syntax for adding a Java ActionListener to a JButton, so here's a little sample code to help me remember:

This isn't the most high-tech way to do things, but I thought I'd share these Windows (DOS) shell scripts that I'm currently using to compile a Java application, create a Jar file to distribute the application, and finally run the application. I ended up creating these scripts because of configuration problems on my Windows PC, but I thought they might be useful samples for others.

Here's a "Java clipboard" method I use when writing a Java/Swing program that needs to place plain text (a String) on the system clipboard:

Earlier tonight I installed JRuby on a Windows XP system, and it was about as easy as anything I've installed. Here were the steps on my computer:

You know what will really screw with your mind? When there is a 1.4.2 version of a java.exe file in the C:\Windows\System32 directory of your Windows XP system, and you're trying to compile and run a Java 1.5 program from the command line. I kept getting this error message and couldn't figure it out, even though I knew what it meant(!):

This is just my second JRuby program, but I thought I might as well go for the gusto. This Ruby/JRuby program creates an instance of a Java Robot class (java.awt.Robot), then moves the mouse to a position where it clicks the Minimize button on a full-screen window (assuming a display resolution of 1024x768). Warning: if you have something else in that location it will click that instead!

Here's the Ruby/JRuby code:

Nothing too major today, I just wanted to note this site that features stylized line drawings. I like this form of art, and didn't want to forget the name/type, as well as this artist.