View Javadoc

1   /*
2    * $Id: AxisConnectorHttpFunctionalTestCase.java 19841 2010-10-05 23:17:20Z dzapata $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.soap.axis;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.api.lifecycle.InitialisationException;
16  import org.mule.api.service.Service;
17  import org.mule.api.source.CompositeMessageSource;
18  import org.mule.config.ExceptionHelper;
19  import org.mule.tck.MuleTestUtils;
20  
21  public class AxisConnectorHttpFunctionalTestCase extends AbstractSoapUrlEndpointFunctionalTestCase
22  {
23      public static class ComponentWithoutInterfaces
24      {
25          public String echo(String msg)
26          {
27              return msg;
28          }
29      }
30  
31      @Override
32      public String getConfigResources()
33      {
34          return "axis-" + getTransportProtocol() + "-mule-config.xml";
35      }
36  
37      @Override
38      protected String getTransportProtocol()
39      {
40          return "http";
41      }
42  
43      @Override
44      protected String getSoapProvider()
45      {
46          return "axis";
47      }
48  
49      /**
50       * The Axis service requires that the service implements at least one interface
51       * This just tests that we get the correct exception if no interfaces are
52       * implemented
53       * 
54       * @throws Throwable
55       */
56      public void testComponentWithoutInterfaces() throws Throwable
57      {
58          try
59          {
60              // TODO MULE-2228 Simplify this API
61              Service c = MuleTestUtils.getTestService("testComponentWithoutInterfaces", ComponentWithoutInterfaces.class, null, muleContext, false);
62              InboundEndpoint ep = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(getComponentWithoutInterfacesEndpoint());
63              ((CompositeMessageSource) c.getMessageSource()).addSource(ep);
64              muleContext.getRegistry().registerService(c);
65              fail("Expected exception");
66          }
67          catch (MuleException e)
68          {
69              e = ExceptionHelper.getRootMuleException(e);
70              assertTrue(e instanceof InitialisationException);
71              assertTrue(e.getMessage(), e.getMessage().indexOf("must implement at least one interface") > -1);
72          }
73      }
74  
75      @Override
76      protected int getNumPortsToFind()
77      {
78          return 3;
79      }
80  }