use of org.apache.camel.CamelContext in project camel by apache.
the class SmppComponentTest method createEndpointStringStringMapShouldReturnASmppEndpoint.
@Test
public void createEndpointStringStringMapShouldReturnASmppEndpoint() throws Exception {
CamelContext context = new DefaultCamelContext();
component = new SmppComponent(context);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("password", "secret");
Endpoint endpoint = component.createEndpoint("smpp://smppclient@localhost:2775", "?password=secret", parameters);
SmppEndpoint smppEndpoint = (SmppEndpoint) endpoint;
assertEquals("smpp://smppclient@localhost:2775", smppEndpoint.getEndpointUri());
assertEquals("smpp://smppclient@localhost:2775", smppEndpoint.getEndpointKey());
assertSame(component, smppEndpoint.getComponent());
assertNotNull(smppEndpoint.getConfiguration());
assertEquals("secret", smppEndpoint.getConfiguration().getPassword());
assertEquals("smpp://smppclient@localhost:2775", smppEndpoint.getConnectionString());
assertEquals(ExchangePattern.InOnly, smppEndpoint.getExchangePattern());
assertTrue(smppEndpoint.getBinding() instanceof SmppBinding);
assertNotNull(smppEndpoint.getCamelContext());
}
use of org.apache.camel.CamelContext in project camel by apache.
the class SmppComponentTest method constructorCamelContextShouldSetTheContext.
@Test
public void constructorCamelContextShouldSetTheContext() {
CamelContext context = new DefaultCamelContext();
component = new SmppComponent(context);
assertSame(context, component.getCamelContext());
}
use of org.apache.camel.CamelContext in project camel by apache.
the class CamelConfiguration method camelContext.
/**
* Get's the {@link CamelContext} to be used.
*/
@Bean
public CamelContext camelContext() throws Exception {
CamelContext camelContext = createCamelContext();
SpringCamelContext.setNoStart(true);
setupCamelContext(camelContext);
return camelContext;
}
use of org.apache.camel.CamelContext in project camel by apache.
the class RoutesCollector method onApplicationEvent.
// Overridden
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext applicationContext = event.getApplicationContext();
// only listen to context refresh of "my" applicationContext
if (this.applicationContext.equals(applicationContext)) {
CamelContext camelContext = event.getApplicationContext().getBean(CamelContext.class);
// only add and start Camel if its stopped (initial state)
if (camelContext.getStatus().isStopped()) {
LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
for (RoutesBuilder routesBuilder : configuration.routes()) {
// filter out abstract classes
boolean abs = Modifier.isAbstract(routesBuilder.getClass().getModifiers());
if (!abs) {
try {
LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder);
camelContext.addRoutes(routesBuilder);
} catch (Exception e) {
throw new CamelSpringJavaconfigInitializationException(e);
}
}
}
try {
boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
if (skip) {
LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
} else {
// start camel
camelContext.start();
}
} catch (Exception e) {
throw new CamelSpringJavaconfigInitializationException(e);
}
}
} else {
LOG.debug("Ignore ContextRefreshedEvent: {}", event);
}
}
use of org.apache.camel.CamelContext in project camel by apache.
the class MainTest method testOptionBP.
@Test
public void testOptionBP() throws Exception {
CamelContext context = createCamelContext(new String[] { "-bp", "org.apache.camel.spring.javaconfig.config" });
context.start();
runTests(context);
context.stop();
}
Aggregations