When we write our server code in Java, we have easy access to dynamic loading on a very granular scale. This dynamic loading is the key to a solution for our testing challenge. A few lines of extra code in the server enables thorough testing of the server while the server is running. A test sequence we wish to perform can be placed in a test class which the server can be directed to dynamically load and execute by name.
Figure 1 shows a set of objects within a CORBA server. The lollipop or jack is a simple way to denote an interface -- a set
of related operations. The arrow flowing into the jack shows usage of that interface. Imagine an object on the server side
that is not directly exposed to the ORB. In this figure, you'll find just such an object, an object of the CustomerStorage class. Thorough testing of the CustomerStorage class from the client side may be difficult or impossible. But to instantiate objects of the CustomerStorage class from a freestanding test program also may be undesirable due to its dependency on the Customer class.

We don't have to live with the limits of either approach. We can test our server code in place, while the server is running! Again, the key is Java's ability to dynamically load a class and to instantiate new objects of that class. In effect, we will inject our test code into the server. The first step is to define a Java interface that our test classes will implement. Our CORBA server will know nothing of the test classes, but it will know of this new interface. We define this interface to eliminate static dependency of the server to specific tests. We can write as many test classes as we like, without ever having to recompile the server.
To keep things simple, we define a test interface called InjectableProgram, with a single operation called start:
interface InjectableProgram {
void start();
}
Each test class must implement this interface. Believe it or not, half our work is done. A test class named CustomerStorageTest that implements InjectableCode, can be loaded and executed with the following code fragment. We will use a more flexible variation if this fragment is in
our server.
Class c = Class.forName("CustomerStorageTest");
InjectableProgram program = (InjectableProgram) c.newInstance();
program.start();
It's almost that simple!