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