Search in sources :

Example 6 with Test

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

the class CassandraComponentConsumerTest method testConsumeAll.

@Test
public void testConsumeAll() throws Exception {
    if (!canTest()) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:resultAll");
    mock.expectedMinimumMessageCount(1);
    mock.whenAnyExchangeReceived(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Object body = exchange.getIn().getBody();
            assertTrue(body instanceof List);
        }
    });
    mock.await(1, TimeUnit.SECONDS);
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) List(java.util.List) Test(org.junit.Test)

Example 7 with Test

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

the class CassandraComponentConsumerTest method testConsumeOne.

@Test
public void testConsumeOne() throws Exception {
    if (!canTest()) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:resultOne");
    mock.expectedMinimumMessageCount(1);
    mock.whenAnyExchangeReceived(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Object body = exchange.getIn().getBody();
            assertTrue(body instanceof Row);
        }
    });
    mock.await(1, TimeUnit.SECONDS);
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Row(com.datastax.driver.core.Row) Test(org.junit.Test)

Example 8 with Test

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

the class CassandraComponentProducerTest method testRequestMessageStatement.

/**
     * Test with incoming message containing a header with RegularStatement.
     */
@Test
public void testRequestMessageStatement() throws Exception {
    if (!canTest()) {
        return;
    }
    Update.Where update = update("camel_user").with(set("first_name", bindMarker())).and(set("last_name", bindMarker())).where(eq("login", bindMarker()));
    Object response = producerTemplate.requestBodyAndHeader(new Object[] { "Claus 2", "Ibsen 2", "c_ibsen" }, CassandraConstants.CQL_QUERY, update);
    Cluster cluster = CassandraUnitUtils.cassandraCluster();
    Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
    ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "c_ibsen");
    Row row = resultSet.one();
    assertNotNull(row);
    assertEquals("Claus 2", row.getString("first_name"));
    assertEquals("Ibsen 2", row.getString("last_name"));
    session.close();
    cluster.close();
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) Cluster(com.datastax.driver.core.Cluster) Row(com.datastax.driver.core.Row) Update(com.datastax.driver.core.querybuilder.Update) Session(com.datastax.driver.core.Session) Test(org.junit.Test)

Example 9 with Test

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

the class CassandraComponentProducerTest method testLoadBalancing.

@Test
public void testLoadBalancing() throws Exception {
    if (!canTest()) {
        return;
    }
    Object response = loadBalancingPolicyTemplate.requestBodyAndHeader(new Object[] { "Claus 2", "Ibsen 2", "c_ibsen" }, CassandraConstants.CQL_QUERY, "update camel_user set first_name=?, last_name=? where login=?");
    Cluster cluster = CassandraUnitUtils.cassandraCluster();
    Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
    ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "c_ibsen");
    Row row = resultSet.one();
    assertNotNull(row);
    assertEquals("Claus 2", row.getString("first_name"));
    assertEquals("Ibsen 2", row.getString("last_name"));
    session.close();
    cluster.close();
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) Cluster(com.datastax.driver.core.Cluster) Row(com.datastax.driver.core.Row) Session(com.datastax.driver.core.Session) Test(org.junit.Test)

Example 10 with Test

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

the class CassandraComponentProducerTest method testRequestMessageCql.

@Test
public void testRequestMessageCql() throws Exception {
    if (!canTest()) {
        return;
    }
    Object response = producerTemplate.requestBodyAndHeader(new Object[] { "Claus 2", "Ibsen 2", "c_ibsen" }, CassandraConstants.CQL_QUERY, "update camel_user set first_name=?, last_name=? where login=?");
    Cluster cluster = CassandraUnitUtils.cassandraCluster();
    Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
    ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "c_ibsen");
    Row row = resultSet.one();
    assertNotNull(row);
    assertEquals("Claus 2", row.getString("first_name"));
    assertEquals("Ibsen 2", row.getString("last_name"));
    session.close();
    cluster.close();
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) Cluster(com.datastax.driver.core.Cluster) Row(com.datastax.driver.core.Row) Session(com.datastax.driver.core.Session) Test(org.junit.Test)

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