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
AbstractTestCase
for 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 void
adjustCurrentTimeMillis(long timeInMilliseconds)
Move current time forward the input number of milliseconds.void
assertThreadUsed(java.lang.Thread thread)
Ensures theThread
is used.DependencyMappingBuilder
bindManagedObject(java.lang.String bindName, ManagedObjectScope managedObjectScope, ManagedFunctionBuilder<?,?> managedFunctionBuilder)
Builds theManagedObject
for use at the desiredManagedObjectScope
.ReflectiveFunctionBuilder
constructFunction(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
.ReflectiveGovernanceBuilder
constructGovernance(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
.OfficeFloor
constructOfficeFloor()
Facade method to create theOfficeFloor
.ReflectiveFunctionBuilder
constructStaticFunction(java.lang.Class<?> clazz, java.lang.String methodName)
Constructs theReflectiveFunctionBuilder
for 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
.OfficeBuilder
getOfficeBuilder()
Obtains theOfficeBuilder
.OfficeFloorBuilder
getOfficeFloorBuilder()
Obtains theOfficeFloorBuilder
.java.lang.String
getOfficeFloorName()
Obtains the name of theOfficeFloor
currently being constructed.java.lang.String
getOfficeName()
Obtains the name of theOffice
currently being constructed.void
invokeFunction(java.lang.String functionName, java.lang.Object parameter)
Facade method to invokeManagedFunction
of anOffice
.void
invokeFunction(java.lang.String functionName, java.lang.Object parameter, int secondsToRun)
Facade method to invokeManagedFunction
of anOffice
.void
invokeFunctionAndValidate(java.lang.String functionName, java.lang.Object parameter, java.lang.String... expectedFunctions)
Facade method to invoke theManagedFunction
of anOffice
and validate theManagedFunction
instances invoked.void
recordReflectiveFunctionMethodInvoked(java.lang.String methodName)
Invoked by theReflectiveFunctionBuilder
when it executes the method.void
setRecordReflectiveFunctionMethodsInvoked(boolean isRecord)
Specifies whether to record the invocations of theReflectiveFunctionBuilder
instances.protected void
setUp()
protected void
tearDown()
Office
triggerFunction(java.lang.String functionName, java.lang.Object parameter, FlowCallback callback)
Triggers theManagedFunction
but does not wait for its completion.void
validateNoTopLevelEscalation()
Validates that no top level escalation occurred.void
validateReflectiveMethodOrder(java.lang.String... methodNames)
Validates the order theReflectiveFunctionBuilder
invoked 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:
setUp
in classjunit.framework.TestCase
- Throws:
java.lang.Exception
-
tearDown
protected void tearDown() throws java.lang.Exception
- Overrides:
tearDown
in 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.Throwable
Validates 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 theOfficeFloor
currently being constructed.- Returns:
- Name of the
OfficeFloor
currently being constructed.
-
getOfficeName
public java.lang.String getOfficeName()
Obtains the name of theOffice
currently being constructed.- Returns:
- Name of the
Office
currently being constructed.
-
constructFunction
public ReflectiveFunctionBuilder constructFunction(java.lang.Object object, java.lang.String methodName)
Constructs theReflectiveFunctionBuilder
.- Parameters:
object
-Object
containing theMethod
.methodName
- Name of theMethod
.- Returns:
ReflectiveFunctionBuilder
.
-
constructStaticFunction
public ReflectiveFunctionBuilder constructStaticFunction(java.lang.Class<?> clazz, java.lang.String methodName)
Constructs theReflectiveFunctionBuilder
for a staticMethod
.- Parameters:
clazz
-Class
containing the staticMethod
.methodName
- Name of theMethod
.- Returns:
ReflectiveFunctionBuilder
.
-
setRecordReflectiveFunctionMethodsInvoked
public void setRecordReflectiveFunctionMethodsInvoked(boolean isRecord)
Specifies whether to record the invocations of the
ReflectiveFunctionBuilder
instances.This is necessary as stress tests using the
ReflectiveFunctionBuilder
will getOutOfMemoryError
issues should everyManagedFunction
executed be recorded.By default this is
false
to not record.- Parameters:
isRecord
-true
to record theManagedFunction
instances invoked.
-
recordReflectiveFunctionMethodInvoked
public void recordReflectiveFunctionMethodInvoked(java.lang.String methodName)
Invoked by theReflectiveFunctionBuilder
when it executes the method.- Parameters:
methodName
- Name of method being invoked.
-
validateReflectiveMethodOrder
public void validateReflectiveMethodOrder(java.lang.String... methodNames)
Validates the order theReflectiveFunctionBuilder
invoked 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 theThread
is 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:
ManagedFunctionBuilder
for 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:
ManagedFunctionBuilder
for 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
-ManagedObjectSource
type.- Parameters:
managedObjectName
- Name of theManagedObject
.managedObjectSourceClass
-ManagedObjectSource
Class
.managingOffice
- Name of the managingOffice
. May benull
to 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
-ManagedObjectSource
type.- Parameters:
managedObjectName
- Name of theManagedObject
.managedObjectSource
-ManagedObjectSource
instance.managingOffice
- Name of the managingOffice
. May benull
to 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 benull
to manually register forManagingOfficeBuilder
.- Returns:
ManagedObjectBuilder
.
-
bindManagedObject
public DependencyMappingBuilder bindManagedObject(java.lang.String bindName, ManagedObjectScope managedObjectScope, ManagedFunctionBuilder<?,?> managedFunctionBuilder)
Builds theManagedObject
for use at the desiredManagedObjectScope
.- Parameters:
bindName
- Name to bind theManagedObject
under.managedObjectScope
-ManagedObjectScope
for theManagedObject
.managedFunctionBuilder
-ManagedFunctionBuilder
if binding toManagedObjectScope.FUNCTION
.- Returns:
DependencyMappingBuilder
for the boundManagedObject
.
-
constructGovernance
public ReflectiveGovernanceBuilder constructGovernance(java.lang.Object object, java.lang.String governanceName)
Constructs theGovernance
.- Parameters:
object
-Object
containing theMethod
instances 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
-TeamSource
type.- Parameters:
teamName
- Name of theTeam
.teamSourceClass
-TeamSource
class.- 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 theManagedFunction
but does not wait for its completion.- Parameters:
functionName
- Name of theManagedFunction
.parameter
- Parameter for theManagedFunction
.callback
-FlowCallback
. May benull
.- Returns:
Office
containing 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.Exception
Facade method to invokeManagedFunction
of anOffice
. It will create theOfficeFloor
if necessary and times out after 3 seconds if invokedManagedFunction
is not complete.- Parameters:
functionName
- Name of theManagedFunction
to invoke.parameter
- Parameter.- Throws:
java.lang.Exception
- If fails to constructOffice
orManagedFunction
invocation failure.
-
invokeFunctionAndValidate
public void invokeFunctionAndValidate(java.lang.String functionName, java.lang.Object parameter, java.lang.String... expectedFunctions) throws java.lang.Exception
Facade method to invoke theManagedFunction
of anOffice
and validate theManagedFunction
instances invoked.- Parameters:
functionName
- Name of theManagedFunction
to invoke.parameter
- Parameter.expectedFunctions
- Names of the expectedManagedFunction
instances to be invoked in the order specified.- Throws:
java.lang.Exception
- If fails to constructOffice
orManagedFunction
invocation failure.
-
invokeFunction
public void invokeFunction(java.lang.String functionName, java.lang.Object parameter, int secondsToRun) throws java.lang.Exception
- Parameters:
functionName
- Name of theManagedFunction
to invoke.parameter
- Parameter.secondsToRun
- Seconds to run.- Throws:
java.lang.Exception
- If fails to constructOffice
orManagedFunction
invocation failure.
-
-