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();
}
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);
}
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);
}
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));
}
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));
}
Aggregations