1 22 package org.jboss.test.webservice.secure; 23 24 import java.io.File ; 25 26 import javax.naming.Context ; 27 import javax.xml.rpc.Service ; 28 import javax.xml.rpc.Stub ; 29 30 import junit.framework.Test; 31 32 import org.jboss.test.webservice.WebserviceTestBase; 33 import org.jboss.test.webservice.ws4eesimple.HelloWs; 34 35 41 public class SimpleClientSecureTestCase extends WebserviceTestBase 42 { 43 44 47 public SimpleClientSecureTestCase(String name) 48 { 49 super(name); 50 } 51 52 55 public static Test suite() throws Exception 56 { 57 return getDeploySetup(SimpleClientSecureTestCase.class, "ws4ee-simple-secure.war, ws4ee-simple-secure-client.jar"); 58 } 59 60 63 public void testWithTransportOptions() throws Exception 64 { 65 Context envCtx = getClientContext(); 66 Service service = (Service )envCtx.lookup("java:comp/env/service/HelloWsSecureService"); 67 HelloWs port = (HelloWs)service.getPort(HelloWs.class); 68 69 String keyStore = "resources/test-configs/webservice-ssl/conf/client.keystore"; 70 assertTrue("Cannot find keystore", new File (keyStore).exists()); 71 72 Stub stub = (Stub )port; 73 if (isWS4EEAvailable()) 74 { 75 stub._setProperty("org.jboss.webservice.keyStore", keyStore); 76 stub._setProperty("org.jboss.webservice.keyStorePassword", "unit-tests-client"); 77 stub._setProperty("org.jboss.webservice.keyStoreType", "JKS"); 78 stub._setProperty("org.jboss.webservice.trustStore", keyStore); 79 stub._setProperty("org.jboss.webservice.trustStorePassword", "unit-tests-client"); 80 stub._setProperty("org.jboss.webservice.trustStoreType", "JKS"); 81 } 82 if (isJBossWSAvailable()) 83 { 84 stub._setProperty("org.jboss.ws.keyStore", keyStore); 85 stub._setProperty("org.jboss.ws.keyStorePassword", "unit-tests-client"); 86 stub._setProperty("org.jboss.ws.keyStoreType", "JKS"); 87 stub._setProperty("org.jboss.ws.trustStore", keyStore); 88 stub._setProperty("org.jboss.ws.trustStorePassword", "unit-tests-client"); 89 stub._setProperty("org.jboss.ws.trustStoreType", "JKS"); 90 } 91 92 String res = port.sayHello("Hello"); 93 assertEquals("'Hello' to you too!", res); 94 } 95 96 public void testWithoutTransportOptions() throws Exception 97 { 98 Context envCtx = getClientContext(); 99 Service service = (Service )envCtx.lookup("java:comp/env/service/HelloWsSecureService"); 100 HelloWs port = (HelloWs)service.getPort(HelloWs.class); 101 102 String res = port.sayHello("Hello"); 103 assertEquals("'Hello' to you too!", res); 104 } 105 } 106 | Popular Tags |