use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class JettyHttpEndpoint method createJettyHttpClient.
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;
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentPropertySuffixFallbackFalse.
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());
}
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentCircularReference.
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());
}
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentPropertyPrefixFallbackFalse.
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());
}
}
use of org.apache.camel.ResolveEndpointFailedException in project camel by apache.
the class ComponentConfigurationTest method testCreateNewDefaultComponentEndpoint.
@Test
public void testCreateNewDefaultComponentEndpoint() throws Exception {
Component component = context.getComponent("cheese");
ComponentConfiguration configuration = component.createComponentConfiguration();
assertNotNull("Should have created a ComponentConfiguration for component " + component, configuration);
// configure the base URI properties
configuration.setBaseUri("something");
// lets try set and get a valid parameter
configuration.setParameter("foo", "xyz");
configuration.setParameter("bar", 5);
NonUriEndpoint endpoint = TestSupport.assertIsInstanceOf(NonUriEndpoint.class, configuration.createEndpoint());
assertEquals("foo", "xyz", endpoint.getFoo());
assertEquals("bar", 5, endpoint.getBar());
LOG.info("Created endpoint " + endpoint + " on URI " + endpoint.getEndpointUri());
// lets try configure a parameter
configuration.setEndpointParameter(endpoint, "bar", 6);
assertEquals("bar", 6, endpoint.getBar());
// lets try configure an invalid parameter
try {
configuration.setEndpointParameter(endpoint, "doesNotExist", 1000);
fail("Should have got InvalidPropertyException thrown!");
} catch (InvalidPropertyException e) {
LOG.info("Got expected exception: " + e);
}
ComponentConfiguration badConfiguration = component.createComponentConfiguration();
badConfiguration.setBaseUri(configuration.getBaseUri());
badConfiguration.setParameters(configuration.getParameters());
// lets try set an invalid parameter on a configuration
// there is no way to validate on non UriEndpoint unless the endpoint
// creates its own configuration object so this always works...
badConfiguration.setParameter("doesNotExist", 1000);
// however it fails if we now try create an
try {
badConfiguration.createEndpoint();
fail("Should have got ResolveEndpointFailedException thrown!");
} catch (ResolveEndpointFailedException e) {
LOG.info("Got expected exception: " + e);
}
}
Aggregations