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