Package com.netflix.eventbus.impl

Examples of com.netflix.eventbus.impl.EventBusImpl


public class AbstractEventBusBridgeTest {
    private static final Logger LOG = LoggerFactory.getLogger(AbstractEventBusBridgeTest.class);
   
    @Test
    public void testString() throws Exception {
        EventBus eventBus = new EventBusImpl();
       
        DummyEventBusBridge bridge = DummyEventBusBridge.builder()
            .withEventBus(eventBus)
            .withEventType(String.class)
            .withExpectedCount(1)
            .build();
       
        eventBus.publish(new String("Foo"));
        Assert.assertTrue(bridge.await(3,  TimeUnit.SECONDS));       
        Assert.assertEquals(1, bridge.getConsumeCount());
        Assert.assertEquals(0, bridge.getConsumeErrorCount());
    }  
View Full Code Here


        Assert.assertEquals(0, bridge.getConsumeErrorCount());
    }  
   
    @Test
    public void testConsumeErrorStats() throws Exception {
        EventBus eventBus = new EventBusImpl();
       
        final RuntimeException e = new RuntimeException("Suro failed to send the message");
       
        DummyEventBusBridge bridge = DummyEventBusBridge.builder()
            .withEventBus(eventBus)
            .withEventType(String.class)
            .build();

        bridge.setError(e);
        eventBus.publish(new String("Foo"));
       
        TimeUnit.SECONDS.sleep(1);
        Assert.assertEquals(0, bridge.getConsumeCount());
        Assert.assertEquals(1, bridge.getConsumeErrorCount());
        Assert.assertEquals(e, bridge.getLastConsumeException());
View Full Code Here

        Assert.assertEquals(e, bridge.getLastConsumeException());
    }
   
    @Test
    public void testGetStatusAreImmutable() throws Exception {
        EventBus eventBus = new EventBusImpl();
        DummyEventBusBridge bridge = DummyEventBusBridge.builder()
            .withEventBus(eventBus)
            .withEventType(String.class)
            .build();
       
View Full Code Here

        }
    }

    @Test
    public void testPauseAndResume() throws Exception {
        EventBus eventBus = new EventBusImpl();
        DummyEventBusBridge bridge = DummyEventBusBridge.builder()
            .withExpectedCount(2)
            .withEventBus(eventBus)
            .withEventType(String.class)
            .build();
       
        eventBus.publish(new String("Foo"));
        Assert.assertTrue(waitForConsumeCount(bridge, 1, 1, TimeUnit.SECONDS));
       
        bridge.pause();
        eventBus.publish(new String("Foo"));
        Assert.assertFalse(waitForConsumeCount(bridge, 2, 1, TimeUnit.SECONDS));
       
        bridge.resume();
        eventBus.publish(new String("Foo"));
        Assert.assertTrue(waitForConsumeCount(bridge, 2, 1, TimeUnit.SECONDS));
    }
View Full Code Here

import com.netflix.eventbus.spi.EventBus;

public class RxEventBusTest {
    @Test
    public void testStream() throws InterruptedException {
        EventBus eventBus = new EventBusImpl();
        RxEventBus rxEventBus = new RxEventBus(eventBus);
       
        final CountDownLatch completion = new CountDownLatch(1);
        final CountDownLatch counter = new CountDownLatch(10);
       
        Subscription sub = rxEventBus.asObservable(Long.class)
            .doOnCompleted(new Action0() {
                @Override
                public void call() {
                    System.out.println("Done");
                    completion.countDown();
                }
            })
            .subscribe(new Action1<Long>() {
                @Override
                public void call(Long t1) {
                    System.out.println(t1);
                    counter.countDown();
                }
            });
       
        for (long i = 0; i < 10; i++) {
            eventBus.publish(i);
        }
       
        Assert.assertTrue(counter.await(1, TimeUnit.SECONDS));
       
        sub.unsubscribe();
View Full Code Here

TOP

Related Classes of com.netflix.eventbus.impl.EventBusImpl

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.