use of org.switchyard.quickstarts.camel.sql.binding.Greeting in project quickstarts by jboss-switchyard.
the class CamelSqlRetrieveTest method getContents.
// method which is capable to hold execution of test until some records pulled from database
private Set<Greeting> getContents(MockHandler handler) {
// first execution of poll done
handler.waitForOKMessage();
long stop = System.nanoTime() + TimeUnit.SECONDS.toNanos(REPLY_TIMEOUT_SECONDS);
Set<Greeting> greetings = new HashSet<Greeting>();
while (System.nanoTime() < stop) {
for (Exchange exchange : handler.getMessages()) {
Greeting greeting = exchange.getMessage().getContent(Greeting.class);
if (greeting != null && !greetings.contains(greeting)) {
greetings.add(greeting);
}
}
}
return greetings;
}
use of org.switchyard.quickstarts.camel.sql.binding.Greeting in project quickstarts by jboss-switchyard.
the class CamelSqlStoreTest method shouldStoreGreet.
@Test
public void shouldStoreGreet() throws Exception {
invoker.operation("store").sendInOnly(new Greeting(RECEIVER, SENDER));
ResultSet result = connection.createStatement().executeQuery("SELECT * FROM greetings");
assertTrue(result.next());
assertEquals(RECEIVER, result.getString("receiver"));
assertEquals(SENDER, result.getString("sender"));
result.close();
}
use of org.switchyard.quickstarts.camel.sql.binding.Greeting in project quickstarts by jboss-switchyard.
the class CamelSqlRetrieveTest method shouldRetrieveGreetings.
@Test
public void shouldRetrieveGreetings() throws Exception {
_testKit.removeService("GreetingService");
MockHandler handler = new MockHandler();
ServiceInterface metadata = JavaService.fromClass(GreetingService.class);
_testKit.getServiceDomain().registerService(_testKit.createQName("GreetingService"), metadata, handler);
PreparedStatement statement = connection.prepareStatement("INSERT INTO greetings (receiver, sender) VALUES (?,?)");
statement.setString(1, RECEIVER);
statement.setString(2, SENDER);
assertEquals(1, statement.executeUpdate());
PreparedStatement statement2 = connection.prepareStatement("INSERT INTO greetings (receiver, sender) VALUES (?,?)");
statement2.setString(1, RECEIVER_2);
statement2.setString(2, SENDER_2);
assertEquals(1, statement2.executeUpdate());
Set<Greeting> greetings = getContents(handler);
assertEquals(2, greetings.size());
assertEquals(true, checkGreeting(RECEIVER, SENDER, greetings));
assertEquals(true, checkGreeting(RECEIVER_2, SENDER_2, greetings));
}
Aggregations