Search in sources :

Example 1 with NumbersRequest

use of com.sun.xml.ws.client.test.NumbersRequest 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)

Example 2 with NumbersRequest

use of com.sun.xml.ws.client.test.NumbersRequest in project metro-jax-ws by eclipse-ee4j.

the class ClientProxyTest method testNullResponseFromTransprt.

@SuppressWarnings("unchecked")
public void testNullResponseFromTransprt() 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() {

                            public NextAction processRequest(Packet request) {
                                NextAction na = new NextAction();
                                na.returnWith(new Packet());
                                return na;
                            }
                        };
                    }
                };
            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<String>(wsdlURL.toString()));
        fail();
    } catch (Exception e) {
        assertFalse(e instanceof NullPointerException);
        assertTrue(e instanceof WebServiceException);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) NumbersRequest(com.sun.xml.ws.client.test.NumbersRequest) WebServiceException(jakarta.xml.ws.WebServiceException) Echo(com.sun.xml.ws.client.test.Echo) EchoService(com.sun.xml.ws.client.test.EchoService) URL(java.net.URL) WebServiceException(jakarta.xml.ws.WebServiceException) TransportTubeFactory(com.sun.xml.ws.api.pipe.TransportTubeFactory) ComponentFeature(com.sun.xml.ws.api.ComponentFeature) NextAction(com.sun.xml.ws.api.pipe.NextAction) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)

Aggregations

ComponentFeature (com.sun.xml.ws.api.ComponentFeature)2 Packet (com.sun.xml.ws.api.message.Packet)2 ClientTubeAssemblerContext (com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext)2 NextAction (com.sun.xml.ws.api.pipe.NextAction)2 TransportTubeFactory (com.sun.xml.ws.api.pipe.TransportTubeFactory)2 Echo (com.sun.xml.ws.client.test.Echo)2 EchoService (com.sun.xml.ws.client.test.EchoService)2 NumbersRequest (com.sun.xml.ws.client.test.NumbersRequest)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 URL (java.net.URL)2 BindingID (com.sun.xml.ws.api.BindingID)1 ServerTubeAssemblerContext (com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext)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 Holder (jakarta.xml.ws.Holder)1