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:
ConstructorInjectionComponentAdapterTestCase, InstanceComponentAdapterTestCase, SetterInjectionComponentAdapterTestCase

public abstract class AbstractComponentAdapterTestCase
extends org.jmock.MockObjectTestCase

Test suite for a ComponentAdapter implementation.

Since:
1.1
Author:
Jörg Schaible

Nested Class Summary
static class AbstractComponentAdapterTestCase.CollectingComponentAdapter
           
static class AbstractComponentAdapterTestCase.CycleDetectorComponentAdapter
           
static class AbstractComponentAdapterTestCase.NotInstantiatableComponentAdapter
           
static class AbstractComponentAdapterTestCase.RecordingLifecycleStrategy
           
(package private) static class AbstractComponentAdapterTestCase.RecordingVisitor
           
 
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.defaults.ComponentAdapterFactory createDefaultComponentAdapterFactory()
           
protected  int getComponentAdapterNature()
           
protected abstract  java.lang.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_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException(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.
private  boolean supportsParameters(java.lang.Class type)
           
 void testDEF_isAbleToTakeParameters()
           
 void testDEF_verifyDoesNotInstantiate()
           
 void testDEF_verifyWithoutDependencyWorks()
           
 void testDEF_visitable()
           
 void testINS_createsNewInstances()
           
 void testINS_errorIsRethrown()
           
 void testINS_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException()
           
 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(java.lang.Class decoratingComponentAdapterClass, org.picocontainer.PicoContainer picoContainer, java.lang.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, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERIALIZABLE

public static int SERIALIZABLE

VERIFYING

public static int VERIFYING

INSTANTIATING

public static int INSTANTIATING

RESOLVING

public static int RESOLVING
Constructor Detail

AbstractComponentAdapterTestCase

public AbstractComponentAdapterTestCase()
Method Detail

getComponentAdapterType

protected abstract java.lang.Class getComponentAdapterType()

getComponentAdapterNature

protected int getComponentAdapterNature()

createDefaultComponentAdapterFactory

protected org.picocontainer.defaults.ComponentAdapterFactory 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 java.io.IOException,
                                         java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.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_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException

protected org.picocontainer.ComponentAdapter prepINS_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException(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 PicoInvocationTargetInitializationException at instantiation. Registration in the pico is not necessary.

testINS_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException

public final void testINS_normalExceptionIsRethrownInsidePicoInvocationTargetInitializationException()

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(java.lang.Class decoratingComponentAdapterClass,
                                                                       org.picocontainer.PicoContainer picoContainer,
                                                                       java.lang.Object[] wrapperDependencies)

supportsParameters

private boolean supportsParameters(java.lang.Class type)