GSBase was written by Mike Bowler of Gargoyle Software and has been released under an apache style license

GSBase in the news

Test Driven Development: A practical guide by Dave Astels has a section covering the test related classes in GSBase with various example of how to use each.

JUnit Recipes by J.B. Rainsberger has an entire chapter devoted to the GSBase testing classes.



A collection of classes that are helpful when writing JUnit test cases.

RecursiveTestSuite is a TestSuite that will recursively walk through the directory structure looking for subclasses of TestCase and will add them. If you start a TestRunner with this class then it will recursively find all available tests and run them. Very handy for those people, like myself, who are too lazy to maintain nested suite() methods throughout the test cases.

OrderedTestSuite is for those situations where you want to specify the order that the tests will run but you want to make sure that you haven't accidentally missed any tests.

EventCatcher can register itself for any events that might be fired by a given bean. Primarily intended for testing custom gui components but can be used to test any bean that fires events.

EqualsTester is used to test the equals contract on objects. The contract as specified by java.lang.Object states that if A.equals(B) is true then B.equals(A) is also true. It also specifies that if A.equals(B) is true then A.hashCode() will equals B.hashCode(). It is also common practice to implement equals using an instanceof check which will result in false positives in some cases. EqualsTester ensures that the equals() and hashCode() methods have been implemented correctly.

BaseTestCase is the common superclass that all of the GSBase test cases inherit from. It includes common methods that we would like to see in junit.framework.TestCase.

See com.gargoylesoftware.base.testing

Tracing / Logging

This is a logging subsystem. At the simplest level, you can just call Trace.print(String) or Trace.println(String) or Trace.printStackTrace(Throwable) to log information. The actual logging will occur on a background thread which makes the logging appear significantly faster than just calling System.out.println(String).

See com.gargoylesoftware.base.trace.Trace

See com.gargoylesoftware.base.trace


TableLayout is a complex layout manager that is suitable as a replacement for GridBagLayout. This was originally written because the author was frustrated with the ugly interface and performance problems associated with GridBagLayout.

The TableLayoutDebuggingPanel is a subclass of JPanel that visually shows the layout grid and is very useful for debugging layout problems. It can be used with any layout manager but will only draw the grid lines when used with TableLayout.

See com.gargoylesoftware.base.gui.TableLayout

See com.gargoylesoftware.base.gui.TableLayoutConstraints

See com.gargoylesoftware.base.gui.TableLayoutDebuggingPanel

ObjectStore and resource management

ObjectStore is a way of encapsulating data access objects in such a way that automatic cleanup of resources occurs.

ResourceFactory is a factory object that can allocate specific resources such as jdbc connections. ResourceManager is a "view" onto a set of resource factories that can be manipulated as a group.

See com.gargoylesoftware.base.objectstore.ObjectStore

See com.gargoylesoftware.base.resource.ResourceFactory

See com.gargoylesoftware.base.resource.ResourceManager


ConnectionWrapper is a wrapper for sql connection objects that provides defined semantics when objects are closed out of order (ie connections before statements)

See com.gargoylesoftware.base.resource.ConnectionWrapper


CondensedObjectOutputStream is a specialized subclass of ObjectOutputStream that is used to serialize objects. This stream will remove duplicate objects from the stream in order to shrink the resulting byte stream.



NotificationList is a List that fires events when it is modified.

See com.gargoylesoftware.base.collections.NotificationList


AbstractUIController is a base class for a general controller object for gui development. Swing is closely modelled after the Model-View-Controller (MVC) pattern where the model, view and controller portions are kept seperate from each other. This class provides some common behaviour for controller objects. For the record, Swing actually uses the "Seperable Model Architecture" which is similar to MVC but is different in a couple of key ways.

See com.gargoylesoftware.base.gui.AbstractUIController

See com.gargoylesoftware.base.gui.WorkerTask


ReflectedAction is a Swing "action" that uses reflection to call a specific target method when the action is fired. Actions are often implemented using inner classes which can be very inefficient in terms of performance and deployment size. This action is a tiny bit slower when it is actually fired but is smaller and generally faster otherwise due to the fact that those inner classes are no longer needed.

See com.gargoylesoftware.base.gui.ReflectedAction


This table model uses reflection to pull values out of a list of objects which makes it easy to quickly populate a table.

See com.gargoylesoftware.base.gui.ReflectedTableModel

Delayed component loading

The DelayedComponentLoaderPanel is a panel that can load expensive components on a background thread while displaying some kind of "please wait" message. When the component is fully loaded, it is automatically displayed.

ComponentLoader is an interface for objects that can perform the component loading. DefaultComponentLoader is a default implementation that uses reflection to load the components.

See com.gargoylesoftware.base.gui.DelayedComponentLoaderPanel

See com.gargoylesoftware.base.gui.ComponentLoader

See com.gargoylesoftware.base.gui.DefaultComponentLoader

Directory walker

DirectoryWalker is used to recursively find all files and/or directories on some part of the file system. For example, find all the *.java files for a specific project.

See com.gargoylesoftware.base.util.DirectoryWalker

Utility classes

StringUtil has methods for splitting and joining strings and other string related tasks. DocumentUtil has methods for dealing with Swing documents. ProxyUtil has methods for creating proxy objects.

See com.gargoylesoftware.base.util

See com.gargoylesoftware.base.util.StringUtil

See com.gargoylesoftware.base.util.DocumentUtil

See com.gargoylesoftware.base.util.ProxyUtil