Search in sources :

Example 16 with ResolveEndpointFailedException

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}]"));
    }
}
Also used : ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) NoSuchEndpointException(org.apache.camel.NoSuchEndpointException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 17 with ResolveEndpointFailedException

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());
}
Also used : ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) Endpoint(org.apache.camel.Endpoint)

Example 18 with ResolveEndpointFailedException

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");
    }
}
Also used : ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) Endpoint(org.apache.camel.Endpoint) UriEndpointComponent(org.apache.camel.impl.UriEndpointComponent) Component(org.apache.camel.Component)

Example 19 with ResolveEndpointFailedException

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"));
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 20 with ResolveEndpointFailedException

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());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Aggregations

ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)25 RouteBuilder (org.apache.camel.builder.RouteBuilder)12 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)9 Endpoint (org.apache.camel.Endpoint)5 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 CamelContext (org.apache.camel.CamelContext)3 Component (org.apache.camel.Component)3 URI (java.net.URI)2 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 HttpBinding (org.apache.camel.http.common.HttpBinding)2 HttpRestHeaderFilterStrategy (org.apache.camel.http.common.HttpRestHeaderFilterStrategy)2 UrlRewrite (org.apache.camel.http.common.UrlRewrite)2 HeaderFilterStrategy (org.apache.camel.spi.HeaderFilterStrategy)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 URISyntaxException (java.net.URISyntaxException)1 LinkedHashSet (java.util.LinkedHashSet)1