org.apache.camel.CamelContext.getComponent() - java examples

Here are the examples of the java api org.apache.camel.CamelContext.getComponent() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

48 Examples 7

19 View Complete Implementation : Components.java
Copyright Apache License 2.0
Author : apache
public Component get(String scheme) {
    return context.getComponent(scheme, true);
}

18 View Complete Implementation : IntegrationTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testComponentConfiguration() {
    configureRoutes("clreplacedpath:routes-with-component-configuration.js");
    SedaComponent seda = context.getComponent("seda", SedaComponent.clreplaced);
    replacedertThat(seda).isNotNull();
    replacedertThat(seda).hasFieldOrPropertyWithValue("queueSize", 1234);
}

18 View Complete Implementation : KnativeComponentTest.java
Copyright Apache License 2.0
Author : apache
// **************************
// 
// Common Tests
// 
// **************************
@Test
void testLoadEnvironment() throws Exception {
    KnativeEnvironment env = mandatoryLoadFromResource(context, "clreplacedpath:/environment.json");
    replacedertThat(env.stream()).hreplacedize(3);
    replacedertThat(env.stream()).anyMatch(s -> s.getType() == Knative.Type.channel);
    replacedertThat(env.stream()).anyMatch(s -> s.getType() == Knative.Type.endpoint);
    KnativeComponent component = context.getComponent("knative", KnativeComponent.clreplaced);
    component.setEnvironment(env);
    // 
    // Channels
    // 
    {
        KnativeEndpoint endpoint = context.getEndpoint("knative:channel/c1", KnativeEndpoint.clreplaced);
        replacedertThat(endpoint.lookupServiceDefinition("c1", Knative.EndpointKind.source)).isPresent();
        replacedertThat(endpoint.lookupServiceDefinition("e1", Knative.EndpointKind.source)).isNotPresent();
    }
    // 
    // Endpoints
    // 
    {
        KnativeEndpoint endpoint = context.getEndpoint("knative:endpoint/e1", KnativeEndpoint.clreplaced);
        replacedertThat(endpoint.lookupServiceDefinition("e1", Knative.EndpointKind.source)).isPresent();
        replacedertThat(endpoint.lookupServiceDefinition("c1", Knative.EndpointKind.source)).isNotPresent();
    }
}

18 View Complete Implementation : KnativeHttpTestSupport.java
Copyright Apache License 2.0
Author : apache
public static KnativeComponent configureKnativeComponent(CamelContext context, CloudEvent ce, List<KnativeEnvironment.KnativeServiceDefinition> definitions) {
    KnativeComponent component = context.getComponent("knative", KnativeComponent.clreplaced);
    component.setCloudEventsSpecVersion(ce.version());
    component.setEnvironment(new KnativeEnvironment(definitions));
    return component;
}

18 View Complete Implementation : ComponentTestCommand.java
Copyright Apache License 2.0
Author : apache
@Override
public Boolean executeTest(ITestConfig config, String component) throws Exception {
    logger.info("Getting Camel component: {}", component);
    org.apache.camel.Component comp = context.getComponent(component, true, config.getAutoStartComponent());
    replacedertNotNull("Cannot get module with name: " + component, comp);
    logger.info("Found Camel module: {} instance: {} with clreplacedName: {}", component, comp, comp.getClreplaced());
    return true;
}

18 View Complete Implementation : AuditTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    // simulate JMS with the SEDA component
    context.addComponent("jms", context.getComponent("seda"));
    return context;
}

18 View Complete Implementation : CamelRiderJavaDSLProdTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    // setup the properties component to use the production file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.clreplaced);
    prop.setLocation("clreplacedpath:rider-prod.properties");
    return context;
}

18 View Complete Implementation : CamelRiderJavaDSLTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    // setup the properties component to use the test file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.clreplaced);
    prop.setLocation("clreplacedpath:rider-test.properties");
    return context;
}

18 View Complete Implementation : FirstMockTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    // replace JMS with SEDA which we can do in this case as seda is a very very basic
    // in memory JMS broker ;). This is of course only possible to switch for a few components.
    context.addComponent("jms", context.getComponent("seda"));
    return context;
}

18 View Complete Implementation : FtpToJMSWithPropertyPlaceholderTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected CamelContext createCamelContext() throws Exception {
    // create CamelContext
    CamelContext camelContext = super.createCamelContext();
    // connect to embedded ActiveMQ JMS broker
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
    camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
    // setup the properties component to use the test file
    PropertiesComponent prop = camelContext.getComponent("properties", PropertiesComponent.clreplaced);
    prop.setLocation("clreplacedpath:rider-test.properties");
    return camelContext;
}

18 View Complete Implementation : AbstractXChangeIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
boolean hasAPICredentials(CamelContext camelctx) {
    XChangeComponent component = camelctx.getComponent("xchange", XChangeComponent.clreplaced);
    XChange xchange = component.getXChange();
    IllegalStatereplacedertion.replacedertNotNull(xchange, "XChange not created");
    return xchange.getExchangeSpecification().getApiKey() != null;
}

17 View Complete Implementation : PropertiesTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testComponentConfiguration() throws Exception {
    int queueSize1 = ThreadLocalRandom.current().nextInt(10, 100);
    int queueSize2 = ThreadLocalRandom.current().nextInt(10, 100);
    Properties properties = new Properties();
    properties.setProperty("camel.component.seda.queueSize", Integer.toString(queueSize1));
    properties.setProperty("camel.component.my-seda.queueSize", Integer.toString(queueSize2));
    ApplicationRuntime runtime = new ApplicationRuntime();
    runtime.setProperties(properties);
    runtime.getRegistry().bind("my-seda", new SedaComponent());
    runtime.addListener(new ContextConfigurer());
    runtime.addListener(Runtime.Phase.Started, r -> {
        CamelContext context = r.getCamelContext();
        replacedertThat(context.getComponent("seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize1);
        replacedertThat(context.getComponent("my-seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize2);
        runtime.stop();
    });
    runtime.run();
}

17 View Complete Implementation : SecuringConfigTest.java
Copyright Apache License 2.0
Author : camelinaction
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    // create the jasypt properties parser
    JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
    // and set the master preplacedword
    jasypt.setPreplacedword("supersecret");
    // we can avoid keeping the master preplacedword in plaintext in the application
    // by referencing a environment variable
    // export CAMEL_ENCRYPTION_PreplacedWORD=supersecret
    // jasypt.setPreplacedword("sysenv:CAMEL_ENCRYPTION_PreplacedWORD");
    // setup the properties component to use the production file
    PropertiesComponent prop = context.getComponent("properties", PropertiesComponent.clreplaced);
    prop.setLocation("clreplacedpath:rider-test.properties");
    // and use the jasypt properties parser so we can decrypt values
    prop.setPropertiesParser(jasypt);
    return context;
}

17 View Complete Implementation : VotingStarter.java
Copyright Apache License 2.0
Author : cschneider
public void run() throws Exception {
    CamelContext context = new DefaultCamelContext();
    TwitterComponent twitterComponent = context.getComponent("twitter", TwitterComponent.clreplaced);
    twitterComponent.setConsumerKey("");
    twitterComponent.setConsumerSecret("");
    twitterComponent.setAccessToken("");
    twitterComponent.setAccessTokenSecret("");
    context.setTracing(true);
    context.addRoutes(new VotingRoutes());
    context.start();
    System.in.read();
    context.stop();
}

17 View Complete Implementation : ComponentVerifier.java
Copyright Apache License 2.0
Author : syndesisio
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
protected ComponentVerifierExtension resolveComponentVerifierExtension(CamelContext context, String scheme) {
    if (verifierExtension == null) {
        synchronized (this) {
            if (verifierExtension == null) {
                Component component = context.getComponent(scheme, true, false);
                if (component == null) {
                    LOG.error("Component {} does not exist", scheme);
                } else {
                    verifierExtension = component.getExtension(verifierExtensionClreplaced).orElse(null);
                    if (verifierExtension == null) {
                        LOG.warn("Component {} does not support verifier extension", scheme);
                    }
                }
            }
        }
    }
    return verifierExtension;
}

17 View Complete Implementation : IntegrationLoggingDisabledTest.java
Copyright Apache License 2.0
Author : syndesisio
@Test
public void testDisabledContextConfiguration() throws Exception {
    CamelContext context = new DefaultCamelContext();
    Properties properties = new Properties();
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.clreplaced);
    pc.setInitialProperties(properties);
    RuntimeSupport.configureContext(context, new InMemoryRegistry());
    context.start();
    replacedertThat(context.getLogListeners()).have(new Condition<LogListener>() {

        @Override
        public boolean matches(LogListener value) {
            return !(value instanceof IntegrationLoggingListener);
        }
    });
    replacedertThat(context.getUuidGenerator()).isInstanceOf(DefaultUuidGenerator.clreplaced);
    context.stop();
}

17 View Complete Implementation : MyBatisIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
private Connection createConnection(CamelContext camelctx) throws Exception {
    MyBatisComponent component = camelctx.getComponent("mybatis", MyBatisComponent.clreplaced);
    return component.getSqlSessionFactory().getConfiguration().getEnvironment().getDataSource().getConnection();
}

16 View Complete Implementation : CamelServlet.java
Copyright Apache License 2.0
Author : apache
@Path("/timer/property-binding")
@GET
@Produces(MediaType.TEXT_PLAIN)
public boolean timerResolvePropertyPlaceholders() throws Exception {
    return context.getComponent("timer", TimerComponent.clreplaced).isBasicPropertyBinding();
}

16 View Complete Implementation : ManageTracerMain.java
Copyright Apache License 2.0
Author : camelinaction
protected CamelContext createCamelContext() throws Exception {
    CamelContext answer = new DefaultCamelContext();
    // simulate JMS with the Mock component
    answer.addComponent("jms", answer.getComponent("mock"));
    // enable connector for remote management
    answer.getManagementStrategy().getManagementAgent().setCreateConnector(true);
    return answer;
}

16 View Complete Implementation : ComponentMetadataRetrieval.java
Copyright Apache License 2.0
Author : syndesisio
protected MetaDataExtension resolveMetaDataExtension(CamelContext context, Clreplaced<? extends MetaDataExtension> metaDataExtensionClreplaced, String componentId, String actionId) {
    Component component = context.getComponent(componentId, true, false);
    if (component == null) {
        throw new IllegalArgumentException(String.format("Component %s does not exists", componentId));
    }
    return component.getExtension(metaDataExtensionClreplaced).orElse(null);
}

16 View Complete Implementation : ComponentOptionsTest.java
Copyright Apache License 2.0
Author : syndesisio
private static void validateRegistryOption(CamelContext context) throws Exception {
    context.start();
    Collection<String> names = context.getComponentNames();
    replacedertThat(names).contains("my-sql-proxy");
    replacedertThat(names).contains("sql");
    replacedertThat(names).doesNotContain("sql-my-sql-proxy");
    SqlComponent sqlComponent = context.getComponent("sql", SqlComponent.clreplaced);
    DataSource sqlDatasource = sqlComponent.getDataSource();
    replacedertThat(sqlDatasource).isNull();
    Map<String, Endpoint> endpoints = context.getEndpointMap();
    replacedertThat(endpoints).containsKey("sql://select%20from%20dual?dataSource=%23ds");
    context.stop();
}

16 View Complete Implementation : ComponentOptionsTest.java
Copyright Apache License 2.0
Author : syndesisio
private void validatePojoOption(CamelContext context) throws Exception {
    context.start();
    Collection<String> names = context.getComponentNames();
    replacedertThat(names).contains("my-sql-proxy");
    replacedertThat(names).contains("sql-my-sql-proxy");
    SqlComponent sqlComponent = context.getComponent("sql-my-sql-proxy", SqlComponent.clreplaced);
    DataSource sqlDatasource = sqlComponent.getDataSource();
    replacedertThat(sqlDatasource).isEqualTo(this.ds);
    Map<String, Endpoint> endpoints = context.getEndpointMap();
    replacedertThat(endpoints).containsKey("sql-my-sql-proxy://select%20from%20dual");
    context.stop();
}

15 View Complete Implementation : ActiveMQConnector.java
Copyright Apache License 2.0
Author : syndesisio
// ************************************
// Helpers
// ************************************
private SjmsComponent lookupComponent() {
    final CamelContext context = getCamelContext();
    final List<String> names = context.getComponentNames();
    if (ObjectHelper.isEmpty(names)) {
        return null;
    }
    // Try to check if a component with same set-up has already been
    // configured, if so reuse it.
    for (String name : names) {
        Component cmp = context.getComponent(name, false, false);
        if (!(cmp instanceof SjmsComponent)) {
            continue;
        }
        ConnectionFactory factory = ((SjmsComponent) cmp).getConnectionFactory();
        if (factory instanceof ActiveMQConnectionFactory) {
            ActiveMQConnectionFactory amqFactory = (ActiveMQConnectionFactory) factory;
            if (!Objects.equals(brokerUrl, amqFactory.getBrokerURL())) {
                continue;
            }
            if (!Objects.equals(username, amqFactory.getUserName())) {
                continue;
            }
            if (!Objects.equals(preplacedword, amqFactory.getPreplacedword())) {
                continue;
            }
            return (SjmsComponent) cmp;
        }
    }
    return null;
}

15 View Complete Implementation : AMQPConnector.java
Copyright Apache License 2.0
Author : syndesisio
private AMQPComponent lookupComponent() {
    final CamelContext context = getCamelContext();
    final List<String> names = context.getComponentNames();
    if (ObjectHelper.isEmpty(names)) {
        return null;
    }
    // lookup existing component with same configuration
    for (String name : names) {
        Component cmp = context.getComponent(name, false, false);
        if (cmp instanceof AMQPComponent) {
            final ConnectionFactory factory;
            try {
                factory = ((AMQPComponent) cmp).getConfiguration().getConnectionFactory();
            } catch (IllegalArgumentException e) {
                // ignore components without a connection factory
                continue;
            }
            if (factory instanceof JmsConnectionFactory) {
                JmsConnectionFactory jmsConnectionFactory = (JmsConnectionFactory) factory;
                if (!Objects.equals(connectionUri, jmsConnectionFactory.getRemoteURI())) {
                    continue;
                }
                if (!Objects.equals(username, jmsConnectionFactory.getUsername())) {
                    continue;
                }
                if (!Objects.equals(preplacedword, jmsConnectionFactory.getPreplacedword())) {
                    continue;
                }
                if (!Objects.equals(clientId, jmsConnectionFactory.getClientID())) {
                    continue;
                }
                return (AMQPComponent) cmp;
            }
        }
    }
    return null;
}

14 View Complete Implementation : ReactiveStreamsAutoConfigurationTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void testConfiguration() throws InterruptedException {
    CamelReactiveStreamsService service = CamelReactiveStreams.get(context);
    replacedertTrue(service instanceof DefaultCamelReactiveStreamsService);
    replacedertEquals(service, reactiveStreamsService);
    ReactiveStreamsComponent component = context.getComponent(ReactiveStreamsConstants.SCHEME, ReactiveStreamsComponent.clreplaced);
    replacedertEquals("rs-test", component.getInternalEngineConfiguration().getThreadPoolName());
}

13 View Complete Implementation : MetricsPaxExamTest.java
Copyright Apache License 2.0
Author : astefanutti
@Test
public void test() throws Exception {
    replacedertThat("Context name is incorrect!", context.getName(), equalTo("camel-cdi-metrics"));
    replacedertThat("Route status is incorrect!", context.getRouteStatus("unreliable-service"), equalTo(ServiceStatus.Started));
    // Wait a while so that the timer can kick in
    Thread.sleep(10000L);
    // We need to retrieve the metrics registry before we stop the Camel context otherwise the component is removed
    MetricRegistry registry = context.getComponent("metrics", MetricsComponent.clreplaced).getMetricRegistry();
    // And stop the Camel context so that inflight exchanges get completed
    context.stop();
    Meter generated = registry.meter("generated");
    Meter attempt = registry.meter("attempt");
    Meter success = registry.meter("success");
    Meter redelivery = registry.meter("redelivery");
    Meter error = registry.meter("error");
    Gauge ratio = registry.getGauges().get("success-ratio");
    replacedertThat("Meter counts are not consistent!", attempt.getCount() - redelivery.getCount() - success.getCount() - error.getCount(), equalTo(0L));
    replacedertThat("Success rate gauge value is incorrect!", ratio.getValue(), equalTo(success.getOneMinuteRate() / generated.getOneMinuteRate()));
}

13 View Complete Implementation : ComponentProxyWithCustomComponentTest.java
Copyright Apache License 2.0
Author : syndesisio
// *************************
// Helpers
// *************************
private void validate(Registry registry) throws Exception {
    final CamelContext context = new DefaultCamelContext(registry);
    try {
        context.setAutoStartup(false);
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("direct:start").to("my-sql-proxy").to("mock:result");
            }
        });
        context.start();
        Collection<String> names = context.getComponentNames();
        replacedertThat(names).contains("my-sql-proxy");
        replacedertThat(names).contains("sql-my-sql-proxy");
        SqlComponent sqlComponent = context.getComponent("sql-my-sql-proxy", SqlComponent.clreplaced);
        DataSource sqlDatasource = sqlComponent.getDataSource();
        replacedertThat(sqlDatasource).isEqualTo(this.ds);
        Map<String, Endpoint> endpoints = context.getEndpointMap();
        replacedertThat(endpoints).containsKey("sql-my-sql-proxy://select%20from%20dual");
    } finally {
        context.stop();
    }
}

13 View Complete Implementation : SlackIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testSlackMessage() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:test").to("slack:#general?iconEmoji=:camel:&username=CamelTest").to("mock:result");
            from("undertow:http://localhost/slack/webhook").setBody(constant("{\"ok\": true}"));
        }
    });
    SlackComponent comp = camelctx.getComponent("slack", SlackComponent.clreplaced);
    comp.setWebhookUrl("http://localhost:8080/slack/webhook");
    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.clreplaced);
    mockEndpoint.expectedMessageCount(1);
    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        producer.sendBody("direct:test", "Hello from Camel!");
        mockEndpoint.replacedertIsSatisfied();
    } finally {
        camelctx.close();
    }
}

12 View Complete Implementation : CamelMicroserviceProvider.java
Copyright Apache License 2.0
Author : SilverThings
@Override
public Set<Object> lookupMicroservice(final MicroserviceMetaData metaData) {
    if (Route.clreplaced.isreplacedignableFrom(metaData.getType())) {
        return Collections.singleton(camelContext.getRoute(metaData.getName()));
    } else if (Endpoint.clreplaced.isreplacedignableFrom(metaData.getType())) {
        return Collections.singleton(camelContext.getEndpoint(metaData.getName()));
    } else if (TypeConverter.clreplaced.isreplacedignableFrom(metaData.getType())) {
        return Collections.singleton(camelContext.getTypeConverter());
    } else if (Component.clreplaced.isreplacedignableFrom(metaData.getType())) {
        return Collections.singleton(camelContext.getComponent(metaData.getName()));
    } else if (ConsumerTemplate.clreplaced.isreplacedignableFrom(metaData.getType())) {
        return Collections.singleton(camelContext.createConsumerTemplate());
    } else if (ProducerTemplate.clreplaced.isreplacedignableFrom(metaData.getType())) {
        return Collections.singleton(camelContext.createProducerTemplate());
    }
    return new HashSet<>();
}

12 View Complete Implementation : ConsulIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testListDatacenters() throws Exception {
    List<String> ref = getConsul().catalogClient().getDatacenters();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.getComponent("consul", ConsulComponent.clreplaced).getConfiguration().setUrl(consulUrl);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:consul").to("consul:catalog");
        }
    });
    camelctx.start();
    try {
        List<?> res = fluentTemplate(camelctx).withHeader(ConsulConstants.CONSUL_ACTION, ConsulCatalogActions.LIST_DATACENTERS).to("direct:consul").request(List.clreplaced);
        replacedert.replacedertFalse(ref.isEmpty());
        replacedert.replacedertFalse(res.isEmpty());
        replacedert.replacedertEquals(ref, res);
    } finally {
        camelctx.close();
    }
}

11 View Complete Implementation : JCloudsBlobStoreIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testBlobStoreProducer() throws Exception {
    BlobStore blobStore = getBlobStore();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").setHeader(JcloudsConstants.BLOB_NAME, constant(BLOB_NAME_WITH_DIR)).setHeader(JcloudsConstants.CONTAINER_NAME, constant(CONTAINER_NAME_WITH_DIR)).to("jclouds:blobstore:transient");
        }
    });
    List<BlobStore> blobStores = new ArrayList<>();
    blobStores.add(blobStore);
    JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.clreplaced);
    jclouds.setBlobStores(blobStores);
    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        String result = template.requestBody("direct:start", "Hello Kermit", String.clreplaced);
        replacedert.replacedertEquals("Hello Kermit", result);
    } finally {
        camelctx.close();
    }
}

11 View Complete Implementation : JCloudsBlobStoreIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testBlobStoreConsumerWithDirectory() throws Exception {
    BlobStore blobStore = getBlobStore();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            fromF("jclouds:blobstore:transient?container=%s&directory=dir", CONTAINER_NAME_WITH_DIR).convertBodyTo(String.clreplaced).to("mock:result");
        }
    });
    List<BlobStore> blobStores = new ArrayList<>();
    blobStores.add(blobStore);
    JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.clreplaced);
    jclouds.setBlobStores(blobStores);
    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.clreplaced);
    mockEndpoint.expectedBodiesReceived("Hello Kermit");
    camelctx.start();
    try {
        JcloudsBlobStoreHelper.writeBlob(blobStore, CONTAINER_NAME_WITH_DIR, BLOB_NAME_WITH_DIR, new StringPayload("Hello Kermit"));
        mockEndpoint.replacedertIsSatisfied();
    } finally {
        camelctx.close();
    }
}

11 View Complete Implementation : JCloudsBlobStoreIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testBlobStoreConsumer() throws Exception {
    BlobStore blobStore = getBlobStore();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            fromF("jclouds:blobstore:transient?container=%s", CONTAINER_NAME).convertBodyTo(String.clreplaced).to("mock:result");
        }
    });
    List<BlobStore> blobStores = new ArrayList<>();
    blobStores.add(blobStore);
    JcloudsComponent jclouds = camelctx.getComponent("jclouds", JcloudsComponent.clreplaced);
    jclouds.setBlobStores(blobStores);
    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.clreplaced);
    mockEndpoint.expectedBodiesReceived("Hello Kermit");
    camelctx.start();
    try {
        JcloudsBlobStoreHelper.writeBlob(blobStore, CONTAINER_NAME, BLOB_NAME, new StringPayload("Hello Kermit"));
        mockEndpoint.replacedertIsSatisfied();
    } finally {
        camelctx.close();
    }
}

11 View Complete Implementation : ConsulIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testListNodes() throws Exception {
    List<Node> ref = getConsul().catalogClient().getNodes().getResponse();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.getComponent("consul", ConsulComponent.clreplaced).getConfiguration().setUrl(consulUrl);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:consul").to("consul:catalog");
        }
    });
    camelctx.start();
    try {
        List<?> res = fluentTemplate(camelctx).withHeader(ConsulConstants.CONSUL_ACTION, ConsulCatalogActions.LIST_NODES).to("direct:consul").request(List.clreplaced);
        replacedert.replacedertFalse(ref.isEmpty());
        replacedert.replacedertFalse(res.isEmpty());
        replacedert.replacedertEquals(ref, res);
    } finally {
        camelctx.close();
    }
}

10 View Complete Implementation : TwilioIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testTwilioProducer() throws Exception {
    replacedume.replacedumeNotNull("TWILIO_ACCOUNT_SID is null", TWILIO_ACCOUNT_SID);
    replacedume.replacedumeNotNull("TWILIO_PreplacedWORD is null", TWILIO_PreplacedWORD);
    CamelContext camelctx = new DefaultCamelContext();
    TwilioComponent component = camelctx.getComponent("twilio", TwilioComponent.clreplaced);
    component.setUsername(TWILIO_ACCOUNT_SID);
    component.setPreplacedword(TWILIO_PreplacedWORD);
    component.setAccountSid(TWILIO_ACCOUNT_SID);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct://start").to("twilio://account/fetch");
        }
    });
    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        Account account = template.requestBodyAndHeader("direct:start", null, "CamelTwilioPathSid", TWILIO_ACCOUNT_SID, Account.clreplaced);
        replacedert.replacedertNotNull("Twilio fetcher result was null", account);
        replacedert.replacedertEquals("Account SID did not match", TWILIO_ACCOUNT_SID, account.getSid());
    } finally {
        camelctx.close();
    }
}

9 View Complete Implementation : JPATransactionManagerIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testJpaTransactionManagerRouteRoute() throws Exception {
    CamelContext camelctx = contextRegistry.getCamelContext("jpa-context");
    replacedert.replacedertNotNull("Expected jpa-context to not be null", camelctx);
    // Persist a new account enreplacedy
    Account account = new Account(1, 500);
    camelctx.createProducerTemplate().sendBody("direct:start", account);
    JpaComponent component = camelctx.getComponent("jpa", JpaComponent.clreplaced);
    EnreplacedyManagerFactory enreplacedyManagerFactory = component.getEnreplacedyManagerFactory();
    // Read the saved enreplacedy back from the database
    EnreplacedyManager em = enreplacedyManagerFactory.createEnreplacedyManager();
    Account result = em.getReference(Account.clreplaced, 1);
    replacedert.replacedertEquals(account, result);
}

8 View Complete Implementation : OrdersServlet.java
Copyright Apache License 2.0
Author : wildfly-extras
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // Gets all orders saved to the in-memory database 'orders' table
    JpaComponent component = camelContext.getComponent("jpa", JpaComponent.clreplaced);
    EnreplacedyManagerFactory enreplacedyManagerFactory = component.getEnreplacedyManagerFactory();
    EnreplacedyManager enreplacedyManager = enreplacedyManagerFactory.createEnreplacedyManager();
    CriteriaBuilder criteriaBuilder = enreplacedyManager.getCriteriaBuilder();
    CriteriaQuery<Order> query = criteriaBuilder.createQuery(Order.clreplaced);
    query.select(query.from(Order.clreplaced));
    request.setAttribute("orders", enreplacedyManager.createQuery(query).getResultList());
    request.getRequestDispatcher("orders.jsp").forward(request, response);
}

6 View Complete Implementation : CamelContextMetadataMBeanTest.java
Copyright Apache License 2.0
Author : syndesisio
@Test
public void testBuilder() throws Exception {
    CamelContext context = new DefaultCamelContext();
    Properties properties = new Properties();
    properties.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "metadata");
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.clreplaced);
    pc.setInitialProperties(properties);
    RuntimeSupport.configureContext(context, new InMemoryRegistry());
    context.start();
    final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    final Set<ObjectInstance> mBeans = mBeanServer.queryMBeans(ObjectName.getInstance("io.syndesis.camel:*"), null);
    replacedertThat(mBeans).hreplacedize(1);
    final ObjectName objectName = mBeans.iterator().next().getObjectName();
    final AttributeList attributes = mBeanServer.getAttributes(objectName, ATTRIBUTES);
    replacedertThat(attributes.asList()).hreplacedize(ATTRIBUTES.length);
    context.stop();
}

6 View Complete Implementation : GoogleMailIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void profile() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    GoogleMailComponent gMailComponent = camelctx.getComponent("google-mail", GoogleMailComponent.clreplaced);
    GoogleApiEnv.configure(gMailComponent.getConfiguration(), getClreplaced(), LOG);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            final String pathPrefix = "users";
            // test route for attachments
            from("direct://GETPROFILE").to("google-mail://" + pathPrefix + "/getProfile?inBody=userId");
        }
    });
    try {
        camelctx.start();
        ProducerTemplate template = camelctx.createProducerTemplate();
        // using String message body for single parameter "userId"
        final Profile result = template.requestBody("direct://GETPROFILE", CURRENT_USERID, Profile.clreplaced);
        replacedert.replacedertNotNull("getProfile result", result);
        replacedert.replacedertNotNull("Should be email address replacedociated with current account", result.getEmailAddress());
        System.out.println("getProfile: " + result);
    } finally {
        camelctx.close();
    }
}

5 View Complete Implementation : CXFWSSecureConsumerIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testCXFSecureConsumer() throws Exception {
    CamelContext camelContext = new DefaultCamelContext();
    CxfComponent cxfComponent = camelContext.getComponent("cxf", CxfComponent.clreplaced);
    CxfEndpoint cxfProducer = createCxfEndpoint(SECURE_WS_ENDPOINT_URL, cxfComponent);
    cxfProducer.setSslContextParameters(createSSLContextParameters());
    CxfEndpoint cxfConsumer = createCxfEndpoint(SECURE_WS_ENDPOINT_URL, cxfComponent);
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to(cxfProducer);
            from(cxfConsumer).transform(simple("Hello ${body}"));
        }
    });
    try {
        // Force WildFly to generate a self-signed SSL cert & keystore
        HttpRequest.get("https://localhost:8443").throwExceptionOnFailure(false).getResponse();
        camelContext.start();
        ProducerTemplate template = camelContext.createProducerTemplate();
        String result = template.requestBody("direct:start", "Kermit", String.clreplaced);
        replacedert.replacedertEquals("Hello Kermit", result);
        // Verify that if we attempt to use HTTP, we get a 302 redirect to the HTTPS endpoint URL
        HttpResponse response = HttpRequest.get(INSECURE_WS_ENDPOINT_URL + "?wsdl").throwExceptionOnFailure(false).followRedirects(false).getResponse();
        replacedert.replacedertEquals(302, response.getStatusCode());
        replacedert.replacedertEquals(response.getHeader("Location"), SECURE_WS_ENDPOINT_URL + "?wsdl");
    } finally {
        camelContext.stop();
    }
}

5 View Complete Implementation : GoogleMailIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testGoogleMailLabels() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    GoogleMailComponent gMailComponent = camelctx.getComponent("google-mail", GoogleMailComponent.clreplaced);
    GoogleApiEnv.configure(gMailComponent.getConfiguration(), getClreplaced(), LOG);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            final String pathPrefix = "labels";
            // test route for create
            from("direct://CREATE").to("google-mail://" + pathPrefix + "/create");
            // test route for delete
            from("direct://DELETE").to("google-mail://" + pathPrefix + "/delete");
            // test route for get
            from("direct://GET").to("google-mail://" + pathPrefix + "/get");
            // test route for list
            from("direct://LIST").to("google-mail://" + pathPrefix + "/list?inBody=userId");
            // test route for patch
            from("direct://PATCH").to("google-mail://" + pathPrefix + "/patch");
            // test route for update
            from("direct://UPDATE").to("google-mail://" + pathPrefix + "/update");
        }
    });
    try {
        camelctx.start();
        ProducerTemplate template = camelctx.createProducerTemplate();
        // using String message body for single parameter "userId"
        ListLabelsResponse labels = template.requestBody("direct://LIST", CURRENT_USERID, ListLabelsResponse.clreplaced);
        final String testLabel = getClreplaced().getSimpleName() + ".labels " + UUID.randomUUID().toString();
        String labelId;
        if (findLabel(labels, testLabel) == null) {
            Map<String, Object> headers = new HashMap<>();
            // parameter type is String
            headers.put("CamelGoogleMail.userId", CURRENT_USERID);
            Label label = new Label().setName(testLabel).setMessageListVisibility("show").setLabelListVisibility("labelShow");
            // parameter type is com.google.api.services.gmail.model.Label
            headers.put("CamelGoogleMail.content", label);
            Label result = template.requestBodyAndHeaders("direct://CREATE", null, headers, Label.clreplaced);
            replacedert.replacedertNotNull("create result", result);
            labelId = result.getId();
        } else {
            labelId = findLabel(labels, testLabel).getId();
        }
        // using String message body for single parameter "userId"
        labels = template.requestBody("direct://LIST", CURRENT_USERID, ListLabelsResponse.clreplaced);
        replacedert.replacedertTrue(findLabel(labels, testLabel) != null);
        Map<String, Object> headers = new HashMap<>();
        // parameter type is String
        headers.put("CamelGoogleMail.userId", CURRENT_USERID);
        // parameter type is String
        headers.put("CamelGoogleMail.id", labelId);
        template.requestBodyAndHeaders("direct://DELETE", null, headers);
        // using String message body for single parameter "userId"
        labels = template.requestBody("direct://LIST", CURRENT_USERID, ListLabelsResponse.clreplaced);
        replacedert.replacedertTrue(findLabel(labels, testLabel) == null);
    } finally {
        camelctx.close();
    }
}

5 View Complete Implementation : GoogleMailIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@SuppressWarnings("serial")
@Test
public void threads() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    GoogleMailComponent gMailComponent = camelctx.getComponent("google-mail", GoogleMailComponent.clreplaced);
    GoogleApiEnv.configure(gMailComponent.getConfiguration(), getClreplaced(), LOG);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            final String pathPrefix = "threads";
            // test route for delete
            from("direct://DELETE").to("google-mail://" + pathPrefix + "/delete");
            // test route for get
            from("direct://GET").to("google-mail://" + pathPrefix + "/get");
            // test route for list
            from("direct://LIST").to("google-mail://" + pathPrefix + "/list?inBody=userId");
            // test route for modify
            from("direct://MODIFY").to("google-mail://" + pathPrefix + "/modify");
            // test route for trash
            from("direct://TRASH").to("google-mail://" + pathPrefix + "/trash");
            // test route for untrash
            from("direct://UNTRASH").to("google-mail://" + pathPrefix + "/untrash");
        }
    });
    try {
        camelctx.start();
        final String subject = getClreplaced().getSimpleName() + ".threads " + UUID.randomUUID().toString();
        ProducerTemplate template = camelctx.createProducerTemplate();
        Message m1 = createThreadedMessage(null, subject, template);
        final String threadId = m1.getThreadId();
        createThreadedMessage(threadId, subject, template);
        // using String message body for single parameter "userId"
        ListThreadsResponse result = template.requestBodyAndHeaders("direct://LIST", CURRENT_USERID, Collections.singletonMap("CamelGoogleMail.q", "subject:\"" + subject + "\""), ListThreadsResponse.clreplaced);
        replacedert.replacedertNotNull("list result", result);
        replacedert.replacedertTrue(result.getThreads().size() > 0);
        // ===== trash it ====
        template.requestBodyAndHeaders("direct://TRASH", null, new HashMap<String, Object>() {

            {
                put("CamelGoogleMail.userId", CURRENT_USERID);
                put("CamelGoogleMail.id", threadId);
            }
        });
        // ==== Search for message we just trashed ====
        result = template.requestBodyAndHeaders("direct://LIST", CURRENT_USERID, Collections.singletonMap("CamelGoogleMail.q", "subject:\"" + subject + "\""), ListThreadsResponse.clreplaced);
        replacedert.replacedertNotNull("list result", result);
        replacedert.replacedertTrue(result.getThreads() == null || result.getThreads().stream().noneMatch(t -> threadId.equals(t.getId())));
        /* For some reason the thread deletion often needs some delay to succeed */
        int attemptCount = 0;
        for (; ; ) {
            try {
                template.requestBodyAndHeaders("direct://DELETE", null, new HashMap<String, Object>() {

                    {
                        put("CamelGoogleMail.userId", CURRENT_USERID);
                        put("CamelGoogleMail.id", threadId);
                    }
                });
                break;
            /* success */
            } catch (Exception e) {
                if (attemptCount >= 5) {
                    throw e;
                /* too many attempts */
                } else {
                    /* retry */
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e1) {
                        Thread.currentThread().interrupt();
                    }
                }
                attemptCount++;
            }
        }
    } finally {
        camelctx.close();
    }
}

4 View Complete Implementation : GoogleMailIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void messages() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    GoogleMailComponent gMailComponent = camelctx.getComponent("google-mail", GoogleMailComponent.clreplaced);
    GoogleApiEnv.configure(gMailComponent.getConfiguration(), getClreplaced(), LOG);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            final String pathPrefix = "messages";
            // test route for attachments
            from("direct://ATTACHMENTS").to("google-mail://" + pathPrefix + "/attachments");
            // test route for delete
            from("direct://DELETE").to("google-mail://" + pathPrefix + "/delete");
            // test route for get
            from("direct://GET").to("google-mail://" + pathPrefix + "/get");
            // test route for gmailImport
            from("direct://GMAILIMPORT").to("google-mail://" + pathPrefix + "/gmailImport");
            // test route for gmailImport
            from("direct://GMAILIMPORT_1").to("google-mail://" + pathPrefix + "/gmailImport");
            // test route for insert
            from("direct://INSERT").to("google-mail://" + pathPrefix + "/insert");
            // test route for insert
            from("direct://INSERT_1").to("google-mail://" + pathPrefix + "/insert");
            // test route for list
            from("direct://LIST").to("google-mail://" + pathPrefix + "/list?inBody=userId");
            // test route for modify
            from("direct://MODIFY").to("google-mail://" + pathPrefix + "/modify");
            // test route for send
            from("direct://SEND").to("google-mail://" + pathPrefix + "/send");
            // test route for send
            from("direct://SEND_1").to("google-mail://" + pathPrefix + "/send");
            // test route for trash
            from("direct://TRASH").to("google-mail://" + pathPrefix + "/trash");
            // test route for untrash
            from("direct://UNTRASH").to("google-mail://" + pathPrefix + "/untrash");
        }
    });
    try {
        camelctx.start();
        ProducerTemplate template = camelctx.createProducerTemplate();
        // ==== Send test email ====
        final String subject = getClreplaced().getSimpleName() + ".messages " + UUID.randomUUID().toString();
        Message testEmail = createMessage(template, subject);
        Map<String, Object> headers = new HashMap<>();
        // parameter type is String
        headers.put("CamelGoogleMail.userId", CURRENT_USERID);
        // parameter type is com.google.api.services.gmail.model.Message
        headers.put("CamelGoogleMail.content", testEmail);
        Message result = template.requestBodyAndHeaders("direct://SEND", null, headers, Message.clreplaced);
        replacedert.replacedertNotNull("send result", result);
        String testEmailId = result.getId();
        // ==== Search for message we just sent ====
        headers = new HashMap<>();
        headers.put("CamelGoogleMail.q", "subject:\"" + subject + "\"");
        // using String message body for single parameter "userId"
        ListMessagesResponse listOfMessages = template.requestBody("direct://LIST", CURRENT_USERID, ListMessagesResponse.clreplaced);
        replacedert.replacedertTrue(idInList(testEmailId, listOfMessages));
        // ===== trash it ====
        headers = new HashMap<>();
        // parameter type is String
        headers.put("CamelGoogleMail.userId", CURRENT_USERID);
        // parameter type is String
        headers.put("CamelGoogleMail.id", testEmailId);
        template.requestBodyAndHeaders("direct://TRASH", null, headers);
        // ==== Search for message we just trashed ====
        headers = new HashMap<>();
        headers.put("CamelGoogleMail.q", "subject:\"" + subject + "\"");
        // using String message body for single parameter "userId"
        listOfMessages = template.requestBody("direct://LIST", CURRENT_USERID, ListMessagesResponse.clreplaced);
        replacedert.replacedertFalse(idInList(testEmailId, listOfMessages));
        // ===== untrash it ====
        headers = new HashMap<>();
        // parameter type is String
        headers.put("CamelGoogleMail.userId", CURRENT_USERID);
        // parameter type is String
        headers.put("CamelGoogleMail.id", testEmailId);
        template.requestBodyAndHeaders("direct://UNTRASH", null, headers);
        // ==== Search for message we just untrashed ====
        headers = new HashMap<>();
        headers.put("CamelGoogleMail.q", "subject:\"" + subject + "\"");
        // using String message body for single parameter "userId"
        listOfMessages = template.requestBody("direct://LIST", CURRENT_USERID, ListMessagesResponse.clreplaced);
        replacedert.replacedertTrue(idInList(testEmailId, listOfMessages));
        // ===== permanently delete it ====
        headers = new HashMap<>();
        // parameter type is String
        headers.put("CamelGoogleMail.userId", CURRENT_USERID);
        // parameter type is String
        headers.put("CamelGoogleMail.id", testEmailId);
        template.requestBodyAndHeaders("direct://DELETE", null, headers);
        // ==== Search for message we just deleted ====
        headers = new HashMap<>();
        headers.put("CamelGoogleMail.q", "subject:\"" + subject + "\"");
        // using String message body for single parameter "userId"
        listOfMessages = template.requestBody("direct://LIST", CURRENT_USERID, ListMessagesResponse.clreplaced);
        replacedert.replacedertFalse(idInList(testEmailId, listOfMessages));
    } finally {
        camelctx.close();
    }
}

3 View Complete Implementation : AtomixMapIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testPutAndGet() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        public void configure() {
            from("direct:start").toF("atomix-map:%s", MAP_NAME);
        }
    });
    final String key = camelctx.getUuidGenerator().generateUuid();
    final String val = camelctx.getUuidGenerator().generateUuid();
    AtomixMapComponent component = camelctx.getComponent("atomix-map", AtomixMapComponent.clreplaced);
    component.setNodes(Collections.singletonList(replicaAddress));
    camelctx.start();
    try {
        Message result;
        FluentProducerTemplate fluent = camelctx.createFluentProducerTemplate().to("direct:start");
        result = fluent.clearAll().withHeader(AtomixClientConstants.RESOURCE_ACTION, AtomixMap.Action.PUT).withHeader(AtomixClientConstants.RESOURCE_KEY, key).withBody(val).request(Message.clreplaced);
        replacedert.replacedertFalse(result.getHeader(AtomixClientConstants.RESOURCE_ACTION_HAS_RESULT, Boolean.clreplaced));
        replacedert.replacedertEquals(val, result.getBody());
        replacedert.replacedertEquals(val, map.get(key).join());
        result = fluent.clearAll().withHeader(AtomixClientConstants.RESOURCE_ACTION, AtomixMap.Action.GET).withHeader(AtomixClientConstants.RESOURCE_KEY, key).request(Message.clreplaced);
        replacedert.replacedertTrue(result.getHeader(AtomixClientConstants.RESOURCE_ACTION_HAS_RESULT, Boolean.clreplaced));
        replacedert.replacedertEquals(val, result.getBody(String.clreplaced));
        replacedert.replacedertTrue(map.containsKey(key).join());
    } finally {
        camelctx.close();
    }
}

3 View Complete Implementation : GoogleDriveIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testGoogleDriveComponent() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    GoogleDriveComponent gDriveComponent = camelctx.getComponent("google-drive", GoogleDriveComponent.clreplaced);
    GoogleApiEnv.configure(gDriveComponent.getConfiguration(), getClreplaced(), LOG);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            final String pathPrefix = "drive-files";
            // test route for copy
            from("direct://COPY").to("google-drive://" + pathPrefix + "/copy");
            // test route for delete
            from("direct://DELETE").to("google-drive://" + pathPrefix + "/delete?inBody=fileId");
            // test route for get
            from("direct://GET").to("google-drive://" + pathPrefix + "/get?inBody=fileId");
            // test route for insert
            from("direct://INSERT").to("google-drive://" + pathPrefix + "/insert?inBody=content");
            // test route for insert
            from("direct://INSERT_1").to("google-drive://" + pathPrefix + "/insert");
            // test route for list
            from("direct://LIST").to("google-drive://" + pathPrefix + "/list");
            // test route for patch
            from("direct://PATCH").to("google-drive://" + pathPrefix + "/patch");
            // test route for touch
            from("direct://TOUCH").to("google-drive://" + pathPrefix + "/touch?inBody=fileId");
            // test route for trash
            from("direct://TRASH").to("google-drive://" + pathPrefix + "/trash?inBody=fileId");
            // test route for untrash
            from("direct://UNTRASH").to("google-drive://" + pathPrefix + "/untrash?inBody=fileId");
            // test route for update
            from("direct://UPDATE").to("google-drive://" + pathPrefix + "/update");
            // test route for update
            from("direct://UPDATE_1").to("google-drive://" + pathPrefix + "/update");
            // test route for watch
            from("direct://WATCH").to("google-drive://" + pathPrefix + "/watch");
        }
    });
    try {
        camelctx.start();
        ProducerTemplate template = camelctx.createProducerTemplate();
        /* Create */
        final File originalFile = uploadTestFile(template, "files");
        /* Ensure it is there */
        replacedert.replacedertNotNull(template.requestBody("direct://GET", originalFile.getId(), File.clreplaced));
        /* Copy */
        final File toFile = new File();
        toFile.setreplacedle(originalFile.getreplacedle() + "_copy");
        final File copyFile = template.requestBodyAndHeaders("direct://COPY", null, new HashMap<String, Object>() {

            {
                put("CamelGoogleDrive.fileId", originalFile.getId());
                // parameter type is com.google.api.services.drive.model.File
                put("CamelGoogleDrive.content", toFile);
            }
        }, File.clreplaced);
        replacedert.replacedertNotNull("copy result", copyFile);
        replacedert.replacedertEquals(toFile.getreplacedle(), copyFile.getreplacedle());
        /* Ensure the copy is there */
        replacedert.replacedertNotNull(template.requestBody("direct://GET", copyFile.getId(), File.clreplaced));
        /* Delete */
        template.sendBody("direct://DELETE", originalFile.getId());
        /* Ensure it was deleted */
        try {
            template.requestBody("direct://GET", originalFile.getId(), File.clreplaced);
            replacedert.fail("template.requestBody(\"direct://GET\", originalFile.getId(), File.clreplaced) should have thrown an exception");
        } catch (Exception expected) {
        }
        /* Delete */
        template.sendBody("direct://DELETE", copyFile.getId());
        /* Ensure it was deleted */
        try {
            template.requestBody("direct://GET", copyFile.getId(), File.clreplaced);
            replacedert.fail("template.requestBody(\"direct://GET\", copyFile.getId(), File.clreplaced) should have thrown an exception");
        } catch (Exception expected) {
        }
    } finally {
        camelctx.close();
    }
}

2 View Complete Implementation : IRCIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testIRCComponent() throws Exception {
    String uri = "irc:kermit@" + TestUtils.getDockerHost() + "/#wfctest";
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from(uri).to("mock:messages");
        }
    });
    MockEndpoint endpoint = camelctx.getEndpoint("mock:messages", MockEndpoint.clreplaced);
    endpoint.expectedMessageCount(3);
    // Expect a JOIN message for each user connection, followed by the actual IRC message
    endpoint.expectedBodiesReceived("JOIN", "JOIN", "Hello Kermit!");
    CountDownLatch latch = new CountDownLatch(1);
    IrcComponent component = camelctx.getComponent("irc", IrcComponent.clreplaced);
    IrcEndpoint ircEndpoint = camelctx.getEndpoint(uri, IrcEndpoint.clreplaced);
    IRCConnection ircConnection = component.getIRCConnection(ircEndpoint.getConfiguration());
    ircConnection.addIRCEventListener(new ChannelJoinListener(latch));
    camelctx.start();
    try {
        replacedert.replacedertTrue("Gave up waiting for user to join IRC channel", latch.await(15, TimeUnit.SECONDS));
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBody("irc:piggy@" + TestUtils.getDockerHost() + "/#wfctest", "Hello Kermit!");
        endpoint.replacedertIsSatisfied(10000);
    } finally {
        camelctx.close();
    }
}

1 View Complete Implementation : PubSubIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@Test
public void testGooglePubSubComponent() throws Exception {
    Properties properties = new Properties();
    properties.load(PubSubIntegrationTest.clreplaced.getResourcereplacedtream("/pubsub.properties"));
    String serviceURL = properties.getProperty("test.serviceURL");
    if (System.getenv("DOCKER_HOST") != null) {
        serviceURL = String.format("http://%s:8590", TestUtils.getDockerHost());
    }
    GooglePubsubConnectionFactory connectionFactory = new GooglePubsubConnectionFactory().setServiceAccount(properties.getProperty("service.account")).setServiceAccountKey(properties.getProperty("service.key")).setServiceURL(serviceURL);
    String topicFullName = String.format("projects/%s/topics/%s", properties.getProperty("project.id"), properties.getProperty("topic.name"));
    String subscriptionFullName = String.format("projects/%s/subscriptions/%s", properties.getProperty("project.id"), properties.getProperty("subscription.name"));
    Pubsub pubsub = connectionFactory.getDefaultClient();
    pubsub.projects().topics().create(topicFullName, new Topic()).execute();
    Subscription subscription = new Subscription().setTopic(topicFullName).setAckDeadlineSeconds(10);
    pubsub.projects().subscriptions().create(subscriptionFullName, subscription).execute();
    CamelContext camelctx = new DefaultCamelContext();
    GooglePubsubComponent component = camelctx.getComponent("google-pubsub", GooglePubsubComponent.clreplaced);
    component.setConnectionFactory(connectionFactory);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:send").toF("google-pubsub:%s:%s", properties.getProperty("project.id"), properties.getProperty("topic.name"));
            fromF("google-pubsub:%s:%s", properties.getProperty("project.id"), properties.getProperty("subscription.name")).to("direct:receive");
            from("direct:receive").to("mock:result");
        }
    });
    MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.clreplaced);
    mockEndpoint.expectedBodiesReceivedInAnyOrder("Hello Kermit");
    camelctx.start();
    try {
        Map<String, String> attributes = new HashMap<>();
        attributes.put("ATTRIBUTE-TEST-KEY", "ATTRIBUTE-TEST-VALUE");
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeader("direct:send", "Hello Kermit", GooglePubsubConstants.ATTRIBUTES, attributes);
        mockEndpoint.replacedertIsSatisfied();
    } finally {
        camelctx.close();
        pubsub.projects().topics().delete(topicFullName).execute();
        pubsub.projects().subscriptions().delete(subscriptionFullName).execute();
    }
}

0 View Complete Implementation : GoogleCalendarIntegrationTest.java
Copyright Apache License 2.0
Author : wildfly-extras
@SuppressWarnings("serial")
@Test
public void testGoogleCalendarComponent() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    GoogleCalendarComponent gCalendarComponent = camelctx.getComponent("google-calendar", GoogleCalendarComponent.clreplaced);
    GoogleApiEnv.configure(gCalendarComponent.getConfiguration(), getClreplaced(), LOG);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            final String pathPrefix = "events";
            // test route for calendarImport
            from("direct://CALENDARIMPORT").to("google-calendar://" + pathPrefix + "/calendarImport");
            // test route for delete
            from("direct://DELETE").to("google-calendar://" + pathPrefix + "/delete");
            // test route for get
            from("direct://GET").to("google-calendar://" + pathPrefix + "/get");
            // test route for insert
            from("direct://INSERT").to("google-calendar://" + pathPrefix + "/insert");
            // test route for instances
            from("direct://INSTANCES").to("google-calendar://" + pathPrefix + "/instances");
            // test route for list
            from("direct://LIST").to("google-calendar://" + pathPrefix + "/list?inBody=calendarId");
            // test route for move
            from("direct://MOVE").to("google-calendar://" + pathPrefix + "/move");
            // test route for patch
            from("direct://PATCH").to("google-calendar://" + pathPrefix + "/patch");
            // test route for quickAdd
            from("direct://QUICKADD").to("google-calendar://" + pathPrefix + "/quickAdd");
            // test route for update
            from("direct://UPDATE").to("google-calendar://" + pathPrefix + "/update");
            // test route for watch
            from("direct://WATCH").to("google-calendar://" + pathPrefix + "/watch");
        }
    });
    try {
        camelctx.start();
        String testId = getClreplaced().getSimpleName() + ".events";
        ProducerTemplate template = camelctx.createProducerTemplate();
        final Calendar cal = createTestCalendar(template, testId);
        LOG.infof("Created test calendar %s", cal.getSummary());
        final String eventText = testId + " feed the camel";
        // Add an event
        final Event quickAddEvent = template.requestBodyAndHeaders("direct://QUICKADD", null, new HashMap<String, Object>() {

            {
                // parameter type is String
                put("CamelGoogleCalendar.calendarId", cal.getId());
                // parameter type is String
                put("CamelGoogleCalendar.text", eventText);
            }
        }, Event.clreplaced);
        replacedert.replacedertNotNull("quickAdd result", quickAddEvent);
        // Check if it is in the list of events for this calendar
        final Events events = template.requestBody("direct://LIST", cal.getId(), Events.clreplaced);
        Event item = events.gereplacedems().get(0);
        String eventId = item.getId();
        replacedert.replacedertEquals(eventText, item.getSummary());
        // Get the event metadata
        final Event completeEvent = template.requestBodyAndHeaders("direct://GET", null, new HashMap<String, Object>() {

            {
                // parameter type is String
                put("CamelGoogleCalendar.calendarId", cal.getId());
                // parameter type is String
                put("CamelGoogleCalendar.eventId", eventId);
            }
        }, Event.clreplaced);
        replacedert.replacedertEquals(eventText, completeEvent.getSummary());
        // Change the event
        completeEvent.setSummary("Feed the camel later");
        // parameter type is com.google.api.services.calendar.model.Event
        Event newResult = template.requestBodyAndHeaders("direct://UPDATE", null, new HashMap<String, Object>() {

            {
                // parameter type is String
                put("CamelGoogleCalendar.calendarId", cal.getId());
                // parameter type is String
                put("CamelGoogleCalendar.eventId", eventId);
                put("CamelGoogleCalendar.content", completeEvent);
            }
        }, Event.clreplaced);
        replacedert.replacedertEquals("Feed the camel later", newResult.getSummary());
        // Delete the event
        template.requestBodyAndHeaders("direct://DELETE", null, new HashMap<String, Object>() {

            {
                // parameter type is String
                put("CamelGoogleCalendar.calendarId", cal.getId());
                // parameter type is String
                put("CamelGoogleCalendar.eventId", eventId);
            }
        });
        // Check if it is NOT in the list of events for this calendar
        Events eventsAfterDeletion = template.requestBody("direct://LIST", cal.getId(), Events.clreplaced);
        replacedert.replacedertEquals(0, eventsAfterDeletion.gereplacedems().size());
    } finally {
        camelctx.close();
    }
}