Package net.officefloor.frame.test
Class AbstractOfficeConstructTestCase
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- net.officefloor.frame.test.OfficeFrameTestCase
-
- net.officefloor.frame.test.AbstractOfficeConstructTestCase
-
- All Implemented Interfaces:
junit.framework.Test
public abstract class AbstractOfficeConstructTestCase extends OfficeFrameTestCase
AbstractTestCasefor construction testing of an Office.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.frame.test.OfficeFrameTestCase
OfficeFrameTestCase.FailOperation, OfficeFrameTestCase.GuiTest, OfficeFrameTestCase.MultithreadedTestLogic<T extends java.lang.Throwable>, OfficeFrameTestCase.StressTest, OfficeFrameTestCase.TestCapture<T extends java.lang.Throwable>, OfficeFrameTestCase.TestLogic<R,T extends java.lang.Throwable>, OfficeFrameTestCase.UsesDockerTest, OfficeFrameTestCase.UsesGCloudTest, OfficeFrameTestCase.WaitForTruePredicate<T extends java.lang.Throwable>
-
-
Field Summary
-
Fields inherited from class net.officefloor.frame.test.OfficeFrameTestCase
CLASS_LOADER_EXTRA_CLASS_NAME, CLASS_LOADER_EXTRA_PACKAGE_NAME, classLoaderTestSupport, END_OF_LINE, fileTestSupport, logTestSupport, mockTestSupport, threadedTestSupport
-
-
Constructor Summary
Constructors Constructor Description AbstractOfficeConstructTestCase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjustCurrentTimeMillis(long timeInMilliseconds)Move current time forward the input number of milliseconds.voidassertThreadUsed(java.lang.Thread thread)Ensures theThreadis used.DependencyMappingBuilderbindManagedObject(java.lang.String bindName, ManagedObjectScope managedObjectScope, ManagedFunctionBuilder<?,?> managedFunctionBuilder)Builds theManagedObjectfor use at the desiredManagedObjectScope.ReflectiveFunctionBuilderconstructFunction(java.lang.Object object, java.lang.String methodName)Constructs theReflectiveFunctionBuilder.<O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>
ManagedFunctionBuilder<O,F>constructFunction(java.lang.String functionName, ManagedFunction<O,F> function)Facade method to register aManagedFunction.<O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>
ManagedFunctionBuilder<O,F>constructFunction(java.lang.String functionName, ManagedFunctionFactory<O,F> functionFactory)Facade method to register aManagedFunction.ReflectiveGovernanceBuilderconstructGovernance(java.lang.Object object, java.lang.String governanceName)Constructs theGovernance.ManagedObjectBuilder<?>constructManagedObject(java.lang.Object object, java.lang.String managedObjectName, java.lang.String managingOffice)Facade method to register aManagedObject.<D extends java.lang.Enum<D>,F extends java.lang.Enum<F>,MS extends ManagedObjectSource<D,F>>
ManagedObjectBuilder<F>constructManagedObject(java.lang.String managedObjectName, java.lang.Class<MS> managedObjectSourceClass, java.lang.String managingOffice)Facade method to register aManagedObject.<D extends java.lang.Enum<D>,F extends java.lang.Enum<F>,MS extends ManagedObjectSource<D,F>>
ManagedObjectBuilder<F>constructManagedObject(java.lang.String managedObjectName, MS managedObjectSource, java.lang.String managingOffice)Facade method to register aManagedObject.OfficeFloorconstructOfficeFloor()Facade method to create theOfficeFloor.ReflectiveFunctionBuilderconstructStaticFunction(java.lang.Class<?> clazz, java.lang.String methodName)Constructs theReflectiveFunctionBuilderfor a staticMethod.<TS extends TeamSource>
TeamBuilder<?>constructTeam(java.lang.String teamName, java.lang.Class<TS> teamSourceClass)Facade method to create aTeam.TeamBuilder<?>constructTeam(java.lang.String teamName, Team team)Facade method to create aTeam.OfficeBuildergetOfficeBuilder()Obtains theOfficeBuilder.OfficeFloorBuildergetOfficeFloorBuilder()Obtains theOfficeFloorBuilder.java.lang.StringgetOfficeFloorName()Obtains the name of theOfficeFloorcurrently being constructed.java.lang.StringgetOfficeName()Obtains the name of theOfficecurrently being constructed.voidinvokeFunction(java.lang.String functionName, java.lang.Object parameter)Facade method to invokeManagedFunctionof anOffice.voidinvokeFunction(java.lang.String functionName, java.lang.Object parameter, int secondsToRun)Facade method to invokeManagedFunctionof anOffice.voidinvokeFunctionAndValidate(java.lang.String functionName, java.lang.Object parameter, java.lang.String... expectedFunctions)Facade method to invoke theManagedFunctionof anOfficeand validate theManagedFunctioninstances invoked.voidrecordReflectiveFunctionMethodInvoked(java.lang.String methodName)Invoked by theReflectiveFunctionBuilderwhen it executes the method.voidsetRecordReflectiveFunctionMethodsInvoked(boolean isRecord)Specifies whether to record the invocations of theReflectiveFunctionBuilderinstances.protected voidsetUp()protected voidtearDown()OfficetriggerFunction(java.lang.String functionName, java.lang.Object parameter, FlowCallback callback)Triggers theManagedFunctionbut does not wait for its completion.voidvalidateNoTopLevelEscalation()Validates that no top level escalation occurred.voidvalidateReflectiveMethodOrder(java.lang.String... methodNames)Validates the order theReflectiveFunctionBuilderinvoked the methods.-
Methods inherited from class net.officefloor.frame.test.OfficeFrameTestCase
assertContents, assertContents, assertFail, assertFail, assertFail, assertGraph, assertList, assertList, assertList, assertList, assertList, assertProperties, assertTextEquals, assertXmlEquals, captureLoggerOutput, clearDirectory, copyDirectory, createFile, createMock, createNewClassLoader, createPlatformIndependentText, createSynchronizedMock, deleteDirectory, displayGraph, displayGraph, doMultiThreadedTest, doMultiThreadedTest, doTest, fail, findFile, findFile, findInputStream, getDisplayRunTime, getDisplayRunTime, getFileContents, getFileLocation, getItem, getPackageRelativePath, getProperty, isGuiAvailable, isPrintMessages, isSkipStressTests, isSkipTestsUsingDocker, isSkipTestsUsingGCloud, param, paramType, printHeapMemoryDiagnostics, printMessage, printMessage, printMessage, recordReturn, recordReturn, recordThrows, recordVoid, removeXmlWhiteSpacing, replayMockObjects, runBare, setDebugVerbose, setLogGC, setName, setVerbose, sleep, throwException, timeout, timeout, verifyMockObjects, waitForTrue, waitForTrue
-
Methods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, toString
-
-
-
-
Method Detail
-
setUp
protected void setUp() throws java.lang.Exception- Overrides:
setUpin classjunit.framework.TestCase- Throws:
java.lang.Exception
-
tearDown
protected void tearDown() throws java.lang.Exception- Overrides:
tearDownin classjunit.framework.TestCase- Throws:
java.lang.Exception
-
adjustCurrentTimeMillis
public void adjustCurrentTimeMillis(long timeInMilliseconds)
Move current time forward the input number of milliseconds.- Parameters:
timeInMilliseconds- Milliseconds to move current time forward.
-
validateNoTopLevelEscalation
public void validateNoTopLevelEscalation() throws java.lang.ThrowableValidates that no top level escalation occurred.
This method will clear the escalation on exit.
- Throws:
java.lang.Throwable- If top levelEscalation.
-
getOfficeFloorBuilder
public OfficeFloorBuilder getOfficeFloorBuilder()
Obtains theOfficeFloorBuilder.- Returns:
OfficeFloorBuilder.
-
getOfficeBuilder
public OfficeBuilder getOfficeBuilder()
Obtains theOfficeBuilder.- Returns:
OfficeBuilder.
-
getOfficeFloorName
public java.lang.String getOfficeFloorName()
Obtains the name of theOfficeFloorcurrently being constructed.- Returns:
- Name of the
OfficeFloorcurrently being constructed.
-
getOfficeName
public java.lang.String getOfficeName()
Obtains the name of theOfficecurrently being constructed.- Returns:
- Name of the
Officecurrently being constructed.
-
constructFunction
public ReflectiveFunctionBuilder constructFunction(java.lang.Object object, java.lang.String methodName)
Constructs theReflectiveFunctionBuilder.- Parameters:
object-Objectcontaining theMethod.methodName- Name of theMethod.- Returns:
ReflectiveFunctionBuilder.
-
constructStaticFunction
public ReflectiveFunctionBuilder constructStaticFunction(java.lang.Class<?> clazz, java.lang.String methodName)
Constructs theReflectiveFunctionBuilderfor a staticMethod.- Parameters:
clazz-Classcontaining the staticMethod.methodName- Name of theMethod.- Returns:
ReflectiveFunctionBuilder.
-
setRecordReflectiveFunctionMethodsInvoked
public void setRecordReflectiveFunctionMethodsInvoked(boolean isRecord)
Specifies whether to record the invocations of the
ReflectiveFunctionBuilderinstances.This is necessary as stress tests using the
ReflectiveFunctionBuilderwill getOutOfMemoryErrorissues should everyManagedFunctionexecuted be recorded.By default this is
falseto not record.- Parameters:
isRecord-trueto record theManagedFunctioninstances invoked.
-
recordReflectiveFunctionMethodInvoked
public void recordReflectiveFunctionMethodInvoked(java.lang.String methodName)
Invoked by theReflectiveFunctionBuilderwhen it executes the method.- Parameters:
methodName- Name of method being invoked.
-
validateReflectiveMethodOrder
public void validateReflectiveMethodOrder(java.lang.String... methodNames)
Validates the order theReflectiveFunctionBuilderinvoked the methods.- Parameters:
methodNames- Order that the reflective methods should be invoked.- See Also:
setRecordReflectiveFunctionMethodsInvoked(boolean)
-
assertThreadUsed
public void assertThreadUsed(java.lang.Thread thread)
Ensures theThreadis used.- Parameters:
thread-Thread.
-
constructFunction
public <O extends java.lang.Enum<O>,F extends java.lang.Enum<F>> ManagedFunctionBuilder<O,F> constructFunction(java.lang.String functionName, ManagedFunctionFactory<O,F> functionFactory)
Facade method to register aManagedFunction.- Type Parameters:
O- Dependency key type.F- Flow key type.- Parameters:
functionName- Name of theManagedFunction.functionFactory-ManagedFunctionFactory.- Returns:
ManagedFunctionBuilderfor theManagedFunction.
-
constructFunction
public <O extends java.lang.Enum<O>,F extends java.lang.Enum<F>> ManagedFunctionBuilder<O,F> constructFunction(java.lang.String functionName, ManagedFunction<O,F> function)
Facade method to register aManagedFunction.- Type Parameters:
O- Dependency key type.F- Flow key type.- Parameters:
functionName- Name of theManagedFunction.function-ManagedFunction.- Returns:
ManagedFunctionBuilderfor theManagedFunction.
-
constructManagedObject
public <D extends java.lang.Enum<D>,F extends java.lang.Enum<F>,MS extends ManagedObjectSource<D,F>> ManagedObjectBuilder<F> constructManagedObject(java.lang.String managedObjectName, java.lang.Class<MS> managedObjectSourceClass, java.lang.String managingOffice)
Facade method to register aManagedObject.- Type Parameters:
D- Dependency key type.F- Flow key type.MS-ManagedObjectSourcetype.- Parameters:
managedObjectName- Name of theManagedObject.managedObjectSourceClass-ManagedObjectSourceClass.managingOffice- Name of the managingOffice. May benullto manually register forManagingOfficeBuilder.- Returns:
ManagedObjectBuilder.
-
constructManagedObject
public <D extends java.lang.Enum<D>,F extends java.lang.Enum<F>,MS extends ManagedObjectSource<D,F>> ManagedObjectBuilder<F> constructManagedObject(java.lang.String managedObjectName, MS managedObjectSource, java.lang.String managingOffice)
Facade method to register aManagedObject.- Type Parameters:
D- Dependency key type.F- Flow key type.MS-ManagedObjectSourcetype.- Parameters:
managedObjectName- Name of theManagedObject.managedObjectSource-ManagedObjectSourceinstance.managingOffice- Name of the managingOffice. May benullto manually register forManagingOfficeBuilder.- Returns:
ManagedObjectBuilder.
-
constructManagedObject
public ManagedObjectBuilder<?> constructManagedObject(java.lang.Object object, java.lang.String managedObjectName, java.lang.String managingOffice)
Facade method to register aManagedObject.- Parameters:
object- Object for theManagedObject.managedObjectName- Name of theManagedObject.managingOffice- Name of the mananagingOffice. May benullto manually register forManagingOfficeBuilder.- Returns:
ManagedObjectBuilder.
-
bindManagedObject
public DependencyMappingBuilder bindManagedObject(java.lang.String bindName, ManagedObjectScope managedObjectScope, ManagedFunctionBuilder<?,?> managedFunctionBuilder)
Builds theManagedObjectfor use at the desiredManagedObjectScope.- Parameters:
bindName- Name to bind theManagedObjectunder.managedObjectScope-ManagedObjectScopefor theManagedObject.managedFunctionBuilder-ManagedFunctionBuilderif binding toManagedObjectScope.FUNCTION.- Returns:
DependencyMappingBuilderfor the boundManagedObject.
-
constructGovernance
public ReflectiveGovernanceBuilder constructGovernance(java.lang.Object object, java.lang.String governanceName)
Constructs theGovernance.- Parameters:
object-Objectcontaining theMethodinstances used forGovernance.governanceName- Name of theGovernance.- Returns:
ReflectiveGovernanceBuilder.
-
constructTeam
public TeamBuilder<?> constructTeam(java.lang.String teamName, Team team)
Facade method to create aTeam.- Parameters:
teamName- Name of theTeam.team-Team.- Returns:
TeamBuilder.
-
constructTeam
public <TS extends TeamSource> TeamBuilder<?> constructTeam(java.lang.String teamName, java.lang.Class<TS> teamSourceClass)
Facade method to create aTeam.- Type Parameters:
TS-TeamSourcetype.- Parameters:
teamName- Name of theTeam.teamSourceClass-TeamSourceclass.- Returns:
TeamBuilder.
-
constructOfficeFloor
public OfficeFloor constructOfficeFloor() throws java.lang.Exception
Facade method to create theOfficeFloor.- Returns:
OfficeFloor.- Throws:
java.lang.Exception- If fails to construct theOfficeFloor.
-
triggerFunction
public Office triggerFunction(java.lang.String functionName, java.lang.Object parameter, FlowCallback callback) throws java.lang.Exception
Triggers theManagedFunctionbut does not wait for its completion.- Parameters:
functionName- Name of theManagedFunction.parameter- Parameter for theManagedFunction.callback-FlowCallback. May benull.- Returns:
Officecontaining theManagedFunction.- Throws:
java.lang.Exception- If fails to trigger theManagedFunction.
-
invokeFunction
public void invokeFunction(java.lang.String functionName, java.lang.Object parameter) throws java.lang.ExceptionFacade method to invokeManagedFunctionof anOffice. It will create theOfficeFloorif necessary and times out after 3 seconds if invokedManagedFunctionis not complete.- Parameters:
functionName- Name of theManagedFunctionto invoke.parameter- Parameter.- Throws:
java.lang.Exception- If fails to constructOfficeorManagedFunctioninvocation failure.
-
invokeFunctionAndValidate
public void invokeFunctionAndValidate(java.lang.String functionName, java.lang.Object parameter, java.lang.String... expectedFunctions) throws java.lang.ExceptionFacade method to invoke theManagedFunctionof anOfficeand validate theManagedFunctioninstances invoked.- Parameters:
functionName- Name of theManagedFunctionto invoke.parameter- Parameter.expectedFunctions- Names of the expectedManagedFunctioninstances to be invoked in the order specified.- Throws:
java.lang.Exception- If fails to constructOfficeorManagedFunctioninvocation failure.
-
invokeFunction
public void invokeFunction(java.lang.String functionName, java.lang.Object parameter, int secondsToRun) throws java.lang.Exception- Parameters:
functionName- Name of theManagedFunctionto invoke.parameter- Parameter.secondsToRun- Seconds to run.- Throws:
java.lang.Exception- If fails to constructOfficeorManagedFunctioninvocation failure.
-
-