1
2
3
4
5
6
7
8
9
10
11 package org.mule.context.notification;
12
13 import org.mule.api.service.Service;
14 import org.mule.module.client.MuleClient;
15
16 import java.util.Arrays;
17 import java.util.Collection;
18
19 import org.junit.Ignore;
20 import org.junit.runners.Parameterized.Parameters;
21
22 import static org.junit.Assert.assertNotNull;
23
24 @Ignore
25 public class ServerNotificationManagerTestCase extends AbstractNotificationTestCase
26 {
27 public static final String MULE_SYSTEM_MODEL = "_muleSystemModel";
28 public static final String MODEL = "the-model";
29 public static final String SERVICE = "the-service";
30
31 @Parameters
32 public static Collection<Object[]> parameters()
33 {
34 return Arrays.asList(new Object[][]{
35 {ConfigVariant.SERVICE, "org/mule/test/integration/notifications/server-notification-manager-test.xml"},
36 });
37 }
38
39 public ServerNotificationManagerTestCase(ConfigVariant variant, String configResources)
40 {
41 super(variant, configResources);
42 }
43
44 @Override
45 public void doTest() throws Exception
46 {
47 MuleClient client = new MuleClient(muleContext);
48 assertNotNull(client.send("vm://in", "hello world", null));
49 Service service = muleContext.getRegistry().lookupService(SERVICE);
50 service.pause();
51 service.resume();
52 }
53
54 @Override
55 public RestrictedNode getSpecification()
56 {
57 return new Node()
58
59 .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_INITIALISED, SERVICE))
60 .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_STARTED, SERVICE))
61 .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_PAUSED, SERVICE))
62 .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_RESUMED, SERVICE))
63 .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_STOPPED, SERVICE))
64 .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_DISPOSED, SERVICE))
65
66 .parallel(new Node()
67
68 .parallel(new Node(ModelNotification.class, ModelNotification.MODEL_INITIALISED, MULE_SYSTEM_MODEL))
69 .parallel(new Node(ModelNotification.class, ModelNotification.MODEL_INITIALISED, MODEL))
70 .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STARTING))
71 .serial(new Node()
72
73 .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STARTED, MODEL))
74 .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STARTED, MULE_SYSTEM_MODEL))
75 .serial(new Node(ModelNotification.class, ModelNotification.MODEL_STARTED, MULE_SYSTEM_MODEL)))
76 .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STARTED))
77 .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_DISPOSING))
78 .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STOPPING))
79 .serial(new Node()
80
81 .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STOPPED, MULE_SYSTEM_MODEL))
82 .serial(new Node(ModelNotification.class, ModelNotification.MODEL_STOPPED, MODEL)))
83 .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STOPPED)
84
85 .parallel(new Node(ModelNotification.class, ModelNotification.MODEL_DISPOSED, MODEL))
86 .parallel(new Node(ModelNotification.class, ModelNotification.MODEL_DISPOSED, MULE_SYSTEM_MODEL)))
87 .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_DISPOSED)));
88 }
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 @Override
135 public void validateSpecification(RestrictedNode spec) throws Exception
136 {
137 verifyNotification(spec, ModelNotification.class, ModelNotification.MODEL_INITIALISED);
138 verifyNotification(spec, ModelNotification.class, ModelNotification.MODEL_STARTED);
139 verifyNotification(spec, ModelNotification.class, ModelNotification.MODEL_STOPPED);
140 verifyNotification(spec, ModelNotification.class, ModelNotification.MODEL_DISPOSED);
141 }
142
143 }