Package org.jetlang.fibers

Examples of org.jetlang.fibers.FiberStub


    @Test
    public void shouldExecuteCallbackWithMostRecentValue() throws Exception {
        InvokedFrequently subscription = mock(InvokedFrequently.class);

        Protocol<InvokedFrequently> protocol = Protocol.create(InvokedFrequently.class);
        FiberStub fiberStub = new FiberStub();
        protocol.subscribe(fiberStub, subscription);
        protocol.publisher().calledFasterThanCanBeProcessed("one");
        protocol.publisher().calledFasterThanCanBeProcessed("two");
        protocol.publisher().calledFasterThanCanBeProcessed("three");
        protocol.publisher().calledFasterThanCanBeProcessed("four");

        fiberStub.executeAllPending();

        verify(subscription).calledFasterThanCanBeProcessed("four");
        verifyNoMoreInteractions(subscription);
    }
View Full Code Here


    @Rule
    public ExpectedException expectedException = ExpectedException.none();

    @Test
    public void shouldSendAsyncMessage() {
        FiberStub executor = new FiberStub();

        Protocol<Mouse> protocol = Protocol.create(Mouse.class);
        Mouse receiver = mock(Mouse.class);
        protocol.subscribe(executor, receiver);

        protocol.publisher().eatCheese("cheddar");
        verifyZeroInteractions(receiver);
        executor.executeAllPending();
        verify(receiver).eatCheese("cheddar");
    }
View Full Code Here

        verify(receiver).eatCheese("cheddar");
    }

    @Test
    public void shouldSendAsyncMessageWithPrimitive() {
        FiberStub executor = new FiberStub();

        Protocol<Mouse> protocol = Protocol.create(Mouse.class);
        Mouse receiver = mock(Mouse.class);
        protocol.subscribe(executor, receiver);

        protocol.publisher().provokeCats(4);
        verifyZeroInteractions(receiver);
        executor.executeAllPending();
        verify(receiver).provokeCats(4);
    }
View Full Code Here

        verify(receiver).provokeCats(4);
    }

    @Test
    public void shouldSendAsyncMessageWithArrays() {
        FiberStub executor = new FiberStub();

        Protocol<Mouse> protocol = Protocol.create(Mouse.class);
        Mouse receiver = mock(Mouse.class);
        protocol.subscribe(executor, receiver);

        protocol.publisher().shoutWords("hello", "world");
        verifyZeroInteractions(receiver);
        executor.executeAllPending();
        verify(receiver).shoutWords("hello", "world");
    }
View Full Code Here

        verify(receiver).shoutWords("hello", "world");
    }

    @Test
    public void shouldSendAsyncMessageWithPrimitiveArrays() {
        FiberStub executor = new FiberStub();

        Protocol<Mouse> protocol = Protocol.create(Mouse.class);
        Mouse receiver = mock(Mouse.class);
        protocol.subscribe(executor, receiver);

        protocol.publisher().reciteNumbers(2, 4, 6, 8);
        verifyZeroInteractions(receiver);
        executor.executeAllPending();
        verify(receiver).reciteNumbers(2, 4, 6, 8);
    }
View Full Code Here

        verify(receiver).reciteNumbers(2, 4, 6, 8);
    }

    @Test
    public void shouldSendAsyncMessageWithMultipleParameters() {
        FiberStub executor = new FiberStub();

        Protocol<Mouse> protocol = Protocol.create(Mouse.class);
        Mouse receiver = mock(Mouse.class);
        protocol.subscribe(executor, receiver);

        protocol.publisher().provokeCatsWithTaunt(4, "mice are clever");
        verifyZeroInteractions(receiver);
        executor.executeAllPending();
        verify(receiver).provokeCatsWithTaunt(4, "mice are clever");
    }
View Full Code Here

        factory.create();
    }

    @Test
    public void shouldHandleMultipleSubscribers() {
        FiberStub executor = new FiberStub();

        Protocol<Mouse> protocol = Protocol.create(Mouse.class);
        protocol.subscribe(executor, mock(Mouse.class, "one"));
        protocol.subscribe(executor, mock(Mouse.class, "two"));
    }
View Full Code Here

        protocol.subscribe(executor, mock(Mouse.class, "two"));
    }

    @Test
    public void shouldSendAsyncSignal() {
        FiberStub executor = new FiberStub();

        Protocol<Pinger> protocol = Protocol.create(Pinger.class);
        Pinger receiver = mock(Pinger.class);
        protocol.subscribe(executor, receiver);

        protocol.publisher().ping();
        verifyZeroInteractions(receiver);
        executor.executeAllPending();
        verify(receiver).ping();
    }
View Full Code Here

TOP

Related Classes of org.jetlang.fibers.FiberStub

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.