use of org.switchyard.test.MockHandler 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.test.MockHandler 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