Package org.jboss.aerogear.simplepush.server

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


        assertThat(store.getPrivateKeySalt(), equalTo(salt));
    }

    @Test
    public void saveChannel() {
        final Channel channel = newChannel2();
        assertThat(newRedisDataStore().saveChannel(channel), is(true));
    }
View Full Code Here


        assertThat(newRedisDataStore().saveChannel(channel), is(true));
    }

    @Test
    public void saveChannelDuplicate() {
        final Channel channel = newChannel2();
        assertThat(newRedisDataStore().saveChannel(channel), is(true));
        assertThat(newRedisDataStore().saveChannel(channel), is(false));
    }
View Full Code Here

    }

    @Test
    public void getChannel() throws ChannelNotFoundException {
        final RedisDataStore store = newRedisDataStore();
        final Channel channel = newChannel2();
        store.saveChannel(channel);
        final Channel retreived = store.getChannel(channel.getChannelId());
        assertThat(retreived.getChannelId(), equalTo(channel.getChannelId()));
        assertThat(retreived.getEndpointToken(), equalTo(channel.getEndpointToken()));
    }
View Full Code Here

    @Override
    public boolean saveChannel(final Channel ch) {
        checkNotNull(ch, "ch");
        final MutableChannel mutableChannel = new MutableChannel(ch);
        final Channel previous = channels.putIfAbsent(ch.getChannelId(), mutableChannel);
        endpoints.put(ch.getEndpointToken(), mutableChannel);
        return previous == null;
    }
View Full Code Here

    @Test
    public void removeChannels() throws ChannelNotFoundException {
        final RedisDataStore store = newRedisDataStore();
        final String uaid = UUIDUtil.newUAID();
        final Channel ch1 = newChannel2(uaid);
        final Channel ch2 = newChannel2(uaid);
        store.saveChannel(ch1);
        store.saveChannel(ch2);
        store.removeChannels(new HashSet<String>(Arrays.asList(ch1.getChannelId(), ch2.getChannelId())));
        assertThat(store.getChannelIds(uaid).size(), is(0));
    }
View Full Code Here

        return previous == null;
    }

    private boolean removeChannel(final String channelId) {
        checkNotNull(channelId, "channelId");
        final Channel channel = channels.remove(channelId);
        if (channel != null) {
            endpoints.remove(endpoints.get(channel.getEndpointToken()));
        }
        return channel != null;
    }
View Full Code Here

    }

    @Test
    public void updateVersion() throws VersionException, ChannelNotFoundException {
        final RedisDataStore store = newRedisDataStore();
        final Channel channel = newChannel2();
        store.saveChannel(channel);
        final String channelId = store.updateVersion(channel.getEndpointToken(), 2L);
        assertThat(channelId, equalTo(channel.getChannelId()));
    }
View Full Code Here

    }

    @Override
    public Channel getChannel(final String channelId) throws ChannelNotFoundException {
        checkNotNull(channelId, "channelId");
        final Channel channel = channels.get(channelId);
        if (channel == null) {
            throw new ChannelNotFoundException("No Channel for [" + channelId + "] was found", channelId);
        }
        return channel;
    }
View Full Code Here

    @Override
    public String saveUnacknowledged(final String channelId, final long version) throws ChannelNotFoundException {
        checkNotNull(channelId, "channelId");
        checkNotNull(version, "version");
        final Channel channel = channels.get(channelId);
        if (channel == null) {
            throw new ChannelNotFoundException("Could not find channel", channelId);
        }
        final String uaid = channel.getUAID();
        final Set<Ack> newAcks = Collections.newSetFromMap(new ConcurrentHashMap<Ack, Boolean>());
        newAcks.add(new AckImpl(channelId, version));
        while (true) {
            final Set<Ack> currentAcks = unacked.get(uaid);
            if (currentAcks == null) {
View Full Code Here

    }

    @Test (expected = VersionException.class)
    public void updateVersionEqualToCurrentVersion() throws VersionException, ChannelNotFoundException {
        final RedisDataStore store = newRedisDataStore();
        final Channel channel = newChannel2();
        store.saveChannel(channel);
        store.updateVersion(channel.getEndpointToken(), 2L);
        store.updateVersion(channel.getEndpointToken(), 2L);
    }
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.