Package org.jboss.aerogear.simplepush.server

Examples of org.jboss.aerogear.simplepush.server.Channel


    @Test
    public void getChannel() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final String channelId = UUID.randomUUID().toString();
        final Channel channel = newChannel(uaid, channelId);
        datastore.saveChannel(channel);
        final Channel retreived = datastore.getChannel(channelId);
        assertThat(retreived.getUAID(), is(equalTo(channel.getUAID())));
        assertThat(retreived.getChannelId(), is(equalTo(channel.getChannelId())));
        assertThat(retreived.getEndpointToken(), is(equalTo(channel.getEndpointToken())));
        assertThat(retreived.getVersion(), is(channel.getVersion()));
    }
View Full Code Here


        assertThat(retreived.getVersion(), is(channel.getVersion()));
    }

    @Test (expected = ChannelNotFoundException.class)
    public void removeChannelAndTryToRetreive() throws ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString());
        datastore.saveChannel(channel);
        datastore.removeChannels(new HashSet<String>(Arrays.asList(channel.getChannelId())));
        datastore.getChannel(channel.getChannelId());
    }
View Full Code Here

        assertThat(channelIds.size(), is(2));
    }

    @Test (expected = ChannelNotFoundException.class)
    public void updateVersionNonExistingEndpointToken() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString());
        datastore.updateVersion(channel.getEndpointToken(), 2);
    }
View Full Code Here

        datastore.updateVersion(channel.getEndpointToken(), 2);
    }

    @Test
    public void updateVersion() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString());
        datastore.saveChannel(channel);
        final String channelId = datastore.updateVersion(channel.getEndpointToken(), 2);
        assertThat(channel.getChannelId(), is(equalTo(channelId)));
    }
View Full Code Here

        assertThat(channel.getChannelId(), is(equalTo(channelId)));
    }

    @Test (expected = VersionException.class)
    public void updateVersionEqualToCurrentVersion() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString());
        datastore.saveChannel(channel);
        datastore.updateVersion(channel.getEndpointToken(), 0);
    }
View Full Code Here

        datastore.updateVersion(channel.getEndpointToken(), 0);
    }

    @Test (expected = VersionException.class)
    public void updateVersionLessThanCurrentVersion() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString(), 10);
        datastore.saveChannel(channel);
        datastore.updateVersion(channel.getEndpointToken(), 5);
    }
View Full Code Here

    }

    @Test
    public void saveUnacknowledged() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final Channel channel = newChannel(uaid, UUID.randomUUID().toString(), 10);
        datastore.saveChannel(channel);
        final String savedUaid = datastore.saveUnacknowledged(channel.getChannelId(), channel.getVersion());
        assertThat(savedUaid, is(equalTo(uaid)));
    }
View Full Code Here

    }

    @Test
    public void getUnacknowledged() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final Channel channel = newChannel(uaid, UUID.randomUUID().toString(), 10);
        datastore.saveChannel(channel);
        datastore.saveUnacknowledged(channel.getChannelId(), channel.getVersion());
        final Set<Ack> unacks = datastore.getUnacknowledged(uaid);
        assertThat(unacks, hasItems(ack(channel)));
    }
View Full Code Here

    }

    @Test
    public void removeAcknowledged() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final Channel channel1 = newChannel(uaid, UUID.randomUUID().toString(), 10);
        final Channel channel2 = newChannel(uaid, UUID.randomUUID().toString(), 22);
        datastore.saveChannel(channel1);
        datastore.saveChannel(channel2);
        datastore.saveUnacknowledged(channel1.getChannelId(), channel1.getVersion());
        datastore.saveUnacknowledged(channel2.getChannelId(), channel2.getVersion());
        final Set<Ack> unacks = datastore.removeAcknowledged(uaid, acks(ack(channel1)));
        assertThat(unacks, hasItem(ack(channel2)));
        assertThat(unacks.size(), is(1));
        assertThat(datastore.removeAcknowledged(uaid, unacks).size(), is(0));
    }
View Full Code Here

                @Override
                public void run() {
                    try {
                        startLatch.await();
                        try {
                            final Channel channel = newChannel(uaid, UUID.randomUUID().toString(), 10);
                            datastore.saveChannel(channel);
                            datastore.saveUnacknowledged(channel.getChannelId(), 11);
                            datastore.saveUnacknowledged(channel.getChannelId(), 12);
                            datastore.saveUnacknowledged(channel.getChannelId(), 13);
                            assertThat(datastore.getUnacknowledged(uaid), hasItems(ack(channel.getChannelId(), 13)));
                            assertThat(datastore.removeAcknowledged(uaid, acks(ack(channel.getChannelId(), 13))), not(hasItem(ack(channel.getChannelId(), 13))));
                        } catch (final Exception e) {
                            e.printStackTrace();
                            outcome.compareAndSet(true, false);
                        } finally {
                            endLatch.countDown();
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.simplepush.server.Channel

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.