Search in sources :

Example 11 with MockHandler

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)));
}
Also used : Exchange(org.switchyard.Exchange) MockHandler(org.switchyard.test.MockHandler) Test(org.junit.Test)

Example 12 with MockHandler

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));
        }
    }
}
Also used : Exchange(org.switchyard.Exchange) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) MockHandler(org.switchyard.test.MockHandler) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 MockHandler (org.switchyard.test.MockHandler)12 Exchange (org.switchyard.Exchange)9 MulticastSocket (java.net.MulticastSocket)2 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)1 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)1 DataOutputStream (java.io.DataOutputStream)1 FileInputStream (java.io.FileInputStream)1 DatagramPacket (java.net.DatagramPacket)1 InetAddress (java.net.InetAddress)1 Socket (java.net.Socket)1 KeyStore (java.security.KeyStore)1 PreparedStatement (java.sql.PreparedStatement)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 SSLContext (javax.net.ssl.SSLContext)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1 FOMEntry (org.apache.abdera.parser.stax.FOMEntry)1 BlockingConnection (org.fusesource.mqtt.client.BlockingConnection)1 MQTT (org.fusesource.mqtt.client.MQTT)1