1
2
3
4
5
6
7
8
9
10 package org.mule.module.rss;
11
12 import org.mule.tck.functional.CounterCallback;
13 import org.mule.tck.functional.FunctionalTestComponent;
14 import org.mule.tck.junit4.FunctionalTestCase;
15 import org.mule.tck.probe.PollingProber;
16 import org.mule.tck.probe.Probe;
17 import org.mule.tck.probe.Prober;
18
19 import org.junit.Test;
20
21 import static org.mule.module.rss.SampleFeed.ENTRIES_IN_RSS_FEED;
22
23 public class FeedConsumeAndSplitExplicitNonHttpTestCase extends FunctionalTestCase
24 {
25 private final CounterCallback counter = new CounterCallback();
26
27 @Override
28 protected String getConfigResources()
29 {
30 return "vm-rss-consume-and-explicit-split.xml";
31 }
32
33 @Override
34 protected void doSetUp() throws Exception
35 {
36 FunctionalTestComponent comp = (FunctionalTestComponent)getComponent("feedConsumer");
37 comp.setEventCallback(counter);
38 }
39
40 @Test
41 public void testConsume() throws Exception
42 {
43 String feed = SampleFeed.feedAsString();
44 muleContext.getClient().dispatch("vm://feed.in", feed, null);
45
46 Prober prober = new PollingProber(10000, 100);
47 prober.check(new Probe()
48 {
49 public boolean isSatisfied()
50 {
51 return counter.getCallbackCount() == ENTRIES_IN_RSS_FEED;
52 }
53
54 public String describeFailure()
55 {
56 return String.format("Did not receive %d feed entries (only got %d)",
57 SampleFeed.ENTRIES_IN_RSS_FEED, counter.getCallbackCount());
58 }
59 });
60 }
61
62 }