Package org.objectweb.celtix.transports

Examples of org.objectweb.celtix.transports.ServerTransport


     * Server-side resend.
     *
     * @param context the message context
     */
    private void serverResend(ObjectMessageContext context) throws IOException {
        ServerTransport transport = handler.getServerTransport();
        if (transport != null) {
            ServerRequest serverRequest = createServerRequest(context);
            serverRequest.processOutbound(transport, null, true);
        } else {
            LOG.log(Level.WARNING, "NO_TRANSPORT_FOR_RESEND_MSG");
View Full Code Here


   
   
    public void testCreateServerTransport() throws Exception {

        factory.setCurrentContainer(container);
        ServerTransport st = factory.createServerTransport(addr);
        assertNotNull("factory must not return null transport", st);
        assertTrue("factory must return GeronimoServerTransport", st instanceof GeronimoServerTransport);
        assertSame("CeltixWebServiceContainer must contain server transport", st,
                   container.getServerTransport());
    }
View Full Code Here

    }

 
    public void testCreateServerTransport() throws Exception {
       
        ServerTransport st = factory.createServerTransport(endpointRef);
        assertNotNull("server transport must not be null", st);
        assertSame("transport must JBIServerTransport", JBIServerTransport.class, st.getClass());
    }
View Full Code Here

        assertNotNull(sb);
        assertTrue(sb instanceof TestServerBinding);
        Binding b = sb.getBinding();
        assertNotNull(b);
        TestServerBinding tsb = (TestServerBinding)sb;
        ServerTransport st = tsb.getTransport();
        assertNull(st);
        EndpointReferenceType ref = ei.getEndpointReferenceType();
        assertNull(ref.getAddress());

    }
View Full Code Here

        }
        EndpointReferenceType ref = ei.getEndpointReferenceType();
        EndpointReferenceUtils.setAddress(ref, "test://localhost:7777/test");
        sb.activate();
        TestServerBinding tsb = (TestServerBinding)sb;
        ServerTransport st = tsb.getTransport();
        assertNotNull(st);

    }
View Full Code Here

        assertNotNull(wsdlUrl);

        createConfiguration(wsdlUrl, serviceName, portName);
        TransportFactory factory = createTransportFactory();

        ServerTransport server = createServerTransport(factory, wsdlUrl, serviceName,
                                                       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

        createConfiguration(wsdlUrl, serviceName, portName);
        TransportFactory factory = createTransportFactory();
        setupOneWayCallbackObject(useAutomaticWorkQueue);

        ServerTransport server = createServerTransport(factory, wsdlUrl, serviceName,
                                                       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

    public void doTestInvokeOneway(boolean decoupled) throws Exception {

        factory = createTransportFactory();

        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();
View Full Code Here

                             final boolean decoupled,
                             final String address) throws Exception {

        factory = createTransportFactory();

        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

            executorService = Executors.newFixedThreadPool(1);
            executor = executorService;
        }
        factory = createTransportFactory();

        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
            }
            assertTrue(!f.isDone());
        }
        server.deactivate();
    }
View Full Code Here

TOP

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

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.