Java 类org.apache.camel.ComponentConfiguration 实例源码

项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Show we can create a URI from the base URI and the underlying query parameter values
 */
@Test
public void testCreateUriStringFromParameters() throws Exception {
    Component component = context.getComponent("seda");
    ComponentConfiguration configuration = component.createComponentConfiguration();
    assertNotNull("Should have created a ComponentConfiguration for component " + component,
            configuration);

    // configure the base URI properties
    configuration.setBaseUri("foo");

    // lets try set and get a valid parameter
    configuration.setParameter("concurrentConsumers", 5);
    configuration.setParameter("size", 1000);

    String uriString = configuration.getUriString();
    assertEquals("uriString", "foo?concurrentConsumers=5&size=1000", uriString);
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Show we can create a URI from the base URI and the underlying query parameter values
 * on any endpoint (even if its not a {@link UriEndpointComponent})
 */
@Test
public void testCreateUriStringFromParametersOnDefaultComponent() 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("somePath");

    // lets try set and get a valid parameter
    configuration.setParameter("foo", "something");
    configuration.setParameter("bar", 123);

    String uriString = configuration.getUriString();
    assertEquals("uriString", "somePath?bar=123&foo=something", uriString);
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Test that parameters are strictly typed on {@link UriEndpointComponent}s
 */
@Test
public void testSetParametersFromUriString() throws Exception {
    Component component = context.getComponent("seda");
    ComponentConfiguration configuration = component.createComponentConfiguration();
    assertNotNull("Should have created a ComponentConfiguration for component " + component,
            configuration);

    // configure the uri and query parameters
    configuration.setUriString("foo?concurrentConsumers=5&size=1000");

    // notice the parameters are all correctly typed due to the use of a UriEndpointComponent
    // and the associated @UriEndpoint / @UriParam annotations
    assertEquals("concurrentConsumers", 5, configuration.getParameter("concurrentConsumers"));
    assertEquals("size", 1000, configuration.getParameter("size"));

    configuration.setUriString("foo?concurrentConsumers=9&size=2000");

    assertEquals("concurrentConsumers", 9, configuration.getParameter("concurrentConsumers"));
    assertEquals("size", 2000, configuration.getParameter("size"));
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Tests that parameters can be used on non-{@link UriEndpointComponent} implementations
 * but that their types tend to be String until we try to create an Endpoint
 */
@Test
public void testSetParametersFromUriStringOnDefaultComponent() throws Exception {
    Component component = context.getComponent("cheese");
    ComponentConfiguration configuration = component.createComponentConfiguration();
    assertNotNull("Should have created a ComponentConfiguration for component " + component,
            configuration);

    // configure the uri and query parameters
    configuration.setUriString("somePath?foo=something&bar=123");

    // notice the parameters are all Strings since we don't use UriEndpointComponent
    assertEquals("foo", "something", configuration.getParameter("foo"));
    assertEquals("bar", "123", configuration.getParameter("bar"));

    configuration.setUriString("somePath?foo=another&bar=456");

    assertEquals("foo", "another", configuration.getParameter("foo"));
    assertEquals("bar", "456", configuration.getParameter("bar"));
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Shows we can introspect a {@link UriEndpointComponent} and find all the available parameters
 * along with their types and {@link ParameterConfiguration}
 */
@Test
public void testIntrospectSedaEndpointParameters() throws Exception {
    Component component = context.getComponent("seda");
    ComponentConfiguration configuration = component.createComponentConfiguration();
    assertNotNull("Should have created a ComponentConfiguration for component " + component,
            configuration);

    SortedMap<String, ParameterConfiguration> parameterMap = configuration.getParameterConfigurationMap();
    assertTrue("getParameterConfigurationMap() should not be empty!", !parameterMap.isEmpty());

    ParameterConfiguration concurrentConsumersConfig = parameterMap.get("concurrentConsumers");
    assertNotNull("parameterMap[concurrentConsumers] should not be null!", concurrentConsumersConfig);
    assertEquals("concurrentConsumersConfig.getName()", "concurrentConsumers",
            concurrentConsumersConfig.getName());
    assertEquals("concurrentConsumersConfig.getParameterType()", int.class,
            concurrentConsumersConfig.getParameterType());

    LOG.info("{} has has configuration properties {}", component, parameterMap.keySet());
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Shows we can introspect the parameters of a DefaultComponent (i.e. a non {@link UriEndpointComponent})
 * though we only get to introspect the parameter values from teh current configuration
 */
@Test
public void testIntrospectDefaultComponentParameters() throws Exception {
    Component component = context.getComponent("cheese");
    ComponentConfiguration configuration = component.createComponentConfiguration();
    assertNotNull("Should have created a ComponentConfiguration for component " + component,
            configuration);

    SortedMap<String, ParameterConfiguration> parameterMap = configuration.getParameterConfigurationMap();
    assertTrue("getParameterConfigurationMap() should be empty as we have no parameters yet",
            parameterMap.isEmpty());

    // configure the uri and query parameters
    configuration.setUriString("somePath?foo=something&bar=123");

    parameterMap = configuration.getParameterConfigurationMap();
    assertEquals("getParameterConfigurationMap() size", 2, parameterMap.size());
    ParameterConfiguration barConfiguration = configuration.getParameterConfiguration("bar");
    assertNotNull("should hav a configuration for 'bar'", barConfiguration);
    assertEquals("barConfiguration.getName()", "bar", barConfiguration.getName());
    assertEquals("barConfiguration.getParameterType()", String.class,
            barConfiguration.getParameterType());
}
项目:Camel    文件:DataSetComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    DataSetComponent comp = context.getComponent("dataset", DataSetComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("dataset:foo?minRate=3&produceDelay=33&consumeDelay=333&preloadSize=3333&initialDelay=33333&disableDataSetIndex=true");

    assertEquals("Unexpected endpoint configuration value for minRate", "3", conf.getParameter("minRate"));
    assertEquals("Unexpected endpoint configuration value for produceDelay", "33", conf.getParameter("produceDelay"));
    assertEquals("Unexpected endpoint configuration value for consumeDelay", "333", conf.getParameter("consumeDelay"));
    assertEquals("Unexpected endpoint configuration value for preloadSize", "3333", conf.getParameter("preloadSize"));
    assertEquals("Unexpected endpoint configuration value for initialDelay", "33333", conf.getParameter("initialDelay"));
    assertEquals("Unexpected endpoint configuration value for disableDataSetIndex", "true", conf.getParameter("disableDataSetIndex"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"group\": \"common\", \"required\": \"true\", \"type\""));
    assertTrue(json.contains("\"kind\": \"parameter\", \"group\": \"consumer\", \"label\": \"consumer\", \"type\": \"integer\""));
    assertTrue(json.contains("\"retainFirst\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\", \"type\": \"integer"));
}
项目:Camel    文件:DataFormatComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    DataFormatComponent comp = context.getComponent("dataformat", DataFormatComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("dataformaat:marshal:string?charset=iso-8859-1");

    assertEquals("iso-8859-1", conf.getParameter("charset"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"group\": \"producer\", \"required\": \"true\", \"type\": \"string\", \"javaType\": \"java.lang.String\","
                    + " \"deprecated\": \"false\", \"description\": \"Name of data format\" }"));
    assertTrue(json.contains("\"operation\": { \"kind\": \"path\", \"group\": \"producer\", \"required\": \"true\", \"type\": \"string\""));
    assertTrue(json.contains("\"synchronous\": { \"kind\": \"parameter\", \"group\": \"advanced\", \"label\": \"advanced\", \"type\": \"boolean\""));
}
项目:Camel    文件:FileComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    FileComponent comp = context.getComponent("file", FileComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("file:target/foo?delete=true");

    assertEquals("true", conf.getParameter("delete"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"directoryName\": { \"kind\": \"path\", \"group\": \"common\", \"required\": \"true\""));
    assertTrue(json.contains("\"doneFileName\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\", \"type\": \"string\""));
    assertTrue(json.contains("\"autoCreate\": { \"kind\": \"parameter\", \"group\": \"advanced\", \"label\": \"advanced\", \"type\": \"boolean\""));
    assertTrue(json.contains("\"readLockMinAge\": { \"kind\": \"parameter\", \"group\": \"lock\", \"label\": \"consumer,lock\""));
}
项目:Camel    文件:UriConfigurationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    CamelContext context = new DefaultCamelContext();

    BeanstalkComponent comp = context.getComponent("beanstalk", BeanstalkComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("beanstalk:tube?command=put");

    assertEquals("put", conf.getParameter("command"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"command\": { \"kind\": \"parameter\", \"group\": \"common\", \"type\": \"string\""));
    assertTrue(json.contains("\"jobTimeToRun\": { \"kind\": \"parameter\", \"group\": \"common\", \"type\": \"integer\""));
    assertTrue(json.contains("\"awaitJob\": { \"kind\": \"parameter\", \"group\": \"consumer\", \"label\": \"consumer\", \"type\": \"boolean\""));
}
项目:daq-eclipse    文件:BrokerComponent.java   
@Override
public List<String> completeEndpointPath(ComponentConfiguration componentConfiguration, String completionText) {
    String brokerName = String.valueOf(componentConfiguration.getParameter("brokerName"));
    MessageBrokerView messageBrokerView = MessageBrokerViewRegistry.getInstance().lookup(brokerName);
    if (messageBrokerView != null) {
        String destinationName = completionText;
        Set<? extends ActiveMQDestination> set = messageBrokerView.getQueues();
        if (completionText.startsWith("topic:")) {
            set = messageBrokerView.getTopics();
            destinationName = completionText.substring(6);
        } else if (completionText.startsWith("queue:")) {
            destinationName = completionText.substring(6);
        }
        ArrayList<String> answer = new ArrayList<String>();
        for (ActiveMQDestination destination : set) {
            if (destination.getPhysicalName().startsWith(destinationName)) {
                answer.add(destination.getPhysicalName());
            }
        }
        return answer;

    }
    return null;
}
项目:Camel    文件:ManagedCamelContext.java   
public List<String> completeEndpointPath(String componentName, Map<String, Object> endpointParameters,
                                         String completionText) throws Exception {
    if (completionText == null) {
        completionText = "";
    }
    Component component = context.getComponent(componentName, false);
    if (component != null) {
        ComponentConfiguration configuration = component.createComponentConfiguration();
        configuration.setParameters(endpointParameters);
        return configuration.completeEndpointPath(completionText);
    } else {
        return new ArrayList<String>();
    }
}
项目:Camel    文件:ManagedCamelContext.java   
public String componentParameterJsonSchema(String componentName) throws Exception {
    // favor using pre generated schema if component has that
    String json = context.getComponentParameterJsonSchema(componentName);
    if (json == null) {
        // okay this requires having the component on the classpath and being instantiated
        Component component = context.getComponent(componentName);
        if (component != null) {
            ComponentConfiguration configuration = component.createComponentConfiguration();
            json = configuration.createParameterJsonSchema();
        }
    }
    return json;
}
项目:Camel    文件:FileComponent.java   
public List<String> completeEndpointPath(ComponentConfiguration configuration, String completionText) {
    boolean empty = ObjectHelper.isEmpty(completionText);
    String pattern = completionText;
    File file = new File(completionText);
    String prefix = completionText;
    if (file.exists()) {
        pattern = "";
    } else {
        String startPath = ".";
        if (!empty) {
            int idx = completionText.lastIndexOf('/');
            if (idx >= 0) {
                startPath = completionText.substring(0, idx);
                if (startPath.length() == 0) {
                    startPath = "/";
                }
                pattern = completionText.substring(idx + 1);
            }
        }
        file = new File(startPath);
        prefix = startPath;
    }
    if (prefix.length() > 0 && !prefix.endsWith("/")) {
        prefix += "/";
    }
    if (prefix.equals("./")) {
        prefix = "";
    }
    File[] list = file.listFiles();
    List<String> answer = new ArrayList<String>();
    for (File aFile : list) {
        String name = aFile.getName();
        if (pattern.length() == 0 || name.contains(pattern)) {
            if (isValidEndpointCompletion(configuration, completionText, aFile)) {
                answer.add(prefix + name);
            }
        }
    }
    return answer;
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * 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);
    }
}
项目:Camel    文件:ComponentConfigurationTest.java   
/**
 * Shows how we can use the configuration to get and set parameters directly on the endpoint
 * which is typesafe and performs validation even if the component is not a {@link UriEndpointComponent}
 */
@Test
public void testConfigureAnExistingDefaultEndpoint() throws Exception {
    NonUriEndpoint endpoint = context
            .getEndpoint("cheese:somePath?bar=123&foo=something", NonUriEndpoint.class);
    Component component = endpoint.getComponent();
    ComponentConfiguration configuration = component.createComponentConfiguration();

    assertEquals("bar", 123, endpoint.getBar());
    assertEquals("bar", 123, configuration.getEndpointParameter(endpoint, "bar"));

    // lets try set and get some valid parameters
    configuration.setEndpointParameter(endpoint, "bar", 10);
    Object bar = configuration.getEndpointParameter(endpoint, "bar");
    assertEquals("endpoint.bar", 10, bar);

    configuration.setEndpointParameter(endpoint, "foo", "anotherThing");
    Object foo = configuration.getEndpointParameter(endpoint, "foo");
    assertEquals("endpoint.foo", "anotherThing", foo);

    // 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);
    }
}
项目:Camel    文件:XsltComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    XsltComponent comp = context.getComponent("xslt", XsltComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("xslt:foo?deleteOutputFile=true");

    assertEquals("true", conf.getParameter("deleteOutputFile"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"resourceUri\": { \"kind\": \"path\", \"group\": \"producer\", \"required\": \"true\""));
    assertTrue(json.contains("\"allowStAX\": { \"kind\": \"parameter\", \"group\": \"producer\", \"type\": \"boolean\""));
    assertTrue(json.contains("\"transformerFactoryClass\": { \"kind\": \"parameter\", \"group\": \"advanced\", \"label\": \"advanced\""));
}
项目:Camel    文件:MockComponentConfigurationAndDocumentationTest.java   
@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\", \"group\": \"producer\", \"required\": \"true\""));
    assertTrue(json.contains("\"expectedCount\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\""));
    assertTrue(json.contains("\"retainFirst\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\""));
}
项目:Camel    文件:SedaComponentConfigurationAndDocumentationTest.java   
@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\", \"group\": \"consumer\", \"label\": \"consumer\""));
    assertTrue(json.contains("\"timeout\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\""));
}
项目:Camel    文件:DirectVmComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    DirectVmComponent comp = context.getComponent("direct-vm", DirectVmComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("direct-vm:foo?block=false");

    assertEquals("false", conf.getParameter("block"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"group\": \"common\", \"required\": \"true\", \"type\": \"string\""));
    assertTrue(json.contains("\"timeout\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\", \"type\": \"integer\""));
}
项目:Camel    文件:LogComponentConfigurationAndDocumentationTest.java   
@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\", \"group\": \"producer\", \"required\": \"true\""));
    assertTrue(json.contains("\"level\": { \"kind\": \"parameter\", \"group\": \"producer\", \"type\": \"string\""));
    assertTrue(json.contains("\"showBody\": { \"kind\": \"parameter\", \"group\": \"formatting\", \"label\": \"formatting\""));
}
项目:Camel    文件:DirectComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    DirectComponent comp = context.getComponent("direct", DirectComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("direct:foo?block=true");

    assertEquals("true", conf.getParameter("block"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"group\": \"common\", \"required\": \"true\", \"type\": \"string\""));
    assertTrue(json.contains("\"timeout\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\", \"type\": \"integer\""));
}
项目:Camel    文件:LanguageComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    LanguageComponent comp = context.getComponent("language", LanguageComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("language:simple:foo?transform=false");

    assertEquals("false", conf.getParameter("transform"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"languageName\": { \"kind\": \"path\", \"group\": \"producer\", \"required\": \"true\""));
    assertTrue(json.contains("\"script\": { \"kind\": \"parameter\", \"group\": \"producer\", \"type\": \"string\""));
}
项目:Camel    文件:BrowseComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    BrowseComponent comp = context.getComponent("browse", BrowseComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("browse:seda:foo?synchronous=true");

    assertEquals("true", conf.getParameter("synchronous"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"group\": \"common\", \"required\": \"true\", \"type\": \"string\""));
    assertTrue(json.contains("\"synchronous\": { \"kind\": \"parameter\", \"group\": \"advanced\", \"label\": \"advanced\", \"type\": \"boolean\""));
}
项目:Camel    文件:TestComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    TestComponent comp = context.getComponent("test", TestComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("test:my:foo?timeout=1000");

    assertEquals("1000", conf.getParameter("timeout"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"group\": \"producer\", \"required\": \"true\""));
    assertTrue(json.contains("\"retainFirst\": { \"kind\": \"parameter\", \"group\": \"producer\", \"label\": \"producer\""));
}
项目:Camel    文件:TimerComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    TimerComponent comp = context.getComponent("timer", TimerComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("timer:foo?period=2000");

    assertEquals("2000", conf.getParameter("period"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"timerName\": { \"kind\": \"path\", \"group\": \"consumer\", \"required\": \"true\""));
    assertTrue(json.contains("\"delay\": { \"kind\": \"parameter\", \"group\": \"consumer\", \"type\": \"integer\""));
    assertTrue(json.contains("\"timer\": { \"kind\": \"parameter\", \"group\": \"advanced\", \"label\": \"advanced\""));
}
项目:Camel    文件:BeanComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    BeanComponent comp = context.getComponent("bean", BeanComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("bean:foo?method=bar");

    assertEquals("bar", conf.getParameter("method"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"method\": { \"kind\": \"parameter\", \"group\": \"producer\", \"type\": \"string\""));
    assertTrue(json.contains("\"cache\": { \"kind\": \"parameter\", \"group\": \"advanced\", \"label\": \"advanced\", \"type\": \"boolean\""));
}
项目:Camel    文件:ControlBusComponentConfigurationAndDocumentationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    ControlBusComponent comp = context.getComponent("controlbus", ControlBusComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("controlbus:route?routeId=bar&action=stop");

    assertEquals("bar", conf.getParameter("routeId"));
    assertEquals("stop", conf.getParameter("action"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    assertTrue(json.contains("\"action\": { \"kind\": \"parameter\", \"group\": \"producer\", \"type\": \"string\""));
    assertTrue(json.contains("\"async\": { \"kind\": \"parameter\", \"group\": \"producer\", \"type\": \"boolean\""));
}
项目:Camel    文件:JmsComponentConfigurationTest.java   
@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());
}
项目:Camel    文件:JmsComponentConfigurationTest.java   
public static void assertParameterConfig(ComponentConfiguration configuration, String name,
                                   Class<?> parameterType) {
    ParameterConfiguration config = configuration.getParameterConfiguration(name);
    assertNotNull("ParameterConfiguration should exist for parameter name " + name, config);
    assertEquals("ParameterConfiguration." + name + ".getName()", name, config.getName());
    assertEquals("ParameterConfiguration." + name + ".getParameterType()", parameterType,
            config.getParameterType());
}
项目:Camel    文件:UriConfigurationTest.java   
@Test
public void testComponentConfiguration() throws Exception {
    TwitterComponent comp = context.getComponent("twitter", TwitterComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("twitter:search?keywords=camel");

    assertEquals("camel", conf.getParameter("keywords"));

    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);

    // REVIST this comparison test may be sensitive to some changes.
    assertTrue(json.contains("\"accessToken\": { \"kind\": \"parameter\", \"group\": \"common\", \"type\": \"string\""));
    assertTrue(json.contains("\"consumerKey\": { \"kind\": \"parameter\", \"group\": \"common\", \"type\": \"string\""));
}
项目:Camel    文件:SalesforceComponentConfigurationTest.java   
@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("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());
}
项目:Camel    文件:SalesforceComponentConfigurationTest.java   
public static void assertParameterConfig(ComponentConfiguration configuration, String name,
                                   Class<?> parameterType) {
    ParameterConfiguration config = configuration.getParameterConfiguration(name);
    assertNotNull("ParameterConfiguration should exist for parameter name " + name, config);
    assertEquals("ParameterConfiguration." + name + ".getName()", name, config.getName());
    assertEquals("ParameterConfiguration." + name + ".getParameterType()", parameterType,
            config.getParameterType());
}
项目:daq-eclipse    文件:ActiveMQComponent.java   
@Override
public List<String> completeEndpointPath(ComponentConfiguration componentConfiguration, String completionText) {
    // try to initialize destination source only the first time
    if (!sourceInitialized) {
        createDestinationSource();
        sourceInitialized = true;
    }
    ArrayList<String> answer = new ArrayList<String>();
    if (source != null) {
        Set candidates = source.getQueues();
        String destinationName = completionText;
        if (completionText.startsWith("topic:")) {
            candidates = source.getTopics();
            destinationName = completionText.substring(6);
        } else if (completionText.startsWith("queue:")) {
            destinationName = completionText.substring(6);
        }

        Iterator it = candidates.iterator();

        while (it.hasNext()) {
            ActiveMQDestination destination = (ActiveMQDestination) it.next();
            if (destination.getPhysicalName().startsWith(destinationName)) {
                answer.add(destination.getPhysicalName());
            }
        }
    }
    return answer;
}
项目:Camel    文件:DefaultComponent.java   
@Override
public ComponentConfiguration createComponentConfiguration() {
    return new DefaultComponentConfiguration(this);
}
项目:Camel    文件:UriEndpointComponent.java   
@Override
public ComponentConfiguration createComponentConfiguration() {
    return new UriComponentConfiguration(this);
}
项目:Camel    文件:FileComponent.java   
/**
 * Returns true if this is a valid file for completion. By default we should ignore files that start with a "."
 */
protected boolean isValidEndpointCompletion(ComponentConfiguration configuration, String completionText,
                                       File file) {
    return !file.getName().startsWith(".");
}
项目:Camel    文件:ConfigurationHelperTest.java   
@Override
public ComponentConfiguration createComponentConfiguration() {
    return null;
}
项目:Camel    文件:EndpointConfigurationTest.java   
@Override
public ComponentConfiguration createComponentConfiguration() {
    return null;
}
项目:Camel    文件:SalesforceComponentConfigurationTest.java   
@Test
    public void testEndpointCompletion() throws Exception {
        Component component = context().getComponent(componentName);
        ComponentConfiguration configuration = component.createComponentConfiguration();

        // get operation names
        assertCompletionOptions(configuration.completeEndpointPath(""),
            "getVersions", "getResources", "getGlobalObjects", "getBasicInfo", "getDescription", "getSObject",
            "createSObject", "updateSObject", "deleteSObject", "getSObjectWithId", "upsertSObject",
            "deleteSObjectWithId", "getBlobField", "query", "queryMore", "search", "createJob", "getJob",
            "closeJob", "abortJob", "createBatch", "getBatch", "getAllBatches", "getRequest", "getResults",
            "createBatchQuery", "getQueryResultIds", "getQueryResult", "[PushTopicName]"
        );

        // get filtered operation names
        assertCompletionOptions(configuration.completeEndpointPath("get"),
            "getVersions", "getResources", "getGlobalObjects", "getBasicInfo", "getDescription", "getSObject",
            "getSObjectWithId", "getBlobField", "getJob", "getBatch", "getAllBatches", "getRequest", "getResults",
            "getQueryResultIds", "getQueryResult"
        );

/* TODO support parameter completion
        // get ALL REST operation parameters
        // TODO support operation specific parameter completion
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?"),
            "apiVersion", "httpClient", "format", "sObjectName", "sObjectId", "sObjectFields",
            "sObjectIdName", "sObjectIdValue", "sObjectBlobFieldName", "sObjectClass", "sObjectQuery", "sObjectSearch");

        // get filtered REST parameters
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?format=XML&"),
            "apiVersion", "httpClient", "sObjectName", "sObjectId", "sObjectFields",
            "sObjectIdName", "sObjectIdValue", "sObjectBlobFieldName", "sObjectClass", "sObjectQuery", "sObjectSearch");

        // get ALL Bulk operation parameters
        // TODO support operation specific parameter completion
        assertCompletionOptions(configuration.completeEndpointPath("createJob?"),
            "apiVersion", "httpClient", "sObjectQuery", "contentType", "jobId", "batchId", "resultId");

        // get filtered Bulk operation parameters
        assertCompletionOptions(configuration.completeEndpointPath("createJob?contentType=XML&"),
            "apiVersion", "httpClient", "sObjectQuery", "jobId", "batchId", "resultId");

        // get ALL topic parameters for consumers
        assertCompletionOptions(configuration.completeEndpointPath("myTopic?"),
            "apiVersion", "httpClient", "updateTopic", "notifyForFields", "notifyForOperations");

        // get filtered topic parameters for consumers
        assertCompletionOptions(configuration.completeEndpointPath("myTopic?updateTopic=true&"),
            "apiVersion", "httpClient", "notifyForFields", "notifyForOperations");

        // get parameters from partial name
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObject"),
            "sObjectName", "sObjectId", "sObjectFields",
            "sObjectIdName", "sObjectIdValue", "sObjectBlobFieldName", "sObjectClass", "sObjectQuery", "sObjectSearch");
*/

        // get sObjectName values, from scanned DTO packages
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObjectName="),
            "Document", "Line_Item__c", "Merchandise__c");

        // get sObjectFields values, from scanned DTO
        assertCompletionOptions(
            configuration.completeEndpointPath("getSObject?sObjectName=Merchandise__c&sObjectFields="),
            "attributes", "Id", "OwnerId", "IsDeleted", "Name", "CreatedDate", "CreatedById",
            "LastModifiedDate", "LastModifiedById", "SystemModstamp", "LastActivityDate",
            "Description__c", "Price__c", "Total_Inventory__c");

        // get sObjectClass values, from scanned DTO packages
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObjectClass="),
            Document.class.getName(),
            Line_Item__c.class.getName(),
            Merchandise__c.class.getName(),
            QueryRecordsLine_Item__c.class.getName());
    }