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.transport.NullPayload;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertFalse;
17  import static org.junit.Assert.assertNotNull;
18  import static org.junit.Assert.assertTrue;
19  
20  public class ComponentReturningNullFlowTestCase extends FunctionalTestCase
21  {
22  
23      @Override
24      protected String getConfigResources()
25      {
26          return "org/mule/test/components/component-returned-null.xml";
27      }
28  
29      @Test
30      public void testNullReturnStopsFlow() throws Exception
31      {
32          MuleClient client = new MuleClient(muleContext);
33  
34          MuleMessage msg = client.send("vm://in", "test data", null);
35          assertNotNull(msg);
36          final String payload = msg.getPayloadAsString();
37          assertNotNull(payload);
38          assertFalse("ERROR".equals(payload));
39          assertTrue(msg.getPayload() instanceof NullPayload);
40      }
41  
42      public static final class ComponentReturningNull
43      {
44          public String process(String input)
45          {
46              return null;
47          }
48      }
49  }