| 1 package org.objectweb.celtix.systest.securebasic; 2 3 import java.lang.reflect.UndeclaredThrowableException ; 4 import java.net.URL ; 5 6 import javax.xml.namespace.QName ; 7 8 import junit.framework.Test; 9 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 ClientPropertiesSetServerTest extends ClientServerTestBase { 18 19 private static ClientServerSetupBase cssb; 20 21 private final QName portName = new QName ("http://objectweb.org/hello_world_soap_http_secure", 22 "SoapPortClientPropertiesSet"); 23 private final QName secureServiceName = new QName ("http://objectweb.org/hello_world_soap_http_secure", 24 "SecureSOAPServiceClientPropertiesSet"); 25 26 27 public static Test suite() throws Exception { 28 29 TestSuite suite = new TestSuite(ClientPropertiesSetServerTest.class); 30 cssb = new ClientServerSetupBase(suite) { 31 public void startServers() throws Exception { 32 System.setProperty("java.util.logging.config.file", 33 SecureBasicUtils.getTestDir(this) 34 + "ClientServerClientPropertiesSetTestLog.txt"); 35 SecureBasicUtils.startServer(getClass().getResource(".") 36 + "WantAndNeedClientAuthServerClientPropertiesSet.xml", 37 "celtix.security.configurer.http-listener.9014", 38 null, 39 cssb, 40 WantAndNeedClientAuthServerClientPropertiesSet.class); 41 } 42 }; 43 return cssb; 44 } 45 46 public void testBasicConnectionSecurityDataSetAsSystemProperties() throws Exception { 47 String configFile = getClass().getResource(".") + "client.xml"; 48 System.setProperty("celtix.config.file", configFile); 49 URL wsdl = getClass().getResource("/wsdl/hello_world_secure.wsdl"); 50 assertNotNull(wsdl); 51 52 SecureSOAPService service = new SecureSOAPService(wsdl, secureServiceName); 53 assertNotNull(service); 54 55 Greeter greeter = service.getPort(portName, Greeter.class); 56 57 System.setProperty("javax.net.ssl.keyStore", 58 SecureBasicUtils.getTestDir(this) + ".clientkeystore"); 59 System.setProperty("javax.net.ssl.keyStorePassword", "clientpass"); 60 System.setProperty("javax.net.ssl.trustStore", 61 SecureBasicUtils.getTestDir(this) + "truststore"); 62 invoke(greeter); 63 } 64 65 private void invoke(Greeter greeter) throws Exception { 66 String response1 = new String ("Hello Milestone-"); 67 try { 68 for (int idx = 0; idx < 2; idx++) { 69 Result ret = greeter.greetMeTwoTier("Milestone-" + idx, 0); 70 if (!ret.isDidPass()) { 71 fail("Sould have succeeded but instead gor error message = " 72 + ret.getFailureReason()); 73 } 74 assertNotNull("no response received from service", ret.getReturnString()); 75 String exResponse = response1 + idx; 76 assertEquals(exResponse, ret.getReturnString()); 77 78 } 79 } catch (UndeclaredThrowableException ex) { 80 fail("Caught unexpected ex = " + ex); 81 throw (Exception )ex.getCause(); 82 } 83 84 } 85 86 public static void main(String [] args) { 87 junit.textui.TestRunner.run(ClientPropertiesSetServerTest.class); 88 } 89 90 91 } 92 | Popular Tags |