use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class JSClientServerTest method testJSMessageMode.
@Test
public void testJSMessageMode() throws Exception {
QName serviceName = new QName(NS, "SOAPService");
QName portName = new QName(NS, "SoapPort");
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
String response1 = new String("TestGreetMeResponse");
String response2 = new String("TestSayHiResponse");
try {
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, JS_PORT);
String greeting = greeter.greetMe("TestGreetMeRequest");
assertNotNull("no response received from service", greeting);
assertEquals(response1, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
} catch (UndeclaredThrowableException ex) {
ex.printStackTrace();
throw (Exception) ex.getCause();
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerTest method testFaultStackTrace.
@Test
public void testFaultStackTrace() throws Exception {
System.setProperty("cxf.config.file.url", getClass().getResource("fault-stack-trace.xml").toString());
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);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
try {
// trigger runtime exception throw of implementor method
greeter.testDocLitFault("");
fail("Should have thrown Runtime exception");
} catch (WebServiceException e) {
assertEquals("can't get back original message", "Unknown source", e.getCause().getMessage());
assertTrue(e.getCause().getStackTrace().length > 0);
}
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerTest method testAsyncDiscardProxy.
@Test
public void testAsyncDiscardProxy() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
assertNotNull(service);
updateAddressPort(greeter, PORT);
Response<GreetMeLaterResponse> r1 = greeter.greetMeLaterAsync(3000);
greeter = null;
service = null;
System.gc();
System.gc();
System.gc();
assertEquals("Hello, finally!", r1.get().getResponseType());
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerTest method testAsyncCallUseProperAssignedExecutor.
@Test
public void testAsyncCallUseProperAssignedExecutor() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
class TestExecutor implements Executor {
private AtomicInteger count = new AtomicInteger();
public void execute(Runnable command) {
int c = count.incrementAndGet();
LOG.info("asyn call time " + c);
command.run();
}
public int getCount() {
return count.get();
}
}
Executor executor = new TestExecutor();
service.setExecutor(executor);
assertNotNull(service);
assertSame(executor, service.getExecutor());
assertEquals(((TestExecutor) executor).getCount(), 0);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
List<Response<GreetMeResponse>> responses = new ArrayList<>();
for (int i = 0; i < 5; i++) {
responses.add(greeter.greetMeAsync("asyn call" + i));
}
// wait for all the responses
for (Response<GreetMeResponse> resp : responses) {
resp.get();
}
assertEquals(5, ((TestExecutor) executor).getCount());
}
use of org.apache.hello_world_soap_http.SOAPService in project cxf by apache.
the class ClientServerTest method testTimeoutConfigutation.
@Test
public void testTimeoutConfigutation() throws Exception {
SOAPService service = new SOAPService();
assertNotNull(service);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(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);
}
}
Aggregations