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.test.components;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.RequestContext;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNotNull;
18  
19  public class ComponentStoppingEventFlowTestCase extends FunctionalTestCase
20  {
21  
22      @Override
23      protected String getConfigResources()
24      {
25          return "org/mule/test/components/component-stopped-processing.xml";
26      }
27  
28      @Test
29      public void testNullReturnStopsFlow() throws Exception
30      {
31          MuleClient client = new MuleClient(muleContext);
32  
33          MuleMessage msg = client.send("vm://in", "test data", null);
34          assertNotNull(msg);
35          final String payload = msg.getPayloadAsString();
36          assertNotNull(payload);
37          assertEquals(TEST_MESSAGE, payload);
38      }
39  
40      public static final class ComponentStoppingFlow
41      {
42  
43          public String process(String input)
44          {
45              RequestContext.getEventContext().setStopFurtherProcessing(true);
46              return TEST_MESSAGE;
47          }
48      }
49  }