View Javadoc

1   /*
2    * $Id: ServerNotificationManagerTestCase.java 22421 2011-07-15 05:05:06Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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                  // all service events are asynchronous, so place parallel to rest
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                  // synchronous events start here
66                  .parallel(new Node()
67                          // parallel because we don't know which model
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                                  // parallel because we don't know which model
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                                  // parallel because we don't know which model
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                                  // parallel because we don't know which model
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  //Before
91  //    public RestrictedNode getSpecificationx()
92  //    {
93  //        return new Node()
94  //                // all service events are asynchronous, so place parallel to rest
95  //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_INITIALISED, SERVICE))
96  //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_STARTED, SERVICE))
97  //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_PAUSED, SERVICE))
98  //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_RESUMED, SERVICE))
99  //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_STOPPED, SERVICE))
100 //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_STOPPED, SERVICE))
101 //                .parallel(new Node(ServiceNotification.class, ServiceNotification.SERVICE_DISPOSED, SERVICE))
102 //                // synchronous events start here
103 //                .parallel(new Node()
104 //                        // parallel because we don't know which model
105 //                        .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_INITIALISING, MULE_SYSTEM_MODEL)
106 //                                .serial(new Node(ModelNotification.class, ModelNotification.MODEL_INITIALISED, MULE_SYSTEM_MODEL)))
107 //                        .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_INITIALISING, MODEL)
108 //                                .serial(new Node(ModelNotification.class, ModelNotification.MODEL_INITIALISED, MODEL)))
109 //                        .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STARTING))
110 //                        .serial(new Node()
111 //                                // parallel because we don't know which model
112 //                                .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STARTING, MODEL)
113 //                                        .serial(new Node(ModelNotification.class, ModelNotification.MODEL_STARTED, MODEL)))
114 //                                .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STARTING, MULE_SYSTEM_MODEL)
115 //                                        .serial(new Node(ModelNotification.class, ModelNotification.MODEL_STARTED, MULE_SYSTEM_MODEL))))
116 //                        .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STARTED))
117 //                        .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_DISPOSING))
118 //                        .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STOPPING))
119 //                        .serial(new Node()
120 //                                // parallel because we don't know which model
121 //                                .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STOPPING, MODEL)
122 //                                        .serial(new Node(ModelNotification.class, ModelNotification.MODEL_STOPPED, MODEL)))
123 //                                .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_STOPPING, MULE_SYSTEM_MODEL)
124 //                                        .serial(new Node(ModelNotification.class, ModelNotification.MODEL_STOPPED, MULE_SYSTEM_MODEL))))
125 //                        .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_STOPPED)
126 //                                // parallel because we don't know which model
127 //                                .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_DISPOSING, MODEL)
128 //                                        .serial(new Node(ModelNotification.class, ModelNotification.MODEL_DISPOSED, MODEL)))
129 //                                .parallelSynch(new Node(ModelNotification.class, ModelNotification.MODEL_DISPOSING, MULE_SYSTEM_MODEL)
130 //                                        .serial(new Node(ModelNotification.class, ModelNotification.MODEL_DISPOSED, MULE_SYSTEM_MODEL))))
131 //                          .serial(new Node(MuleContextNotification.class, MuleContextNotification.CONTEXT_DISPOSED)));
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 }