1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.quartz;
12
13 import org.mule.api.MuleEventContext;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.tck.functional.CountdownCallback;
16 import org.mule.tck.functional.FunctionalTestComponent;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 public class QuartzEventGeneratorTestCase extends FunctionalTestCase
22 {
23
24 private static final String PAYLOAD = "TRIGGER STRING";
25
26 private final List<String> receivedPayloads = new ArrayList<String>();
27
28 @Override
29 protected String getConfigResources()
30 {
31 return "quartz-event-generator.xml";
32 }
33
34 public void testEventGeneratorPayload() throws Exception
35 {
36 FunctionalTestComponent component = (FunctionalTestComponent) getComponent("quartzService");
37 assertNotNull(component);
38 CountdownCallback callback = new Callback(1, receivedPayloads);
39 component.setEventCallback(callback);
40
41
42 assertTrue(callback.await(60000));
43 assertTrue(receivedPayloads.size() > 0);
44 assertEquals(PAYLOAD, receivedPayloads.get(0));
45 }
46
47 private static class Callback extends CountdownCallback
48 {
49 private List<String> messageList;
50
51 public Callback(int messagesExpected, List<String> payloadStore)
52 {
53 super(messagesExpected);
54 messageList = payloadStore;
55 }
56
57 @Override
58 public void eventReceived(MuleEventContext context, Object component) throws Exception
59 {
60 synchronized (this)
61 {
62 String payloadString = context.getMessage().getPayloadAsString();
63 messageList.add(payloadString);
64 }
65
66 super.eventReceived(context, component);
67 }
68 }
69
70 }
71
72