Keel 2.1RC2

org.keel.util.test
Class AbstractKeelTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.keel.util.test.AbstractKeelTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractKeelServiceTest, DefaultAuthTests, KeelModelTestCase, ModelServiceTest, QueryTests

public abstract class AbstractKeelTest
extends junit.framework.TestCase

AbstractKeelTest can be used as the superclass for all kinds of unit tests that require a Keel container. It takes care of initializing the container for you, and cleans up in the tearDown method properly. See the many unit tests in the src/tests directories of each module for examples of this class being used. Please see the Wiki documentation for specific instructions about using the Abstract tests for specific implementations of services. For testing Models, see KeelModelTestCase instead.


Field Summary
protected static java.lang.String hint
          The default "hint" to be used when looking up services
protected  Container myContainer
          The Keel container, initialized and ready for use by sub-classes
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
AbstractKeelTest(java.lang.String name)
          Constructs a test case with the given name.
 
Method Summary
protected  Container getContainer()
           
 java.lang.Object getService(java.lang.String role, java.lang.String hint)
          Returns a service from the container
static void main(java.lang.String[] args)
          Allows this class to be run directly from the command-line.
protected  void setUp()
          Set up a Keel container.
static junit.framework.Test suite()
          Your own test class will override this method, subsituting it's class name below as appropriate.
protected  void tearDown()
          Calls "dispose" on the container, closing up anything left open.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, 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, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myContainer

protected Container myContainer
The Keel container, initialized and ready for use by sub-classes


hint

protected static java.lang.String hint
The default "hint" to be used when looking up services

Constructor Detail

AbstractKeelTest

public AbstractKeelTest(java.lang.String name)
Constructs a test case with the given name.

Parameters:
name -
Method Detail

setUp

protected void setUp()
              throws NestedException
Set up a Keel container. NOTE: Do not manually set up another Keel container in your tests - if you want to set up your own container, or use a KeelClient class, don't extend this class to do it, as you'll end up (probably) starting two containers, which, although it can be done, is probably not what you want for unit testing.

Throws:
NestedException - If container setup fails

tearDown

protected void tearDown()
                 throws java.lang.Exception
Calls "dispose" on the container, closing up anything left open.

Throws:
java.lang.Exception

suite

public static junit.framework.Test suite()
Your own test class will override this method, subsituting it's class name below as appropriate.

Returns:
The test suite to be run.

getContainer

protected Container getContainer()
Returns:
Returns the test container

getService

public java.lang.Object getService(java.lang.String role,
                                   java.lang.String hint)
                            throws java.lang.Exception
Returns a service from the container

Parameters:
role - The Avalon role for the service interface
hint - The hint defined in config files for the service impl.
Returns:
The service, needs to be cast to the service interface
Throws:
java.lang.Exception - Whenever the container cannot provide the service

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Allows this class to be run directly from the command-line. We recommend using the "ant test" target from the keel-build module, or "ant tests" to run all tests available in a given deployment.

Parameters:
args - Use hint=xxx to use a different default hint.
Throws:
java.lang.Exception - If the tests cannot be run

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.