Search in sources :

Example 26 with EndpointConfiguration

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));
}
Also used : EndpointConfiguration(org.apache.camel.EndpointConfiguration) Test(org.junit.Test)

Example 27 with EndpointConfiguration

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

Aggregations

EndpointConfiguration (org.apache.camel.EndpointConfiguration)27 Test (org.junit.Test)26 ComponentConfiguration (org.apache.camel.ComponentConfiguration)16 Component (org.apache.camel.Component)1 BeanComponent (org.apache.camel.component.bean.BeanComponent)1 BrowseComponent (org.apache.camel.component.browse.BrowseComponent)1 ControlBusComponent (org.apache.camel.component.controlbus.ControlBusComponent)1 DataFormatComponent (org.apache.camel.component.dataformat.DataFormatComponent)1 DataSetComponent (org.apache.camel.component.dataset.DataSetComponent)1 DirectComponent (org.apache.camel.component.direct.DirectComponent)1 DirectVmComponent (org.apache.camel.component.directvm.DirectVmComponent)1 FileComponent (org.apache.camel.component.file.FileComponent)1 FtpComponent (org.apache.camel.component.file.remote.FtpComponent)1 LanguageComponent (org.apache.camel.component.language.LanguageComponent)1 LogComponent (org.apache.camel.component.log.LogComponent)1 MockComponent (org.apache.camel.component.mock.MockComponent)1 SedaComponent (org.apache.camel.component.seda.SedaComponent)1 TestComponent (org.apache.camel.component.test.TestComponent)1 TimerComponent (org.apache.camel.component.timer.TimerComponent)1 XsltComponent (org.apache.camel.component.xslt.XsltComponent)1