use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.
the class DispatchHello method kkktestHelloRequestResponseJAXBandSource.
/* public void testStubPropertySoapUseActionNegative() {
try {
Hello stub = getDynamicStubDynamicServer();
// get stub
Boolean prop = (Boolean)((BindingProvider) stub).getRequestContext().get(BindingProvider.SOAPACTION_USE_PROPERTY);
((BindingProvider) stub).getRequestContext().get(BindingProvider.SOAPACTION_URI_PROPERTY);
} catch (Exception ex) {
if (ex instanceof WebServiceException) {
System.out.println("Property test passes");
}
}
}
*/
public void kkktestHelloRequestResponseJAXBandSource() throws Exception {
// test for bug 6194159
JAXBContext jc = null;
HelloResponse helloResult = null;
Hello_Type hello = new Hello_Type();
jc = createJAXBContext();
try {
hello.setArgument("foo");
hello.setExtra("Test ");
Dispatch dispatch = getDispatchJAXB();
Dispatch dispatch2 = getDispatchSource();
dispatch.getRequestContext().put("com.sun.xml.pw.testprop", "test");
Response response = dispatch.invokeAsync(hello);
if (!response.isDone()) {
dispatch2.invokeAsync(makeStreamSource(helloMsg));
}
Object result = response.get();
assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
} catch (Exception jex) {
fail("Expected HelloResponse go Exception");
}
}
use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.
the class Hello1CallbackHandler method testHelloAsyncCallback0Handler.
/*
* Adds handler to increment value of request and response.
*/
public void testHelloAsyncCallback0Handler() throws Exception {
try {
// should be no handlers, but to be safe
ClientServerTestUtil.clearHandlers((BindingProvider) stub);
// test with no handler first
int orig = 1;
final IntHolder intHolder = new IntHolder();
Future<?> response = stub.hello0Async(orig, new AsyncHandler<Integer>() {
public void handleResponse(Response<Integer> resp) {
try {
// add 10 to make sure this was called
intHolder.setValue(resp.get().intValue() + 10);
} catch (Exception e) {
e.printStackTrace();
// will cause failure
intHolder.setValue(-100);
}
}
});
// wait, but only up to 15 seconds. if it takes more,
// it's considered a hangup
response.get(15, TimeUnit.SECONDS);
assertEquals("did not get expected value back in response", orig + 10, intHolder.getValue());
// add handler
ClientServerTestUtil.addHandlerToBinding(new SOAPTestHandler(), (BindingProvider) stub);
// 1 per handler invocation
int diff = 2;
response = stub.hello0Async(orig, new AsyncHandler<Integer>() {
public void handleResponse(Response<Integer> resp) {
try {
intHolder.setValue(resp.get().intValue());
} catch (Exception e) {
e.printStackTrace();
// will cause failure
intHolder.setValue(-100);
}
}
});
response.get(15, TimeUnit.SECONDS);
assertEquals("handlers did not execute successfully", orig + diff, intHolder.getValue());
} finally {
ClientServerTestUtil.clearHandlers((BindingProvider) stub);
}
}
use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.
the class DispatchHelloLiteralTest method testHelloAsyncPollXMLMulti.
public void testHelloAsyncPollXMLMulti() throws Exception {
Dispatch dispatch = getDispatchSource();
int i = 0;
while (i < 20) {
Collection<Source> sourceList = makeMsgSource(helloMsg);
Collection<Source> responseList = makeMsgSource(helloResponse);
for (Iterator iter = sourceList.iterator(); iter.hasNext(); ) {
Object sourceObject = iter.next();
Response result = null;
result = dispatch.invokeAsync(sourceObject);
result.get();
}
i++;
}
}
use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.
the class DispatchHelloLiteralTest method FAILSMULTITHREADISSUEtestHelloAsyncPollJAXBSource.
// test for bug
public void FAILSMULTITHREADISSUEtestHelloAsyncPollJAXBSource() throws Exception {
JAXBContext jc = createJAXBContext();
Hello_Type hello = new Hello_Type();
HelloResponse helloResult = new HelloResponse();
hello.setExtra("Test ");
hello.setArgument("Dispatch ");
Dispatch dispatch = getDispatchJAXB();
Dispatch dispatchSrc = getDispatchSource();
StreamSource streamSource = new StreamSource(new StringReader(helloMsg));
Response result = dispatch.invokeAsync(hello);
if (!result.isDone()) {
dispatchSrc.invoke(streamSource);
}
Object obj = result.get();
HelloResponse res = (HelloResponse) obj;
assertEquals(result.isCancelled(), false);
assertEquals(res.getExtra(), hello.getExtra());
assertEquals(res.getArgument(), hello.getArgument());
}
use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.
the class DispatchHelloLiteralTest method testHelloAsyncPollJAXB.
public void testHelloAsyncPollJAXB() throws Exception {
JAXBContext jc = createJAXBContext();
Hello_Type hello = new Hello_Type();
HelloResponse helloResult = new HelloResponse();
hello.setExtra("Test ");
hello.setArgument("Dispatch ");
Dispatch dispatch = getDispatchJAXB();
Response result = dispatch.invokeAsync(hello);
Object obj = result.get();
HelloResponse res = (HelloResponse) obj;
assertEquals(result.isCancelled(), false);
assertEquals(res.getExtra(), hello.getExtra());
assertEquals(res.getArgument(), hello.getArgument());
}
Aggregations