org.jboss.test.kernel.junit
Class MicrocontainerTestDelegate

java.lang.Object
  extended by org.jboss.test.AbstractTestDelegate
      extended by org.jboss.test.kernel.junit.MicrocontainerTestDelegate

public class MicrocontainerTestDelegate
extends org.jboss.test.AbstractTestDelegate

A MicrocontainerTestDelegate.

Version:
$Revision: 70576 $
Author:
Adrian Brock

Field Summary
protected  ControllerMode defaultMode
          The default mode
protected  BasicXMLDeployer deployer
          The deployer
protected  Kernel kernel
          The kernel
 
Fields inherited from class org.jboss.test.AbstractTestDelegate
clazz, enableSecurity, log, logging, policy, securityPolicyName
 
Constructor Summary
MicrocontainerTestDelegate(Class<?> clazz)
          Create a new MicrocontainerTestDelegate.
 
Method Summary
protected  void assertNoControllerContext(Object name, ControllerState state)
          Assert there is no context at the given state
protected  ControllerState change(KernelControllerContext context, ControllerState required)
          Change the context to the given state
protected  BasicXMLDeployer createDeployer()
           
protected  void deploy()
          Deploy the beans
protected  KernelControllerContext deploy(BeanMetaData beanMetaData)
          Deploy a bean
protected  void deploy(KernelDeployment deployment)
          Deploy a deployment
protected  KernelDeployment deploy(URL url)
          Deploy a url
protected  Object getBean(Object name, ControllerState state)
          Get a bean
protected
<T> T
getBean(Object name, ControllerState state, Class<T> expected)
          Get a bean
protected  AbstractBootstrap getBootstrap()
          Get the kernel bootstrap
protected  KernelControllerContext getControllerContext(Object name, ControllerState state)
          Get a context
 ControllerMode getDefaultMode()
          Get the defaultMode.
protected  KernelMetaDataRepository getMetaDataRepository()
          Get the metadata repository
protected  String getTestName()
           
protected  URL getTestResource(String testName)
           
protected  KernelControllerContext handleNotFoundContext(Controller controller, Object name, ControllerState state)
          Handle not found context.
 void setDefaultMode(ControllerMode defaultMode)
          Set the defaultMode.
 void setUp()
           
protected  void shutdown()
           
 void tearDown()
           
protected  void undeploy()
          Undeploy all
protected  void undeploy(KernelControllerContext context)
          Undeploy a bean
protected  void undeploy(KernelDeployment deployment)
          Undeploy a deployment
protected  void undeploy(URL url)
          Undeploy a deployment
protected  void validate()
          Validate
 
Methods inherited from class org.jboss.test.AbstractTestDelegate
enableTrace, getDelegate, getLog, log, setUpLogging, setUpSecurity, tearDownLogging, tearDownSecurity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kernel

protected Kernel kernel
The kernel


deployer

protected BasicXMLDeployer deployer
The deployer


defaultMode

protected ControllerMode defaultMode
The default mode

Constructor Detail

MicrocontainerTestDelegate

public MicrocontainerTestDelegate(Class<?> clazz)
                           throws Exception
Create a new MicrocontainerTestDelegate.

Parameters:
clazz - the test class
Throws:
Exception - for any error
Method Detail

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class org.jboss.test.AbstractTestDelegate
Throws:
Exception

createDeployer

protected BasicXMLDeployer createDeployer()

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class org.jboss.test.AbstractTestDelegate
Throws:
Exception

getDefaultMode

public ControllerMode getDefaultMode()
Get the defaultMode.

Returns:
the defaultMode.

setDefaultMode

public void setDefaultMode(ControllerMode defaultMode)
Set the defaultMode.

Parameters:
defaultMode - the defaultMode.

getBootstrap

protected AbstractBootstrap getBootstrap()
                                  throws Exception
Get the kernel bootstrap

Returns:
the bootstrap
Throws:
Exception - for any error

getBean

protected Object getBean(Object name,
                         ControllerState state)
Get a bean

Parameters:
name - the name of the bean
state - the state of the bean
Returns:
the bean
Throws:
IllegalStateException - when the bean does not exist at that state

getBean

protected <T> T getBean(Object name,
                        ControllerState state,
                        Class<T> expected)
Get a bean

Type Parameters:
T - the expected type
Parameters:
name - the name of the bean
state - the state of the bean
expected - the expected type
Returns:
the bean
Throws:
IllegalStateException - when the bean does not exist at that state

getMetaDataRepository

protected KernelMetaDataRepository getMetaDataRepository()
Get the metadata repository

Returns:
the metadata repository
Throws:
IllegalStateException - when the bean does not exist at that state

getControllerContext

protected KernelControllerContext getControllerContext(Object name,
                                                       ControllerState state)
Get a context

Parameters:
name - the name of the bean
state - the state of the bean
Returns:
the context
Throws:
IllegalStateException - when the context does not exist at that state

assertNoControllerContext

protected void assertNoControllerContext(Object name,
                                         ControllerState state)
Assert there is no context at the given state

Parameters:
name - the name of the bean
state - the state of the bean
Throws:
IllegalStateException - when the context exists at that state

handleNotFoundContext

protected KernelControllerContext handleNotFoundContext(Controller controller,
                                                        Object name,
                                                        ControllerState state)
Handle not found context.

Parameters:
controller - the controller
name - the name of the bean
state - the state of the bean
Returns:
the context
Throws:
IllegalStateException - when the context does not exist at that state

change

protected ControllerState change(KernelControllerContext context,
                                 ControllerState required)
                          throws Throwable
Change the context to the given state

Parameters:
context - the context
required - the required state
Returns:
the actual state
Throws:
Throwable - for any error

validate

protected void validate()
                 throws Exception
Validate

Throws:
Exception - for any error

deploy

protected KernelDeployment deploy(URL url)
                           throws Exception
Deploy a url

Parameters:
url - the deployment url
Returns:
the deployment
Throws:
Exception - for any error

deploy

protected KernelControllerContext deploy(BeanMetaData beanMetaData)
                                  throws Exception
Deploy a bean

Parameters:
beanMetaData - the bean metadata
Returns:
the deployment
Throws:
Exception - for any error

deploy

protected void deploy(KernelDeployment deployment)
               throws Exception
Deploy a deployment

Parameters:
deployment - the deployment
Throws:
Exception - for any error

undeploy

protected void undeploy(KernelControllerContext context)
Undeploy a bean

Parameters:
context - the context

undeploy

protected void undeploy(KernelDeployment deployment)
Undeploy a deployment

Parameters:
deployment - the deployment

undeploy

protected void undeploy(URL url)
Undeploy a deployment

Parameters:
url - the url

deploy

protected void deploy()
               throws Exception
Deploy the beans

Throws:
Exception - for any error

shutdown

protected void shutdown()

getTestName

protected String getTestName()

getTestResource

protected URL getTestResource(String testName)

undeploy

protected void undeploy()
Undeploy all



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