org.picocontainer.tck
Class AbstractComponentAdapterTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jmock.core.VerifyingTestCase
              extended by org.jmock.core.MockObjectSupportTestCase
                  extended by org.jmock.MockObjectTestCase
                      extended by org.picocontainer.tck.AbstractComponentAdapterTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
ConstructorInjectorTestCase, InstanceAdapterTestCase, SetterInjectorTestCase

public abstract class AbstractComponentAdapterTestCase
extends org.jmock.MockObjectTestCase

Test suite for a ComponentAdapter implementation.

Author:
Jörg Schaible

Nested Class Summary
static class AbstractComponentAdapterTestCase.CollectingBehavior
           
static class AbstractComponentAdapterTestCase.CycleDetectorBehavior
           
static class AbstractComponentAdapterTestCase.NotInstantiatableBehavior
           
static class AbstractComponentAdapterTestCase.RecordingLifecycleStrategy
           
 
Field Summary
static int INSTANTIATING
           
static int RESOLVING
           
static int SERIALIZABLE
           
static int VERIFYING
           
 
Fields inherited from class org.jmock.core.MockObjectSupportTestCase
ANYTHING, NOT_NULL, NULL
 
Constructor Summary
AbstractComponentAdapterTestCase()
           
 
Method Summary
protected  org.picocontainer.ComponentFactory createDefaultComponentAdapterFactory()
           
protected  int getComponentAdapterNature()
           
protected abstract  Class getComponentAdapterType()
           
protected  org.picocontainer.ComponentAdapter prepDEF_isAbleToTakeParameters(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test isAbleToTakeParameters.
protected abstract  org.picocontainer.ComponentAdapter prepDEF_verifyDoesNotInstantiate(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test verifyDoesNotInstantiate.
protected abstract  org.picocontainer.ComponentAdapter prepDEF_verifyWithoutDependencyWorks(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test verifyWithoutDependencyWorks.
protected abstract  org.picocontainer.ComponentAdapter prepDEF_visitable()
          Prepare the test visitable.
protected  org.picocontainer.ComponentAdapter prepINS_createsNewInstances(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test createsNewInstances.
protected  org.picocontainer.ComponentAdapter prepINS_errorIsRethrown(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test errorIsRethrown.
protected  org.picocontainer.ComponentAdapter prepINS_normalExceptionIsRethrownInsidePicoInitializationException(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException.
protected  org.picocontainer.ComponentAdapter prepINS_runtimeExceptionIsRethrown(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test runtimeExceptionIsRethrown.
protected  org.picocontainer.ComponentAdapter prepRES_dependenciesAreResolved(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test dependenciesAreResolved.
protected  org.picocontainer.ComponentAdapter prepRES_failingInstantiationWithCyclicDependencyException(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test failingInstantiationWithCyclicDependencyException.
protected  org.picocontainer.ComponentAdapter prepRES_failingVerificationWithCyclicDependencyException(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test failingVerificationWithCyclicDependencyException.
protected  org.picocontainer.ComponentAdapter prepSER_isSerializable(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test isSerializable.
protected  org.picocontainer.ComponentAdapter prepSER_isXStreamSerializable(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test isXStreamSerializable.
protected  org.picocontainer.ComponentAdapter prepVER_verificationFails(org.picocontainer.MutablePicoContainer picoContainer)
          Prepare the test verificationFailsWithUnsatisfiedDependency.
 void testDEF_isAbleToTakeParameters()
           
 void testDEF_verifyDoesNotInstantiate()
           
 void testDEF_verifyWithoutDependencyWorks()
           
 void testDEF_visitable()
           
 void testINS_createsNewInstances()
           
 void testINS_errorIsRethrown()
           
 void testINS_normalExceptionIsRethrownInsidePicoInitializationException()
           
 void testINS_runtimeExceptionIsRethrown()
           
 void testRES_dependenciesAreResolved()
           
 void testRES_failingInstantiationWithCyclicDependencyException()
           
 void testRES_failingVerificationWithCyclicDependencyException()
           
 void testSER_isSerializable()
           
 void testSER_isXStreamSerializable()
           
 void testSER_isXStreamSerializableWithPureReflection()
           
 void testVER_verificationFails()
           
protected  org.picocontainer.PicoContainer wrapComponentInstances(Class decoratingComponentAdapterClass, org.picocontainer.PicoContainer picoContainer, Object[] wrapperDependencies)
           
 
Methods inherited from class org.jmock.MockObjectTestCase
atLeastOnce, atMostOnce, defaultMockNameForType, doAll, doAll, doAll, doAll, exactly, mock, mock, never, never, newCoreMock, newDummy, newDummy, newDummy, once, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, onConsecutiveCalls, returnIterator, returnIterator, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, returnValue, throwException
 
Methods inherited from class org.jmock.core.MockObjectSupportTestCase
and, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, collectionContaining, collectionContaining, compatibleType, contains, endsWith, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, hasProperty, hasProperty, isA, isIn, isIn, mapContaining, mapContaining, mapWithKey, mapWithKey, mapWithValue, mapWithValue, not, or, same, startsWith, stringContains, toString
 
Methods inherited from class org.jmock.core.VerifyingTestCase
registerToVerify, runBare, unregisterToVerify, verify
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, 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

SERIALIZABLE

public static final int SERIALIZABLE
See Also:
Constant Field Values

VERIFYING

public static final int VERIFYING
See Also:
Constant Field Values

INSTANTIATING

public static final int INSTANTIATING
See Also:
Constant Field Values

RESOLVING

public static final int RESOLVING
See Also:
Constant Field Values
Constructor Detail

AbstractComponentAdapterTestCase

public AbstractComponentAdapterTestCase()
Method Detail

getComponentAdapterType

protected abstract Class getComponentAdapterType()

getComponentAdapterNature

protected int getComponentAdapterNature()

createDefaultComponentAdapterFactory

protected org.picocontainer.ComponentFactory createDefaultComponentAdapterFactory()

prepDEF_verifyWithoutDependencyWorks

protected abstract org.picocontainer.ComponentAdapter prepDEF_verifyWithoutDependencyWorks(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test verifyWithoutDependencyWorks.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test for a component without dependencies. Registration in the pico is not necessary.

testDEF_verifyWithoutDependencyWorks

public final void testDEF_verifyWithoutDependencyWorks()

prepDEF_verifyDoesNotInstantiate

protected abstract org.picocontainer.ComponentAdapter prepDEF_verifyDoesNotInstantiate(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test verifyDoesNotInstantiate.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test for a component that may throw on instantiation. Registration in the pico is not necessary.

testDEF_verifyDoesNotInstantiate

public final void testDEF_verifyDoesNotInstantiate()

prepDEF_visitable

protected abstract org.picocontainer.ComponentAdapter prepDEF_visitable()
Prepare the test visitable.

Returns:
a ComponentAdapter of the type to test. If the ComponentAdapter supports Parameter, you have to select a component, that have some.

testDEF_visitable

public final void testDEF_visitable()

prepDEF_isAbleToTakeParameters

protected org.picocontainer.ComponentAdapter prepDEF_isAbleToTakeParameters(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test isAbleToTakeParameters. Overload this function, if the ComponentAdapter to test supports Parameter.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test. Select a component, that has some parameters. Registration in the pico is not necessary.

testDEF_isAbleToTakeParameters

public final void testDEF_isAbleToTakeParameters()

prepSER_isSerializable

protected org.picocontainer.ComponentAdapter prepSER_isSerializable(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test isSerializable. Overload this function, if the ComponentAdapter supports serialization.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test. Registration in the pico is not necessary.

testSER_isSerializable

public final void testSER_isSerializable()
                                  throws IOException,
                                         ClassNotFoundException
Throws:
IOException
ClassNotFoundException

prepSER_isXStreamSerializable

protected org.picocontainer.ComponentAdapter prepSER_isXStreamSerializable(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test isXStreamSerializable. Overload this function, if the ComponentAdapter supports serialization.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test. Registration in the pico is not necessary.

testSER_isXStreamSerializableWithPureReflection

public final void testSER_isXStreamSerializableWithPureReflection()

testSER_isXStreamSerializable

public final void testSER_isXStreamSerializable()

prepVER_verificationFails

protected org.picocontainer.ComponentAdapter prepVER_verificationFails(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test verificationFailsWithUnsatisfiedDependency. Overload this function, if the ComponentAdapter's verification can fail e.g. due to an unresolved dependency.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test, that fails for the verification, e.g. because of a compoennt with missing dependencies. Registration in the pico is not necessary.

testVER_verificationFails

public final void testVER_verificationFails()

prepINS_createsNewInstances

protected org.picocontainer.ComponentAdapter prepINS_createsNewInstances(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test createsNewInstances. Overload this function, if the ComponentAdapter is instantiating. It should create a new instance with every call.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test. Registration in the pico is not necessary.

testINS_createsNewInstances

public final void testINS_createsNewInstances()

prepINS_errorIsRethrown

protected org.picocontainer.ComponentAdapter prepINS_errorIsRethrown(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test errorIsRethrown. Overload this function, if the ComponentAdapter is instantiating.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test with a component that fails with an Error at instantiation. Registration in the pico is not necessary.

testINS_errorIsRethrown

public final void testINS_errorIsRethrown()

prepINS_runtimeExceptionIsRethrown

protected org.picocontainer.ComponentAdapter prepINS_runtimeExceptionIsRethrown(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test runtimeExceptionIsRethrown. Overload this function, if the ComponentAdapter is instantiating.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test with a component that fails with a RuntimeException at instantiation. Registration in the pico is not necessary.

testINS_runtimeExceptionIsRethrown

public final void testINS_runtimeExceptionIsRethrown()

prepINS_normalExceptionIsRethrownInsidePicoInitializationException

protected org.picocontainer.ComponentAdapter prepINS_normalExceptionIsRethrownInsidePicoInitializationException(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException. Overload this function, if the ComponentAdapter is instantiating.

Parameters:
picoContainer - container, may probably not be used.
Returns:
a ComponentAdapter of the type to test with a component that fails with a PicoCompositionException at instantiation. Registration in the pico is not necessary.

testINS_normalExceptionIsRethrownInsidePicoInitializationException

public final void testINS_normalExceptionIsRethrownInsidePicoInitializationException()

prepRES_dependenciesAreResolved

protected org.picocontainer.ComponentAdapter prepRES_dependenciesAreResolved(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test dependenciesAreResolved. Overload this function, if the ComponentAdapter is resolves dependencies.

Parameters:
picoContainer - container, used to register dependencies.
Returns:
a ComponentAdapter of the type to test with a component that has dependencies. Registration in the pico is not necessary.

testRES_dependenciesAreResolved

public final void testRES_dependenciesAreResolved()

prepRES_failingVerificationWithCyclicDependencyException

protected org.picocontainer.ComponentAdapter prepRES_failingVerificationWithCyclicDependencyException(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test failingVerificationWithCyclicDependencyException. Overload this function, if the ComponentAdapter is resolves dependencies.

Parameters:
picoContainer - container, used to register dependencies.
Returns:
a ComponentAdapter of the type to test with a component that has cyclic dependencies. You have to register the component itself in the pico.

testRES_failingVerificationWithCyclicDependencyException

public final void testRES_failingVerificationWithCyclicDependencyException()

prepRES_failingInstantiationWithCyclicDependencyException

protected org.picocontainer.ComponentAdapter prepRES_failingInstantiationWithCyclicDependencyException(org.picocontainer.MutablePicoContainer picoContainer)
Prepare the test failingInstantiationWithCyclicDependencyException. Overload this function, if the ComponentAdapter is resolves dependencies.

Parameters:
picoContainer - container, used to register dependencies.
Returns:
a ComponentAdapter of the type to test with a component that has cyclic dependencies. You have to register the component itself in the pico.

testRES_failingInstantiationWithCyclicDependencyException

public final void testRES_failingInstantiationWithCyclicDependencyException()

wrapComponentInstances

protected final org.picocontainer.PicoContainer wrapComponentInstances(Class decoratingComponentAdapterClass,
                                                                       org.picocontainer.PicoContainer picoContainer,
                                                                       Object[] wrapperDependencies)


Copyright © 2003-2007 Codehaus. All Rights Reserved.