Search in sources :

Example 1 with ServerTubeAssemblerContext

use of com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext in project metro-jax-ws by eclipse-ee4j.

the class ClientProxyTest method testNullResponseFromTube.

@SuppressWarnings("unchecked")
public void testNullResponseFromTube() throws Exception {
    URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("etc/EchoService.wsdl");
    EchoService srv = new EchoService(wsdlURL, new ComponentFeature(new com.sun.xml.ws.api.Component() {

        public <S> S getSPI(Class<S> spiType) {
            if (TransportTubeFactory.class.equals(spiType))
                return (S) new TransportTubeFactory() {

                    public Tube doCreate(ClientTubeAssemblerContext context) {
                        return new EchoTube();
                    }
                };
            if (TubelineAssemblerFactory.class.equals(spiType))
                return (S) new TubelineAssemblerFactory() {

                    public TubelineAssembler doCreate(BindingID bindingId) {
                        return new TubelineAssembler() {

                            public Tube createClient(ClientTubeAssemblerContext context) {
                                final Tube head = context.createTransportTube();
                                return new EchoTube() {

                                    public NextAction processRequest(Packet request) {
                                        NextAction na = new NextAction();
                                        na.invoke(head, request);
                                        return na;
                                    }

                                    public NextAction processResponse(Packet response) {
                                        NextAction na = new NextAction();
                                        na.returnWith(new Packet());
                                        return na;
                                    }
                                };
                            }

                            public Tube createServer(ServerTubeAssemblerContext context) {
                                return null;
                            }
                        };
                    }
                };
            return null;
        }
    }));
    Echo echo = srv.getEchoPort();
    try {
        int res = echo.add(new NumbersRequest());
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
    try {
        echo.echoString(new Holder(wsdlURL.toString()));
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) ServerTubeAssemblerContext(com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext) NumbersRequest(com.sun.xml.ws.client.test.NumbersRequest) Tube(com.sun.xml.ws.api.pipe.Tube) WebServiceException(jakarta.xml.ws.WebServiceException) Echo(com.sun.xml.ws.client.test.Echo) EchoService(com.sun.xml.ws.client.test.EchoService) Holder(jakarta.xml.ws.Holder) TubelineAssembler(com.sun.xml.ws.api.pipe.TubelineAssembler) BindingID(com.sun.xml.ws.api.BindingID) URL(java.net.URL) WebServiceException(jakarta.xml.ws.WebServiceException) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) TubelineAssemblerFactory(com.sun.xml.ws.api.pipe.TubelineAssemblerFactory) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) NextAction(com.sun.xml.ws.api.pipe.NextAction) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Aggregations

BindingID (com.sun.xml.ws.api.BindingID)1 ComponentFeature (com.sun.xml.ws.api.ComponentFeature)1 Packet (com.sun.xml.ws.api.message.Packet)1 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)1 NextAction (com.sun.xml.ws.api.pipe.NextAction)1 ServerTubeAssemblerContext (com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext)1 TransportTubeFactory (com.sun.xml.ws.api.pipe.TransportTubeFactory)1 Tube (com.sun.xml.ws.api.pipe.Tube)1 TubelineAssembler (com.sun.xml.ws.api.pipe.TubelineAssembler)1 TubelineAssemblerFactory (com.sun.xml.ws.api.pipe.TubelineAssemblerFactory)1 Echo (com.sun.xml.ws.client.test.Echo)1 EchoService (com.sun.xml.ws.client.test.EchoService)1 NumbersRequest (com.sun.xml.ws.client.test.NumbersRequest)1 Holder (jakarta.xml.ws.Holder)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 URL (java.net.URL)1