org.apache.camel.test.blueprint
Class CamelBlueprintTestSupport

java.lang.Object
  extended by org.junit.Assert
      extended by org.apache.camel.test.junit4.TestSupport
          extended by org.apache.camel.test.junit4.CamelTestSupport
              extended by org.apache.camel.test.blueprint.CamelBlueprintTestSupport

public abstract class CamelBlueprintTestSupport
extends org.apache.camel.test.junit4.CamelTestSupport

Base class for OSGi Blueprint unit tests with Camel.


Field Summary
static String SPROP_CAMEL_CONTEXT_CREATION_TIMEOUT
          Name of a system property that sets camel context creation timeout.
 
Fields inherited from class org.apache.camel.test.junit4.CamelTestSupport
camelContextService, consumer, context, template
 
Fields inherited from class org.apache.camel.test.junit4.TestSupport
log, LS, testName
 
Constructor Summary
CamelBlueprintTestSupport()
           
 
Method Summary
protected  void addServicesOnStartup(Map<String,org.apache.camel.util.KeyValueHolder<Object,Dictionary>> services)
          Override this method to add services to be registered on startup.
protected  org.apache.camel.util.KeyValueHolder<Object,Dictionary> asService(Object service, Dictionary dict)
          Creates a holder for the given service, which make it easier to use addServicesOnStartup(java.util.Map)
protected  org.apache.camel.util.KeyValueHolder<Object,Dictionary> asService(Object service, String key, String value)
          Creates a holder for the given service, which make it easier to use addServicesOnStartup(java.util.Map)
protected  org.osgi.framework.BundleContext createBundleContext()
           
protected  org.apache.camel.CamelContext createCamelContext()
           
protected  String getBlueprintDescriptor()
          Gets the bundle descriptor from the classpath.
protected  org.osgi.framework.BundleContext getBundleContext()
          Return the system bundle context
protected  String getBundleDirectives()
          Gets the bundle directives.
protected  String getBundleFilter()
          Gets filter expression of bundle descriptors.
protected  String getBundleVersion()
          Gets test bundle version.
protected  Long getCamelContextCreationTimeout()
          Returns how long to wait for Camel Context to be created.
protected
<T> T
getOsgiService(Class<T> type)
           
protected
<T> T
getOsgiService(Class<T> type, long timeout)
           
protected
<T> T
getOsgiService(Class<T> type, String filter)
           
protected
<T> T
getOsgiService(Class<T> type, String filter, long timeout)
           
protected  boolean includeTestBundle()
          Override this method if you don't want CamelBlueprintTestSupport create the test bundle
protected  String[] loadConfigAdminConfigurationFile()
          Override this method and provide the name of the .cfg configuration file to use for Blueprint ConfigAdmin service.
 void setUp()
           
 void tearDown()
           
static void tearDownAfterClass()
           
protected  String useOverridePropertiesWithConfigAdmin(Dictionary props)
          Override this method to override config admin properties.
 
Methods inherited from class org.apache.camel.test.junit4.CamelTestSupport
applyCamelPostProcessor, assertExpression, assertMockEndpointsSatisfied, assertMockEndpointsSatisfied, assertPredicate, assertResolveLanguage, assertValidContext, camelContextService, consumer, context, createExchangeWithBody, createJndiContext, createRegistry, createRouteBuilder, createRouteBuilders, debugAfter, debugBefore, disableJMX, doPostSetup, doPreSetup, enableJMX, getCamelContextService, getMandatoryEndpoint, getMandatoryEndpoint, getMockEndpoint, getMockEndpoint, getShutdownTimeout, ignoreMissingLocationWithPropertiesComponent, isCreateCamelContextPerClass, isLazyLoadingTypeConverter, isMockEndpoints, isMockEndpointsAndSkip, isUseAdviceWith, isUseDebugger, isUseRouteBuilder, postProcessTest, replaceRouteFromWith, resetMocks, resolveMandatoryEndpoint, resolveMandatoryEndpoint, sendBodies, sendBody, sendBody, setCamelContextService, setUseRouteBuilder, startCamelContext, stopCamelContext, template, useJmx, useOverridePropertiesWithPropertiesComponent
 
Methods inherited from class org.apache.camel.test.junit4.TestSupport
assertCollectionSize, assertCollectionSize, assertDirectoryEquals, assertDirectoryEquals, assertEndpointUri, assertExpression, assertFileExists, assertFileNotExists, 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, isJava16, isJava17, isJava18, isJavaVendor, isPlatform, outBody, outBodyAs, property, resolveMandatoryEndpoint, resolveMandatoryEndpoint, systemProperty, systemProperty, unwrap, unwrapChannel
 
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPROP_CAMEL_CONTEXT_CREATION_TIMEOUT

public static final String SPROP_CAMEL_CONTEXT_CREATION_TIMEOUT
Name of a system property that sets camel context creation timeout.

See Also:
Constant Field Values
Constructor Detail

CamelBlueprintTestSupport

public CamelBlueprintTestSupport()
Method Detail

includeTestBundle

protected boolean includeTestBundle()
Override this method if you don't want CamelBlueprintTestSupport create the test bundle

Returns:
includeTestBundle If the return value is true CamelBlueprintTestSupport creates the test bundle which includes blueprint configuration files If the return value is false CamelBlueprintTestSupport won't create the test bundle

createBundleContext

protected org.osgi.framework.BundleContext createBundleContext()
                                                        throws Exception
Throws:
Exception

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class org.apache.camel.test.junit4.CamelTestSupport
Throws:
Exception

addServicesOnStartup

protected void addServicesOnStartup(Map<String,org.apache.camel.util.KeyValueHolder<Object,Dictionary>> services)
Override this method to add services to be registered on startup.

You can use the builder methods asService(Object, java.util.Dictionary), asService(Object, String, String) to make it easy to add the services to the map.


asService

protected org.apache.camel.util.KeyValueHolder<Object,Dictionary> asService(Object service,
                                                                            Dictionary dict)
Creates a holder for the given service, which make it easier to use addServicesOnStartup(java.util.Map)


asService

protected org.apache.camel.util.KeyValueHolder<Object,Dictionary> asService(Object service,
                                                                            String key,
                                                                            String value)
Creates a holder for the given service, which make it easier to use addServicesOnStartup(java.util.Map)


useOverridePropertiesWithConfigAdmin

protected String useOverridePropertiesWithConfigAdmin(Dictionary props)
                                               throws Exception
Override this method to override config admin properties.

Parameters:
props - properties where you add the properties to override
Returns:
the PID of the OSGi ConfigurationAdmin which are defined in the Blueprint XML file.
Throws:
Exception

loadConfigAdminConfigurationFile

protected String[] loadConfigAdminConfigurationFile()
Override this method and provide the name of the .cfg configuration file to use for Blueprint ConfigAdmin service.

Returns:
the name of the path for the .cfg file to load, and the persistence-id of the property placeholder.

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class org.apache.camel.test.junit4.CamelTestSupport
Throws:
Exception

tearDownAfterClass

public static void tearDownAfterClass()
                               throws Exception
Throws:
Exception

getBundleContext

protected org.osgi.framework.BundleContext getBundleContext()
Return the system bundle context


getBlueprintDescriptor

protected String getBlueprintDescriptor()
Gets the bundle descriptor from the classpath.

Return the location(s) of the bundle descriptors from the classpath. Separate multiple locations by comma, or return a single location.

For example override this method and return OSGI-INF/blueprint/camel-context.xml

Returns:
the location of the bundle descriptor file.

getBundleFilter

protected String getBundleFilter()
Gets filter expression of bundle descriptors. Modify this method if you wish to change default behavior.

Returns:
filter expression for OSGi bundles.

getBundleVersion

protected String getBundleVersion()
Gets test bundle version. Modify this method if you wish to change default behavior.

Returns:
test bundle version

getBundleDirectives

protected String getBundleDirectives()
Gets the bundle directives.

Modify this method if you wish to add some directives.


getCamelContextCreationTimeout

protected Long getCamelContextCreationTimeout()
Returns how long to wait for Camel Context to be created.

Returns:
timeout in milliseconds.

createCamelContext

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

getOsgiService

protected <T> T getOsgiService(Class<T> type)

getOsgiService

protected <T> T getOsgiService(Class<T> type,
                               long timeout)

getOsgiService

protected <T> T getOsgiService(Class<T> type,
                               String filter)

getOsgiService

protected <T> T getOsgiService(Class<T> type,
                               String filter,
                               long timeout)


Apache Camel