Package org.jboss.aerogear.simplepush.server

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


    }


    @Test (expected = VersionException.class)
    public void updateVersionSameVersion() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString(), 1);
        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 (expected = VersionException.class)
    public void updateVersionLessThanCurrent() throws VersionException, ChannelNotFoundException {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString(), 10);
        jpaDataStore.saveChannel(channel);
        jpaDataStore.getChannel(jpaDataStore.updateVersion(channel.getEndpointToken(), 9));
    }
View Full Code Here

        jpaDataStore.getChannel(jpaDataStore.updateVersion(channel.getEndpointToken(), 9));
    }

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

    }

    @Test
    public void saveUnacknowledgement() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final Channel channel = newChannel(uaid, UUID.randomUUID().toString(), 10L);
        jpaDataStore .saveChannel(channel);
        jpaDataStore.saveUnacknowledged(channel.getChannelId(), 10);
        assertThat(jpaDataStore.getUnacknowledged(uaid).size(), is(1));
    }
View Full Code Here

    }

    @Test
    public void getUnacknowledged() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final Channel channel1 = newChannel(uaid, UUID.randomUUID().toString(), 1);
        final Channel channel2 = newChannel(uaid, UUID.randomUUID().toString(), 2);
        jpaDataStore.saveChannel(channel1);
        jpaDataStore.saveChannel(channel2);
        jpaDataStore.saveUnacknowledged(channel1.getChannelId(), 10);
        jpaDataStore.saveUnacknowledged(channel2.getChannelId(), 10);
        assertThat(jpaDataStore.getUnacknowledged(uaid).size(), is(2));
    }
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(), 2);
        jpaDataStore.saveChannel(channel1);
        jpaDataStore.saveChannel(channel2);
        jpaDataStore.saveUnacknowledged(channel1.getChannelId(), 11);
        jpaDataStore.saveUnacknowledged(channel2.getChannelId(), 3);
        final Set<Ack> storedUpdates = jpaDataStore.getUnacknowledged(uaid);
        assertThat(storedUpdates.size(), is(2));

        jpaDataStore.removeAcknowledged(uaid, acks(new AckImpl(channel1.getChannelId(), 11)));
        assertThat(jpaDataStore.getUnacknowledged(uaid).size(), is(1));
View Full Code Here

    }

    private void removeChannel(final String channelId) {
        final Jedis jedis = jedisPool.getResource();
        try {
            final Channel channel = getChannel(channelId);
            final String endpointToken = channel.getEndpointToken();
            final Transaction tx = jedis.multi();
            tx.del(endpointToken);
            tx.del(chidLookupKey(channelId));
            tx.del(tokenLookupKey(endpointToken));
            tx.srem(uaidLookupKey(channel.getUAID()), channelId);
            tx.exec();
        } catch (final ChannelNotFoundException e) {
            logger.debug("ChannelId [" + channelId + "] was not found");
        } finally {
            jedisPool.returnResource(jedis);
View Full Code Here

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

    @Test
    public void saveChannel() {
        final Channel channel = newChannel(UUIDUtil.newUAID(), UUID.randomUUID().toString());
        final boolean saved = datastore.saveChannel(channel);
        assertThat(saved, is(true));
    }
View Full Code Here

    public void saveChannelWithIdContainingUnderscore() {
        final String uaid = UUIDUtil.newUAID();
        final String channelId = UUID.randomUUID().toString();
        final byte[] keySalt = "some string as a salt".getBytes();
        final String endpointToken = CryptoUtil.endpointToken(uaid, channelId, CryptoUtil.secretKey("testKey", keySalt));
        final Channel channel = new DefaultChannel(uaid, channelId, "_" + endpointToken);
        final boolean saved = datastore.saveChannel(channel);
        assertThat(saved, is(true));
    }
View Full Code Here

    @Test (expected = IllegalStateException.class)
    public void getChannelMultipleResults() throws ChannelNotFoundException {
        final String uaid = UUIDUtil.newUAID();
        final String channelId = UUID.randomUUID().toString();
        final Channel channel1 = newChannel(uaid, channelId);
        datastore.saveChannel(channel1);
        final String uaid2 = UUIDUtil.newUAID();
        final Channel channel2 = newChannel(uaid2, channelId);
        datastore.saveChannel(channel2);
        datastore.getChannel(channelId);
    }
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.