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.integration.routing.nested;
8   
9   import static org.junit.Assert.assertTrue;
10  import org.mule.api.client.LocalMuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  public class ComponentBindingReturningNullTestCase extends FunctionalTestCase
16  {
17  
18      private static boolean nullResultAccepted;
19  
20      @Override
21      protected String getConfigResources()
22      {
23          return "org/mule/test/integration/routing/nested/component-binding-returning-null-config.xml";
24      }
25  
26      @Test
27      public void componentBindingAcceptNullResult() throws Exception
28      {
29          LocalMuleClient client = muleContext.getClient();
30  
31          client.send("vm://testInput", "test", null);
32  
33          assertTrue(nullResultAccepted);
34      }
35  
36      public static interface HelloInterface
37      {
38  
39          public String sayHello(String s);
40      }
41  
42      public static class HelloImpl implements HelloInterface
43      {
44  
45          public String sayHello(String s)
46          {
47              return null;
48          }
49      }
50  
51      public static class Component
52      {
53  
54          private HelloInterface helloInterface;
55  
56          public String invoke(String s)
57          {
58              String result = helloInterface.sayHello(s);
59              nullResultAccepted = true;
60  
61              return result;
62          }
63  
64          public void setInterface(HelloInterface helloInterface)
65          {
66              this.helloInterface = helloInterface;
67          }
68  
69          public HelloInterface getInterface()
70          {
71              return helloInterface;
72          }
73      }
74  }