1 22 package org.jboss.test.webservice.header; 23 24 import junit.framework.Test; 25 import org.jboss.test.webservice.WebserviceTestBase; 26 import org.jboss.util.id.UID; 27 28 import javax.naming.InitialContext ; 29 import javax.xml.rpc.Service ; 30 31 37 public class HeaderEndpointTestCase extends WebserviceTestBase 38 { 39 public HeaderEndpointTestCase(String name) 40 { 41 super(name); 42 } 43 44 45 public static Test suite() throws Exception 46 { 47 return getDeploySetup(HeaderEndpointTestCase.class, "ws4ee-header.war, ws4ee-header-client.jar"); 48 } 49 50 53 public void testSimpleHeaderEndpoint() throws Exception 54 { 55 InitialContext iniCtx = getClientContext(); 56 Service service = (Service )iniCtx.lookup("java:comp/env/service/SimpleHeaderService"); 57 SimpleHeaderEndpoint port = (SimpleHeaderEndpoint)service.getPort(SimpleHeaderEndpoint.class); 58 59 boolean result = port.doStuff("Hello World!", "kermit"); 60 assertTrue(result); 61 } 62 63 66 public void testBeanHeaderEndpoint() throws Exception 67 { 68 InitialContext iniCtx = getClientContext(); 69 Service service = (Service )iniCtx.lookup("java:comp/env/service/BeanHeaderService"); 70 BeanHeaderEndpoint port = (BeanHeaderEndpoint)service.getPort(BeanHeaderEndpoint.class); 71 72 SessionHeader header = new SessionHeader(); 73 header.setUsername("kermit"); 74 header.setSessionID(UID.asString()); 75 76 boolean result = port.doStuff("Hello World!", header); 77 assertTrue(result); 78 } 79 80 83 public void testImplicitHeaderEndpoint() throws Exception 84 { 85 InitialContext iniCtx = getClientContext(); 86 Service service = (Service )iniCtx.lookup("java:comp/env/service/ImplicitHeaderService"); 87 ImplicitHeaderEndpoint port = (ImplicitHeaderEndpoint)service.getPort(ImplicitHeaderEndpoint.class); 88 89 boolean result = port.doStuff("Hello World!"); 90 assertTrue(result); 91 92 result = port.doStuff("Hello World!"); 94 assertTrue(result); 95 } 96 97 100 public void testExplicitHeaderEndpoint() throws Exception 101 { 102 InitialContext iniCtx = getClientContext(); 103 Service service = (Service )iniCtx.lookup("java:comp/env/service/ExplicitHeaderService"); 104 ExplicitHeaderEndpoint port = (ExplicitHeaderEndpoint)service.getPort(ExplicitHeaderEndpoint.class); 105 106 SessionHeader header = new SessionHeader(); 107 header.setUsername("kermit"); 108 SessionHeaderHolder holder = new SessionHeaderHolder(); 109 holder.value = header; 110 111 boolean result = port.doStuff("Hello World!", holder); 112 assertTrue(result); 113 assertNotNull(holder.value); 114 115 header = holder.value; 116 assertEquals("kermit", header.getUsername()); 117 assertNotNull(header.getSessionID()); 118 119 result = port.doStuff("Hello World!", holder); 121 assertTrue(result); 122 assertNotNull(holder.value); 123 124 header = holder.value; 125 assertEquals("kermit", header.getUsername()); 126 assertNotNull(header.getSessionID()); 127 } 128 } 129 | Popular Tags |