use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-camel by wildfly-extras.
the class NettyIntegrationTest method testDeployedContext.
@Test
public void testDeployedContext() throws Exception {
CamelContextRegistry registry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
CamelContext camelctx = registry.getCamelContext("netty-context");
Assert.assertNotNull("CamelContext not null", camelctx);
Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());
PollingConsumer pollingConsumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
pollingConsumer.start();
Socket socket = new Socket(SOCKET_HOST, 7999);
socket.setKeepAlive(true);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
try {
out.write("Kermit\n");
} finally {
out.close();
socket.close();
}
String result = pollingConsumer.receive().getIn().getBody(String.class);
Assert.assertEquals("Hello Kermit", result);
}
use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-camel by wildfly-extras.
the class CamelContextRegistryBindingService method addService.
public static ServiceController<?> addService(ServiceTarget serviceTarget) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_REGISTRY_BINDING_NAME);
BinderService binderService = new BinderService(bindInfo.getBindName()) {
@Override
public synchronized void start(StartContext context) throws StartException {
super.start(context);
LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName());
}
@Override
public synchronized void stop(StopContext context) {
LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName());
super.stop(context);
}
};
Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector();
ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService);
builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
builder.addDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelContextRegistry.class, new ManagedReferenceInjector<CamelContextRegistry>(injector));
return builder.install();
}
use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-swarm by wildfly-swarm.
the class SystemContextTransformTest method testSimpleTransform.
@Test
public void testSimpleTransform() throws Exception {
CamelContextRegistry contextRegistry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
CamelContext camelctx = contextRegistry.getCamelContext("myname");
Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", "Kermit", String.class);
Assert.assertEquals("Hello Kermit", result);
}
use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-swarm by wildfly-swarm.
the class JMXIntegrationTest method testMonitorMBeanAttribute.
@Test
public void testMonitorMBeanAttribute() throws Exception {
Context context = new InitialContext();
CamelContextRegistry contextRegistry = (CamelContextRegistry) context.lookup("java:jboss/camel/CamelContextRegistry");
CamelContext sysctx = contextRegistry.getCamelContext("camel-1");
Assert.assertEquals(ServiceStatus.Started, sysctx.getStatus());
final String routeName = sysctx.getRoutes().get(0).getId();
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jmx:platform?format=raw&objectDomain=org.apache.camel&key.context=camel-1&key.type=routes&key.name=\"" + routeName + "\"" + "&monitorType=counter&observedAttribute=ExchangesTotal&granularityPeriod=500").to("direct:end");
}
});
camelctx.start();
try {
ConsumerTemplate consumer = camelctx.createConsumerTemplate();
MonitorNotification notifcation = consumer.receiveBody("direct:end", MonitorNotification.class);
Assert.assertEquals("ExchangesTotal", notifcation.getObservedAttribute());
} finally {
camelctx.stop();
}
}
use of org.wildfly.extension.camel.CamelContextRegistry in project wildfly-swarm by wildfly-swarm.
the class SystemContextTransformTest method testSimpleTransform.
/*
@Deployment
public static JARArchive deployment() {
JARArchive archive = ShrinkWrap.create(JARArchive.class, "system-context-tests.jar");
archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return archive;
}
*/
/*
@CreateSwarm
public static Swarm newContainer() throws Exception {
return new Swarm().fraction(new CamelFraction().addRouteBuilder("myname", new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.transform(simple("Hello ${body}"));
}
}));
}
*/
@Test
public void testSimpleTransform() throws Exception {
CamelContextRegistry contextRegistry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
CamelContext camelctx = contextRegistry.getCamelContext("myname");
Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", "Kermit", String.class);
Assert.assertEquals("Hello Kermit", result);
}
Aggregations