org.apache.camel.testng
Class CamelSpringTestSupport

java.lang.Object
  extended by org.testng.Assert
      extended by org.apache.camel.testng.TestSupport
          extended by org.apache.camel.testng.CamelTestSupport
              extended by org.apache.camel.testng.CamelSpringTestSupport

public abstract class CamelSpringTestSupport
extends CamelTestSupport

Version:
$Revision: 1172870 $

Field Summary
protected static AbstractApplicationContext applicationContext
           
protected static java.lang.Object lock
           
protected static java.lang.ThreadLocal<AbstractApplicationContext> threadAppContext
           
 
Fields inherited from class org.apache.camel.testng.CamelTestSupport
camelContextService, consumer, context, template
 
Fields inherited from class org.apache.camel.testng.TestSupport
log, LS
 
Constructor Summary
CamelSpringTestSupport()
           
 
Method Summary
protected  void assertValidContext(org.apache.camel.CamelContext context)
           
protected abstract  AbstractApplicationContext createApplicationContext()
           
protected  org.apache.camel.CamelContext createCamelContext()
           
 void doPreSetup()
          Strategy to perform any pre setup, before CamelContext is created
protected  java.lang.Class<?> excludeRoute()
          Template method used to exclude a Route from the test camel context
protected  java.lang.Class<?>[] excludeRoutes()
          Template method used to exclude Route from the test time context route scanning
protected  int getExpectedRouteCount()
           
<T> T
getMandatoryBean(java.lang.Class<T> type, java.lang.String name)
          Looks up the mandatory spring bean of the given name and type, failing if it is not present or the correct type
protected  ApplicationContext getRouteExcludingApplicationContext()
          Create a parent context that initializes a PackageScanClassResolver to exclude a set of given classes from being resolved.
 void postProcessTest()
          Lets post process this test instance to process any Camel annotations.
 void tearDown()
           
static void tearSpringDownAfterClass()
           
 
Methods inherited from class org.apache.camel.testng.CamelTestSupport
assertExpression, assertMockEndpointsSatisfied, assertMockEndpointsSatisfied, assertPredicate, assertResolveLanguage, camelContextService, consumer, context, createExchangeWithBody, createJndiContext, createRegistry, createRouteBuilder, createRouteBuilders, debugAfter, debugBefore, disableJMX, doPostSetup, enableJMX, getCamelContextService, getMandatoryEndpoint, getMandatoryEndpoint, getMockEndpoint, getShutdownTimeout, isCreateCamelContextPerClass, isLazyLoadingTypeConverter, isMockEndpoints, isUseRouteBuilder, resetMocks, resolveMandatoryEndpoint, resolveMandatoryEndpoint, sendBodies, sendBody, sendBody, setCamelContextService, setUp, setUseRouteBuilder, startCamelContext, stopCamelContext, tearDownAfterClass, template, useJmx
 
Methods inherited from class org.apache.camel.testng.TestSupport
assertCollectionSize, assertCollectionSize, assertDirectoryEquals, assertDirectoryEquals, assertEndpointUri, assertExpression, assertFileExists, assertInMessageBodyEquals, assertInMessageHeader, assertIsInstanceOf, assertListSize, assertListSize, assertMessageHeader, assertOneElement, assertOutMessageBodyEquals, assertOutMessageHeader, assertPredicate, assertPredicateDoesNotMatch, assertPredicateMatches, assertStringContains, body, bodyAs, createDirectory, createExchangeWithBody, deleteDirectory, deleteDirectory, faultBody, faultBodyAs, getRouteList, getTestMethodName, header, isJava15, isJavaVendor, isPlatform, outBody, outBodyAs, property, resolveMandatoryEndpoint, resolveMandatoryEndpoint, systemProperty, systemProperty, unwrap, unwrapChannel
 
Methods inherited from class org.testng.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadAppContext

protected static java.lang.ThreadLocal<AbstractApplicationContext> threadAppContext

lock

protected static java.lang.Object lock

applicationContext

protected static AbstractApplicationContext applicationContext
Constructor Detail

CamelSpringTestSupport

public CamelSpringTestSupport()
Method Detail

createApplicationContext

protected abstract AbstractApplicationContext createApplicationContext()

postProcessTest

public void postProcessTest()
                     throws java.lang.Exception
Description copied from class: CamelTestSupport
Lets post process this test instance to process any Camel annotations. Note that using Spring Test or Guice is a more powerful approach.

Overrides:
postProcessTest in class CamelTestSupport
Throws:
java.lang.Exception

doPreSetup

public void doPreSetup()
                throws java.lang.Exception
Description copied from class: CamelTestSupport
Strategy to perform any pre setup, before CamelContext is created

Overrides:
doPreSetup in class CamelTestSupport
Throws:
java.lang.Exception

tearDown

public void tearDown()
              throws java.lang.Exception
Overrides:
tearDown in class CamelTestSupport
Throws:
java.lang.Exception

tearSpringDownAfterClass

public static void tearSpringDownAfterClass()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

getRouteExcludingApplicationContext

protected ApplicationContext getRouteExcludingApplicationContext()
Create a parent context that initializes a PackageScanClassResolver to exclude a set of given classes from being resolved. Typically this is used at test time to exclude certain routes, which might otherwise be just noisy, from being discovered and initialized.

To use this filtering mechanism it is necessary to provide the ApplicationContext returned from here as the parent context to your test context e.g.

 protected AbstractXmlApplicationContext createApplicationContext() {
     return new ClassPathXmlApplicationContext(new String[] {"test-context.xml"}, getRouteExcludingApplicationContext());
 }
 
This will, in turn, call the template methods excludedRoutes and excludedRoute to determine the classes to be excluded from scanning.

Returns:
ApplicationContext a parent ApplicationContext configured to exclude certain classes from package scanning

excludeRoutes

protected java.lang.Class<?>[] excludeRoutes()
Template method used to exclude Route from the test time context route scanning

Returns:
Class[] the classes to be excluded from test time context route scanning

excludeRoute

protected java.lang.Class<?> excludeRoute()
Template method used to exclude a Route from the test camel context


getMandatoryBean

public <T> T getMandatoryBean(java.lang.Class<T> type,
                              java.lang.String name)
Looks up the mandatory spring bean of the given name and type, failing if it is not present or the correct type


assertValidContext

protected void assertValidContext(org.apache.camel.CamelContext context)
Overrides:
assertValidContext in class CamelTestSupport

getExpectedRouteCount

protected int getExpectedRouteCount()

createCamelContext

protected org.apache.camel.CamelContext createCamelContext()
                                                    throws java.lang.Exception
Overrides:
createCamelContext in class CamelTestSupport
Throws:
java.lang.Exception


Apache CAMEL