| org.sape.carbon.core.component.test.ComponentKeeperTest
ComponentKeeperTest | public class ComponentKeeperTest extends TestCase (Code) | | This test case tests all the methods of the ComponentKeeper. It tests
to make sure that
- returned components references remain consistent
- returned components are in the correct state
- components are destroyed when requested
- fetch requests are blocked appropriately when a component is being
created
- the keeper behaves correctly in a multi-threaded environment
Copyright 2002 Sapient
since: carbon 1.0 author: Douglas Voet, Febuary 2002 version: $Revision: 1.14 $($Author: ghinkl $ / $Date: 2003/10/16 13:22:00 $) |
Method Summary | |
protected void | setUp() | public static Test | suite() | public void | testCircularDependency() This method tests that components with circular dependancies do not
cause deadlocks. | public void | testComponentConsistency() This method tests that repeated calls the the fetchComponent method
returns the same reference. | public void | testComponentNotFound() This method tests to make sure that a ComponentNotFoundException is
thrown when a non-existent component is requested. | public void | testComponentState() This method tests to make sure that the component returned from the
keeper is in the LifecycleStateEnum.RUNNING state. | public void | testCreationBlocking() Tests to make sure that building a component will block all requests
for that component until the component is in either the
LifecycleStateEnum.STOPPED or .STARTING states.
This test depends on the component being requested taking a long
time to load. | public void | testCreationNonBlocking() Tests to make sure that creating a component does not block the
retrieval of other components. | public void | testDestroyAllComponents() Same as testDestroyComponent, but repeats the test for 2 components
to make sure that more than one component is destroyed. | public void | testDestroyComponent() This test checks 2 things, that fetching a destroyed component will
return a new component and that the destroyed component is in the
LifecycleStateEnum.DESTROYED state. | public void | testFetchComponentA() Fetches a component multiple times and makes sure the return references
remain consistent. | public void | testFetchComponentB() Fetches a component multiple times and makes sure the return references
remain consistent. | public void | testFetchComponentC() Fetches a component multiple times and makes sure the return references
remain consistent. | public void | testFetchDestroyedComponent() | public void | testNullComponentName() This method tests to make sure that an IllegalArgumentException is
thrown when null is passed as the requested component name. | public void | testReturnedComponentState() |
TEST_LOCK | final public static Object TEST_LOCK(Code) | | Lock object used by test components that need to wait for an extended
period of time
|
ComponentKeeperTest | public ComponentKeeperTest(String name)(Code) | | |
setUp | protected void setUp()(Code) | | Gets a reference to the keeper for use in all tests
|
suite | public static Test suite()(Code) | | Method called by jUnit to get all the tests in this test case
|
testCircularDependency | public void testCircularDependency()(Code) | | This method tests that components with circular dependancies do not
cause deadlocks. It does this by creating 3 components A, B, and C.
A depends on B, B depends on C, and C depends on A. This request will
be made on a separate thread. If the thread does not complete execution
within a reasonable amount of time, the test fails.
|
testComponentConsistency | public void testComponentConsistency()(Code) | | This method tests that repeated calls the the fetchComponent method
returns the same reference.
|
testComponentNotFound | public void testComponentNotFound()(Code) | | This method tests to make sure that a ComponentNotFoundException is
thrown when a non-existent component is requested.
|
testComponentState | public void testComponentState()(Code) | | This method tests to make sure that the component returned from the
keeper is in the LifecycleStateEnum.RUNNING state. This test assumes
no other thread is creating the component.
|
testCreationBlocking | public void testCreationBlocking()(Code) | | Tests to make sure that building a component will block all requests
for that component until the component is in either the
LifecycleStateEnum.STOPPED or .STARTING states.
This test depends on the component being requested taking a long
time to load. This test makes 2 requests for a component, one on this
thread, one on a new one. This thread contains the second request.
The second request should complete while the new thread is still alive
(i.e. the first request is still being processed). This test fails if
the new thread has completed or if the component is not in the
LifecycleStateEnum.STOPPED or .STARTING states.
|
testCreationNonBlocking | public void testCreationNonBlocking()(Code) | | Tests to make sure that creating a component does not block the
retrieval of other components. This is done by kicking off 2 threads.
The first will try to fetch a component that takes a long time to
create. The second will fetch a component that is already created.
If the second thread completes first, the test is sucessful.
|
testDestroyAllComponents | public void testDestroyAllComponents()(Code) | | Same as testDestroyComponent, but repeats the test for 2 components
to make sure that more than one component is destroyed.
|
testDestroyComponent | public void testDestroyComponent()(Code) | | This test checks 2 things, that fetching a destroyed component will
return a new component and that the destroyed component is in the
LifecycleStateEnum.DESTROYED state.
|
testFetchComponentA | public void testFetchComponentA()(Code) | | Fetches a component multiple times and makes sure the return references
remain consistent. This test method is used as part of a multi-threaded
test, each thread repeatedly asking for a different component.
|
testFetchComponentB | public void testFetchComponentB()(Code) | | Fetches a component multiple times and makes sure the return references
remain consistent. This test method is used as part of a multi-threaded
test, each thread repeatedly asking for a different component.
|
testFetchComponentC | public void testFetchComponentC()(Code) | | Fetches a component multiple times and makes sure the return references
remain consistent. This test method is used as part of a multi-threaded
test, each thread repeatedly asking for a different component.
|
testFetchDestroyedComponent | public void testFetchDestroyedComponent()(Code) | | This method tests to make sure that if a component is destroyed by
calling the destroyComponent lifecycle method directly, the next
call to fetchComponent will return a new component, not the destroyed
one
|
testNullComponentName | public void testNullComponentName()(Code) | | This method tests to make sure that an IllegalArgumentException is
thrown when null is passed as the requested component name.
|
testReturnedComponentState | public void testReturnedComponentState()(Code) | | |
|
|