View Javadoc

1   /*
2    * $Id: EndpointMessageNotificationTestCase.java 23030 2011-09-26 18:02:33Z mike.schilling $
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.module.client.MuleClient;
14  
15  import java.util.Arrays;
16  import java.util.Collection;
17  
18  import org.junit.runners.Parameterized.Parameters;
19  
20  import static org.junit.Assert.assertNotNull;
21  
22  public class EndpointMessageNotificationTestCase extends AbstractNotificationTestCase
23  {
24      public static final String NO_ID = null;
25      public static final String SERVICE_1_ID = "service-1";
26      public static final String SERVICE_2_ID = "service-2";
27      public static final String CLIENT_ID = "MuleClient";
28  
29      @Parameters
30      public static Collection<Object[]> parameters()
31      {
32          return Arrays.asList(new Object[][]{
33              {ConfigVariant.SERVICE, "org/mule/test/integration/notifications/endpoint-message-notification-test-service.xml"},
34              {ConfigVariant.FLOW, "org/mule/test/integration/notifications/endpoint-message-notification-test-flow.xml"}
35          });
36      }
37  
38      public EndpointMessageNotificationTestCase(ConfigVariant variant, String configResources)
39      {
40          super(variant, configResources);
41      }
42  
43      @Override
44      public void doTest() throws Exception
45      {
46          final MuleClient client = new MuleClient(muleContext);
47          assertNotNull(client.send("vm://in-1?connector=direct", "hello sweet world", null));
48          client.dispatch("vm://in-2?connector=direct", "goodbye cruel world", null);
49          assertNotNull(client.request("vm://out-2?connector=queue", 5000));
50      }
51  
52      @Override
53      public RestrictedNode getSpecification()
54      {
55          return new Node().parallel(
56              new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_SEND_BEGIN, CLIENT_ID))
57              .parallel(
58                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_SEND_END, CLIENT_ID))
59              .parallel(
60                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RECEIVED,
61                      SERVICE_1_ID))
62              .parallel(
63                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RESPONSE,
64                      SERVICE_1_ID))
65              .parallel(
66                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCH_BEGIN,
67                      CLIENT_ID))
68              .parallel(
69                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCH_END,
70                      CLIENT_ID)
71              .parallel(
72                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RECEIVED,
73                      SERVICE_2_ID))
74               .parallel(
75                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCH_BEGIN,
76                      SERVICE_2_ID))
77              .parallel(
78                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCH_END,
79                      SERVICE_2_ID))
80              .parallel(
81                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_REQUEST_END,
82                      NO_ID))
83              .parallel(
84                  new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_REQUEST_BEGIN,
85                      NO_ID))); // a request notification bears no resource ID
86      }
87  
88      @Override
89      public void validateSpecification(RestrictedNode spec) throws Exception
90      {
91          // A
92      }
93  }