use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testFaults.
@Test
public void testFaults() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
ExecutorService ex = Executors.newFixedThreadPool(1);
service.setExecutor(ex);
assertNotNull(service);
String noSuchCodeFault = "NoSuchCodeLitFault";
String badRecordFault = "BadRecordLitFault";
Greeter greeter = service.getPort(portName, Greeter.class);
updateGreeterAddress(greeter, PORT);
for (int idx = 0; idx < 2; idx++) {
try {
greeter.testDocLitFault(noSuchCodeFault);
fail("Should have thrown NoSuchCodeLitFault exception");
} catch (NoSuchCodeLitFault nslf) {
assertNotNull(nslf.getFaultInfo());
assertNotNull(nslf.getFaultInfo().getCode());
}
try {
greeter.testDocLitFault(badRecordFault);
fail("Should have thrown BadRecordLitFault exception");
} catch (BadRecordLitFault brlf) {
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> responseContext = bp.getResponseContext();
String contentType = (String) responseContext.get(Message.CONTENT_TYPE);
assertEquals("text/xml; charset=utf-8", contentType.toLowerCase());
Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
assertEquals(500, responseCode.intValue());
assertNotNull(brlf.getFaultInfo());
assertEquals("BadRecordLitFault", brlf.getFaultInfo());
}
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testBasicConnection2.
@Test
public void testBasicConnection2() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
// getPort only passing in SEI
Greeter greeter = service.getPort(Greeter.class);
updateGreeterAddress(greeter, PORT);
String response1 = new String("Hello Milestone-");
String response2 = new String("Bonjour");
try {
for (int idx = 0; idx < 5; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
String exResponse = response1 + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
greeter.greetMeOneWay("Milestone-" + idx);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testTimeoutConfigutation.
@Test
public void testTimeoutConfigutation() throws Exception {
SOAPService service = new SOAPService();
Greeter greeter = service.getPort(portName, Greeter.class);
updateGreeterAddress(greeter, PORT);
((javax.xml.ws.BindingProvider) greeter).getRequestContext().put("javax.xml.ws.client.receiveTimeout", "1");
try {
greeter.greetMe("test");
// remove fail() check to let this test pass in the powerful machine
} catch (Throwable ex) {
Object cause = null;
if (ex.getCause() != null) {
cause = ex.getCause();
}
assertTrue("Timeout cause is expected", cause instanceof java.net.SocketTimeoutException);
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testAsyncPollingCall.
@Test
public void testAsyncPollingCall() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
Greeter greeter = service.getPort(portName, Greeter.class);
updateGreeterAddress(greeter, PORT);
long before = System.currentTimeMillis();
long delay = 3000;
Response<GreetMeLaterResponse> r1 = greeter.greetMeLaterAsync(delay);
Response<GreetMeLaterResponse> r2 = greeter.greetMeLaterAsync(delay);
long after = System.currentTimeMillis();
assertTrue("Duration of calls exceeded " + (2 * delay) + " ms", after - before < (2 * delay));
// first time round, responses should not be available yet
assertFalse("Response already available.", r1.isDone());
assertFalse("Response already available.", r2.isDone());
// after three seconds responses should be available
long waited = 0;
while (waited < (delay + 1000)) {
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
// ignore
}
if (r1.isDone() && r2.isDone()) {
break;
}
waited += 500;
}
assertTrue("Response is not available.", r1.isDone());
assertTrue("Response is not available.", r2.isDone());
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerWebSocketTest method testBasicConnection.
@Test
public void testBasicConnection() throws Exception {
SOAPService service = new SOAPService();
Greeter greeter = service.getPort(portName, Greeter.class);
updateGreeterAddress(greeter, PORT);
try {
String reply = greeter.greetMe("test");
assertNotNull("no response received from service", reply);
assertEquals("Hello test", reply);
reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals("Bonjour", reply);
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> responseContext = bp.getResponseContext();
Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE);
assertEquals(200, responseCode.intValue());
}
Aggregations