Examples of EventBusImpl


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

Examples of com.netflix.eventbus.impl.EventBusImpl

        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

Examples of com.netflix.eventbus.impl.EventBusImpl

        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

Examples of com.netflix.eventbus.impl.EventBusImpl

        }
    }

    @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

Examples of com.netflix.eventbus.impl.EventBusImpl

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

Examples of io.vertx.core.eventbus.impl.EventBusImpl

                int serverPort = publicPort == -1 ? server.actualPort() : publicPort;
                String serverHost = publicHost == null ? options.getClusterHost() : publicHost;
                ServerID serverID = new ServerID(serverPort, serverHost);
                // Provide a memory barrier as we are setting from a different thread
                synchronized (VertxImpl.this) {
                  eventBus = new EventBusImpl(this, options.getClusterPingInterval(), options.getClusterPingReplyInterval(),
                    clusterManager, subs, serverID, ebServer);
                }
                if (resultHandler != null) {
                  resultHandler.handle(Future.completedFuture(this));
                }
              } else {
                if (resultHandler != null) {
                  resultHandler.handle(Future.completedFuture(ar.cause()));
                } else {
                  log.error(ar.cause());
                }
             }
            });
          } else {
            if (resultHandler != null) {
              resultHandler.handle(Future.completedFuture(ar.cause()));
            } else {
              log.error(ar.cause());
            }
          }
        });
      });
      this.sharedData = new SharedDataImpl(this, clusterManager);
    } else {
      this.clusterManager = null;
      this.sharedData = new SharedDataImpl(this, null);
      this.eventBus = new EventBusImpl(this);
      if (resultHandler != null) {
        resultHandler.handle(Future.completedFuture(this));
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.