Developer's Daily Java Education - Test Projects
  front page | java | perl | unix | DevDirectory
   
Front Page
Java
Education
   
 

 

ConstructorOrder

This is a fun little test that looks at the order in which constructors are called. It includes one class named ChildClass, and another named ParentClass. Hopefully the intent of these classes are obvious from their names -- the ChildClass is a child class of the ParentClass.

The question for you is this: Without running the program and looking at its output, do you know the order in which the constructors are called?


DirectoryTest

This is a simple test program that shows how to get a listing of files in a directory, sort that list, and then print the sorted list.


DogFactory

This is a simple test project, demonstrating how to implement the Factory Design Pattern in Java. The project contains a Dog base class, as well as sub-classes such as Rottweiler, Poodle, and Husky, as well as a DogFactory.


ExceptionThrowingTest

Here's a simple example of how to create your own Exception, and use it in a Java program, in particular within the context of a try/catch block. I've created my own exception named NoNameException, and can throw it from the getName() method in the User class.


GE_Pizza

A small project to start looking at Pizzas and Toppings, two of my favorite subjects. :)


Inheritance

Another look at inheritance. This time the comparison is between Animals, Dogs, and Birds. Note how both fido and bigbird are Animals (and not a Dog and Bird, respectively.)


JTidyTests


JUnitTemplatesForJBuilder

This project really just contains several templates I use for JUnit testing inside of JBuilder. I integrate these into my JBuilder environment by selecting Tools | Editor Options | Templates, then adding the contents of these files as templates.

By doing this, I can easily create stub code for unit tests in JBuilder by invoking these with JBuilder [Ctrl]-J shortcut. Any time I want to create a new unit test, I don't need to remember any unusual syntax ... I just create the stub with the template, then edit it from there.

Note that there are three different templates:

  • AllTests is a template that can be used to run all of your JUnit tests.
  • JunitTemplate is the template that I use for most unit tests.
  • JunitDBTemplate is the template I use for creating JUnit tests that involve database access.

Hopefull you will find these templates as helpful as I do.


JavaTests

I'm doing some crazy things here, testing number formatting in one file, random numbers in another file, and in another file I started creating a program to convert Unix/Linux files to DOS format.


Javadoc

Nothing too exciting here. Just a little demonstration of how to use basic Javadoc tags, and the output that these tags produce when you run the javadoc command on the Java file(s).


Jget

JGet is a simple program that I use to retrieve a web page from a web site. What happened is that I was working at a customer site that uses the horrible WebSense software to block the URLs that I am allowed to visit during the day. The first thing I did was look for wget on one of our servers, but when I couldn't locate it I wrote this little program. I use it to get certain URLs during the day, then took it a step farther and now email the contents of those URLs to my mailbox.


MemoryEater

A very simple program that tries to consume as much memory in the computer as it can. To do this, it allocates memory in 1 MB byte arrays. Note that you will need to also use the -Xmx Java runtime parameter to get this to consume more memory than the default.


MemoryLeakTester

In this test case, I've implemented some code that I found referred to in a book, although I can't remember the name of the book at the time of this writing. The purpose of this test code is to look at how the author of the book thought it was possible to create a memory leak in Java by creating references that the garbage collector could not reclaim.


PostgresConnectionTest

Here's a simple demo of how to connect to a sample PostgreSQL (Postgres) database. Note that it assumes that you have a PostgreSQL database driver correclty installed. It's not too important, but I used the driver in jdbc7.0-1.2.jar for this test.


RegularExpressionTests

These are some old regular expression tests using the ORO package. Note that I know use the regular expression package included with JDK/JVM 1.4.x.


SocketTest

I don't remember the exact reason for this test, but it is makes for a nice little example of how to open a Java Socket.


StaticClassRamUsage

A test of when a static class is instantiated and when it is garbage collected. Heavily documented with println()'s so you can see when different parts of the code are executed.


StrutsTestProject

The basic idea here is that Struts is very difficult to get started with, so I created a little sample project that helps me start new Struts projects. Actually, I went a little bit farther than that, and also created a simple directory structure that can help you deploy your Struts projects using Ant.


Telephone

A simple little test project to convert phone numbers like 1-800-GO-FEDEX to their numerical equivalent. I actually started this project when I first got involved with unit testing. I was trying to think of little projects I could use to get started with unit testing, and this one came to mind for some reason.


WorkingBackwards

This project is a little hard to explain, and indeed is worth a full article. Basically, I read an article in an Extreme Programming book titled "Working Backwards" (with unit testing). I like the concept so much I decided to do a seminar on the subject. These are the working files from that seminar.

Note that these files by themselves may be confusing, but I thought I would at least try to share them. Hopefully some day I will have more time to write about this subject and explain this in more detail.


 
Copyright 1998-2003 DevDaily Interactive, Inc.
All Rights Reserved.