1
2
3
4
5
6
7
8
9
10 package org.mule.test.integration;
11
12 import org.mule.tck.FunctionalTestCase;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 public class PollingTestCase extends FunctionalTestCase
18 {
19 private static List<String> foo = new ArrayList<String>();
20 private static List<String> bar = new ArrayList<String>();
21
22 @Override
23 protected String getConfigResources()
24 {
25 return "org/mule/test/integration/polling-config.xml";
26 }
27
28 public void testPolling() throws Exception
29 {
30 Thread.sleep(5000);
31 synchronized (foo)
32 {
33 assertTrue(foo.size() > 0);
34 for (String s: foo)
35 {
36 assertEquals(s, "foo");
37 }
38 }
39 synchronized (bar)
40 {
41 assertTrue(bar.size() > 0);
42 for (String s: bar)
43 {
44 assertEquals(s, "bar");
45 }
46 }
47 }
48
49 public static class FooComponent
50 {
51 public boolean process(String s)
52 {
53 synchronized (foo)
54 {
55 if (foo.size() < 10)
56 {
57 foo.add(s);
58 return true;
59 }
60 }
61 return false;
62 }
63 }
64
65 public static class BarComponent
66 {
67 public boolean process(String s)
68 {
69 synchronized (bar)
70 {
71 if (bar.size() < 10)
72 {
73 bar.add(s);
74 return true;
75 }
76 }
77 return false;
78 }
79 }
80 }