use of org.apache.camel.EndpointConfiguration in project camel by apache.
the class ConfigurationHelperTest method testUrlWithQuery.
@Test
public void testUrlWithQuery() throws Exception {
EndpointConfiguration cfg = ConfigurationHelper.createConfiguration("uri-dump://hadrian@localhost:9001/context/path/?bar=true&baz=2#none", context);
logConfigurationObject(cfg);
assertEquals(URIDUMP_SCHEME, cfg.getParameter(EndpointConfiguration.URI_SCHEME));
assertEquals("//hadrian@localhost:9001/context/path/?bar=true&baz=2#none", cfg.getParameter(EndpointConfiguration.URI_SCHEME_SPECIFIC_PART));
assertEquals("hadrian@localhost:9001", cfg.getParameter(EndpointConfiguration.URI_AUTHORITY));
assertEquals("hadrian", cfg.getParameter(EndpointConfiguration.URI_USER_INFO));
assertEquals("localhost", cfg.getParameter(EndpointConfiguration.URI_HOST));
assertEquals(Integer.valueOf(9001), cfg.getParameter(EndpointConfiguration.URI_PORT));
assertEquals("/context/path/", cfg.getParameter(EndpointConfiguration.URI_PATH));
assertEquals("bar=true&baz=2#none", cfg.getParameter(EndpointConfiguration.URI_QUERY));
assertEquals(null, cfg.getParameter(EndpointConfiguration.URI_FRAGMENT));
}
use of org.apache.camel.EndpointConfiguration in project camel by apache.
the class ConfigurationHelper method createConfiguration.
public static EndpointConfiguration createConfiguration(String uri, CamelContext context) throws Exception {
int schemeSeparator = uri.indexOf(':');
if (schemeSeparator == -1) {
// not an URIConfiguration
return null;
}
String scheme = uri.substring(0, schemeSeparator);
Component component = context.getComponent(scheme);
if (LOG.isTraceEnabled()) {
LOG.trace("Lookup for Component handling \"{}:\" configuration returned {}", new Object[] { scheme, component != null ? component.getClass().getName() : "<null>" });
}
if (component != null) {
EndpointConfiguration config = component.createConfiguration(scheme);
if (config instanceof DefaultEndpointConfiguration) {
((DefaultEndpointConfiguration) config).setURI(uri);
}
return config;
} else {
// no component to create the configuration
return null;
}
}
Aggregations