KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > webservice > secure > SimpleClientSecureTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.webservice.secure;
23
24 import java.io.File JavaDoc;
25
26 import javax.naming.Context JavaDoc;
27 import javax.xml.rpc.Service JavaDoc;
28 import javax.xml.rpc.Stub JavaDoc;
29
30 import junit.framework.Test;
31
32 import org.jboss.test.webservice.WebserviceTestBase;
33 import org.jboss.test.webservice.ws4eesimple.HelloWs;
34
35 /**
36  * Tests of the ws4ee functionality for a simple Hello EJB.
37  *
38  * @author Thomas.Diesler@jboss.org
39  * @since 06-May-2004
40  */

41 public class SimpleClientSecureTestCase extends WebserviceTestBase
42 {
43
44    /**
45     * Construct the test case with a given name
46     */

47    public SimpleClientSecureTestCase(String JavaDoc name)
48    {
49       super(name);
50    }
51
52    /**
53     * deploy the test archives
54     */

55    public static Test suite() throws Exception JavaDoc
56    {
57       return getDeploySetup(SimpleClientSecureTestCase.class, "ws4ee-simple-secure.war, ws4ee-simple-secure-client.jar");
58    }
59
60    /**
61     * Test client application access
62     */

63    public void testWithTransportOptions() throws Exception JavaDoc
64    {
65       Context JavaDoc envCtx = getClientContext();
66       Service JavaDoc service = (Service JavaDoc)envCtx.lookup("java:comp/env/service/HelloWsSecureService");
67       HelloWs port = (HelloWs)service.getPort(HelloWs.class);
68
69       String JavaDoc keyStore = "resources/test-configs/webservice-ssl/conf/client.keystore";
70       assertTrue("Cannot find keystore", new File JavaDoc(keyStore).exists());
71
72       Stub JavaDoc stub = (Stub JavaDoc)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 JavaDoc res = port.sayHello("Hello");
93       assertEquals("'Hello' to you too!", res);
94    }
95
96    public void testWithoutTransportOptions() throws Exception JavaDoc
97    {
98       Context JavaDoc envCtx = getClientContext();
99       Service JavaDoc service = (Service JavaDoc)envCtx.lookup("java:comp/env/service/HelloWsSecureService");
100       HelloWs port = (HelloWs)service.getPort(HelloWs.class);
101
102       String JavaDoc res = port.sayHello("Hello");
103       assertEquals("'Hello' to you too!", res);
104    }
105 }
106
Popular Tags