info.jedi.testsuite
Class Server

java.lang.Object
  |
  +--info.jedi.testsuite.Server

public class Server
extends java.lang.Object

Class Server helps to test the parts.basic package by providing a set of methods that can be called remotely. A Server is started from the command line with the simple syntax


 java info.jedi.testsuite.Server

 


Field Summary
static int SEMAPHORE_NUMBER
          The number of calls necessary to the semaphore before it triggers and releases all threads inside.
 
Constructor Summary
Server()
          Creates a Server
 
Method Summary
 boolean booleanFunction(boolean argument)
          Used to test boolean arguments and return values.
 void bounceFunction(Proxy next, int bouncesLeft)
          Bounces a call recursively between client and server, decrementing the number of bounces left at each call until they are 0, at which point the whole stack unwinds.
 ComplexObject complexObjectFunction(ComplexObject argument)
          Used to test serializable complex object arguments and return values.
 int countFunction()
          Increments the internal message count and returns the current count.
 Proxy getProxy()
          Returns a proxy to this Server
 void initialize()
          Initializes the server.
 int intFunction(int argument)
          Used to test integer arguments and return values.
static void main(java.lang.String[] args)
          Creates a server.
 java.util.Vector multipleFunction(int arg1, boolean arg2, float arg3, double arg4, java.lang.String arg5, ComplexObject arg6)
          Takes 6 arguments, all of different types: some object, some basic.
 void semaphoreFunction()
          Acts like a semaphore.
static int staticFunction(int argument)
          For testing static functions.
 java.lang.String stringFunction(java.lang.String argument)
          Used to test String arguments and return values.
 int throwsException()
          A method that throws an exception
 void unserializableParameter(Client client)
          A method with an unserializable parameter.
 Server unserializableReturnValue()
          A method that returns an unserializable value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEMAPHORE_NUMBER

public static final int SEMAPHORE_NUMBER
The number of calls necessary to the semaphore before it triggers and releases all threads inside.
Constructor Detail

Server

public Server()
Creates a Server
Method Detail

initialize

public void initialize()
Initializes the server. Primarily this resets the internal count so that it is synchronized with the client's count. This count is later used in countFunction.

stringFunction

public java.lang.String stringFunction(java.lang.String argument)
Used to test String arguments and return values. Returns the passed string in upper case.

booleanFunction

public boolean booleanFunction(boolean argument)
Used to test boolean arguments and return values. Returns the inverse of the argument.

intFunction

public int intFunction(int argument)
Used to test integer arguments and return values. Returns the negation of the argument.

complexObjectFunction

public ComplexObject complexObjectFunction(ComplexObject argument)
Used to test serializable complex object arguments and return values. Touches the object and returns it. See ComplexObject for a description of the object passed--it is a complicated tree-like structure.

multipleFunction

public java.util.Vector multipleFunction(int arg1,
                                         boolean arg2,
                                         float arg3,
                                         double arg4,
                                         java.lang.String arg5,
                                         ComplexObject arg6)
Takes 6 arguments, all of different types: some object, some basic. Returns a vector with copies of all the arguments, except that the complex object is just touched.

staticFunction

public static int staticFunction(int argument)
For testing static functions. Returns argument * 10.

countFunction

public int countFunction()
Increments the internal message count and returns the current count.

semaphoreFunction

public void semaphoreFunction()
                       throws java.lang.InterruptedException
Acts like a semaphore. All incoming methods block until SEMAPHORE_NUMBER of method have been received. Then all blocked processes are notified and return.
Throws:
java.lang.InterruptedException - if this thread is interrupted while waiting on the semaphore

getProxy

public Proxy getProxy()
               throws java.net.UnknownHostException
Returns a proxy to this Server

bounceFunction

public void bounceFunction(Proxy next,
                           int bouncesLeft)
                    throws java.lang.Exception
Bounces a call recursively between client and server, decrementing the number of bounces left at each call until they are 0, at which point the whole stack unwinds. Each call passes the proxy that will be called next to the other machine, ensuring that Proxies can be passed reliably.
Throws:
java.lang.Exception - if one of the global method calls throws an unexpected exception

throwsException

public int throwsException()
                    throws java.net.SocketException
A method that throws an exception

unserializableParameter

public void unserializableParameter(Client client)
A method with an unserializable parameter.

unserializableReturnValue

public Server unserializableReturnValue()
A method that returns an unserializable value.

main

public static void main(java.lang.String[] args)
                 throws java.net.SocketException
Creates a server. An optional first argument will set the server up at a different port.