use of org.apache.camel.NoSuchEndpointException in project camel by apache.
the class EndpointReferenceTest method testReferenceEndpointFromOtherCamelContext.
public void testReferenceEndpointFromOtherCamelContext() throws Exception {
CamelContext context = applicationContext.getBean("camel2", CamelContext.class);
RouteContext routeContext = new DefaultRouteContext(context);
try {
routeContext.resolveEndpoint(null, "endpoint1");
fail("Should have thrown exception");
} catch (NoSuchEndpointException exception) {
assertTrue("Get a wrong exception message", exception.getMessage().contains("make sure the endpoint has the same camel context as the route does"));
}
}
use of org.apache.camel.NoSuchEndpointException in project camel by apache.
the class ExpressionBuilder method toExpression.
/**
* Returns an expression processing the exchange to the given endpoint uri
*
* @param uri endpoint uri to send the exchange to
* @return an expression object which will return the OUT body
*/
public static Expression toExpression(final String uri) {
return new ExpressionAdapter() {
public Object evaluate(Exchange exchange) {
String text = simpleExpression(uri).evaluate(exchange, String.class);
Endpoint endpoint = exchange.getContext().getEndpoint(text);
if (endpoint == null) {
throw new NoSuchEndpointException(text);
}
Producer producer;
try {
producer = endpoint.createProducer();
producer.start();
producer.process(exchange);
producer.stop();
} catch (Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
// return the OUT body, but check for exchange pattern
if (ExchangeHelper.isOutCapable(exchange)) {
return exchange.getOut().getBody();
} else {
return exchange.getIn().getBody();
}
}
@Override
public String toString() {
return "to(" + uri + ")";
}
};
}
use of org.apache.camel.NoSuchEndpointException in project camel by apache.
the class CamelDestinationTest method testCAMEL4073.
@Test
public void testCAMEL4073() throws Exception {
try {
Endpoint.publish("camel://foo", new Person() {
public void getPerson(Holder<String> personId, Holder<String> ssn, Holder<String> name) throws UnknownPersonFault {
}
});
fail("Should throw and Exception");
} catch (WebServiceException ex) {
Throwable c = ex.getCause();
assertNotNull(c);
assertTrue(c instanceof NoSuchEndpointException);
}
}
Aggregations