use of org.switchyard.Exchange in project quickstarts by jboss-switchyard.
the class CamelJMSBindingTest method sendTextMessageToJMSQueue.
@Test
public void sendTextMessageToJMSQueue() throws Exception {
final String payload = "dummy payload";
// replace existing implementation for testing purposes
_testKit.removeService("GreetingService");
final MockHandler greetingService = _testKit.registerInOnlyService("GreetingService");
sendTextToQueue(payload, QUEUE_NAME);
// Allow for the JMS Message to be processed.
Thread.sleep(3000);
final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
assertThat(recievedMessages, is(notNullValue()));
final Exchange recievedExchange = recievedMessages.iterator().next();
assertThat(recievedExchange.getMessage().getContent(String.class), is(equalTo(payload)));
}
use of org.switchyard.Exchange in project quickstarts by jboss-switchyard.
the class CamelServiceTest method testXQueryRouting.
@Test
public void testXQueryRouting() throws Exception {
_testKit.removeService("HelloService");
_testKit.removeService("GoodbyeService");
MockHandler helloService = _testKit.registerInOnlyService("HelloService");
MockHandler goodbyeService = _testKit.registerInOnlyService("GoodbyeService");
greet.sendInOnly(REQUEST_HELLO);
greet.sendInOnly(REQUEST_GOODBYE);
Thread.sleep(1000);
LinkedBlockingQueue<Exchange> helloReceived = helloService.getMessages();
Assert.assertNotNull(helloReceived);
Exchange helloExchange = helloReceived.iterator().next();
Assert.assertTrue(helloExchange.getMessage().getContent(String.class).matches(".*Douglas.*"));
LinkedBlockingQueue<Exchange> goodbyeReceived = goodbyeService.getMessages();
Assert.assertNotNull(goodbyeReceived);
Exchange goodbyeExchange = goodbyeReceived.iterator().next();
Assert.assertTrue(goodbyeExchange.getMessage().getContent(String.class).matches(".*Garfield.*"));
}
use of org.switchyard.Exchange 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.Exchange in project quickstarts by jboss-switchyard.
the class CamelQuartzBindingTest method shouldExecuteService.
@Test
public void shouldExecuteService() throws Exception {
// replace existing implementation for testing purposes
_testKit.removeService("GreetingService");
final MockHandler greetingService = _testKit.registerInOnlyService("GreetingService");
// Number of executions can vary, depends on moment when sleep will be executed
// eg. 10:50:999, 10:51:003, 10:52:000 - we'll get three executions
// or 10:50:000, 10:51:001 - we'll get two executions
// however we never should get more than three triggers and less than two
Thread.sleep(1001);
final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
assertThat(recievedMessages, is(notNullValue()));
assertThat(recievedMessages.size(), is(greaterThanOrEqualTo(1)));
}
use of org.switchyard.Exchange in project quickstarts by jboss-switchyard.
the class CamelRSSPollTest method shouldRetrieveGreetings.
@Test
public void shouldRetrieveGreetings() throws Exception {
_testKit.removeService("PrintService");
final MockHandler printService = _testKit.registerInOnlyService("PrintService");
Thread.sleep(10001);
final LinkedBlockingQueue<Exchange> receivedMessages = printService.getMessages();
for (Exchange e : receivedMessages) {
SyndFeed feed = (SyndFeed) e.getMessage().getContent();
@SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries();
Assert.assertEquals(feed.getEntries().size(), 1);
Iterator<SyndEntry> itEntries = entries.iterator();
while (itEntries.hasNext()) {
SyndEntry entry = (SyndEntry) itEntries.next();
Assert.assertTrue(entry.getTitle().equals(SONG_TITLE));
Assert.assertTrue(entry.getLink().equals(SONG_URL));
Assert.assertTrue(entry.getDescription().getValue().equals(SONG_DESCRIPTION));
}
}
}
Aggregations