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  /**
14   * Test ComponentNotifications/Listeners by sending events to a component. A pre and
15   * post notification should be received by listeners.
16   */
17  public class ComponentMessageNotificationTestCase extends AbstractNotificationTestCase
18  {
19  
20      @Override
21      protected String getConfigResources()
22      {
23          return "org/mule/test/integration/notifications/component-message-notification-test.xml";
24      }
25  
26      @Override
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      @Override
36      public RestrictedNode getSpecification()
37      {
38          return new Node().parallel(
39              new Node(ComponentMessageNotification.class, ComponentMessageNotification.COMPONENT_PRE_INVOKE))
40              .parallel(
41                  new Node(ComponentMessageNotification.class,
42                      ComponentMessageNotification.COMPONENT_POST_INVOKE))
43              .parallel(
44                  new Node(ComponentMessageNotification.class,
45                      ComponentMessageNotification.COMPONENT_PRE_INVOKE))
46              .parallel(
47                  new Node(ComponentMessageNotification.class,
48                      ComponentMessageNotification.COMPONENT_POST_INVOKE));
49      }
50  
51      @Override
52      public void validateSpecification(RestrictedNode spec) throws Exception
53      {
54          verifyAllNotifications(spec, ComponentMessageNotification.class,
55              ComponentMessageNotification.COMPONENT_PRE_INVOKE,
56              ComponentMessageNotification.COMPONENT_POST_INVOKE);
57      }
58  }