An "Admin" is an object that is responsible for starting and stopping the program you are testing. If you wish to automate Jini(TM) Technology Lookup, Discovery, and Join Compatibility Kit (LDJ Kit) testing of your program, you will need to implement your own, specialized Admin object to start and stop your program automatically. In addition, it may be necessary to implement your own Admin in certain circumstances where the supplied default Admins do not work for your program.
The LDJ Kit includes three default Admins (one each for clients, services,
and lookup services), which simply ask you to start and stop your program at the
times determined to be appropriate by each test. Also included are Admins written
for the services and lookup service contributed by Sun Microsystems, which serve
as examples of how to write Admins using the service starter framework. For details
on this framework, see the Jini API documentation, generated by the javadoc
tool, for the com.sun.jini.start
package.
There are four related Admin interfaces. Most of the interfaces have a static string that is the name of the category for which the interface is used. When writing your own Admin, you must implement one or more of these interfaces. The interface(s) you implement must be the one(s) appropriate for your program category.
BasicAdmin
package com.sun.jini.compat.harness; public interface BasicAdmin { void setConfig(Config conf); void start() throws RemoteException; InetAddress getAddress() throws RemoteException; void stop() throws RemoteException; }
The methods of BasicAdmin
are:
setConfig
: This method provides the Admin object access to theConfig
object (see "Config
Object"). This method is always called immediately after the Admin constructor.start
: This method starts the program being tested. The LDJ Kit tests will call this method whenever they need the program started. The implementation of this method should put the program in a state where it is starting to participate in the Jini discovery protocols. Typically this method will call the service starter framework orRuntime.getRuntime().exec()
to start the service.getAddress
: This method should return the network address of the program or the hardware on which the program is running. If a program is multi-homed, one working address should be returned. This method can only be called between thestart
andstop
methods; otherwise the behavior is undefined.stop
: This method stops the program being tested. The LDJ Kit tests will callstop
whenever they need the program stopped. The implementation of this method should completely stop the program, cleaning up any state, and resetting the program to its initial pre-test state.
BasicClientAdmin
BasicClientAdmin
interface is used for testing clients and requires no additional methods.
package com.sun.jini.compat.harness; public interface BasicClientAdmin extends BasicAdmin { String CATEGORY = "client"; }
BasicServiceAdmin
BasicServiceAdmin
interface is used for testing services.
package com.sun.jini.compat.harness; public interface BasicServiceAdmin extends BasicAdmin { String CATEGORY = "service"; ServiceItem pickService(ServiceItem[] services) throws RemoteException; ServiceTemplate getTemplate() throws RemoteException; }
The additional methods of BasicServiceAdmin
will only be called after calls to BasicAdmin.setConfig()
and BasicAdmin.start()
and before a call to BasicAdmin.stop()
. The additional methods are:
pickService
: Given an array ofServiceItem
instances, this method must return theServiceItem
of the service being tested or returnnull
if the service is not represented in the array.getTemplate
: This method must return aServiceTemplate
that matches the service being tested. The template does not need to be exact, but the more exact it is, the more efficient the testing will be. In fact a fully wildcardedServiceTemplate
is a legal return value.
BasicLookupAdmin
BasicLookupAdmin
interface is used for testing lookup services.
package com.sun.jini.compat.harness; public interface BasicLookupAdmin extends BasicAdmin { String CATEGORY = "lookup"; ServiceRegistrar getServiceRegistrar() throws RemoteException; }
The additional method of BasicLookupAdmin
will only be called after calls to BasicAdmin.setConfig()
and BasicAdmin.start()
and before a call to BasicAdmin.stop()
. The additional method is:
getServiceRegistrar
: This method must return theServiceRegistrar
of the lookup service being tested.
String
object (or both). The string is provided from the property
com.sun.jini.compat.adminArg
. If this property is not set, the no-argument constructor
is used. If the adminArg
property is set, the constructor that accepts a String
argument is used. If there is no constructor that takes a string and the adminArg
property is set, the LDJ Kit will throw java.lang.Exception
and halt execution.
Your Admin must not start your program in the same virtual machine for the Java(TM) platform (VM) as the LDJ Kit. Starting
a program in the same VM as the LDJ Kit will likely cause the CodeDownloadTest
to fail.
Do not call System.exit()
in your Admin implementation.
Calling this method will stop the LDJ Kit prematurely.
Config
Objectcom.sun.jini.compat.harness.Config
object (Config
Object) passed to the BasicAdmin.setConfig()
method gives you access to LDJ Kit objects. The most useful of these objects, com.sun.jini.compat.harness.SysConfig
, is returned by
the Config
object's getSysConfig()
method and gives you access to LDJ Kit configuration properties found on the LDJ Kit command line and in the LDJ Kit property file. The LDJ Kit API documentation for com.sun.jini.compat.harness.Config
, generated by the javadoc
tool, describes its other methods.
com.sun.jini.compat.adminClass
property
in the LDJ Kit configuration file or on the LDJ Kit command line. Naturally, this class and
any classes it needs must be in the LDJ Kit's classpath. If the Admin object you specify
does not implement the appropriate Admin interface for the test category you specify,
the LDJ Kit will not run any tests.