use of org.switchyard.quickstarts.camel.jpa.binding.domain.Greet in project quickstarts by jboss-switchyard.
the class PeriodicServiceImpl method execute.
@Override
public void execute() {
Greet greet = createRandomGreet();
_logger.info("Sending " + greet + " to JPA store");
_store.storeGreeting(greet);
}
use of org.switchyard.quickstarts.camel.jpa.binding.domain.Greet in project quickstarts by jboss-switchyard.
the class PeriodicServiceImpl method createRandomGreet.
private Greet createRandomGreet() {
Random random = new Random(System.currentTimeMillis());
Greet event = new Greet();
event.setReceiver(NAMES[random.nextInt(NAMES.length)]);
event.setSender(NAMES[random.nextInt(NAMES.length)]);
event.setCreatedAt(Calendar.getInstance());
return event;
}
use of org.switchyard.quickstarts.camel.jpa.binding.domain.Greet in project quickstarts by jboss-switchyard.
the class CamelJpaBindingStoreTest method storeEntity.
@Test
public void storeEntity() throws Exception {
Calendar createdAt = Calendar.getInstance();
Greet event = new Greet();
event.setReceiver(RECEIVER);
event.setSender(SENDER);
event.setCreatedAt(createdAt);
_testKit.newInvoker("StoreReference").sendInOnly(event);
PreparedStatement statement = connection.prepareStatement("select createdAt, sender, receiver from events");
ResultSet resultSet = statement.executeQuery();
assertTrue(resultSet.next());
assertEquals(SENDER, resultSet.getString("sender"));
assertEquals(RECEIVER, resultSet.getString("receiver"));
assertEquals(createdAt.getTimeInMillis(), resultSet.getTimestamp("createdAt").getTime());
}
use of org.switchyard.quickstarts.camel.jpa.binding.domain.Greet in project quickstarts by jboss-switchyard.
the class CamelJpaBindingReceiveTest method receiveEntity.
@Test
public void receiveEntity() throws Exception {
_testKit.removeService("GreetingService");
_testKit.removeService("StoreReference");
service = _testKit.registerInOnlyService("GreetingService");
PreparedStatement statement = connection.prepareStatement("insert into events (createdAt,sender,receiver) values(now(), ?, ?)");
statement.setString(1, SENDER);
statement.setString(2, RECEIVER);
statement.execute();
service.waitForOKMessage();
final LinkedBlockingQueue<Exchange> receivedMessages = service.getMessages();
assertNotNull(receivedMessages);
final Exchange recievedExchange = receivedMessages.iterator().next();
Greet receiver = recievedExchange.getMessage().getContent(Greet.class);
assertEquals(SENDER, receiver.getSender());
assertEquals(RECEIVER, receiver.getReceiver());
}