Java 类org.apache.camel.ResolveEndpointFailedException 实例源码

项目:beyondj    文件:JettyHttpEndpoint.java   
protected HttpClient createJettyHttpClient() throws Exception {
    // create a new client
    // thread pool min/max from endpoint take precedence over from component
    Integer min = httpClientMinThreads != null ? httpClientMinThreads : getComponent().getHttpClientMinThreads();
    Integer max = httpClientMaxThreads != null ? httpClientMaxThreads : getComponent().getHttpClientMaxThreads();
    HttpClient httpClient = getComponent().createHttpClient(this, min, max, sslContextParameters);

    // set optional http client parameters
    if (httpClientParameters != null) {
        // copy parameters as we need to re-use them again if creating a new producer later
        Map<String, Object> params = new HashMap<String, Object>(httpClientParameters);
        // Can not be set on httpClient for jetty 9
        params.remove("timeout");
        IntrospectionSupport.setProperties(httpClient, params);
        // validate we could set all parameters
        if (params.size() > 0) {
            throw new ResolveEndpointFailedException(getEndpointUri(), "There are " + params.size()
                    + " parameters that couldn't be set on the endpoint."
                    + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
                    + " Unknown parameters=[" + params + "]");
        }
    }
    return httpClient;
}
项目:Camel    文件:ScheduledPollEndpoint.java   
@Override
protected void configurePollingConsumer(PollingConsumer consumer) throws Exception {
    Map<String, Object> copy = new HashMap<String, Object>(getConsumerProperties());
    Map<String, Object> throwaway = new HashMap<String, Object>();

    // filter out unwanted options which is intended for the scheduled poll consumer
    // as these options are not supported on the polling consumer
    configureScheduledPollConsumerProperties(copy, throwaway);

    // set reference properties first as they use # syntax that fools the regular properties setter
    EndpointHelper.setReferenceProperties(getCamelContext(), consumer, copy);
    EndpointHelper.setProperties(getCamelContext(), consumer, copy);

    if (!isLenientProperties() && copy.size() > 0) {
        throw new ResolveEndpointFailedException(this.getEndpointUri(), "There are " + copy.size()
                + " parameters that couldn't be set on the endpoint polling consumer."
                + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
                + " Unknown consumer parameters=[" + copy + "]");
    }
}
项目:Camel    文件:DefaultComponent.java   
/**
 * Strategy for validation of the uri when creating the endpoint.
 *
 * @param uri        the uri
 * @param path       the path - part after the scheme
 * @param parameters the parameters, an empty map if no parameters given
 * @throws ResolveEndpointFailedException should be thrown if the URI validation failed
 */
protected void validateURI(String uri, String path, Map<String, Object> parameters) {
    // check for uri containing double && markers without include by RAW
    if (uri.contains("&&")) {
        Pattern pattern = Pattern.compile("RAW(.*&&.*)");
        Matcher m = pattern.matcher(uri);
        // we should skip the RAW part
        if (!m.find()) {
            throw new ResolveEndpointFailedException(uri, "Invalid uri syntax: Double && marker found. "
                + "Check the uri and remove the duplicate & marker.");
        }
    }

    // if we have a trailing & then that is invalid as well
    if (uri.endsWith("&")) {
        throw new ResolveEndpointFailedException(uri, "Invalid uri syntax: Trailing & marker found. "
            + "Check the uri and remove the trailing & marker.");
    }
}
项目:Camel    文件:DeferServiceStartupListener.java   
@Override
public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception {
    // new services may be added while starting a service
    // so use a while loop to get the newly added services as well
    while (!services.isEmpty()) {
        Service service = services.iterator().next();
        try {
            ServiceHelper.startService(service);
        } catch (Exception e) {
            if (service instanceof Endpoint) {
                Endpoint endpoint = (Endpoint) service;
                throw new ResolveEndpointFailedException(endpoint.getEndpointUri(), e);
            } else {
                throw e;
            }
        } finally {
            services.remove(service);
        }
    }
}
项目:Camel    文件:DeadLetterChannelBuilderWithInvalidDeadLetterUriTest.java   
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}]"));
    }
}
项目:Camel    文件:RecipientListIgnoreInvalidEndpointsTest.java   
public void testRecipientListWithoutIgnoreInvalidEndpointsOption() throws Exception {
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedMessageCount(0);

    MockEndpoint endpointA = getMockEndpoint("mock:endpointA");
    endpointA.expectedMessageCount(0);

    try {
        template.requestBody("direct:startB", "Hello World", String.class);
        fail("Expect the exception here.");
    } catch (Exception ex) {
        assertTrue("Get a wrong cause of the exception", ex.getCause() instanceof ResolveEndpointFailedException);                         
    }

    assertMockEndpointsSatisfied();
}
项目:Camel    文件:RouteWithMistypedComponentNameTest.java   
public void testNoSuchEndpoint() throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:hello").to("mock:result");

                // unknown component
                endpoint("mistyped:hello");
            }
        });
        fail("Should have thrown a ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        // expected
    }
}
项目:Camel    文件:RouteWithMistypedComponentNameTest.java   
public void testNoSuchEndpointType() throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:hello").to("mock:result");

                // unknown component
                endpoint("mistyped:hello", Endpoint.class);
            }
        });
        fail("Should have thrown a ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        // expected
    }
}
项目:Camel    文件:CamelPostProcessorHelperTest.java   
public void testEndpointInjectProducerTemplateFieldUrlUnknown() throws Exception {
    CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);

    MyEndpointInjectProducerTemplateUrlUnknown bean = new MyEndpointInjectProducerTemplateUrlUnknown();
    Field field = bean.getClass().getField("producer");

    EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
    Class<?> type = field.getType();
    String propertyName = "producer";

    try {
        helper.getInjectionValue(type, endpointInject.uri(), endpointInject.ref(), endpointInject.property(), propertyName, bean, "foo");
        fail("Should throw exception");
    } catch (ResolveEndpointFailedException e) {
        assertEquals("Failed to resolve endpoint: xxx://foo due to: No component found with scheme: xxx", e.getMessage());
    }
}
项目:Camel    文件:DefaultCamelContextTest.java   
public void testHasEndpoint() throws Exception {
    DefaultCamelContext ctx = new DefaultCamelContext();
    ctx.disableJMX();
    ctx.getEndpoint("mock://foo");

    assertNotNull(ctx.hasEndpoint("mock://foo"));
    assertNull(ctx.hasEndpoint("mock://bar"));

    Map<String, Endpoint> map = ctx.getEndpointMap();
    assertEquals(1, map.size());

    try {
        ctx.hasEndpoint(null);
        fail("Should have thrown exception");
    } catch (ResolveEndpointFailedException e) {
        // expected
    }
}
项目:Camel    文件:LogCustomFormatterTest.java   
@Test
public void testCustomFormatterInRegistryUnknownOption() throws Exception {
    context.stop();

    exchangeFormatter = new TestExchangeFormatter();
    JndiRegistry registry = getRegistryAsJndi();
    registry.bind("logFormatter", exchangeFormatter);
    assertEquals("", exchangeFormatter.getPrefix());

    context.start();

    // unknown parameter
    try {
        String endpointUri2 = "log:" + LogCustomFormatterTest.class.getCanonicalName() + "?prefix=foo&bar=no";
        template.requestBody(endpointUri2, "Hello World");
        fail("Should have thrown exception");
    } catch (Exception e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        assertTrue(cause.getMessage().endsWith("Unknown parameters=[{bar=no}]"));
    }
}
项目:Camel    文件:PropertiesComponentDefaultTest.java   
public void testPropertiesComponentDefaultNoFileFound() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:bar.end?locations=org/apache/camel/component/properties/unknown.properties");
        }
    });
    try {
        context.start();
        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        FileNotFoundException fnfe = assertIsInstanceOf(FileNotFoundException.class, cause.getCause());
        assertEquals("Properties file org/apache/camel/component/properties/unknown.properties not found in classpath", fnfe.getMessage());
    }
}
项目:Camel    文件:PropertiesComponentTest.java   
public void testPropertiesComponentInvalidKey() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:{{foo.unknown}}");
        }
    });
    try {
        context.start();
        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
        assertEquals("Property with key [foo.unknown] not found in properties from text: {{foo.unknown}}", iae.getMessage());
    }
}
项目:Camel    文件:PropertiesComponentTest.java   
public void testPropertiesComponentCircularReference() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:cool.a");
        }
    });
    try {
        context.start();
        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
        assertEquals("Circular reference detected with key [cool.a] from text: {{cool.a}}", iae.getMessage());
    }
}
项目:Camel    文件:PropertiesComponentTest.java   
public void testPropertiesComponentPropertyPrefixFallbackDefaultNotFound() throws Exception {
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setPropertyPrefix("cool.");

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:doesnotexist");
        }
    });

    try {
        context.start();

        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
        assertEquals("Property with key [cool.doesnotexist] (and original key [doesnotexist]) not found in properties from text: {{doesnotexist}}", iae.getMessage());
    }
}
项目:Camel    文件:PropertiesComponentTest.java   
public void testPropertiesComponentPropertyPrefixFallbackFalse() throws Exception {
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setPropertyPrefix("cool.");
    pc.setFallbackToUnaugmentedProperty(false);

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:cool.end");
            from("direct:foo").to("properties:mock:{{result}}");
        }
    });

    try {
        context.start();

        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
        assertEquals("Property with key [cool.cool.end] not found in properties from text: {{cool.end}}", iae.getMessage());
    }
}
项目:Camel    文件:PropertiesComponentTest.java   
public void testPropertiesComponentPropertySuffixFallbackFalse() throws Exception {
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setPropertySuffix(".end");
    pc.setFallbackToUnaugmentedProperty(false);

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:cool.end");
        }
    });

    try {
        context.start();

        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
        assertEquals("Property with key [cool.end.end] not found in properties from text: {{cool.end}}", iae.getMessage());
    }
}
项目:Camel    文件:ClassComponentInvalidConfigurationTest.java   
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());
    }
}
项目:Camel    文件:ClassComponentInvalidConfigurationTest.java   
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"));
    }
}
项目:Camel    文件:HttpEndpointURLTest.java   
@Test
public void testHttpEndpointHttpUri() throws Exception {
    HttpEndpoint http1 = context.getEndpoint("http4://www.google.com", HttpEndpoint.class);
    HttpEndpoint http2 = context.getEndpoint("https4://www.google.com?test=parameter&proxyAuthHost=myotherproxy&proxyAuthPort=2345", HttpEndpoint.class);
    HttpEndpoint http3 = context.getEndpoint("https4://www.google.com?test=parameter", HttpEndpoint.class);

    assertEquals("Get a wrong HttpUri of http1", "http://www.google.com", http1.getHttpUri().toString());
    assertEquals("Get a wrong HttpUri of http2", "https://www.google.com?test=parameter", http2.getHttpUri().toString());
    assertEquals("Get a wrong HttpUri of http2 andhttp3", http2.getHttpUri(), http3.getHttpUri());

    try {
        // need to catch the exception here
        context.getEndpoint("https4://http://www.google.com", HttpEndpoint.class);
        fail("need to throw an exception here");
    } catch (ResolveEndpointFailedException ex) {
        assertTrue("Get a wrong exception message", ex.getMessage().indexOf("You have duplicated the http(s) protocol") > 0);
    }


}
项目:Camel    文件:JettyHttpEndpoint.java   
protected HttpClient createJettyHttpClient() throws Exception {
    // create a new client
    // thread pool min/max from endpoint take precedence over from component
    Integer min = httpClientMinThreads != null ? httpClientMinThreads : getComponent().getHttpClientMinThreads();
    Integer max = httpClientMaxThreads != null ? httpClientMaxThreads : getComponent().getHttpClientMaxThreads();
    HttpClient httpClient = getComponent().createHttpClient(this, min, max, sslContextParameters);

    // set optional http client parameters
    if (httpClientParameters != null) {
        // copy parameters as we need to re-use them again if creating a new producer later
        Map<String, Object> params = new HashMap<String, Object>(httpClientParameters);
        // Can not be set on httpClient for jetty 9
        params.remove("timeout");
        IntrospectionSupport.setProperties(httpClient, params);
        // validate we could set all parameters
        if (params.size() > 0) {
            throw new ResolveEndpointFailedException(getEndpointUri(), "There are " + params.size()
                    + " parameters that couldn't be set on the endpoint."
                    + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
                    + " Unknown parameters=[" + params + "]");
        }
    }
    return httpClient;
}
项目:Camel    文件:MinaEncodingTest.java   
@Test
public void testInvalidEncoding() throws Exception {
    final String uri = "mina:tcp://localhost:{{port}}?textline=true&encoding=XXX&sync=false";

    try {
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from(uri).to("mock:result");
            }
        });
        fail("Should have thrown a ResolveEndpointFailedException due invalid encoding parameter");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        assertTrue(cause.getCause() instanceof IllegalArgumentException);
        assertEquals("The encoding: XXX is not supported", cause.getCause().getMessage());
    }
}
项目:Camel    文件:QualifiedContextComponent.java   
@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");
    }
}
项目:camel-file-loadbalancer    文件:LoadBalancedFileComponent.java   
@Override
protected void afterPropertiesSet(GenericFileEndpoint<File> endpoint) throws Exception {
    super.afterPropertiesSet(endpoint);

    if (endpoint instanceof LoadBalancedFileEndpoint) {
        LoadBalancedFileEndpoint lbEndpoint = (LoadBalancedFileEndpoint)endpoint;

        PriorityFileFilterFactory factory = lbEndpoint.getPriorityFileFilterFactory();
        if (factory == null) {
            throw new ResolveEndpointFailedException(lbEndpoint.getEndpointUri(), "PriorityFileFilterFactory is null");
        }

        updateFilter(lbEndpoint, factory);
        updateMaxMessagesPerPoll(lbEndpoint, factory);
        updateMove(lbEndpoint);
    }
}
项目:switchyard    文件:CamelTransformerTest.java   
@Test
public void testNoCamelContextConfig() throws Exception {
    SwitchYardCamelContextImpl camelContext = new SwitchYardCamelContextImpl();
    ServiceDomain domain = new MockDomain();
    camelContext.setServiceDomain(domain);
    camelContext.start();

    try {
        getTransformer("sw-config-no-camel-context-config.xml", domain);
    } catch (ResolveEndpointFailedException e) {
        _logger.info("Caught expected Exception", e);
        return;
    } finally {
        camelContext.stop();
    }
    Assert.fail("Camel transform succeeded without target endpoint");
}
项目:switchyard    文件:CamelTransformerTest.java   
@Test
public void testNoEndpointRef() throws Exception {
    SwitchYardCamelContextImpl camelContext = new SwitchYardCamelContextImpl();
    ServiceDomain domain = new MockDomain();
    domain.setProperty(CamelContextConfigurator.CAMEL_CONTEXT_CONFIG_XML, PATH_CAMEL_CONTEXT_XML);
    camelContext.setServiceDomain(domain);
    camelContext.start();

    try {
        getTransformer("sw-config-no-endpoint-ref.xml", domain);
    } catch (ResolveEndpointFailedException e) {
        _logger.info("Caught expected Exception", e);
        return;
    } finally {
        camelContext.stop();
    }
    Assert.fail("Camel transform succeeded without target endpoint");
}
项目:Camel    文件:DefaultEndpoint.java   
protected void configureConsumer(Consumer consumer) throws Exception {
    if (consumerProperties != null) {
        // use a defensive copy of the consumer properties as the methods below will remove the used properties
        // and in case we restart routes, we need access to the original consumer properties again
        Map<String, Object> copy = new HashMap<String, Object>(consumerProperties);

        // set reference properties first as they use # syntax that fools the regular properties setter
        EndpointHelper.setReferenceProperties(getCamelContext(), consumer, copy);
        EndpointHelper.setProperties(getCamelContext(), consumer, copy);

        // special consumer.bridgeErrorHandler option
        Object bridge = copy.remove("bridgeErrorHandler");
        if (bridge != null && "true".equals(bridge)) {
            if (consumer instanceof DefaultConsumer) {
                DefaultConsumer defaultConsumer = (DefaultConsumer) consumer;
                defaultConsumer.setExceptionHandler(new BridgeExceptionHandlerToErrorHandler(defaultConsumer));
            } else {
                throw new IllegalArgumentException("Option consumer.bridgeErrorHandler is only supported by endpoints,"
                        + " having their consumer extend DefaultConsumer. The consumer is a " + consumer.getClass().getName() + " class.");
            }
        }

        if (!this.isLenientProperties() && copy.size() > 0) {
            throw new ResolveEndpointFailedException(this.getEndpointUri(), "There are " + copy.size()
                + " parameters that couldn't be set on the endpoint consumer."
                + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
                + " Unknown consumer parameters=[" + copy + "]");
        }
    }
}
项目:Camel    文件:DefaultComponent.java   
/**
 * Strategy for validation of parameters, that was not able to be resolved to any endpoint options.
 *
 * @param uri          the uri
 * @param parameters   the parameters, an empty map if no parameters given
 * @param optionPrefix optional prefix to filter the parameters for validation. Use <tt>null</tt> for validate all.
 * @throws ResolveEndpointFailedException should be thrown if the URI validation failed
 */
protected void validateParameters(String uri, Map<String, Object> parameters, String optionPrefix) {
    Map<String, Object> param = parameters;
    if (optionPrefix != null) {
        param = IntrospectionSupport.extractProperties(parameters, optionPrefix);
    }

    if (param.size() > 0) {
        throw new ResolveEndpointFailedException(uri, "There are " + param.size()
            + " parameters that couldn't be set on the endpoint."
            + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
            + " Unknown parameters=[" + param + "]");
    }
}
项目:Camel    文件:DefaultCamelContext.java   
/**
 * Normalize uri so we can do endpoint hits with minor mistakes and parameters is not in the same order.
 *
 * @param uri the uri
 * @return normalized uri
 * @throws ResolveEndpointFailedException if uri cannot be normalized
 */
protected static String normalizeEndpointUri(String uri) {
    try {
        uri = URISupport.normalizeUri(uri);
    } catch (Exception e) {
        throw new ResolveEndpointFailedException(uri, e);
    }
    return uri;
}
项目:Camel    文件:RoutingSlipIgnoreInvalidEndpointsTest.java   
public void testEndpointResolvedFailedWithoutIgnoreInvalidEndpoints() throws Exception {
    MockEndpoint result = getMockEndpoint("mock:result");
    result.expectedMessageCount(0);
    MockEndpoint end = getMockEndpoint("mock:end");
    end.expectedMessageCount(0);
    try {        
        template.sendBodyAndHeader("direct:b", "Hello", "myHeader", "direct:start,fail:endpoint,mock:result");        
        fail("Expect the exception here.");
    } catch (Exception ex) {
        assertTrue("Get a wrong cause of the exception", ex.getCause() instanceof ResolveEndpointFailedException);
    }
    assertMockEndpointsSatisfied();
}
项目:Camel    文件:AdviceWithReplaceFromTest.java   
public void testReplaceFromInvalidUri() throws Exception {
    try {
        context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                replaceFromWith("xxx:foo");
            }
        });
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
    }
}
项目:Camel    文件:ToDynamicTest.java   
public void testToDynamicInvalid() throws Exception {
    try {
        template.sendBody("direct:start", "Hello Camel");
        fail("Should fail");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
    }
}
项目:Camel    文件:DefaultComponentValidateURITest.java   
public void testUnknownParameter() throws Exception {
    try {
        context.getEndpoint("timer://foo?delay=250&unknown=1&period=500");
        fail("Should have thrown ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        // ok
    }
}
项目:Camel    文件:DefaultComponentValidateURITest.java   
public void testDoubleAmpersand() throws Exception {
    try {
        context.getEndpoint("timer://foo?delay=250&&period=500");
        fail("Should have thrown ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        // ok
    }
}
项目:Camel    文件:DefaultComponentValidateURITest.java   
public void testTrailingAmpersand() throws Exception {
    try {
        context.getEndpoint("timer://foo?delay=250&period=500&");
        fail("Should have thrown ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        // ok
    }
}
项目:Camel    文件:DefaultCamelContextTest.java   
public void testGetEndpointNotFound() throws Exception {
    DefaultCamelContext ctx = new DefaultCamelContext();
    ctx.disableJMX();
    try {
        ctx.getEndpoint("xxx:foo");
        fail("Should have thrown a ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        assertTrue(e.getMessage().contains("No component found with scheme: xxx"));
    }
}
项目:Camel    文件:DefaultComponentReferencePropertiesTest.java   
public void testTypoInParameter() throws Exception {
    MyComponent component = new MyComponent(context);
    try {
        component.createEndpoint("foo://?xxxexpression=#hello");
        fail("Should have throw a ResolveEndpointFailedException");
    } catch (ResolveEndpointFailedException e) {
        // ok
    }
}
项目:Camel    文件:SameVmQueueSizeAndNoSizeTest.java   
public void testSameQueueDifferentSize() throws Exception {
    try {
        template.sendBody("vm:foo?size=200", "Should fail");
        fail("Should fail");
    } catch (ResolveEndpointFailedException e) {
        IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("Cannot use existing queue vm://foo as the existing queue size 100 does not match given queue size 200", ise.getMessage());
    }
}
项目:Camel    文件:SameVmQueueSizeAndNoSizeTest.java   
public void testSameQueueDifferentSizeBar() throws Exception {
    try {
        template.sendBody("vm:bar?size=200", "Should fail");
        fail("Should fail");
    } catch (ResolveEndpointFailedException e) {
        IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("Cannot use existing queue vm://bar as the existing queue size " + Integer.MAX_VALUE + " does not match given queue size 200", ise.getMessage());
    }
}
项目:Camel    文件:SameSedaQueueSizeAndNoSizeTest.java   
public void testSameQueueDifferentSize() throws Exception {
    try {
        template.sendBody("seda:foo?size=200", "Should fail");
        fail("Should fail");
    } catch (ResolveEndpointFailedException e) {
        IllegalArgumentException ise = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("Cannot use existing queue seda://foo as the existing queue size 100 does not match given queue size 200", ise.getMessage());
    }
}