View Javadoc

1   /*
2    * $Id: ProxyServiceConfigurationTestCase.java 19383 2010-09-06 20:37:51Z epere4 $
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.module.cxf.support;
12  
13  import org.mule.MuleServer;
14  import org.mule.tck.AbstractMuleTestCase;
15  import org.mule.util.ExceptionUtils;
16  
17  import java.net.URL;
18  
19  import org.apache.cxf.service.factory.ServiceConstructionException;
20  
21  public class ProxyServiceConfigurationTestCase extends AbstractMuleTestCase
22  {
23      public void testGetEndpointName_CorrectNameSpace()
24      {
25          String configFilePath = "/org/mule/module/cxf/support/test-proxy-mule-config-correct-namespace.xml";
26          startServer(configFilePath);
27      }
28  
29      public void testGetEndpointName_NoNameSpace()
30      {
31          String configFilePath = "/org/mule/module/cxf/support/test-proxy-mule-config-no-namespace.xml";
32          try
33          {
34              startServer(configFilePath);
35              fail("It should have failed because no namespace was specified");
36          }
37          catch (RuntimeException e)
38          {
39              Throwable rootCause = ExceptionUtils.getRootCause(e);
40              assertTrue("Exception must be of type " + ServiceConstructionException.class + ", instead of "
41                         + rootCause, rootCause instanceof ServiceConstructionException);
42          }
43      }
44  
45      private void startServer(String configFilePath)
46      {
47          URL configURL = this.getClass().getResource(configFilePath);
48          MuleServer muleServer = new MuleServer(configURL.toString())
49          {
50              @Override
51              public void shutdown(Throwable e)
52              {
53                  throw new RuntimeException(e);
54              }
55          };
56          muleServer.start(false, false);
57      }
58  
59  }