Package org.cometd.common

Examples of org.cometd.common.HashMapMessage


        bayeux.setSecurityPolicy(authenticator);
        BayeuxClient client = newBayeuxClient();

        Map<String, Object> authentication = new HashMap<>();
        authentication.put("token", "1234567890");
        Message.Mutable fields = new HashMapMessage();
        fields.getExt(true).put("authentication", authentication);
        client.handshake(fields);

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

        Assert.assertEquals(client.getId(), sessionId.get());
View Full Code Here


        if (_logger.isDebugEnabled())
            _logger.debug("Connecting to comet {}", cometURL);

        String b64Secret = encodeSecret(getSecret());
        Message.Mutable fields = new HashMapMessage();
        Map<String, Object> ext = fields.getExt(true);
        Map<String, Object> oortExt = new HashMap<>(4);
        ext.put(EXT_OORT_FIELD, oortExt);
        oortExt.put(EXT_OORT_URL_FIELD, getURL());
        oortExt.put(EXT_OORT_ID_FIELD, getId());
        oortExt.put(EXT_OORT_SECRET_FIELD, b64Secret);
View Full Code Here

        // do local delivery
        if (_localSession != null && hasNonLazyMessages())
        {
            for (ServerMessage msg : takeQueue())
                _localSession.receive(new HashMapMessage(msg));
        }
    }
View Full Code Here

        {
            BayeuxClient client = newBayeuxClient();

            Map<String, Object> authentication = new HashMap<>();
            authentication.put("token", "1234567890");
            Message.Mutable fields = new HashMapMessage();
            fields.getExt(true).put("authentication", authentication);
            client.handshake(fields);

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

            Assert.assertEquals(client.getId(), sessionId.get());
View Full Code Here

        LatchListener messageLatch3 = new LatchListener(1);
        client3.getChannel(channelName).subscribe(messageLatch3);
        Assert.assertTrue(subscribeLatch3.await(5, TimeUnit.SECONDS));

        // Sending a message to Oort2, must be received by client1 but not by client3
        client2.getChannel(channelName).publish(new HashMapMessage());
        Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));
        Assert.assertFalse(messageLatch3.await(1, TimeUnit.SECONDS));

        // Sending a message to Oort3, must be received by client1 and by client3
        messageLatch1.reset(1);
        client3.getChannel(channelName).publish(new HashMapMessage());
        Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));
        Assert.assertTrue(messageLatch3.await(5, TimeUnit.SECONDS));
    }
View Full Code Here

        LatchListener messageLatch1 = new LatchListener(1);
        client1.getChannel(channelName).subscribe(messageLatch1);
        Assert.assertTrue(subscribeLatch1.await(5, TimeUnit.SECONDS));

        // Sending a message to Oort2, must be received by client1
        client2.getChannel(channelName).publish(new HashMapMessage());
        Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));

        // Be sure it's been received once only
        Thread.sleep(1000);
        Assert.assertEquals(1, messageLatch1.count());
View Full Code Here

        LatchListener messageLatch1 = new LatchListener(1);
        client1.getChannel(channelName).subscribe(messageLatch1);
        Assert.assertTrue(subscribeLatch1.await(5, TimeUnit.SECONDS));

        // Sending a message to Oort2, must be received by client1
        client2.getChannel(channelName).publish(new HashMapMessage());
        Assert.assertTrue(messageLatch1.await(5, TimeUnit.SECONDS));

        // Deobserve the channel
        oort1.deobserveChannel(channelName);

        // Wait a while to be sure to be unsubscribed
        Thread.sleep(1000);

        // Resend, the message must not be received
        messageLatch1.reset(1);
        client2.getChannel(channelName).publish(new HashMapMessage());
        Assert.assertFalse(messageLatch1.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

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

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

        return Collections.unmodifiableMap(options);
    }

    protected Message.Mutable newMessage()
    {
        return new HashMapMessage();
    }
View Full Code Here

                transport.setURL(serverURL);
                transport.setCookieStore(new HttpCookieStore());
                transport.init();

                List<Message.Mutable> messages = new ArrayList<>(1);
                messages.add(new HashMapMessage());
                long start = System.nanoTime();
                transport.send(new TransportListener.Empty()
                {
                    @Override
                    public void onMessages(List<Message.Mutable> messages)
View Full Code Here

TOP

Related Classes of org.cometd.common.HashMapMessage

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.