Package org.cometd.client

Examples of org.cometd.client.BayeuxClient.waitFor()


        Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
        OortComet oortComet21 = oort2.findComet(oort1.getURL());
        Assert.assertTrue(oortComet21.waitFor(5000, BayeuxClient.State.CONNECTED));

        BayeuxClient client1 = startClient(oort1, null);
        Assert.assertTrue(client1.waitFor(5000, BayeuxClient.State.CONNECTED));
        BayeuxClient client2 = startClient(oort2, null);
        Assert.assertTrue(client2.waitFor(5000, BayeuxClient.State.CONNECTED));

        // Oort1 observes the channel, so any publish to Oort2 is forwarded to Oort1
        String channelName = "/oort_test";
View Full Code Here


        Assert.assertTrue(oortComet21.waitFor(5000, BayeuxClient.State.CONNECTED));

        BayeuxClient client1 = startClient(oort1, null);
        Assert.assertTrue(client1.waitFor(5000, BayeuxClient.State.CONNECTED));
        BayeuxClient client2 = startClient(oort2, null);
        Assert.assertTrue(client2.waitFor(5000, BayeuxClient.State.CONNECTED));

        // Oort1 observes the channel, so any publish to Oort2 is forwarded to Oort1
        String channelName = "/oort_test";
        oort1.observeChannel(channelName);
View Full Code Here

        ServerTransport transport = bayeuxServer.getTransport("websocket");
        Assert.assertNotNull(transport);

        final BayeuxClient client = newBayeuxClient();
        client.handshake();
        Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED));

        // Wait for connect to establish
        Thread.sleep(1000);

        ClientTransport clientTransport = client.getTransport();
View Full Code Here

        // Test that a valid remote client can connect
        Message.Mutable authFields = new HashMapMessage();
        authFields.getExt(true).put(TestSecurityPolicy.TOKEN_FIELD, "something");
        BayeuxClient client1 = startClient(oort1, authFields);
        Assert.assertTrue(client1.waitFor(5000, BayeuxClient.State.CONNECTED));
        // Wait for long poll to be established
        Thread.sleep(1000);
        Assert.assertTrue(client1.disconnect(5000));

        // An invalid client may not connect
View Full Code Here

        Thread.sleep(1000);
        Assert.assertTrue(client1.disconnect(5000));

        // An invalid client may not connect
        BayeuxClient client2 = startClient(oort1, null);
        Assert.assertTrue(client2.waitFor(5000, BayeuxClient.State.DISCONNECTED));

        // A client that forges an Oort comet authentication may not connect
        Message.Mutable forgedAuthFields = new HashMapMessage();
        Map<String, Object> ext = forgedAuthFields.getExt(true);
        Map<String, Object> oortExt = new HashMap<>();
View Full Code Here

        ext.put(Oort.EXT_OORT_FIELD, oortExt);
        oortExt.put(Oort.EXT_OORT_URL_FIELD, oort1.getURL());
        oortExt.put(Oort.EXT_OORT_SECRET_FIELD, "anything");
        oortExt.put(Oort.EXT_COMET_URL_FIELD, oort2.getURL());
        BayeuxClient client3 = startClient(oort1, forgedAuthFields);
        Assert.assertTrue(client3.waitFor(5000, BayeuxClient.State.DISCONNECTED));
    }

    private class TestSecurityPolicy extends DefaultSecurityPolicy
    {
        private static final String TOKEN_FIELD = "token";
View Full Code Here

        Assert.assertEquals(2, oortC.getKnownComets().size());
        Assert.assertTrue(oortC.getKnownComets().contains(oortA.getURL()));
        Assert.assertTrue(oortC.getKnownComets().contains(oortB.getURL()));

        BayeuxClient clientA = startClient(oortA, null);
        Assert.assertTrue(clientA.waitFor(5000, BayeuxClient.State.CONNECTED));
        // Be sure that disconnecting clientA we do not mess with the known comets
        stopClient(clientA);

        Assert.assertEquals(2, oortA.getKnownComets().size());
        Assert.assertEquals(2, oortB.getKnownComets().size());
View Full Code Here

        String channelName = "/foo";
        oortA.observeChannel(channelName);
        oortB.observeChannel(channelName);

        BayeuxClient clientA = startClient(oortA, null);
        Assert.assertTrue(clientA.waitFor(5000, BayeuxClient.State.CONNECTED));
        BayeuxClient clientB = startClient(oortB, null);
        Assert.assertTrue(clientB.waitFor(5000, BayeuxClient.State.CONNECTED));

        final AtomicReference<CountDownLatch> messageLatch = new AtomicReference<>(new CountDownLatch(1));
        clientB.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
View Full Code Here

        oortB.observeChannel(channelName);

        BayeuxClient clientA = startClient(oortA, null);
        Assert.assertTrue(clientA.waitFor(5000, BayeuxClient.State.CONNECTED));
        BayeuxClient clientB = startClient(oortB, null);
        Assert.assertTrue(clientB.waitFor(5000, BayeuxClient.State.CONNECTED));

        final AtomicReference<CountDownLatch> messageLatch = new AtomicReference<>(new CountDownLatch(1));
        clientB.getChannel(channelName).subscribe(new ClientSessionChannel.MessageListener()
        {
            public void onMessage(ClientSessionChannel channel, Message message)
View Full Code Here

                });
                client.getChannel(channelName).publish("hello");
            }
        });

        Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED));

        Assert.assertEquals(channelName, messages.poll(1, TimeUnit.SECONDS));
        Assert.assertEquals("hello", messages.poll(1, TimeUnit.SECONDS));

        disconnectBayeuxClient(client);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.