Search in sources :

Example 16 with Test

use of org.junit.Test in project camel by apache.

the class CassandraAggregationRepositoryTest method testGetNotExists.

@Test
public void testGetNotExists() {
    if (!canTest()) {
        return;
    }
    // Given
    String key = "Get_NotExists";
    assertFalse(exists(key));
    // When
    Exchange exchange2 = aggregationRepository.get(camelContext, key);
    // Then
    assertNull(exchange2);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) Test(org.junit.Test) BaseCassandraTest(org.apache.camel.component.cassandra.BaseCassandraTest)

Example 17 with Test

use of org.junit.Test in project camel by apache.

the class MarshalDomainObjectTest method testMarshalDomainObjectTwice.

@Test
public void testMarshalDomainObjectTwice() throws Exception {
    // some platform cannot test using Castor as it uses a SUN dependent Xerces
    if (isJavaVendor("IBM")) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(2);
    PurchaseOrder order = new PurchaseOrder();
    order.setName("Tiger");
    order.setAmount(1);
    order.setPrice(99.95);
    template.sendBody("direct:in", order);
    template.sendBody("direct:in", order);
    mock.assertIsSatisfied();
    String body1 = mock.getExchanges().get(0).getIn().getBody(String.class);
    String body2 = mock.getExchanges().get(1).getIn().getBody(String.class);
    assertEquals("The body should marshalled to the same", body1, body2);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 18 with Test

use of org.junit.Test in project camel by apache.

the class SpringMarshalDomainObjectTest method testMarshalDomainObject.

@Test
public void testMarshalDomainObject() throws Exception {
    // some platform cannot test using Castor as it uses a SUN dependent Xerces
    if (isJavaVendor("IBM")) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    PurchaseOrder order = new PurchaseOrder();
    order.setName("Tiger");
    order.setAmount(1);
    order.setPrice(99.95);
    template.sendBody("direct:in", order);
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 19 with Test

use of org.junit.Test in project camel by apache.

the class CassandraAggregationTest method testAggregationRoute.

@Test
public void testAggregationRoute() throws Exception {
    if (!canTest()) {
        return;
    }
    // Given
    MockEndpoint mockOutput = getMockEndpoint("mock:output");
    mockOutput.expectedMessageCount(2);
    mockOutput.expectedBodiesReceivedInAnyOrder("A,C,E", "B,D");
    // When
    send("1", "A");
    send("2", "B");
    send("1", "C");
    send("2", "D");
    send("1", "E");
    // Then
    mockOutput.assertIsSatisfied(4000L);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 20 with Test

use of org.junit.Test in project camel by apache.

the class CacheProducerTest method testUpdatingDataInCacheDoesFailOnEmptyBody.

@Test
public void testUpdatingDataInCacheDoesFailOnEmptyBody() throws Exception {
    context.addRoutes(new RouteBuilder() {

        public void configure() {
            onException(CacheException.class).handled(true).to("log:LOGGER").to("mock:CacheProducerTest.cacheException");
            from("direct:a").setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_UPDATE)).setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson")).to("cache://TestCache1");
        }
    });
    cacheExceptionEndpoint.expectedMessageCount(1);
    context.start();
    log.debug("------------Beginning CacheProducer Update Does Fail On Empty Body Test---------------");
    sendEmptyBody();
    cacheExceptionEndpoint.assertIsSatisfied();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test) BaseCacheTest(org.apache.camel.component.BaseCacheTest)

Aggregations

Test (org.junit.Test)198823 ArrayList (java.util.ArrayList)9546 File (java.io.File)9168 HashMap (java.util.HashMap)5749 IOException (java.io.IOException)5434 List (java.util.List)4309 QuickTest (com.hazelcast.test.annotation.QuickTest)4024 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3265 Configuration (org.apache.hadoop.conf.Configuration)3260 Properties (java.util.Properties)3016 Date (java.util.Date)2950 Path (org.apache.hadoop.fs.Path)2924 Map (java.util.Map)2907 Response (javax.ws.rs.core.Response)2884 InputStream (java.io.InputStream)2876 ByteArrayInputStream (java.io.ByteArrayInputStream)2777 CountDownLatch (java.util.concurrent.CountDownLatch)2681 Connection (java.sql.Connection)2478 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2462 Session (org.hibernate.Session)2419