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