1   /*
2    * $Id: MessageNotificationTestCase.java 12247 2008-07-07 21:25:01Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  public class MessageNotificationTestCase extends AbstractNotificationTestCase
16  {
17  
18      public static final String SERVICE_1 = "service-1";
19      public static final String SERVICE_2 = "service-2";
20      public static final String CLIENT = null; // client id is null
21  
22      protected String getConfigResources()
23      {
24          return "org/mule/test/integration/notifications/message-notification-test.xml";
25      }
26  
27      public void doTest() throws Exception
28      {
29          MuleClient client = new MuleClient();
30          assertNotNull(client.send("vm://in-1?connector=direct", "hello sweet world", null));
31          client.dispatch("vm://in-2?connector=direct", "goodbye cruel world", null);
32          assertNotNull(client.request("vm://out-2?connector=queue", 5000));
33      }
34  
35      public RestrictedNode getSpecification()
36      {
37          return new Node()
38                  .parallel(new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_SENT, CLIENT))
39                  .parallel(new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RECEIVED, SERVICE_1))
40                  .parallel(new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCHED, CLIENT))
41                  .parallel(new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_RECEIVED, SERVICE_2))
42                  .parallel(new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_DISPATCHED, SERVICE_2))
43                  .parallel(new Node(EndpointMessageNotification.class, EndpointMessageNotification.MESSAGE_REQUESTED, CLIENT));
44      }
45  
46      public void validateSpecification(RestrictedNode spec) throws Exception
47      {
48          verifyAllNotifications(spec, EndpointMessageNotification.class,
49              EndpointMessageNotification.MESSAGE_RECEIVED, EndpointMessageNotification.MESSAGE_REQUESTED);
50      }
51  
52  }