Search in sources :

Example 11 with Test

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

the class CassandraComponentProducerUnpreparedTest method testRequestMessageStatement.

/**
     * Test with incoming message containing a header with RegularStatement.
     */
@Test
public void testRequestMessageStatement() throws Exception {
    Update.Where update = update("camel_user").with(set("first_name", "Claus 2")).and(set("last_name", "Ibsen 2")).where(eq("login", "c_ibsen"));
    Object response = producerTemplate.requestBodyAndHeader(null, 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 12 with Test

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

the class ResultSetConversionStrategiesTest method testOne.

@Test
public void testOne() {
    ResultSetConversionStrategy strategy = ResultSetConversionStrategies.fromName("ONE");
    ResultSet resultSet = mock(ResultSet.class);
    Row row = mock(Row.class);
    when(resultSet.one()).thenReturn(row);
    Object body = strategy.getBody(resultSet);
    assertTrue(body instanceof Row);
    assertSame(row, body);
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) Test(org.junit.Test)

Example 13 with Test

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

the class CassandraAggregationRepositoryTest method testRecover.

@Test
public void testRecover() {
    if (!canTest()) {
        return;
    }
    // Given
    String[] keys = { "Recover1", "Recover2" };
    addExchanges(keys);
    // When
    Exchange exchange2 = aggregationRepository.recover(camelContext, "Exchange-Recover2");
    Exchange exchange3 = aggregationRepository.recover(camelContext, "Exchange-Recover3");
    // Then
    assertNotNull(exchange2);
    assertNull(exchange3);
}
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 14 with Test

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

the class CassandraAggregationRepositoryTest method testRemoveNotExists.

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

Example 15 with Test

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

the class CassandraAggregationRepositoryTest method testAdd.

@Test
public void testAdd() {
    // Given
    String key = "Add";
    assertFalse(exists(key));
    Exchange exchange = new DefaultExchange(camelContext);
    // When
    aggregationRepository.add(camelContext, key, exchange);
    // Then
    assertTrue(exists(key));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Test(org.junit.Test) BaseCassandraTest(org.apache.camel.component.cassandra.BaseCassandraTest)

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