org.jboss.arquillian.impl.context
Class ContextLifecycleManager

java.lang.Object
  extended by org.jboss.arquillian.impl.context.ContextLifecycleManager

public class ContextLifecycleManager
extends Object

Handles creation and destruction of the scopes; Suite, Class, Test
There can only be one SuiteContext pr run. A SuiteContext can be associated with multiple ClassContexts that again can be associated with multiple TestContexts.

Normal Lifecycle:
createRestoreSuiteContext()

createRestoreClassContext(Class)
...
createRestoreTestContext(Object)
destroyTestContext(Object)
...
destroyClassContext(Class)

destroySuiteContext()

Version:
$Revision: $
Author:
Aslak Knutsen

Constructor Summary
ContextLifecycleManager(Configuration configuration, ProfileBuilder profileBuilder, ServiceLoader serviceLoader)
           
ContextLifecycleManager(ProfileBuilder profileBuilder, ServiceLoader serviceLoader)
           
 
Method Summary
 ClassContext createRestoreClassContext(Class<?> testClass)
          Creates or restores the ClassContext.
 SuiteContext createRestoreSuiteContext()
          Creates or restores the SuiteContext.
 TestContext createRestoreTestContext(Object testInstance)
          Creates or restores the TestContext.
 void destroyClassContext(Class<?> testClass)
          Destroy the Context associated with given test class.
 void destroySuiteContext()
          Destroy the Context.
 void destroyTestContext(Object testInstance)
          Destroy the Context associated with given test instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextLifecycleManager

public ContextLifecycleManager(ProfileBuilder profileBuilder,
                               ServiceLoader serviceLoader)

ContextLifecycleManager

public ContextLifecycleManager(Configuration configuration,
                               ProfileBuilder profileBuilder,
                               ServiceLoader serviceLoader)
Method Detail

createRestoreSuiteContext

public SuiteContext createRestoreSuiteContext()
Creates or restores the SuiteContext.
If the Context has previously been created, the same instance will be returned.

Returns:
A SuiteContext instance

destroySuiteContext

public void destroySuiteContext()
Destroy the Context.
A new Context instance will be returned on next createRestoreSuiteContext() call.

Parameters:
testClass - Context association

createRestoreClassContext

public ClassContext createRestoreClassContext(Class<?> testClass)
Creates or restores the ClassContext.
If the Context has previously been created, the same instance will be returned.

Parameters:
testClass - The TestClass this Context belongs to
Returns:
A ClassContext instance
Throws:
IllegalArgumentException - if testClass is null
IllegalStateException - if createRestoreSuiteContext() has not been called

destroyClassContext

public void destroyClassContext(Class<?> testClass)
Destroy the Context associated with given test class.
A new Context instance will be returned on next createRestoreClassContext(Class) call.

Parameters:
testClass - Context association

createRestoreTestContext

public TestContext createRestoreTestContext(Object testInstance)
Creates or restores the TestContext.
If the Context has previously been created, the same instance will be returned.

Parameters:
testInstance - The TestObject this Context belongs to
Returns:
A TestContext instance
Throws:
IllegalArgumentException - if testInstance is null

destroyTestContext

public void destroyTestContext(Object testInstance)
Destroy the Context associated with given test instance.
A new Context instance will be returned on next createRestoreTestContext(Object) call.

Parameters:
testInstance - Context association


Copyright © 2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.