Stand Alone Testing

You can run your application within a stand-alone environment. This is useful when testing your application's logic (which is independent of the hosting service provider's network of TaskServers & Hosts).

The HspAgent constructor takes 1 argument: a String denoting the domain name of the machine that is running the hosting service provider which you would like to use. The special String "test" causes the HspAgent to construct a minimal hosting service provider, depicted in the diagram below.

When your application invokes the getClient2Hsp() method, it is returned a reference to this internal hosting service provider. Thus, when testing, you need to run only 1 JVM.

The application below shows this tiny change in code (the HspAgent constructor argument).

There are 2 aspects of test mode that you should know:
  • The output of the Hsp, TaskServer, Host, and your application is combined on System.out. I have displayed the application's output  in red (as opposed to that of the Janet system components, which appears in black).
  • Although the application's main thread terminates, the JVM does not: You do this manually (e.g., ctrl-c).

Hsp: Constructed.
TaskServer: Ready.
TaskServer: registerHost: complete.
Host: Ready.
TaskServer: loginClient: complete.
Hsp: login: complete
Hello, world!
TaskServer: logout: complete.
HSP: Client logged out.