View Javadoc

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