Search in sources :

Example 1 with BraintreeConfiguration

use of org.apache.camel.component.braintree.BraintreeConfiguration in project wildfly-camel by wildfly-extras.

the class BraintreeIntegrationTest method testBraintreeCustomerGateway.

@Test
public void testBraintreeCustomerGateway() throws Exception {
    Map<String, Object> braintreeOptions = createBraintreeOptions();
    // Do nothing if the required credentials are not present
    Assume.assumeTrue(braintreeOptions.size() == BraintreeOption.values().length);
    final CountDownLatch latch = new CountDownLatch(2);
    final CamelContext camelctx = new DefaultCamelContext();
    final BraintreeConfiguration configuration = new BraintreeConfiguration();
    IntrospectionSupport.setProperties(configuration, braintreeOptions);
    // add BraintreeComponent to Camel context
    final BraintreeComponent component = new BraintreeComponent(camelctx);
    component.setConfiguration(configuration);
    camelctx.addComponent("braintree", component);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:create").to("braintree:customer/create?inBody=request").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    latch.countDown();
                }
            });
            from("direct:delete").to("braintree:customer/delete?inBody=id").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    latch.countDown();
                }
            });
        }
    });
    camelctx.start();
    // ****************************
    // Create a customer
    // ****************************
    @SuppressWarnings("unchecked") Result<Customer> createResult = camelctx.createProducerTemplate().requestBody("direct:create", new CustomerRequest().firstName("user").lastName(UUID.randomUUID().toString()).company("Apache").email("user@braintree.camel").website("http://user.braintree.camel"), Result.class);
    Assert.assertNotNull(createResult);
    Assert.assertTrue(createResult.isSuccess());
    Assert.assertNotNull(createResult.getTarget());
    Assert.assertNotNull(createResult.getTarget().getId());
    // ****************************
    // Delete the customer
    // ****************************
    @SuppressWarnings("unchecked") Result<Customer> deleteResult = camelctx.createProducerTemplate().requestBody("direct:delete", createResult.getTarget().getId(), Result.class);
    Assert.assertNotNull(deleteResult);
    Assert.assertTrue(deleteResult.isSuccess());
    Assert.assertNull(deleteResult.getTarget());
    try {
        Assert.assertTrue("Countdown reached zero", latch.await(5, TimeUnit.MINUTES));
    } finally {
        camelctx.close();
    }
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Customer(com.braintreegateway.Customer) BraintreeComponent(org.apache.camel.component.braintree.BraintreeComponent) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) BraintreeConfiguration(org.apache.camel.component.braintree.BraintreeConfiguration) Exchange(org.apache.camel.Exchange) CustomerRequest(com.braintreegateway.CustomerRequest) Test(org.junit.Test)

Example 2 with BraintreeConfiguration

use of org.apache.camel.component.braintree.BraintreeConfiguration in project wildfly-camel by wildfly-extras.

the class BraintreeIntegrationTest method testBraintreeClientTokenGateway.

@Test
public void testBraintreeClientTokenGateway() throws Exception {
    Map<String, Object> braintreeOptions = createBraintreeOptions();
    Assume.assumeTrue("[#1679] Enable Braintree testing in Jenkins", braintreeOptions.size() == BraintreeOption.values().length);
    final CountDownLatch latch = new CountDownLatch(1);
    final CamelContext camelctx = new DefaultCamelContext();
    final BraintreeConfiguration configuration = new BraintreeConfiguration();
    configuration.setHttpLogLevel(Level.WARNING);
    IntrospectionSupport.setProperties(configuration, braintreeOptions);
    // add BraintreeComponent to Camel context
    final BraintreeComponent component = new BraintreeComponent(camelctx);
    component.setConfiguration(configuration);
    camelctx.addComponent("braintree", component);
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("timer://braintree?repeatCount=1").to("braintree:clientToken/generate").process(new Processor() {

                @Override
                public void process(Exchange exchange) throws Exception {
                    latch.countDown();
                }
            }).to("mock:result");
        }
    });
    camelctx.start();
    try {
        Assert.assertTrue("Countdown reached zero", latch.await(5, TimeUnit.MINUTES));
    } finally {
        camelctx.close();
    }
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) BraintreeComponent(org.apache.camel.component.braintree.BraintreeComponent) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) BraintreeConfiguration(org.apache.camel.component.braintree.BraintreeConfiguration) Exchange(org.apache.camel.Exchange) Test(org.junit.Test)

Example 3 with BraintreeConfiguration

use of org.apache.camel.component.braintree.BraintreeConfiguration in project camel-quarkus by apache.

the class BraintreeRecorder method configureBraintreeComponent.

/**
 * Always disable the {@link org.apache.camel.component.braintree.internal.BraintreeLogHandler}.
 *
 * It's not desirable to configure this where an existing JUL - SLF4J bridge exists on the classpath.
 */
public RuntimeValue<BraintreeComponent> configureBraintreeComponent() {
    BraintreeComponent component = new BraintreeComponent();
    BraintreeConfiguration configuration = new BraintreeConfiguration();
    configuration.setLogHandlerEnabled(false);
    component.setConfiguration(configuration);
    return new RuntimeValue<>(component);
}
Also used : BraintreeComponent(org.apache.camel.component.braintree.BraintreeComponent) RuntimeValue(io.quarkus.runtime.RuntimeValue) BraintreeConfiguration(org.apache.camel.component.braintree.BraintreeConfiguration)

Aggregations

BraintreeComponent (org.apache.camel.component.braintree.BraintreeComponent)3 BraintreeConfiguration (org.apache.camel.component.braintree.BraintreeConfiguration)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 CamelContext (org.apache.camel.CamelContext)2 Exchange (org.apache.camel.Exchange)2 Processor (org.apache.camel.Processor)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 Test (org.junit.Test)2 Customer (com.braintreegateway.Customer)1 CustomerRequest (com.braintreegateway.CustomerRequest)1 RuntimeValue (io.quarkus.runtime.RuntimeValue)1