use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class DeadLetterChannelBuilderWithInvalidDeadLetterUriTest method testInvalidOption.
public void testInvalidOption() throws Exception {
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(deadLetterChannel("direct:error?foo=bar"));
from("direct:start").to("mock:foo");
}
});
fail("Should have thrown an exception");
} catch (ResolveEndpointFailedException e) {
assertTrue(e.getMessage().endsWith("Unknown parameters=[{foo=bar}]"));
}
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class LocalContextComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// first check if we are using a fully qualified name: [context:]contextId:endpointUri
Map<String, Endpoint> map = getLocalCamelContext().getEndpointMap();
if (LOG.isTraceEnabled()) {
LOG.trace("Trying to lookup {} in local map {}", remaining, map.keySet());
}
Endpoint endpoint = map.get(remaining);
if (endpoint != null) {
logUsingEndpoint(uri, endpoint);
return new ContextEndpoint(uri, this, endpoint);
//return new ExportedEndpoint(endpoint);
}
// look to see if there is an endpoint of name 'remaining' using one of the local endpoints within
// the black box CamelContext
String[] separators = { ":", "://" };
for (String scheme : localProtocolSchemes) {
for (String separator : separators) {
String newUri = scheme + separator + remaining;
endpoint = map.get(newUri);
if (endpoint != null) {
logUsingEndpoint(uri, endpoint);
return new ContextEndpoint(uri, this, endpoint);
//return new ExportedEndpoint(endpoint);
}
}
}
throw new ResolveEndpointFailedException("Cannot find the endpoint with uri " + uri + " in the CamelContext " + getLocalCamelContext().getName());
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class QualifiedContextComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
String[] splitURI = ObjectHelper.splitOnCharacter(remaining, ":", 2);
if (splitURI[1] != null) {
String contextId = splitURI[0];
String localEndpoint = splitURI[1];
Component component = getCamelContext().getComponent(contextId);
if (component != null) {
LOG.debug("Attempting to create local endpoint: {} inside the component: {}", localEndpoint, component);
Endpoint endpoint = component.createEndpoint(localEndpoint);
if (endpoint == null) {
// throw the exception tell we cannot find an then endpoint from the given context
throw new ResolveEndpointFailedException("Cannot create a endpoint with uri" + localEndpoint + " for the CamelContext Component " + contextId);
} else {
ContextEndpoint answer = new ContextEndpoint(uri, this, endpoint);
answer.setContextId(contextId);
answer.setLocalEndpointUrl(localEndpoint);
return answer;
}
} else {
throw new ResolveEndpointFailedException("Cannot create the camel context component for context " + contextId);
}
} else {
// the uri is wrong
throw new ResolveEndpointFailedException("The uri " + remaining + "from camel context component is wrong");
}
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class ClassComponentInvalidConfigurationTest method testPropertyNotFoundOnClass.
public void testPropertyNotFoundOnClass() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("class:org.apache.camel.component.bean.MyPrefixBean?bean.foo=bar").to("mock:result");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
assertTrue(cause.getMessage().contains("Unknown parameters"));
assertTrue(cause.getMessage().contains("foo=bar"));
}
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class ClassComponentInvalidConfigurationTest method testClassNotFound.
public void testClassNotFound() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("class:org.apache.camel.component.bean.XXX").to("mock:result");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
ClassNotFoundException not = assertIsInstanceOf(ClassNotFoundException.class, cause.getCause());
assertEquals("org.apache.camel.component.bean.XXX", not.getMessage());
}
}
Aggregations