org.jboss.test.kernel.junit
Class MicrocontainerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jboss.test.AbstractTestCase
              extended by org.jboss.test.AbstractTestCaseWithSetup
                  extended by org.jboss.test.kernel.junit.MicrocontainerTest
All Implemented Interfaces:
junit.framework.Test

public class MicrocontainerTest
extends org.jboss.test.AbstractTestCaseWithSetup

A MicrocontainerTest.

Version:
$Revision: 78898 $
Author:
Adrian Brock

Constructor Summary
MicrocontainerTest(String name)
          Create a new Microcontainer test
MicrocontainerTest(String name, boolean autowireCandidate)
           
 
Method Summary
protected  void afterSetUp()
          Configure after set up.
protected
<T> T
assertBean(Object name, Class<T> expected)
          Get a bean
protected
<T> T
assertBean(Object name, ControllerState state, Class<T> expected)
          Get a bean
protected  void assertNoBean(Object name)
          Assert there is no bean
protected  void assertNoBean(Object name, ControllerState state)
          Assert there is no bean
protected  void assertNoControllerContext(Object name, ControllerState state)
          Assert there is no context at the given state
protected  void autowireThis()
          Autowire this test instance.
 ControllerState change(KernelControllerContext context, ControllerState required)
          Change the context to the given state
protected  void clearAutowire()
          Clear things after autowiring.
protected  String createTestBeanName()
          Get the test's bean name.
protected  KernelControllerContext deploy(BeanMetaData beanMetaData)
          Deploy a bean
protected  void deploy(KernelDeployment deployment)
          Deploy a deployment
protected  KernelDeployment deploy(String resource)
          Deploy a resource
protected  KernelDeployment deploy(URL url)
          Deploy a url
protected  Object getBean(Object name)
          Get a bean
protected  Object getBean(Object name, ControllerState state)
          Get a bean
protected  KernelControllerContext getControllerContext(Object name)
          Get a context
protected  KernelControllerContext getControllerContext(Object name, ControllerState state)
          Get a context
static org.jboss.test.AbstractTestDelegate getDelegate(Class<?> clazz)
          Get the test delegate
protected  MicrocontainerTestDelegate getMCDelegate()
          Get the delegate
protected  KernelMetaDataRepository getMetaDataRepository()
          Get the metadata repository
protected  String getMethodDeployment()
           
protected  URL getMethodResource()
           
protected  void setAutowireCandidate(boolean autowireCandidate)
          Set the autowire flag.
protected  void setUp()
           
protected  void shutdown()
          Shutdown the controller
protected  void tearDown()
           
protected  void undeploy(KernelControllerContext context)
          Undeploy a bean
protected  void undeploy(KernelDeployment deployment)
          Undeploy a deployment
protected  void undeploy(String resource)
          Undeploy a deployment
protected  void validate()
          Validate
 
Methods inherited from class org.jboss.test.AbstractTestCaseWithSetup
enableTrace, getDelegate, getLog, resumeSecurity, suite, suspendSecurity
 
Methods inherited from class org.jboss.test.AbstractTestCase
assertEmpty, assertEmpty, assertEmpty, assertEquals, assertEquals, assertEquals, assertEquals, assertInstanceOf, assertInstanceOf, checkDeepThrowable, checkDeepThrowableRethrow, checkThrowable, checkThrowableRethrow, configureLogging, deserialize, failure, findResource, getResource, serialize, serializeDeserialize
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MicrocontainerTest

public MicrocontainerTest(String name)
Create a new Microcontainer test

Parameters:
name - the test name

MicrocontainerTest

public MicrocontainerTest(String name,
                          boolean autowireCandidate)
Method Detail

getDelegate

public static org.jboss.test.AbstractTestDelegate getDelegate(Class<?> clazz)
                                                       throws Exception
Get the test delegate

Parameters:
clazz - the test class
Returns:
the delegate
Throws:
Exception - for any error

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class org.jboss.test.AbstractTestCaseWithSetup
Throws:
Exception

getMethodDeployment

protected String getMethodDeployment()

getMethodResource

protected URL getMethodResource()

afterSetUp

protected void afterSetUp()
                   throws Exception
Configure after set up.

Throws:
Exception - for any error

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class org.jboss.test.AbstractTestCaseWithSetup
Throws:
Exception

autowireThis

protected void autowireThis()
                     throws Exception
Autowire this test instance. Registering it into underlying controller.

Throws:
Exception - for any error

createTestBeanName

protected String createTestBeanName()
Get the test's bean name. By default it's random uuid.

Returns:
test's bean name

clearAutowire

protected void clearAutowire()
Clear things after autowiring.


getBean

protected Object getBean(Object name)
Get a bean

Parameters:
name - the bean name
Returns:
the bean
Throws:
IllegalStateException - when the bean does not exist

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

assertBean

protected <T> T assertBean(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

assertBean

protected <T> T assertBean(Object name,
                           Class<T> expected)
Get a bean

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

assertNoBean

protected void assertNoBean(Object name)
Assert there is no bean

Parameters:
name - the name of the bean
Throws:
IllegalStateException - when the bean exists

assertNoBean

protected void assertNoBean(Object name,
                            ControllerState state)
Assert there is no bean

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

getControllerContext

protected KernelControllerContext getControllerContext(Object name)
Get a context

Parameters:
name - the bean name
Returns:
the context
Throws:
IllegalStateException - when the context does not exist

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

change

public 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

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 KernelDeployment deploy(String resource)
                           throws Exception
Deploy a resource

Parameters:
resource - the deployment resource
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(String resource)
Undeploy a deployment

Parameters:
resource - the url

validate

protected void validate()
                 throws Exception
Validate

Throws:
Exception - for any error

getMetaDataRepository

protected KernelMetaDataRepository getMetaDataRepository()
Get the metadata repository

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

shutdown

protected void shutdown()
Shutdown the controller


getMCDelegate

protected MicrocontainerTestDelegate getMCDelegate()
Get the delegate

Returns:
the delegate

setAutowireCandidate

protected void setAutowireCandidate(boolean autowireCandidate)
Set the autowire flag.

Parameters:
autowireCandidate - the autowire flag


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