use of org.apache.camel.ComponentConfiguration in project camel by apache.
the class ComponentConfigurationTest method testConfigureAnExistingSedaEndpoint.
/**
* Shows how we can use the configuration to get and set parameters directly on the endpoint
* for a {@link UriEndpointComponent}
*/
@Test
public void testConfigureAnExistingSedaEndpoint() throws Exception {
SedaEndpoint endpoint = context.getEndpoint("seda:cheese?concurrentConsumers=5", SedaEndpoint.class);
SedaComponent component = endpoint.getComponent();
ComponentConfiguration configuration = component.createComponentConfiguration();
assertEquals("concurrentConsumers", 5, endpoint.getConcurrentConsumers());
assertEquals("concurrentConsumers", 5, configuration.getEndpointParameter(endpoint, "concurrentConsumers"));
// lets try set and get some valid parameters
configuration.setEndpointParameter(endpoint, "concurrentConsumers", 10);
Object concurrentConsumers = configuration.getEndpointParameter(endpoint, "concurrentConsumers");
assertEquals("endpoint.concurrentConsumers", 10, concurrentConsumers);
configuration.setEndpointParameter(endpoint, "size", 1000);
Object size = configuration.getEndpointParameter(endpoint, "size");
assertEquals("endpoint.size", 1000, size);
// lets try set an invalid parameter
try {
configuration.setEndpointParameter(endpoint, "doesNotExist", 1000);
fail("Should have got InvalidPropertyException thrown!");
} catch (InvalidPropertyException e) {
LOG.info("Got expected exception: " + e);
}
}
Aggregations