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.transport.soap.axis;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.endpoint.InboundEndpoint;
11  import org.mule.api.lifecycle.InitialisationException;
12  import org.mule.api.service.Service;
13  import org.mule.api.source.CompositeMessageSource;
14  import org.mule.config.ExceptionHelper;
15  import org.mule.tck.MuleTestUtils;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertTrue;
20  import static org.junit.Assert.fail;
21  
22  public class AxisConnectorHttpFunctionalTestCase extends AbstractSoapUrlEndpointFunctionalTestCase
23  {
24  
25      public static class ComponentWithoutInterfaces
26      {
27          public String echo(String msg)
28          {
29              return msg;
30          }
31      }
32  
33      @Override
34      public String getConfigResources()
35      {
36          return "axis-" + getTransportProtocol() + "-mule-config.xml";
37      }
38  
39      @Override
40      protected String getTransportProtocol()
41      {
42          return "http";
43      }
44  
45      @Override
46      protected String getSoapProvider()
47      {
48          return "axis";
49      }
50  
51      /**
52       * The Axis service requires that the service implements at least one interface
53       * This just tests that we get the correct exception if no interfaces are
54       * implemented
55       * 
56       * @throws Throwable
57       */
58      @Test
59      public void testComponentWithoutInterfaces() throws Throwable
60      {
61          try
62          {
63              // TODO MULE-2228 Simplify this API
64              Service c = MuleTestUtils.getTestService("testComponentWithoutInterfaces", ComponentWithoutInterfaces.class, null, muleContext, false);
65              InboundEndpoint ep = muleContext.getEndpointFactory().getInboundEndpoint(getComponentWithoutInterfacesEndpoint());
66              ((CompositeMessageSource) c.getMessageSource()).addSource(ep);
67              muleContext.getRegistry().registerService(c);
68              fail("Expected exception");
69          }
70          catch (MuleException e)
71          {
72              e = ExceptionHelper.getRootMuleException(e);
73              assertTrue(e instanceof InitialisationException);
74              assertTrue(e.getMessage(), e.getMessage().indexOf("must implement at least one interface") > -1);
75          }
76      }
77  
78  }