1 22 package org.jboss.test.webservice.ws4eesimple; 23 24 import junit.framework.Test; 25 import org.jboss.test.webservice.WebserviceTestBase; 26 27 import javax.naming.Context ; 28 import javax.naming.InitialContext ; 29 import javax.xml.rpc.Service ; 30 import java.io.BufferedReader ; 31 import java.io.InputStreamReader ; 32 import java.net.URL ; 33 34 41 public class SimpleClientTestCase extends WebserviceTestBase 42 { 43 44 47 public SimpleClientTestCase(String name) 48 { 49 super(name); 50 } 51 52 55 public static Test suite() throws Exception 56 { 57 return getDeploySetup(SimpleClientTestCase.class, "ws4ee-simple.jar, ws4ee-simple-client.ear"); 58 } 59 60 63 public void testApplClient() throws Exception 64 { 65 Context envCtx = getClientContext(); 66 Service service = (Service )envCtx.lookup("java:comp/env/service/HelloService"); 67 HelloWs ws = (HelloWs)service.getPort(HelloWs.class); 68 String res = ws.sayHello("Hello"); 69 assertEquals("'Hello' to you too!", res); 70 } 71 72 75 public void testWebClient() throws Exception 76 { 77 URL url = new URL ("http://" + getServerHost() + ":8080/ws4ee-simple-client/HelloWsClientServlet?input=Hello"); 78 BufferedReader br = new BufferedReader (new InputStreamReader (url.openStream())); 79 String res = br.readLine(); 80 br.close(); 81 82 assertEquals("'Hello' to you too!", res); 83 } 84 85 88 public void testEJBClient() throws Exception 89 { 90 InitialContext iniCtx = getClientContext(); 92 HelloHome home = (HelloHome)iniCtx.lookup("java:comp/env/HelloClientEjb"); 93 Hello ejb = home.create(); 94 95 String output = ejb.sayHello("Hello"); 96 assertEquals("'Hello' to you too!", output); 97 98 Context envCtx = getClientContext(); 100 Service svc = (Service )envCtx.lookup("java:comp/env/service/HelloService"); 101 102 HelloWs sei = (HelloWs)svc.getPort(HelloWs.class); 103 output = sei.sayHello("Hello"); 104 assertEquals("'Hello' to you too!", output); 105 } 106 } 107 | Popular Tags |