001: package org.objectweb.celtix.systest.securebasic;
002:
003: import java.lang.reflect.UndeclaredThrowableException;
004: import java.net.URL;
005:
006: import javax.xml.namespace.QName;
007:
008: import junit.framework.Test;
009: import junit.framework.TestSuite;
010:
011: import org.objectweb.celtix.systest.common.ClientServerSetupBase;
012: import org.objectweb.celtix.systest.common.ClientServerTestBase;
013: import org.objectweb.hello_world_soap_http_secure.Greeter;
014: import org.objectweb.hello_world_soap_http_secure.SecureSOAPService;
015: import org.objectweb.hello_world_soap_http_secure.types.Result;
016:
017: public class ClientPropertiesSetServerTest extends ClientServerTestBase {
018:
019: private static ClientServerSetupBase cssb;
020:
021: private final QName portName = new QName(
022: "http://objectweb.org/hello_world_soap_http_secure",
023: "SoapPortClientPropertiesSet");
024: private final QName secureServiceName = new QName(
025: "http://objectweb.org/hello_world_soap_http_secure",
026: "SecureSOAPServiceClientPropertiesSet");
027:
028: public static Test suite() throws Exception {
029:
030: TestSuite suite = new TestSuite(
031: ClientPropertiesSetServerTest.class);
032: cssb = new ClientServerSetupBase(suite) {
033: public void startServers() throws Exception {
034: System
035: .setProperty(
036: "java.util.logging.config.file",
037: SecureBasicUtils.getTestDir(this )
038: + "ClientServerClientPropertiesSetTestLog.txt");
039: SecureBasicUtils
040: .startServer(
041: getClass().getResource(".")
042: + "WantAndNeedClientAuthServerClientPropertiesSet.xml",
043: "celtix.security.configurer.http-listener.9014",
044: null,
045: cssb,
046: WantAndNeedClientAuthServerClientPropertiesSet.class);
047: }
048: };
049: return cssb;
050: }
051:
052: public void testBasicConnectionSecurityDataSetAsSystemProperties()
053: throws Exception {
054: String configFile = getClass().getResource(".") + "client.xml";
055: System.setProperty("celtix.config.file", configFile);
056: URL wsdl = getClass().getResource(
057: "/wsdl/hello_world_secure.wsdl");
058: assertNotNull(wsdl);
059:
060: SecureSOAPService service = new SecureSOAPService(wsdl,
061: secureServiceName);
062: assertNotNull(service);
063:
064: Greeter greeter = service.getPort(portName, Greeter.class);
065:
066: System.setProperty("javax.net.ssl.keyStore", SecureBasicUtils
067: .getTestDir(this )
068: + ".clientkeystore");
069: System.setProperty("javax.net.ssl.keyStorePassword",
070: "clientpass");
071: System.setProperty("javax.net.ssl.trustStore", SecureBasicUtils
072: .getTestDir(this )
073: + "truststore");
074: invoke(greeter);
075: }
076:
077: private void invoke(Greeter greeter) throws Exception {
078: String response1 = new String("Hello Milestone-");
079: try {
080: for (int idx = 0; idx < 2; idx++) {
081: Result ret = greeter.greetMeTwoTier("Milestone-" + idx,
082: 0);
083: if (!ret.isDidPass()) {
084: fail("Sould have succeeded but instead gor error message = "
085: + ret.getFailureReason());
086: }
087: assertNotNull("no response received from service", ret
088: .getReturnString());
089: String exResponse = response1 + idx;
090: assertEquals(exResponse, ret.getReturnString());
091:
092: }
093: } catch (UndeclaredThrowableException ex) {
094: fail("Caught unexpected ex = " + ex);
095: throw (Exception) ex.getCause();
096: }
097:
098: }
099:
100: public static void main(String[] args) {
101: junit.textui.TestRunner
102: .run(ClientPropertiesSetServerTest.class);
103: }
104:
105: }
|