Package org.jboss.aerogear.simplepush.server

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


    }

    @Test (expected = VersionException.class)
    public void updateVersionLessThanCurrentVersion() throws VersionException, ChannelNotFoundException {
        final RedisDataStore store = newRedisDataStore();
        final Channel channel = newChannel2();
        store.saveChannel(channel);
        store.updateVersion(channel.getEndpointToken(), 2L);
        store.updateVersion(channel.getEndpointToken(), 1L);
    }
View Full Code Here


    }

    @Test
    public void saveUnacknowledged() {
        final RedisDataStore store = newRedisDataStore();
        final Channel channel = newChannel2();
        store.saveChannel(channel);
        store.saveUnacknowledged(channel.getChannelId(), channel.getVersion());
        final Set<Ack> unacknowledged = store.getUnacknowledged(channel.getUAID());
        assertThat(unacknowledged.size(), is(1));
    }
View Full Code Here

    @Test
    public void removeAcknowledged() {
        final RedisDataStore store = newRedisDataStore();
        final String uaid = UUIDUtil.newUAID();
        final Channel channel1 = newChannel2(uaid);
        final Channel channel2 = newChannel2(uaid);
        store.saveChannel(channel1);
        store.saveChannel(channel2);

        store.saveUnacknowledged(channel1.getChannelId(), channel1.getVersion());
        store.saveUnacknowledged(channel2.getChannelId(), channel2.getVersion());

        final Set<Ack> acks = asSet(new AckImpl(channel1.getChannelId(), channel1.getVersion()));
        final Set<Ack> unacknowledged = store.removeAcknowledged(channel1.getUAID(), acks);
        assertThat(unacknowledged.size(), is(1));
        assertThat(unacknowledged, hasItem(new AckImpl(channel2.getChannelId(), channel2.getVersion())));
    }
View Full Code Here

public class InMemoryDataStoreTest {

    @Test
    public void saveChannel() {
        final InMemoryDataStore store = new InMemoryDataStore();
        final Channel channel = mockChannel(UUIDUtil.newUAID(), "channel-1", 1, "endpointToken");
        final boolean saved = store.saveChannel(channel);
        assertThat(saved, is(true));
    }
View Full Code Here

    @Test
    public void getChannel() throws ChannelNotFoundException {
        final InMemoryDataStore store = new InMemoryDataStore();
        store.saveChannel(mockChannel(UUIDUtil.newUAID(), "channel-1", 1, "endpointToken"));
        final Channel channel = store.getChannel("channel-1");
        assertThat(channel, is(notNullValue()));
        assertThat(channel.getChannelId(), equalTo("channel-1"));
        assertThat(channel.getEndpointToken(), equalTo("endpointToken"));
    }
View Full Code Here

                @Override
                public void run() {
                    try {
                        startLatch.await();
                        try {
                            final Channel channel = newChannel(uaid, UUID.randomUUID().toString(), 10);
                            store.saveChannel(channel);
                            store.saveUnacknowledged(channel.getChannelId(), 11);
                            store.saveUnacknowledged(channel.getChannelId(), 12);
                            store.saveUnacknowledged(channel.getChannelId(), 13);
                            final Set<Ack> acks = store.getUnacknowledged(uaid);
                            assertThat(acks, hasItems(ack(channel.getChannelId(), 13)));
                            assertThat(store.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

        }

    }

    private Channel mockChannel(final String uaid, final String channelId, final long version, final String endpointToken) {
        final Channel channel = mock(Channel.class);
        when(channel.getUAID()).thenReturn(uaid);
        when(channel.getChannelId()).thenReturn(channelId);
        when(channel.getVersion()).thenReturn(version);
        when(channel.getEndpointToken()).thenReturn(endpointToken);
        return channel;
    }
View Full Code Here

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

        assertThat(channelExists(channelId1, jpaDataStore), is(false));
    }

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

        assertThat(updated.getVersion(), is(1L));
    }

    @Test
    public void updateVersionLarger() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString(), 10);
        jpaDataStore.saveChannel(channel);
        final String channelId = jpaDataStore.updateVersion(channel.getEndpointToken(), 121);
        assertThat(channelId, is(equalTo(channel.getChannelId())));
        final Channel updated = jpaDataStore.getChannel(channelId);
        assertThat(updated.getVersion(), is(121L));
    }
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.