Search in sources :

Example 21 with ComponentConfiguration

use of org.apache.camel.ComponentConfiguration in project camel by apache.

the class LogComponentConfigurationAndDocumentationTest method testComponentConfiguration.

@Test
public void testComponentConfiguration() throws Exception {
    LogComponent comp = context.getComponent("log", LogComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("log:foo?level=DEBUG");
    assertEquals("DEBUG", conf.getParameter("level"));
    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);
    assertTrue(json.contains("\"loggerName\": { \"kind\": \"path\", \"displayName\": \"Logger Name\", \"group\": \"producer\", \"required\": true"));
    assertTrue(json.contains("\"level\": { \"kind\": \"parameter\", \"displayName\": \"Level\", \"group\": \"producer\", \"type\": \"string\""));
    assertTrue(json.contains("\"showBody\": { \"kind\": \"parameter\", \"displayName\": \"Show Body\", \"group\": \"formatting\", \"label\": \"formatting\""));
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) EndpointConfiguration(org.apache.camel.EndpointConfiguration) LogComponent(org.apache.camel.component.log.LogComponent) Test(org.junit.Test)

Example 22 with ComponentConfiguration

use of org.apache.camel.ComponentConfiguration in project camel by apache.

the class MockComponentConfigurationAndDocumentationTest method testComponentConfiguration.

@Test
public void testComponentConfiguration() throws Exception {
    MockComponent comp = context.getComponent("mock", MockComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("mock:foo?retainFirst=10");
    assertEquals("10", conf.getParameter("retainFirst"));
    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);
    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"displayName\": \"Name\", \"group\": \"producer\", \"required\": true"));
    assertTrue(json.contains("\"expectedCount\": { \"kind\": \"parameter\", \"displayName\": \"Expected Count\", \"group\": \"producer\", \"label\": \"producer\""));
    assertTrue(json.contains("\"retainFirst\": { \"kind\": \"parameter\", \"displayName\": \"Retain First\", \"group\": \"producer\", \"label\": \"producer\""));
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) MockComponent(org.apache.camel.component.mock.MockComponent) EndpointConfiguration(org.apache.camel.EndpointConfiguration) Test(org.junit.Test)

Example 23 with ComponentConfiguration

use of org.apache.camel.ComponentConfiguration in project camel by apache.

the class SedaComponentConfigurationAndDocumentationTest method testComponentConfiguration.

@Test
public void testComponentConfiguration() throws Exception {
    SedaComponent comp = context.getComponent("seda", SedaComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("seda:foo?blockWhenFull=true");
    assertEquals("true", conf.getParameter("blockWhenFull"));
    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);
    assertTrue(json.contains("\"concurrentConsumers\": { \"kind\": \"parameter\", \"displayName\": \"Concurrent Consumers\", \"group\": \"consumer\", \"label\": \"consumer\""));
    assertTrue(json.contains("\"timeout\": { \"kind\": \"parameter\", \"displayName\": \"Timeout\", \"group\": \"producer\", \"label\": \"producer\""));
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) SedaComponent(org.apache.camel.component.seda.SedaComponent) EndpointConfiguration(org.apache.camel.EndpointConfiguration) Test(org.junit.Test)

Example 24 with ComponentConfiguration

use of org.apache.camel.ComponentConfiguration in project camel by apache.

the class SalesforceComponentConfigurationIntegrationTest method testConfiguration.

@Test
public void testConfiguration() throws Exception {
    Component component = context().getComponent(componentName);
    ComponentConfiguration configuration = component.createComponentConfiguration();
    SortedMap<String, ParameterConfiguration> parameterConfigurationMap = configuration.getParameterConfigurationMap();
    if (verbose) {
        Set<Map.Entry<String, ParameterConfiguration>> entries = parameterConfigurationMap.entrySet();
        for (Map.Entry<String, ParameterConfiguration> entry : entries) {
            String name = entry.getKey();
            ParameterConfiguration config = entry.getValue();
            LOG.info("Has name: {} with type {}", name, config.getParameterType().getName());
        }
    }
    assertParameterConfig(configuration, "format", PayloadFormat.class);
    assertParameterConfig(configuration, "sObjectName", String.class);
    assertParameterConfig(configuration, "sObjectFields", String.class);
    assertParameterConfig(configuration, "updateTopic", boolean.class);
    configuration.setParameter("format", PayloadFormat.XML);
    configuration.setParameter("sObjectName", "Merchandise__c");
    configuration.setParameter("sObjectFields", "Description__c,Total_Inventory__c");
    configuration.setParameter("updateTopic", false);
    // operation name is base uri
    configuration.setBaseUri(componentName + ":getSObject");
    SalesforceEndpoint endpoint = assertIsInstanceOf(SalesforceEndpoint.class, configuration.createEndpoint());
    final SalesforceEndpointConfig endpointConfig = endpoint.getConfiguration();
    assertEquals("endpoint.format", PayloadFormat.XML, endpointConfig.getFormat());
    assertEquals("endpoint.sObjectName", "Merchandise__c", endpointConfig.getSObjectName());
    assertEquals("endpoint.sObjectFields", "Description__c,Total_Inventory__c", endpointConfig.getSObjectFields());
    assertEquals("endpoint.updateTopic", false, endpointConfig.isUpdateTopic());
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) Component(org.apache.camel.Component) ParameterConfiguration(org.apache.camel.impl.ParameterConfiguration) Map(java.util.Map) SortedMap(java.util.SortedMap) Test(org.junit.Test) MSPTest(org.apache.camel.component.salesforce.dto.generated.MSPTest)

Example 25 with ComponentConfiguration

use of org.apache.camel.ComponentConfiguration in project camel by apache.

the class JmsComponentConfigurationTest method testConfiguration.

@Test
public void testConfiguration() throws Exception {
    Component component = context().getComponent(componentName);
    ComponentConfiguration configuration = component.createComponentConfiguration();
    SortedMap<String, ParameterConfiguration> parameterConfigurationMap = configuration.getParameterConfigurationMap();
    if (verbose) {
        Set<Map.Entry<String, ParameterConfiguration>> entries = parameterConfigurationMap.entrySet();
        for (Map.Entry<String, ParameterConfiguration> entry : entries) {
            String name = entry.getKey();
            ParameterConfiguration config = entry.getValue();
            LOG.info("Has name: {} with type {}", name, config.getParameterType().getName());
        }
    }
    assertParameterConfig(configuration, "concurrentConsumers", int.class);
    assertParameterConfig(configuration, "clientId", String.class);
    assertParameterConfig(configuration, "disableReplyTo", boolean.class);
    assertParameterConfig(configuration, "timeToLive", long.class);
    configuration.setParameter("concurrentConsumers", 10);
    configuration.setParameter("clientId", "foo");
    configuration.setParameter("disableReplyTo", true);
    configuration.setParameter("timeToLive", 1000L);
    JmsEndpoint endpoint = assertIsInstanceOf(JmsEndpoint.class, configuration.createEndpoint());
    assertEquals("endpoint.concurrentConsumers", 10, endpoint.getConcurrentConsumers());
    assertEquals("endpoint.clientId", "foo", endpoint.getClientId());
    assertEquals("endpoint.disableReplyTo", true, endpoint.isDisableReplyTo());
    assertEquals("endpoint.timeToLive", 1000L, endpoint.getTimeToLive());
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) Component(org.apache.camel.Component) ParameterConfiguration(org.apache.camel.impl.ParameterConfiguration) Map(java.util.Map) SortedMap(java.util.SortedMap) Test(org.junit.Test)

Aggregations

ComponentConfiguration (org.apache.camel.ComponentConfiguration)31 Test (org.junit.Test)29 EndpointConfiguration (org.apache.camel.EndpointConfiguration)16 Component (org.apache.camel.Component)14 SedaComponent (org.apache.camel.component.seda.SedaComponent)11 InvalidPropertyException (org.apache.camel.InvalidPropertyException)4 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 MSPTest (org.apache.camel.component.salesforce.dto.generated.MSPTest)2 SedaEndpoint (org.apache.camel.component.seda.SedaEndpoint)2 ParameterConfiguration (org.apache.camel.impl.ParameterConfiguration)2 ArrayList (java.util.ArrayList)1 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)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