1 22 package org.jboss.test.webservice.secure.noenv; 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 import junit.framework.TestSuite; 32 33 import org.jboss.test.JBossTestCase; 34 import org.jboss.test.webservice.WebserviceTestBase; 35 import org.jboss.test.webservice.ws4eesimple.HelloWs; 36 37 42 public class TransportOptionsTestCase extends WebserviceTestBase 43 { 44 public TransportOptionsTestCase(String name) 45 { 46 super(name); 47 } 48 49 public static Test suite() throws Exception 50 { 51 TestSuite suite = new TestSuite(); 54 suite.addTest(new TransportOptionsTestCase("testWithTransportOptions")); 55 suite.addTest(new TransportOptionsTestCase("testWithoutKeystore")); 56 57 return JBossTestCase.getDeploySetup(suite, "ws4ee-simple-secure.war, ws4ee-simple-secure-client.jar"); 58 } 59 60 61 public void testWithTransportOptions() throws Exception 62 { 63 Context envCtx = getClientContext(); 64 Service service = (Service )envCtx.lookup("java:comp/env/service/HelloWsSecureService"); 65 HelloWs port = (HelloWs)service.getPort(HelloWs.class); 66 67 String keyStore = "resources/test-configs/webservice-ssl/conf/client.keystore"; 68 assertTrue("Keystore exists", new File (keyStore).exists()); 69 70 Stub stub = (Stub )port; 71 if (isWS4EEAvailable()) 72 { 73 stub._setProperty("org.jboss.webservice.keyStore", keyStore); 74 stub._setProperty("org.jboss.webservice.keyStorePassword", "unit-tests-client"); 75 stub._setProperty("org.jboss.webservice.keyStoreType", "JKS"); 76 stub._setProperty("org.jboss.webservice.trustStore", keyStore); 77 stub._setProperty("org.jboss.webservice.trustStorePassword", "unit-tests-client"); 78 stub._setProperty("org.jboss.webservice.trustStoreType", "JKS"); 79 } 80 if (isJBossWSAvailable()) 81 { 82 stub._setProperty("org.jboss.ws.keyStore", keyStore); 83 stub._setProperty("org.jboss.ws.keyStorePassword", "unit-tests-client"); 84 stub._setProperty("org.jboss.ws.keyStoreType", "JKS"); 85 stub._setProperty("org.jboss.ws.trustStore", keyStore); 86 stub._setProperty("org.jboss.ws.trustStorePassword", "unit-tests-client"); 87 stub._setProperty("org.jboss.ws.trustStoreType", "JKS"); 88 } 89 90 String res = port.sayHello("Hello"); 91 assertEquals("'Hello' to you too!", res); 92 93 res = port.sayHello("Hello2"); 94 assertEquals("'Hello2' to you too!", res); 95 } 96 97 public void testWithoutKeystore() throws Exception 98 { 99 Context envCtx = getClientContext(); 100 Service service = (Service )envCtx.lookup("java:comp/env/service/HelloWsSecureService"); 101 HelloWs port = (HelloWs)service.getPort(HelloWs.class); 102 103 String keyStore = "resources/test-configs/webservice-ssl/conf/client.keystore"; 104 assertTrue("Keystore exists", new File (keyStore).exists()); 105 106 Stub stub = (Stub )port; 107 if (isWS4EEAvailable()) 108 { 109 stub._setProperty("org.jboss.webservice.trustStore", keyStore); 110 stub._setProperty("org.jboss.webservice.trustStorePassword", "unit-tests-client"); 111 stub._setProperty("org.jboss.webservice.trustStoreType", "JKS"); 112 } 113 if (isJBossWSAvailable()) 114 { 115 stub._setProperty("org.jboss.ws.trustStore", keyStore); 116 stub._setProperty("org.jboss.ws.trustStorePassword", "unit-tests-client"); 117 stub._setProperty("org.jboss.ws.trustStoreType", "JKS"); 118 } 119 120 try 121 { 122 String res = port.sayHello("Hello"); 123 System.out.println("FIXME: JBWS-777"); 124 } 126 catch (Exception e) 127 { 128 } 130 } 131 } 132 | Popular Tags |