View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.context.notification;
8   
9   import org.mule.module.client.MuleClient;
10  
11  import static org.junit.Assert.assertNotNull;
12  
13  public class EndpointMessageNotificationTestCase extends AbstractNotificationTestCase
14  {
15  
16      public static final String NO_ID = null;
17      public static final String SERVICE_1_ID = "service-1";
18      public static final String SERVICE_2_ID = "service-2";
19      public static final String CLIENT_ID = "MuleClient";
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "org/mule/test/integration/notifications/endpoint-message-notification-test.xml";
25      }
26  
27      @Override
28      public void doTest() throws Exception
29      {
30          final MuleClient client = new MuleClient(muleContext);
31          assertNotNull(client.send("vm://in-1?connector=direct", "hello sweet world", null));
32          client.dispatch("vm://in-2?connector=direct", "goodbye cruel world", null);
33          assertNotNull(client.request("vm://out-2?connector=queue", 5000));
34      }
35  
36      @Override
37      public RestrictedNode getSpecification()
38      {
39          return new Node().parallel(
40              new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_SENT, CLIENT_ID))
41              .parallel(
42                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RECEIVED,
43                      SERVICE_1_ID))
44              .parallel(
45                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RESPONSE,
46                      SERVICE_1_ID))
47              .parallel(
48                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCHED,
49                      CLIENT_ID))
50              .parallel(
51                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RECEIVED,
52                      SERVICE_2_ID))
53              .parallel(
54                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCHED,
55                      SERVICE_2_ID))
56              .parallel(
57                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_REQUESTED,
58                      NO_ID)); // a request notification bears no resource ID
59      }
60  
61      @Override
62      public void validateSpecification(RestrictedNode spec) throws Exception
63      {
64          verifyAllNotifications(spec, EndpointMessageNotification.class,
65              EndpointMessageNotification.MESSAGE_RECEIVED, EndpointMessageNotification.MESSAGE_REQUESTED);
66      }
67  
68  }