Package org.objectweb.celtix.transports

Examples of org.objectweb.celtix.transports.ClientTransport


     */
    private void clientResend(ObjectMessageContext context) throws IOException {
        Request request = createClientRequest(context);
        OutputStreamMessageContext outputStreamContext =
            request.process(null, true, true);
        ClientTransport transport = handler.getClientTransport();
        if (transport != null) {
            // decoupled response channel always being used with RM,
            // hence a partial response must be processed
            invokePartial(request, transport, outputStreamContext);
        } else {
View Full Code Here


        clientBinding.createResponseCallback();
        EasyMock.expectLastCall().andReturn(responseCallback);
       
        EasyMock.replay(clientBinding);
       
        ClientTransport ct = factory.createClientTransport(endpointRef, clientBinding);
        assertNotNull("server transport must not be null", ct);
        assertSame("transport must JBIClientTransport", JBIClientTransport.class, ct.getClass());
        EasyMock.verify(clientBinding);
   
    }
View Full Code Here

                                                       portName, address);
        setupCallbackObject(useAutomaticWorkQueue);

        server.activate(callback);

        ClientTransport client = createClientTransport(factory, wsdlUrl, serviceName, portName);
        assertTrue("targetEndpoint address mismatch. Expected : " + address
                   + "  received : " + client.getTargetEndpoint(),
                   address.equals(client.getTargetEndpoint().getAddress().getValue()));

        OutputStreamMessageContext octx = null;
        byte outBytes[] = "Hello World!!!".getBytes();
        InputStreamMessageContext ictx = doClientInvoke(client, octx, outBytes, false);

        byte bytes[] = new byte[10000];
        int len = ictx.getInputStream().read(bytes);
        assertTrue("Did not read anything " + len, len > 0);
        assertEquals(new String(outBytes), new String(bytes, 0, len));

        //long request
        outBytes = new byte[5000];
        for (int x = 0; x < outBytes.length; x++) {
            outBytes[x] = (byte)('a' + (x % 26));
        }

        ictx = doClientInvoke(client, octx, outBytes, false);
        int total = readBytes(bytes, ictx.getInputStream());

        assertTrue("Did not read anything " + total, total > 0);
        assertEquals(new String(outBytes), new String(bytes, 0, total));

        outBytes = "Hello World!!!".getBytes();

        server.deactivate();

        try {
            ictx = doClientInvoke(client, octx, outBytes, true);
            len = ictx.getInputStream().read(bytes);

            if (len != -1) {
                fail("was able to process a message after the servant was deactivated: " + len
                     + " - " + new String(bytes));
            }
        } catch (IOException ex) {
            //ignore - this is what we want
        }

        server.activate(callback);

        outBytes = "New String and must match with response".getBytes();
        ictx = doClientInvoke(client, octx, outBytes, false);
        len = ictx.getInputStream().read(bytes);
        assertTrue("Did not read anything " + len, len > 0);
        assertEquals(new String(outBytes), new String(bytes, 0, len));
        server.shutdown();
        client.shutdown();
    }
View Full Code Here

                                                       portName, address);


        server.activate(callback1);

        ClientTransport client = createClientTransport(factory, wsdlUrl, serviceName, portName);
       
        assertTrue("targetEndpoint address mismatch. Expected : " + address
                   + "  received : " + client.getTargetEndpoint(),
                   address.equals(client.getTargetEndpoint().getAddress().getValue()));
        OutputStreamMessageContext octx =
            client.createOutputStreamContext(new GenericMessageContext());
        client.finalPrepareOutputStreamContext(octx);
        byte outBytes[] = "Hello World!!!".getBytes();
        octx.getOutputStream().write(outBytes);
        client.invokeOneway(octx);
        Thread.sleep(500L);
        assertEquals(new String(outBytes),
                          serverRcvdInOneWayCall.substring(0, outBytes.length));

        server.shutdown();
        client.shutdown();
    }
View Full Code Here

    private ClientTransport createClientTransport(TransportFactory factory, URL wsdlUrl,
                                                  QName serviceName, String portName)
        throws WSDLException, IOException {
        EndpointReferenceType ref = EndpointReferenceUtils
            .getEndpointReference(wsdlUrl, serviceName, portName);
        ClientTransport transport =
            factory.createClientTransport(ref, new TestClientBinding(bus, ref));

        return transport;
    }
View Full Code Here

        ServerTransport server =
            createServerTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, ADDRESS);
        byte[] buffer = new byte[64];
        activateServer(server, false, 200, buffer, true, decoupled);

        ClientTransport client =
            createClientTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, ADDRESS, decoupled);
        byte outBytes[] = "Hello World!!!".getBytes();

        long start = System.currentTimeMillis();
        OutputStreamMessageContext octx = doRequest(client, outBytes, true, decoupled);
        client.invokeOneway(octx);
        long stop = System.currentTimeMillis();

        octx = doRequest(client, outBytes, false, decoupled);
        client.invokeOneway(octx);
        octx = doRequest(client, outBytes, false, decoupled);
        client.invokeOneway(octx);
        long stop2 = System.currentTimeMillis();

        server.deactivate();
        EasyMock.reset(bus);
        checkBusRemovedEvent();
        EasyMock.replay(bus);
        client.shutdown();

        assertTrue("Total one call: " + (stop - start), (stop - start) < 400);
        assertTrue("Total: " + (stop2 - start), (stop2 - start) < 600);
        assertEquals(new String(outBytes), new String(buffer, 0, outBytes.length));
        Thread.sleep(200);
View Full Code Here

        ServerTransport server =
            createServerTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, address);

        activateServer(server, useAutomaticWorkQueue, 0, null, false, decoupled);
        //short request
        ClientTransport client =
            createClientTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, address, decoupled);
        doRequestResponse(client, "Hello World".getBytes(), true, decoupled);

        //long request
        byte outBytes[] = new byte[5000];
        for (int x = 0; x < outBytes.length; x++) {
            outBytes[x] = (byte)('a' + (x % 26));
        }
        client =
            createClientTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, address, decoupled);
        doRequestResponse(client, outBytes, false, decoupled);

        server.deactivate();
        outBytes = "HelloWorld".getBytes();

        try {
            OutputStreamMessageContext octx = client.createOutputStreamContext(new GenericMessageContext());
            client.finalPrepareOutputStreamContext(octx);
            octx.getOutputStream().write(outBytes);
            octx.getOutputStream().close();
            InputStreamMessageContext ictx = client.invoke(octx);
            byte bytes[] = new byte[10000];
            int len = ictx.getInputStream().read(bytes);
            if (len != -1
                && new String(bytes, 0, len).indexOf("HTTP Status 503") == -1
                && new String(bytes, 0, len).indexOf("Error 404") == -1) {
                fail("was able to process a message after the servant was deactivated: " + len
                     + " - " + new String(bytes));
            }
        } catch (IOException ex) {
            //ignore - this is what we want
        }
        activateServer(server, useAutomaticWorkQueue, 0, null, false, decoupled);
        doRequestResponse(client, "Hello World   3".getBytes(), false, decoupled);
        server.deactivate();
        activateServer(server, useAutomaticWorkQueue, 0, null, false, decoupled);
        doRequestResponse(client, "Hello World   4".getBytes(), false, decoupled);
        server.deactivate();
        EasyMock.reset(bus);
        checkBusRemovedEvent();
        EasyMock.replay(bus);
        client.shutdown();
    }
View Full Code Here

        ServerTransport server =
            createServerTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, ADDRESS);
        activateServer(server, false, 400, null, false, decoupled);

        ClientTransport client =
            createClientTransport(WSDL_URL, SERVICE_NAME, PORT_NAME, ADDRESS, decoupled);
        byte outBytes[] = "Hello World!!!".getBytes();

        // wait then read without blocking
        OutputStreamMessageContext octx = doRequest(client, outBytes, true, decoupled);
        Future<InputStreamMessageContext> f = client.invokeAsync(octx, executor);
        assertNotNull(f);
        int i = 0;
        while (i < 10) {
            Thread.sleep(100);
            if (f.isDone()) {
                break;
            }
            i++;
        }
        assertTrue(f.isDone());
        InputStreamMessageContext ictx = f.get();
        doResponse(client, ictx, outBytes, decoupled);

        // blocking read (on new thread)
        octx = doRequest(client, outBytes, false, decoupled);
        f = client.invokeAsync(octx, executor);
        ictx = f.get();
        assertTrue(f.isDone());
        doResponse(client, ictx, outBytes, decoupled);

        // blocking read times out
        boolean timeoutImplemented = false;
        if (timeoutImplemented) {
            octx = doRequest(client, outBytes, false, decoupled);
            f = client.invokeAsync(octx, executor);
            try {
                ictx = f.get(200, TimeUnit.MILLISECONDS);
                fail("Expected TimeoutException not thrown.");
            } catch (TimeoutException ex) {
                // ignore
View Full Code Here

        EasyMock.replay(bc);
        EasyMock.replay(pc);

        EndpointReferenceType ref = EndpointReferenceUtils
            .getEndpointReference(wsdlUrl, serviceName, portName);
        ClientTransport transport = factory.createClientTransport(ref, clientBinding);
        if (decoupled) {
            ((HTTPClientTransport)transport).policy.setDecoupledEndpoint(DECOUPLED_ADDRESS);
        }

        EasyMock.verify(bus);
View Full Code Here

        assert transport != null : "transport is null";
        return clientTransport();
    }

    protected ClientTransport createTransport(EndpointReferenceType ref) throws WSDLException, IOException {
        ClientTransport ret = null;
        try {
            LOG.info("creating client transport for " + ref);

            port = EndpointReferenceUtils.getPort(bus.getWSDLManager(), ref);
            List<?> exts = port.getExtensibilityElements();
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.transports.ClientTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.