Package org.jboss.aerogear.simplepush.protocol

Examples of org.jboss.aerogear.simplepush.protocol.HelloMessage


            @Override
            public void handle(final Buffer buffer) {
                final MessageType messageType = JsonUtil.parseFrame(buffer.toString());
                switch (messageType.getMessageType()) {
                    case HELLO:
                        HelloMessage handshakeMessage = fromJson(buffer.toString(), HelloMessageImpl.class);
                        if (!writeHandlerMap.containsKey(handshakeMessage.getUAID())) {
                            handshakeMessage = new HelloMessageImpl(UUIDUtil.newUAID());
                        }
                        final HelloResponse helloResponse = simplePushServer.handleHandshake(handshakeMessage);
                        sock.write(new Buffer(toJson(helloResponse)));
                        uaid = helloResponse.getUAID();
View Full Code Here


    @Test
    public void fromJson() {
        final String uaid = UUIDUtil.newUAID();
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"" + uaid + "\", \"channelIDs\": [\"123abc\", \"efg456\"]}";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(equalTo(uaid)));
        assertThat(handshake.getChannelIds(), hasItems("123abc", "efg456"));
    }
View Full Code Here

    }

    @Test
    public void fromJsonWithoutUAID() {
        final String json = "{\"messageType\": \"hello\"}";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(notNullValue()));
        assertThat(handshake.getChannelIds().isEmpty(), is(true));
    }
View Full Code Here

    }

    @Test
    public void fromJsonWithEmptyUAID() {
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"\"}";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(notNullValue()));
        assertThat(handshake.getChannelIds().isEmpty(), is(true));
    }
View Full Code Here

    @Test
    public void fromJsonWithNullChannelIds() {
        final String uaid = UUIDUtil.newUAID();
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"" + uaid + "\"}";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(equalTo(uaid)));
        assertThat(handshake.getChannelIds().isEmpty(), is(true));
    }
View Full Code Here

    @Test
    public void fromJsonWithEmptyChannelIds() {
        final String uaid = UUIDUtil.newUAID();
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"" + uaid + "\", \"channelIDs\": [] }";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(equalTo(uaid)));
        assertThat(handshake.getChannelIds().isEmpty(), is(true));
    }
View Full Code Here

    @Test
    public void fromJsonWithChannelIds() {
        final String uaid = UUIDUtil.newUAID();
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"" + uaid + "\", \"channelIDs\": [\"123\", \"456\"] }";
        final HelloMessage handshake = JsonUtil.fromJson(json, HelloMessageImpl.class);
        assertThat(handshake.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(handshake.getUAID(), is(equalTo(uaid)));
        assertThat(handshake.getChannelIds().isEmpty(), is(false));
        assertThat(handshake.getChannelIds(), hasItems("123", "456"));
    }
View Full Code Here

    @Test
    public void toJson() {
        final String uaid = UUIDUtil.newUAID();
        final HelloMessageImpl handshake = new HelloMessageImpl(uaid, channelIds("123abc", "efg456"));
        final String asJson = JsonUtil.toJson(handshake);
        final HelloMessage parsed = JsonUtil.fromJson(asJson, HelloMessageImpl.class);
        assertThat(parsed.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
        assertThat(parsed.getUAID(), is(equalTo(uaid)));
        assertThat(parsed.getChannelIds(), hasItems("123abc", "efg456"));
    }
View Full Code Here

    @Test
    public void handleHandshakeWithChannels() throws ChannelNotFoundException {
        final String channelId1 = UUID.randomUUID().toString();
        final String channelId2 = UUID.randomUUID().toString();
        final Set<String> channelIds = new HashSet<String>(Arrays.asList(channelId1, channelId2));
        final HelloMessage handshakeImpl = new HelloMessageImpl(UUIDUtil.newUAID(), channelIds);
        final HelloResponse response = server.handleHandshake(handshakeImpl);
        assertThat(response.getUAID(), is(notNullValue()));
        assertThat(server.getChannel(channelId1), is(notNullValue()));
        assertThat(server.getChannel(channelId2), is(notNullValue()));
    }
View Full Code Here

    @Test
    public void handleHandshakeWithEmptyChannels() throws ChannelNotFoundException {
        final Set<String> channelIds = Collections.emptySet();
        final String uaid = UUIDUtil.newUAID();
        final HelloMessage handshakeImpl = new HelloMessageImpl(uaid, channelIds);
        final HelloResponse response = server.handleHandshake(handshakeImpl);
        assertThat(response.getUAID(), is(notNullValue()));
        assertThat(server.hasChannel(uaid, "channel1"), is(false));
    }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.simplepush.protocol.HelloMessage

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.