org.apache.camel.test
Class CamelSpringTestSupport

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.camel.test.TestSupport
              extended by org.apache.camel.test.CamelTestSupport
                  extended by org.apache.camel.test.CamelSpringTestSupport
All Implemented Interfaces:
junit.framework.Test

public abstract class CamelSpringTestSupport
extends CamelTestSupport

Version:

Field Summary
protected  org.springframework.context.support.AbstractApplicationContext applicationContext
           
 
Fields inherited from class org.apache.camel.test.CamelTestSupport
consumer, context, template
 
Fields inherited from class org.apache.camel.test.TestSupport
log
 
Constructor Summary
CamelSpringTestSupport()
           
 
Method Summary
protected  void assertValidContext(CamelContext context)
           
protected abstract  org.springframework.context.support.AbstractApplicationContext createApplicationContext()
           
protected  CamelContext createCamelContext()
           
protected  Class<?> excludeRoute()
          Template method used to exclude a Route from the test camel context
protected  Class<?>[] excludeRoutes()
          Template method used to exclude Route from the test time context route scanning
protected  int getExpectedRouteCount()
           
<T> T
getMandatoryBean(Class<T> type, 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  org.springframework.context.ApplicationContext getRouteExcludingApplicationContext()
          Create a parent context that initializes a PackageScanClassResolver to exclude a set of given classes from being resolved.
protected  void setUp()
           
protected  void tearDown()
           
 
Methods inherited from class org.apache.camel.test.CamelTestSupport
assertExpression, assertMockEndpointsSatisfied, assertMockEndpointsSatisfied, assertPredicate, assertResolveLanguage, createExchangeWithBody, createJndiContext, createRegistry, createRouteBuilder, createRouteBuilders, debugAfter, debugBefore, disableJMX, enableJMX, getCamelContextService, getMandatoryEndpoint, getMandatoryEndpoint, getMockEndpoint, getShutdownTimeout, isMockEndpoints, isUseRouteBuilder, postProcessTest, resetMocks, resolveMandatoryEndpoint, resolveMandatoryEndpoint, sendBodies, sendBody, sendBody, setCamelContextService, setUseRouteBuilder, startCamelContext, stopCamelContext, useJmx
 
Methods inherited from class org.apache.camel.test.TestSupport
assertCollectionSize, assertCollectionSize, assertDirectoryEquals, assertDirectoryEquals, assertEndpointUri, assertExpression, assertFileExists, assertInMessageBodyEquals, assertInMessageHeader, assertIsInstanceOf, assertListSize, assertListSize, assertMessageHeader, assertOneElement, assertOutMessageBodyEquals, assertOutMessageHeader, assertPredicate, assertPredicateDoesNotMatch, assertPredicateMatches, assertStringContains, body, bodyAs, canRunOnThisPlatform, createDirectory, createExchangeWithBody, deleteDirectory, deleteDirectory, faultBody, faultBodyAs, getRouteList, getTestMethodName, header, isJava15, isJavaVendor, isPlatform, outBody, outBodyAs, property, resolveMandatoryEndpoint, resolveMandatoryEndpoint, runBare, systemProperty, systemProperty, unwrap, unwrapChannel
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, 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
 

Field Detail

applicationContext

protected org.springframework.context.support.AbstractApplicationContext applicationContext
Constructor Detail

CamelSpringTestSupport

public CamelSpringTestSupport()
Method Detail

createApplicationContext

protected abstract org.springframework.context.support.AbstractApplicationContext createApplicationContext()

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class CamelTestSupport
Throws:
Exception

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class CamelTestSupport
Throws:
Exception

getRouteExcludingApplicationContext

protected org.springframework.context.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 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 Class<?> excludeRoute()
Template method used to exclude a Route from the test camel context


getMandatoryBean

public <T> T getMandatoryBean(Class<T> type,
                              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(CamelContext context)
Overrides:
assertValidContext in class CamelTestSupport

getExpectedRouteCount

protected int getExpectedRouteCount()

createCamelContext

protected CamelContext createCamelContext()
                                   throws Exception
Overrides:
createCamelContext in class CamelTestSupport
Throws:
Exception


Apache CAMEL