de.kosi.servertest
Class ServerTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--de.kosi.servertest.ServerTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
DistributedListImplTest, MovementTest, TableTest

public abstract class ServerTestCase
extends junit.framework.TestCase

ServerTestCase implements an abstract superclass for all tests, that require a running server. The server is operating on a testdatabase, that is created every time a test is run. The database contains 4 regular accounts : 'kosi1' - 'kosi4' and one administrator account 'system'. Classes extending this class have to implement the method public Test suite(). The implementation should be return suite(.class);. This is because it is not possible to find out the class, suite() has been invoked in.

ChangeLog:

 $Log: ServerTestCase.java,v $
 Revision 1.3  2001/06/12 17:14:33  jiriki
 - Reimplemented DistributedList to make filters working
 - Made ServertestCase working.

 Revision 1.2  2001/06/04 14:21:10  jiriki
 Made source more comliant to coding guidelines.

 Revision 1.1.1.1  2001/04/29 18:05:19  jiriki
 Imported sources from zola.

 Revision 1.2  2001/04/19 19:01:26  wombat
 Removed Bugs

 Revision 1.1  2001/04/19 18:51:28  wombat
 - updated junit (new Version: 3.6)
 - implemented ServerTestCase
 - Added license files

 

Version:
$Revision: 1.3 $ ($Date: 2001/06/12 17:14:33 $)
Author:
Jan-Ole Janssen, Niklas Mehner, Time Sticher

Constructor Summary
ServerTestCase(java.lang.String name)
          Create a new ServerTestCase.
 
Method Summary
 void doAsUser(UserImpl user, java.lang.Runnable task)
          Execute a piece of code, as if it was invoked by a user.
static UserImpl[] getAdminUsers()
          Return an array containing the admin Users.
static UserImpl[] getUsers()
          Return an array containing the regular Users.
static void init()
          Initialize the test environment.
 void loginUser(UserImpl user)
           
 void loginUser(UserImpl user, FoyerListener listener)
           
 void logoutUser(UserImpl user)
           
static void shutdown()
          Shut down the test environment.
static junit.framework.Test suite()
          This method is only implemented, to ensure, that every class extending this class averrides this method.
static junit.framework.Test suite(java.lang.Class testClass)
          This method returns a test suit for the given testclass.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, name, run, run, runBare, runTest, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerTestCase

public ServerTestCase(java.lang.String name)
Create a new ServerTestCase.
Parameters:
name - Name of the test.
Method Detail

init

public static void init()
Initialize the test environment. This starts the server and populates the Database.

getUsers

public static UserImpl[] getUsers()
Return an array containing the regular Users.
Returns:
Array containing regular users.

getAdminUsers

public static UserImpl[] getAdminUsers()
Return an array containing the admin Users.
Returns:
Array containing admin users.

loginUser

public void loginUser(UserImpl user)
               throws java.rmi.RemoteException,
                      KosiAccessException

loginUser

public void loginUser(UserImpl user,
                      FoyerListener listener)
               throws java.rmi.RemoteException,
                      KosiAccessException

logoutUser

public void logoutUser(UserImpl user)

doAsUser

public void doAsUser(UserImpl user,
                     java.lang.Runnable task)
Execute a piece of code, as if it was invoked by a user.
Parameters:
user - User the code is invoked for.
task - Code to execute.

shutdown

public static void shutdown()
                     throws java.io.IOException
Shut down the test environment.
Throws:
java.io.IOException - If loading the configuration values fails.

suite

public static junit.framework.Test suite()
                                  throws java.lang.Exception
This method is only implemented, to ensure, that every class extending this class averrides this method. The overriding method has to return suite(.class).
Returns:
Nothing. This method never successfully terminates.
Throws:
java.lang.Exception - To stop testcases that do not override this method.

suite

public static junit.framework.Test suite(java.lang.Class testClass)
                                  throws java.lang.Exception
This method returns a test suit for the given testclass. The class has to be specified, because it is not possible to find out the class in a static environment.
Parameters:
testClass - ServerTestCase, this method is called from.
Returns:
A TestSuite for the given ServertestCase.
Throws:
java.lang.Exception - If creating the TestSuit fails.