Package co.paralleluniverse.galaxy.core.Message

Examples of co.paralleluniverse.galaxy.core.Message.LineMessage


     */
    @Test
    public void whenGETReservedAndNoOwnerThenCreateAndReplyPUTX() throws Exception {
        when(store.casOwner(15, sh(-1), sh(10))).thenReturn(sh(10));

        final LineMessage get = Message.GET(sh(10), 15);
        mm.receive(get);

        verify(store).casOwner(15, sh(-1), sh(10));
        verify(store).write(15, sh(10), 1, new byte[0], null);
        verify(comm).send(argThat(equalTo(Message.PUTX(get, 15, new short[0], 0, 1, null))));
View Full Code Here


    }

    @Test
    public void testPUTSer() {
        final long line = rand.nextLong();
        final LineMessage m = new LineMessage((short) rand.nextInt(), Message.Type.GET, line);
        testSerialize(Message.PUT(m, line, rand.nextLong(), randomBuffer(150)));

        testSerialize(Message.PUT((short) rand.nextInt(), rand.nextLong(), rand.nextLong(), randomBuffer(100)));

        testSerialize(Message.PUT(randomShortArray(4), rand.nextLong(), rand.nextLong(), randomBuffer(100)));
View Full Code Here

    }

    @Test
    public void testPUTXSer() {
        final long line = rand.nextLong();
        final LineMessage m = new LineMessage((short) rand.nextInt(), Message.Type.GET, line);
        testSerialize(Message.PUTX(m, line, randomShortArray(5), rand.nextInt(1000), rand.nextLong(), randomBuffer(100)));
    }
View Full Code Here

    }

    @Test
    public void testCHNGD_OWNRSer() {
        final long line = rand.nextLong();
        final LineMessage m = new LineMessage((short) rand.nextInt(), Message.Type.GET, line);
        testSerialize(Message.CHNGD_OWNR(m, line, (short) rand.nextInt(), rand.nextBoolean()));

        testSerialize(Message.CHNGD_OWNR((short) rand.nextInt(), rand.nextLong(), (short) rand.nextInt(), rand.nextBoolean()));
    }
View Full Code Here

        testSerialize(Message.CHNGD_OWNR((short) rand.nextInt(), rand.nextLong(), (short) rand.nextInt(), rand.nextBoolean()));
    }

    @Test
    public void testNOT_FOUNDSer() {
        final LineMessage m = new LineMessage((short) rand.nextInt(), Message.Type.GET, rand.nextLong());
        testSerialize(Message.NOT_FOUND(m));
    }
View Full Code Here

        verify(channel, atLeast(3)).write(argThat(equalTo(packet(m))), eq(node2Address));
    }

    @Test
    public void whenNoResponseThenTimeout() throws Exception {
        final LineMessage m = Message.GET(sh(2), id(1234L));
        comm.send(m);
        sleep(400);
        await();
        verify(receiver).receive(argThat(equalTo(Message.TIMEOUT(m))));
    }
View Full Code Here

        verify(receiver).receive(argThat(equalTo(Message.TIMEOUT(m))));
    }

    @Test
    public void whenNoResponseForINVThenNoTimeout() throws Exception {
        final LineMessage m = Message.INV(sh(2), id(1234L), sh(10));
        comm.send(m);
        sleep(400);
        await();
        verify(receiver, never()).receive(argThat(equalTo(Message.TIMEOUT(m))));
    }
View Full Code Here

        verify(receiver, never()).receive(argThat(equalTo(Message.TIMEOUT(m))));
    }

    @Test
    public void whenReceiveResponseThenStopResendingAndNoTimeout() throws Exception {
        final LineMessage m = Message.INV(sh(2), id(1234L), sh(10));

        comm.send(m);
        sleep(200);
        comm.messageReceived(packet(Message.INVACK(m).setIncoming()));
        verify(channel, atLeast(3)).write(argThat(equalTo(packet(m))), eq(node2Address));
View Full Code Here

        verify(channel, times(1)).write(argThat(is(packetThatContains(m))), eq(node2Address));
    }

    @Test
    public void whenRequestAgainAndHasResponseThenResendResponse() throws Exception {
        final LineMessage m = Message.INV(sh(2), id(1234L), sh(10)).setMessageId(10001).setIncoming();
        comm.messageReceived(packet(m));
        comm.send(Message.INVACK(m));
        sleep(100);

        verify(channel, times(1)).write(argThat(is(packetThatContains(Message.INVACK(m)))), eq(node2Address));
View Full Code Here

        verify(channel, times(2)).write(argThat(is(packetThatContains(Message.INVACK(m)))), eq(node2Address));
    }

    @Test
    public void testSimpleBroadcast() throws Exception {
        final LineMessage m = Message.GET(sh(-1), id(1234L));
        comm.send(m);

        await();
        verify(channel, atLeastOnce()).write(argThat(is(packetThatContains(m))), eq(GROUP));
    }
View Full Code Here

TOP

Related Classes of co.paralleluniverse.galaxy.core.Message.LineMessage

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.