View Javadoc

1   /*
2    * $Id: ComponentMessageNotificationTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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  /**
16   * Test ComponentNotifications/Listeners by sending events to a component. A pre and
17   * post notification should be received by listeners.
18   */
19  public class ComponentMessageNotificationTestCase extends AbstractNotificationTestCase
20  {
21  
22      protected String getConfigResources()
23      {
24          return "org/mule/test/integration/notifications/component-message-notification-test.xml";
25      }
26  
27      public void doTest() throws Exception
28      {
29          MuleClient client = new MuleClient(muleContext);
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().parallel(
38              new Node(ComponentMessageNotification.class, ComponentMessageNotification.COMPONENT_PRE_INVOKE))
39              .parallel(
40                  new Node(ComponentMessageNotification.class,
41                      ComponentMessageNotification.COMPONENT_POST_INVOKE))
42              .parallel(
43                  new Node(ComponentMessageNotification.class,
44                      ComponentMessageNotification.COMPONENT_PRE_INVOKE))
45              .parallel(
46                  new Node(ComponentMessageNotification.class,
47                      ComponentMessageNotification.COMPONENT_POST_INVOKE));
48      }
49  
50      public void validateSpecification(RestrictedNode spec) throws Exception
51      {
52          verifyAllNotifications(spec, ComponentMessageNotification.class,
53              ComponentMessageNotification.COMPONENT_PRE_INVOKE,
54              ComponentMessageNotification.COMPONENT_POST_INVOKE);
55      }
56  }