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