use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class EndToEndErrorTester method testServiceSpecificException1.
/*
* Have the endpoint throw a service specific exception and make
* sure that the client gets it back. Test case for bug 6232002.
*/
public void testServiceSpecificException1() throws Exception {
TestService_Service service = getService();
HandlerTracker tracker = HandlerTracker.getClientInstance();
// get stubs and clear the trackers
TestService testStub = getTestStub(service);
ReportService reportStub = getReportStub(service);
reportStub.clearHandlerTracker();
tracker.clearAll();
try {
testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
fail("did not receive exception (1)");
} catch (MyFaultException mfe) {
// passed
} catch (Exception e) {
fail("did not receive MyFaultException (1), received " + e);
}
// check closed handlers to be sure
List<String> actualClosed = tracker.getClosedHandlers();
int[] closed = { 7, 5, 4, 3, 1, 0 };
assertEquals("Did not get proper number of closed handlers", closed.length, actualClosed.size());
for (int i = 0; i < closed.length; i++) {
assertEquals("did not find expected handler", CLIENT_PREFIX + closed[i], actualClosed.get(i));
}
// remove all client handlers and try again
Binding binding = ((BindingProvider) testStub).getBinding();
binding.setHandlerChain(new ArrayList<Handler>());
tracker.clearAll();
try {
testStub.testInt(SERVER_THROW_MYFAULT_EXCEPTION);
fail("did not receive exception (2)");
} catch (MyFaultException mfe) {
// passed
} catch (Exception e) {
fail("did not receive MyFaultException (2), received " + e);
}
// this just makes sure there really were no handlers
actualClosed = tracker.getClosedHandlers();
assertTrue("should not have been closed handlers", actualClosed.isEmpty());
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class MtomApp method main.
public static void main(String[] args) throws Exception {
Hello port = new HelloService().getHelloPort(new MTOMFeature());
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
testUpload(port);
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class ClientFeatureTest method validateFeatureList.
private void validateFeatureList(Object bindingProvider, String expectedEncoding) throws Exception {
Binding binding = ((BindingProvider) bindingProvider).getBinding();
WSFeatureList list = (((WSBinding) binding).getFeatures());
// System.out.println(list);
SerializationFeature encoding = list.get(SerializationFeature.class);
if (expectedEncoding == null) {
assertNull("There should not be a SerializationFeature", encoding);
} else {
assertEquals("Mismatched encoding in SerializationFeature", expectedEncoding, encoding.getEncoding());
}
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testLogicalSource.
/*
* Test removes the static handler and adds a logical
* handler that uses a Source to change the message.
*/
public void testLogicalSource() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 4;
int y = stub.hello(x);
// x+4 with all handlers
assertEquals(x + diff, y);
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testSOAP12Binding1.
/*
* The normal tests in this file are for soap 1.1. This is a soap 1.2
* test to make sure that the port is created with the proper binding
* so that the proper handlers are called. See bug 6353179.
*
* Not working right now -- can't get endpoint to work.
*/
public void testSOAP12Binding1() throws Exception {
Hello_Service service = createService();
Hello12 stub = create12Stub(service);
// make sure port is working
int x = 1;
// server handler only
int diff = 2;
int y = stub.hello12(x);
assertEquals(x + diff, y);
Binding binding = ((BindingProvider) stub).getBinding();
List<Handler> handlers = binding.getHandlerChain();
assertEquals("should be 1 handler in chain", 1, handlers.size());
Handler handler = handlers.get(0);
assertTrue("handler should be type Port12Handler, not " + handler.getClass().toString(), handler instanceof Port12Handler);
Port12Handler p12h = (Port12Handler) handler;
p12h.resetCalled();
stub.hello12(2);
assertEquals("handler should have been called two times", 2, p12h.getCalled());
}
Aggregations