01: package org.objectweb.celtix.systest.securebasic;
02:
03: import java.lang.reflect.UndeclaredThrowableException;
04: import java.net.URL;
05:
06: import javax.xml.namespace.QName;
07:
08: import junit.framework.Test;
09: import junit.framework.TestSuite;
10:
11: import org.objectweb.celtix.systest.common.ClientServerSetupBase;
12: import org.objectweb.celtix.systest.common.ClientServerTestBase;
13: import org.objectweb.hello_world_soap_http_secure.Greeter;
14: import org.objectweb.hello_world_soap_http_secure.SecureSOAPService;
15: import org.objectweb.hello_world_soap_http_secure.types.Result;
16:
17: public class ClientPropertiesNotSetServerTest extends
18: ClientServerTestBase {
19:
20: private static ClientServerSetupBase cssb;
21:
22: private final QName portName = new QName(
23: "http://objectweb.org/hello_world_soap_http_secure",
24: "SoapPortClientPropertiesNotSet");
25: private final QName secureServiceName = new QName(
26: "http://objectweb.org/hello_world_soap_http_secure",
27: "SecureSOAPServiceClientPropertiesNotSet");
28:
29: public static Test suite() throws Exception {
30:
31: TestSuite suite = new TestSuite(
32: ClientPropertiesNotSetServerTest.class);
33: cssb = new ClientServerSetupBase(suite) {
34: public void startServers() throws Exception {
35: System
36: .setProperty(
37: "java.util.logging.config.file",
38: getClass().getResource(".")
39: + "ClientPropertiesNotSetServerTestLog.txt");
40: SecureBasicUtils
41: .startServer(
42: getClass().getResource(".")
43: + "WantAndNeedClientAuthServerClientPropertiesNotSet.xml",
44: "celtix.security.configurer.http-listener.9015",
45: null,
46: cssb,
47: WantAndNeedClientAuthServerClientPropertiesNotSet.class);
48: }
49: };
50:
51: return cssb;
52: }
53:
54: public void testBasicConnectionClientNoPropertiesSet()
55: throws Exception {
56: System.setProperty("java.util.logging.config.file",
57: SecureBasicUtils.getTestDir(this ) + "clientlog.txt");
58: System.setProperty("celtix.config.file", getClass()
59: .getResource(".")
60: + "client.xml");
61:
62: URL wsdl = getClass().getResource(
63: "/wsdl/hello_world_secure.wsdl");
64: assertNotNull(wsdl);
65:
66: SecureSOAPService service = new SecureSOAPService(wsdl,
67: secureServiceName);
68: assertNotNull(service);
69:
70: Greeter greeter = service.getPort(portName, Greeter.class);
71:
72: invoke(greeter);
73:
74: }
75:
76: private void invoke(Greeter greeter) throws Exception {
77:
78: try {
79: Result ret = greeter.greetMeTwoTier("Milestone", 0);
80: if (ret.isDidPass()) {
81: fail("Should not have succeeded, client properties not setup");
82: }
83: } catch (UndeclaredThrowableException ex) {
84: assertTrue(
85: "Failed to catch expected exception, instead caught ex.getClass() = "
86: + ex.getClass(), ex != null);
87: }
88:
89: }
90:
91: public static void main(String[] args) {
92: junit.textui.TestRunner
93: .run(ClientPropertiesNotSetServerTest.class);
94: }
95:
96: }
|