1 package org.objectweb.celtix.systest.provider; 2 3 import java.lang.reflect.UndeclaredThrowableException ; 4 import java.net.URL ; 5 import javax.xml.namespace.QName ; 6 7 import junit.framework.Test; 8 import junit.framework.TestSuite; 9 10 import org.objectweb.celtix.systest.common.ClientServerSetupBase; 11 import org.objectweb.celtix.systest.common.ClientServerTestBase; 12 13 import org.objectweb.hello_world_rpclit.GreeterRPCLit; 14 import org.objectweb.hello_world_rpclit.SOAPServiceRPCLit; 15 16 public class ProviderClientServerTest extends ClientServerTestBase { 17 18 public static Test suite() throws Exception { 19 TestSuite suite = new TestSuite(ProviderClientServerTest.class); 20 return new ClientServerSetupBase(suite) { 21 public void startServers() throws Exception { 22 assertTrue("server did not launch correctly", launchServer(Server.class)); 23 } 24 }; 25 } 26 27 public void testMessageModeWithSOAPMessageData() throws Exception { 28 29 QName serviceName = 30 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit"); 31 QName portName = 32 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit"); 33 34 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 35 assertNotNull(wsdl); 36 37 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 38 assertNotNull(service); 39 40 String response1 = new String ("TestGreetMeResponse"); 41 String response2 = new String ("TestSayHiResponse"); 42 try { 43 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 44 for (int idx = 0; idx < 2; idx++) { 45 String greeting = greeter.greetMe("Milestone-" + idx); 46 assertNotNull("no response received from service", greeting); 47 assertEquals(response1, greeting); 48 49 String reply = greeter.sayHi(); 50 assertNotNull("no response received from service", reply); 51 assertEquals(response2, reply); 52 } 53 } catch (UndeclaredThrowableException ex) { 54 throw (Exception )ex.getCause(); 55 } 56 } 57 58 public void testMessageModeWithDOMSourceData() throws Exception { 59 QName serviceName = 60 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit1"); 61 QName portName = 62 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit1"); 63 64 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 65 assertNotNull(wsdl); 66 67 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 68 assertNotNull(service); 69 70 String response1 = new String ("TestGreetMeResponse"); 71 String response2 = new String ("TestSayHiResponse"); 72 try { 73 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 74 for (int idx = 0; idx < 2; idx++) { 75 String greeting = greeter.greetMe("Milestone-" + idx); 76 assertNotNull("no response received from service", greeting); 77 assertEquals(response1, greeting); 78 79 String reply = greeter.sayHi(); 80 assertNotNull("no response received from service", reply); 81 assertEquals(response2, reply); 82 } 83 } catch (UndeclaredThrowableException ex) { 84 throw (Exception )ex.getCause(); 85 } 86 } 87 88 public void testPayloadModeWithDOMSourceData() throws Exception { 89 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 90 assertNotNull(wsdl); 91 92 QName serviceName = 93 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit2"); 94 QName portName = 95 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit2"); 96 97 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 98 assertNotNull(service); 99 100 String response1 = new String ("TestGreetMeResponse"); 101 String response2 = new String ("TestSayHiResponse"); 102 try { 103 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 104 for (int idx = 0; idx < 1; idx++) { 105 String greeting = greeter.greetMe("Milestone-" + idx); 106 assertNotNull("no response received from service", greeting); 107 assertEquals(response1, greeting); 108 109 String reply = greeter.sayHi(); 110 assertNotNull("no response received from service", reply); 111 assertEquals(response2, reply); 112 } 113 } catch (UndeclaredThrowableException ex) { 114 throw (Exception )ex.getCause(); 115 } 116 } 117 118 public void testMessageModeWithSAXSourceData() throws Exception { 119 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 120 assertNotNull(wsdl); 121 122 QName serviceName = 123 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit3"); 124 QName portName = 125 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit3"); 126 127 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 128 assertNotNull(service); 129 130 String response1 = new String ("TestGreetMeResponse"); 131 String response2 = new String ("TestSayHiResponse"); 132 try { 133 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 134 for (int idx = 0; idx < 1; idx++) { 135 String greeting = greeter.greetMe("Milestone-" + idx); 136 assertNotNull("no response received from service", greeting); 137 assertEquals(response1, greeting); 138 139 String reply = greeter.sayHi(); 140 assertNotNull("no response received from service", reply); 141 assertEquals(response2, reply); 142 } 143 } catch (UndeclaredThrowableException ex) { 144 throw (Exception )ex.getCause(); 145 } 146 } 147 148 public void testMessageModeWithStreamSourceData() throws Exception { 149 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 150 assertNotNull(wsdl); 151 152 QName serviceName = 153 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit4"); 154 QName portName = 155 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit4"); 156 157 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 158 assertNotNull(service); 159 160 String response1 = new String ("TestGreetMeResponse"); 161 String response2 = new String ("TestSayHiResponse"); 162 try { 163 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 164 for (int idx = 0; idx < 1; idx++) { 165 String greeting = greeter.greetMe("Milestone-" + idx); 166 assertNotNull("no response received from service", greeting); 167 assertEquals(response1, greeting); 168 169 String reply = greeter.sayHi(); 170 assertNotNull("no response received from service", reply); 171 assertEquals(response2, reply); 172 } 173 } catch (UndeclaredThrowableException ex) { 174 throw (Exception )ex.getCause(); 175 } 176 } 177 178 179 180 public void testPayloadModeWithSAXSourceData() throws Exception { 181 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 182 assertNotNull(wsdl); 183 184 QName serviceName = 185 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit5"); 186 QName portName = 187 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit5"); 188 189 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 190 assertNotNull(service); 191 192 String response1 = new String ("TestGreetMeResponse"); 193 String response2 = new String ("TestSayHiResponse"); 194 try { 195 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 196 for (int idx = 0; idx < 1; idx++) { 197 String greeting = greeter.greetMe("Milestone-" + idx); 198 assertNotNull("no response received from service", greeting); 199 assertEquals(response1, greeting); 200 201 String reply = greeter.sayHi(); 202 assertNotNull("no response received from service", reply); 203 assertEquals(response2, reply); 204 } 205 } catch (UndeclaredThrowableException ex) { 206 throw (Exception )ex.getCause(); 207 } 208 } 209 210 211 public void testPayloadModeWithStreamSourceData() throws Exception { 212 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 213 assertNotNull(wsdl); 214 215 QName serviceName = 216 new QName ("http://objectweb.org/hello_world_rpclit", "SOAPServiceRPCLit6"); 217 QName portName = 218 new QName ("http://objectweb.org/hello_world_rpclit", "SoapPortRPCLit6"); 219 220 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 221 assertNotNull(service); 222 223 String response1 = new String ("TestGreetMeResponse"); 224 String response2 = new String ("TestSayHiResponse"); 225 try { 226 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 227 for (int idx = 0; idx < 1; idx++) { 228 String greeting = greeter.greetMe("Milestone-" + idx); 229 assertNotNull("no response received from service", greeting); 230 assertEquals(response1, greeting); 231 232 String reply = greeter.sayHi(); 233 assertNotNull("no response received from service", reply); 234 assertEquals(response2, reply); 235 } 236 } catch (UndeclaredThrowableException ex) { 237 throw (Exception )ex.getCause(); 238 } 239 } 240 241 242 243 public static void main(String [] args) { 244 junit.textui.TestRunner.run(ProviderClientServerTest.class); 245 } 246 } 247 | Popular Tags |