1 7 package org.jboss.test.webservice.secure.ws4eesimple; 8 9 11 import javax.naming.Context ; 12 import javax.xml.rpc.Service ; 13 14 import junit.framework.Test; 15 16 import org.jboss.test.webservice.WebserviceTestBase; 17 import org.jboss.test.webservice.ws4eesimple.HelloWs; 18 import org.jboss.webservice.client.CallImpl; 19 import org.jboss.webservice.client.Stub; 20 21 28 public class SimpleClientSecureTestCase extends WebserviceTestBase 29 { 30 31 34 public SimpleClientSecureTestCase(String name) 35 { 36 super(name); 37 } 38 39 42 public static Test suite() throws Exception 43 { 44 return getDeploySetup(SimpleClientSecureTestCase.class, "ws4ee-simple-secure.war, ws4ee-simple-secure-client.jar"); 45 } 46 47 50 public void testWithTransportOptions() throws Exception 51 { 52 Context envCtx = getClientContext(); 53 Object obj = envCtx.lookup("java:comp/env/service/HelloWsSecureService"); 54 assertTrue("Is not a javax.xml.rpc.Service, but: " + obj, javax.xml.rpc.Service .class.isAssignableFrom(obj.getClass())); 55 Service service = (Service )obj; 56 HelloWs ws = (HelloWs)service.getPort(HelloWs.class); 57 Stub stub = (Stub)ws; 58 59 String root = System.getProperty("rootDir"); 60 if (root == null) 61 root = ""; 62 else 63 root += "/"; 64 65 stub.setTransportOption("keyStore", root + "test-configs/webservice-ssl/conf/client.keystore"); 66 stub.setTransportOption("keyStorePassword", "unit-tests-client"); 67 stub.setTransportOption("keyStoreType", "JKS"); 68 stub.setTransportOption("trustStore", root + "test-configs/webservice-ssl/conf/client.keystore"); 69 stub.setTransportOption("trustStorePassword", "unit-tests-client"); 70 stub.setTransportOption("trustStoreType", "JKS"); 71 72 String res = ws.sayHello("Hello"); 73 assertEquals("'Hello' to you too!", res); 74 } 75 76 public void testWithoutTransportOptions() throws Exception 77 { 78 Context envCtx = getClientContext(); 79 Object obj = envCtx.lookup("java:comp/env/service/HelloWsSecureService"); 80 assertTrue("Is not a javax.xml.rpc.Service, but: " + obj, javax.xml.rpc.Service .class.isAssignableFrom(obj.getClass())); 81 Service service = (Service )obj; 82 HelloWs ws = (HelloWs)service.getPort(HelloWs.class); 83 84 String res = ws.sayHello("Hello"); 85 assertEquals("'Hello' to you too!", res); 86 } 87 } 88 | Popular Tags |