use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class EchoRpcIT method checkDefinedTimeout.
@Test(timeout = 60000)
public void checkDefinedTimeout() throws Exception {
System.getProperties().setProperty(CamelRpcClientPreProcessor.CAMEL_JMS_REQUEST_TIMEOUT_PROPERTY, "12345");
SimpleRegistry registry = new SimpleRegistry();
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("queuingservice", queuingservice);
CamelRpcRequest<EchoRequest, EchoResponse> wrapper = new CamelRpcRequest<>(new EchoRpcModule(), new EchoRequest());
CamelRpcClientPreProcessor camelRpcClientPreProcessor = new CamelRpcClientPreProcessor();
DefaultExchange defaultExchange = new DefaultExchange(context);
defaultExchange.getIn().setBody(wrapper);
camelRpcClientPreProcessor.process(defaultExchange);
context.stop();
assertEquals(12345L, defaultExchange.getIn().getHeader(CamelRpcConstants.CAMEL_JMS_REQUEST_TIMEOUT_HEADER));
}
use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class EchoRpcIT method futureFailsWithRemoteExecutionExceptionWhenExecutingRemotely.
/**
* Verifies that the future fails with a {@code RemoteExecutionException} when
* if an error occurs when executing remotely.
*/
@Test(timeout = 60000)
public void futureFailsWithRemoteExecutionExceptionWhenExecutingRemotely() throws Exception {
assertNotEquals(REMOTE_LOCATION_NAME, identity.getLocation());
EchoRpcModule echoRpcModule = new EchoRpcModule();
SimpleRegistry registry = new SimpleRegistry();
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("queuingservice", queuingservice);
context.start();
CamelRpcServerRouteManager routeManager = new CamelRpcServerRouteManager(context, new MockMinionIdentity(REMOTE_LOCATION_NAME));
routeManager.bind(echoRpcModule);
EchoRequest request = new EchoRequest("Oops!");
request.shouldThrow(true);
request.setLocation(REMOTE_LOCATION_NAME);
try {
echoClient.execute(request).get();
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause().getMessage(), e.getCause().getMessage().contains("Oops!"));
assertEquals(RemoteExecutionException.class, e.getCause().getClass());
}
routeManager.unbind(echoRpcModule);
context.stop();
}
use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class EchoRpcIT method checkUndefinedTimeout.
@Test(timeout = 60000)
public void checkUndefinedTimeout() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("queuingservice", queuingservice);
CamelRpcRequest<EchoRequest, EchoResponse> wrapper = new CamelRpcRequest<>(new EchoRpcModule(), new EchoRequest());
CamelRpcClientPreProcessor camelRpcClientPreProcessor = new CamelRpcClientPreProcessor();
DefaultExchange defaultExchange = new DefaultExchange(context);
defaultExchange.getIn().setBody(wrapper);
camelRpcClientPreProcessor.process(defaultExchange);
context.stop();
assertEquals(CamelRpcClientPreProcessor.CAMEL_JMS_REQUEST_TIMEOUT_DEFAULT, defaultExchange.getIn().getHeader(CamelRpcConstants.CAMEL_JMS_REQUEST_TIMEOUT_HEADER));
}
use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class NCSPathProviderTest method setUp.
@Before
public void setUp() throws Exception {
NCSPathRouteUtil pathUtil = new NCSPathRouteUtil(new MockNCSComponentRepository(), new MockNodeDao());
SimpleRegistry registry = new SimpleRegistry();
registry.put("pathProviderUtil", pathUtil);
CamelContext camel = new DefaultCamelContext(registry);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").setHeader(Exchange.HTTP_URI, simple("http://localhost:10346/ncs-provider/api/space/nsas/service-management/services/884779")).to("http://dummyhost").beanRef("pathProviderUtil", "getServiceName").setHeader(Exchange.HTTP_URI, simple("http://localhost:10346/ncs-provider/api/space/nsas/eline-ptp/service-management/services/884779/servicepath?deviceA=${header.deviceA}&deviceZ=${header.deviceZ}")).to("http://dummyhost").beanRef("pathProviderUtil", "createPath");
}
});
camel.start();
m_ncsPathService = new NCSPathProviderService(camel);
}
use of org.apache.camel.impl.SimpleRegistry in project camel by apache.
the class XmlRpcEndpointTest method createRegistry.
protected Registry createRegistry() {
SimpleRegistry answer = new SimpleRegistry();
// Binding the client configurer
answer.put("myClientConfigurer", new MyClientConfigurer());
return answer;
}
Aggregations