com.google.common.eventbus.EventBus Java Examples

The following examples show how to use com.google.common.eventbus.EventBus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OriginsInventoryHandlerTest.java    From styx with Apache License 2.0 6 votes vote down vote up
@Test
public void prettyPrintsOriginsSnapshot() {
    EventBus eventBus = new EventBus();
    OriginsInventoryHandler handler = new OriginsInventoryHandler(eventBus);

    Set<Origin> disabledOrigins = generateOrigins(2);

    eventBus.post(new OriginsSnapshot(APP_ID, pool(emptySet()), pool(emptySet()), pool(disabledOrigins)));

    HttpResponse response = Mono.from(handler.handle(get("/?pretty=1").build(), requestContext())).block();
    assertThat(body(response).replace("\r\n", "\n"),
            matchesRegex("\\{\n" +
                    "  \"" + APP_ID + "\" : \\{\n" +
                    "    \"appId\" : \"" + APP_ID + "\",\n" +
                    "    \"activeOrigins\" : \\[ ],\n" +
                    "    \"inactiveOrigins\" : \\[ ],\n" +
                    "    \"disabledOrigins\" : \\[ \\{\n" +
                    "      \"id\" : \"origin.\",\n" +
                    "      \"host\" : \"localhost:....\"\n" +
                    "    }, \\{\n" +
                    "      \"id\" : \"origin.\",\n" +
                    "      \"host\" : \"localhost:....\"\n" +
                    "    } ]\n" +
                    "  }\n" +
                    "}"));
}
 
Example #2
Source File: UI.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initPreApplicationState() {
    logger.info(Version.getCurrentVersion().toString());
    UI.events = this;

    Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) ->
            logger.error(throwable.getMessage(), throwable));

    TestController.setUI(this, getParameters());
    prefs = TestController.loadApplicationPreferences();

    eventBus = new EventBus();
    if (TestController.isTestMode()) {
        registerTestEvents();
    }
    registerEvent((UnusedStoredReposChangedEventHandler) e -> onRepoOpened());
    registerEvent((UsedReposChangedEventHandler) e -> removeUnusedModelsAndUpdate());

    uiManager = new UIManager(this);
    status = new HTStatusBar(this);

    updateManager = TestController.createUpdateManager();
    updateManager.run();
}
 
Example #3
Source File: OriginsInventoryHandlerTest.java    From styx with Apache License 2.0 6 votes vote down vote up
@Test
public void respondsWithCorrectSnapshot() throws IOException {
    EventBus eventBus = new EventBus();
    OriginsInventoryHandler handler = new OriginsInventoryHandler(eventBus);

    Set<Origin> activeOrigins = generateOrigins(3);
    Set<Origin> inactiveOrigins = generateOrigins(4);
    Set<Origin> disabledOrigins = generateOrigins(2);

    eventBus.post(new OriginsSnapshot(APP_ID, pool(activeOrigins), pool(inactiveOrigins), pool(disabledOrigins)));

    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    assertThat(response.bodyAs(UTF_8).split("\n").length, is(1));

    Map<Id, OriginsSnapshot> output = deserialiseJson(response.bodyAs(UTF_8));

    assertThat(output.keySet(), contains(APP_ID));

    OriginsSnapshot snapshot = output.get(APP_ID);

    assertThat(snapshot.appId(), is(APP_ID));
    assertThat(snapshot.activeOrigins(), is(activeOrigins));
    assertThat(snapshot.inactiveOrigins(), is(inactiveOrigins));
    assertThat(snapshot.disabledOrigins(), is(disabledOrigins));
}
 
Example #4
Source File: ScheduledJobConfigurationManager.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
public ScheduledJobConfigurationManager(EventBus eventBus, Config config) {
  super(eventBus, config);

  this.jobSpecs = Maps.newHashMap();
  this.refreshIntervalInSeconds = ConfigUtils.getLong(config, GobblinClusterConfigurationKeys.JOB_SPEC_REFRESH_INTERVAL,
      DEFAULT_JOB_SPEC_REFRESH_INTERVAL);

  this.fetchJobSpecExecutor = Executors.newSingleThreadScheduledExecutor(
      ExecutorsUtils.newThreadFactory(Optional.of(LOGGER), Optional.of("FetchJobSpecExecutor")));

  this.aliasResolver = new ClassAliasResolver<>(SpecConsumer.class);
  try {
    String specConsumerClassName = GobblinClusterConfigurationKeys.DEFAULT_SPEC_CONSUMER_CLASS;
    if (config.hasPath(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY)) {
      specConsumerClassName = config.getString(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY);
    }
    LOGGER.info("Using SpecConsumer ClassNameclass name/alias " + specConsumerClassName);
    this._specConsumer = (SpecConsumer) ConstructorUtils
        .invokeConstructor(Class.forName(this.aliasResolver.resolve(specConsumerClassName)), config);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
Example #5
Source File: ValidatorApiHandler.java    From teku with Apache License 2.0 6 votes vote down vote up
public ValidatorApiHandler(
    final CombinedChainDataClient combinedChainDataClient,
    final SyncStateTracker syncStateTracker,
    final StateTransition stateTransition,
    final BlockFactory blockFactory,
    final AggregatingAttestationPool attestationPool,
    final AttestationManager attestationManager,
    final AttestationTopicSubscriber attestationTopicSubscriber,
    final EventBus eventBus) {
  this.combinedChainDataClient = combinedChainDataClient;
  this.syncStateTracker = syncStateTracker;
  this.stateTransition = stateTransition;
  this.blockFactory = blockFactory;
  this.attestationPool = attestationPool;
  this.attestationManager = attestationManager;
  this.attestationTopicSubscriber = attestationTopicSubscriber;
  this.eventBus = eventBus;
}
 
Example #6
Source File: BeaconBlocksByRootIntegrationTest.java    From teku with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void setUp() throws Exception {
  final EventBus eventBus1 = new EventBus();
  final RpcEncoding rpcEncoding = getEncoding();

  storageClient1 = MemoryOnlyRecentChainData.create(eventBus1);
  BeaconChainUtil.create(0, storageClient1).initializeStorage();
  final Eth2Network network1 =
      networkFactory
          .builder()
          .rpcEncoding(rpcEncoding)
          .eventBus(eventBus1)
          .recentChainData(storageClient1)
          .startNetwork();
  final Eth2Network network2 =
      networkFactory.builder().rpcEncoding(rpcEncoding).peer(network1).startNetwork();
  peer1 = network2.getPeer(network1.getNodeId()).orElseThrow();
}
 
Example #7
Source File: MediaMappingChangeEventHandler.java    From DataLink with Apache License 2.0 6 votes vote down vote up
public MediaMappingChangeEventHandler() {
    EventBus eventBus = EventBusFactory.getEventBus();
    eventBus.register(new Object() {
        @Subscribe
        public void listener(MediaMappingChangeEvent event) {
            logger.info("Receive an mediaMapping change event with task-id " + event.getTaskId());
            try {
                cleanMediaMapping(event.getTaskId());
                event.getCallback().onCompletion(null, null);
            } catch (Throwable t) {
                logger.error("something goes wrong when clean mediaMapping cache.", t);
                event.getCallback().onCompletion(t, null);
            }
        }
    });
}
 
Example #8
Source File: CollectionUpdater.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void execute(JobExecutionContext context) throws JobExecutionException {
  EventBus eventBus = (EventBus) context.getJobDetail().getJobDataMap().get(EVENT_BUS);
  String collectionName = (String) context.getJobDetail().getJobDataMap().get(COLLECTION_NAME);
  org.slf4j.Logger loggerfc = (org.slf4j.Logger) context.getJobDetail().getJobDataMap().get(LOGGER);
  CollectionUpdateType type = (CollectionUpdateType) context.getTrigger().getJobDataMap().get(UpdateType);
  String source = (String) context.getTrigger().getJobDataMap().get(Source);
  String groupName = context.getTrigger().getKey().getGroup();

  try {
    eventBus.post(new CollectionUpdateEvent(type, collectionName, source));
    fcLogger.debug("CollectionUpdate post event {} on {}", type, collectionName);

  } catch (Throwable e) {
    if (loggerfc != null)
      loggerfc.error("UpdateCollectionJob.execute " + groupName + " failed collection=" + collectionName, e);
  }
}
 
Example #9
Source File: SchedulerModule.java    From dynein with Apache License 2.0 6 votes vote down vote up
@Provides
@Singleton
public HeartbeatManager provideHeartBeat(EventBus eventBus, Clock clock) {
  HeartbeatManager heartbeatManager =
      new HeartbeatManager(
          new ConcurrentHashMap<>(),
          MoreExecutors.getExitingScheduledExecutorService(
              (ScheduledThreadPoolExecutor)
                  Executors.newScheduledThreadPool(
                      1,
                      new ThreadFactoryBuilder().setNameFormat("heartbeat-manager-%d").build())),
          eventBus,
          clock,
          heartbeatConfiguration);
  eventBus.register(heartbeatManager);
  return heartbeatManager;
}
 
Example #10
Source File: TestApplication.java    From mt-flume with Apache License 2.0 6 votes vote down vote up
@Test
public void testFLUME1854() throws Exception {
  File configFile = new File(baseDir, "flume-conf.properties");
  Files.copy(new File(getClass().getClassLoader()
      .getResource("flume-conf.properties").getFile()), configFile);
  Random random = new Random();
  for (int i = 0; i < 3; i++) {
    EventBus eventBus = new EventBus("test-event-bus");
    PollingPropertiesFileConfigurationProvider configurationProvider =
        new PollingPropertiesFileConfigurationProvider("host1",
            configFile, eventBus, 1);
    List<LifecycleAware> components = Lists.newArrayList();
    components.add(configurationProvider);
    Application application = new Application(components);
    eventBus.register(application);
    application.start();
    Thread.sleep(random.nextInt(10000));
    application.stop();
  }
}
 
Example #11
Source File: Activator.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * The constructor
 */
public Activator() {
	
	eventBus = new EventBus((exception, context) -> {
		System.out.println("EventBusSubscriberException: " + exception + " | " + "BUS:" + context.getEventBus()
				+ " EVENT: " + context.getEvent() + " SUBSRIBER: " + context.getSubscriber() + " METHOD: "
				+ context.getSubscriberMethod());
		exception.printStackTrace();
	});
	
	setLookAndFeel();
}
 
Example #12
Source File: EventTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testSuperclassHandlerOnSubclassEvent() {
    EventBus eventsSuperSub = new EventBus();

    final EventHandler superclassHandlerSucceed = (UnusedStoredReposChangedEventHandler) e -> assertTrue(true);
    final EventHandler subclassHandlerSucceed = (PrimaryRepoOpenedEventHandler) e -> assertTrue(true);
    final EventHandler subclassHandlerFail =
            (PrimaryRepoOpenedEventHandler) e -> fail("PrimaryRepoOpenedEventHandler failed");

    // Dispatch superclass event, ensure subclass handler doesn't fire
    eventsSuperSub.register(superclassHandlerSucceed);
    eventsSuperSub.register(subclassHandlerFail);

    UnusedStoredReposChangedEvent superclassEvent = new UnusedStoredReposChangedEvent();

    eventsSuperSub.post(superclassEvent);

    eventsSuperSub.unregister(superclassHandlerSucceed);
    eventsSuperSub.unregister(subclassHandlerFail);

    // Dispatch subclass event, ensure both handler fire
    eventsSuperSub.register(superclassHandlerSucceed);
    eventsSuperSub.register(subclassHandlerSucceed);

    PrimaryRepoOpenedEvent subclassEvent = new PrimaryRepoOpenedEvent();

    eventsSuperSub.post(subclassEvent);
}
 
Example #13
Source File: HealthCheck.java    From micro-server with Apache License 2.0 5 votes vote down vote up
@Autowired
public HealthCheck(HealthChecker healthChecker, @Value("${health.check.error.list.size:25}") int maxSize,
        @Value("${health.check.max.error.list.size:2500}") int hardMax, EventBus errorBus) {
    this.healthCheckHelper = healthChecker;
    this.maxSize = maxSize;
    this.hardMax = hardMax;
    this.errorBus = errorBus;
}
 
Example #14
Source File: PubsubEventModule.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Provides
@RegisteredEvents
@Singleton
EventBus provideRegisteredEventBus(SubscriberExceptionHandler subscriberExceptionHandler,
                                   @DeadEventHandler Object deadEventHandler) {

  EventBus eventBus = new AsyncEventBus(registeredExecutor, subscriberExceptionHandler);
  eventBus.register(deadEventHandler);
  return eventBus;
}
 
Example #15
Source File: EventBusPublishingTaskFactory.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Override
public TaskIFace createTask(TaskContext taskContext) {
  String taskId = taskContext.getTaskState().getProp(TASK_ID_KEY);
  EventBus eventBus = null;
  if (taskContext.getTaskState().contains(EVENTBUS_ID_KEY)) {
    String eventbusId = taskContext.getTaskState().getProp(EVENTBUS_ID_KEY);
    eventBus = TestingEventBuses.getEventBus(eventbusId);
  }
  return new Task(taskContext, taskId, eventBus);
}
 
Example #16
Source File: AstyanaxThriftClusterAdminResource.java    From staash with Apache License 2.0 5 votes vote down vote up
@Inject
public AstyanaxThriftClusterAdminResource(
                                EventBus                 eventBus,
                                DaoProvider              daoProvider, 
        @Named("tasks")         ScheduledExecutorService taskExecutor,
                                ClusterDiscoveryService  discoveryService,
                                ClusterClientProvider    clusterProvider,
        @Assisted               ClusterKey               clusterKey) {
    this.clusterKey   = clusterKey;
    this.cluster      = clusterProvider.acquireCluster(clusterKey);
    this.daoProvider  = daoProvider;
    this.eventBus     = eventBus;
}
 
Example #17
Source File: TestingEventBusAsserterTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssertNext() throws InterruptedException, TimeoutException, IOException {
  EventBus testBus = TestingEventBuses.getEventBus("TestingEventBusAsserterTest.testHappyPath");

  try(final TestingEventBusAsserter asserter =
      new TestingEventBusAsserter("TestingEventBusAsserterTest.testHappyPath")) {
    testBus.post(new TestingEventBuses.Event("event1"));
    testBus.post(new TestingEventBuses.Event("event2"));

    asserter.assertNextValueEq("event1");
    Assert.assertThrows(new ThrowingRunnable() {
      @Override public void run() throws Throwable {
        asserter.assertNextValueEq("event3");
      }
    });

    testBus.post(new TestingEventBuses.Event("event13"));
    testBus.post(new TestingEventBuses.Event("event11"));
    testBus.post(new TestingEventBuses.Event("event12"));
    testBus.post(new TestingEventBuses.Event("event10"));

    asserter.assertNextValuesEq(Arrays.asList("event10", "event11", "event12", "event13"));

    testBus.post(new TestingEventBuses.Event("event22"));
    testBus.post(new TestingEventBuses.Event("event20"));

    Assert.assertThrows(new ThrowingRunnable() {
      @Override public void run() throws Throwable {
        asserter.assertNextValuesEq(Arrays.asList("event22", "event21"));
      }
    });
  }
}
 
Example #18
Source File: EventCollectionApparatus.java    From bazel with Apache License 2.0 5 votes vote down vote up
/**
 * Determine which events the {@link #collector()} created by this apparatus
 * will collect. Default: {@link EventKind#ERRORS_AND_WARNINGS}.
 */
public EventCollectionApparatus(Set<EventKind> mask) {
  eventCollector = new EventCollector(mask);
  printingEventHandler = new PrintingEventHandler(EventKind.ERRORS_AND_WARNINGS_AND_OUTPUT);
  reporter = new Reporter(new EventBus(), eventCollector, printingEventHandler);
  this.setFailFast(true);
}
 
Example #19
Source File: RuleFactoryTest.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Test
public void testOutputFileNotEqualDot() throws Exception {
  Path myPkgPath = scratch.resolve("/workspace/mypkg");
  Package.Builder pkgBuilder =
      packageFactory
          .newPackageBuilder(
              PackageIdentifier.createInMainRepo("mypkg"), "TESTING", StarlarkSemantics.DEFAULT)
          .setFilename(RootedPath.toRootedPath(root, myPkgPath));

  Map<String, Object> attributeValues = new HashMap<>();
  attributeValues.put("outs", Lists.newArrayList("."));
  attributeValues.put("name", "some");
  RuleClass ruleClass = provider.getRuleClassMap().get("genrule");
  RuleFactory.InvalidRuleException e =
      assertThrows(
          RuleFactory.InvalidRuleException.class,
          () ->
              RuleFactory.createAndAddRuleImpl(
                  pkgBuilder,
                  ruleClass,
                  new BuildLangTypedAttributeValuesMap(attributeValues),
                  new Reporter(new EventBus()),
                  StarlarkSemantics.DEFAULT,
                  DUMMY_STACK));
  assertWithMessage(e.getMessage())
      .that(e.getMessage().contains("output file name can't be equal '.'"))
      .isTrue();
}
 
Example #20
Source File: TransitionBenchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial)
public void init() throws Exception {
  Constants.setConstants("mainnet");
  BeaconStateUtil.BLS_VERIFY_DEPOSIT = false;

  String blocksFile =
      "/blocks/blocks_epoch_"
          + Constants.SLOTS_PER_EPOCH
          + "_validators_"
          + validatorsCount
          + ".ssz.gz";
  String keysFile = "/bls-key-pairs/bls-key-pairs-200k-seed-0.txt.gz";

  System.out.println("Generating keypairs from " + keysFile);
  List<BLSKeyPair> validatorKeys =
      BlsKeyPairIO.createReaderForResource(keysFile).readAll(validatorsCount);

  EventBus localEventBus = mock(EventBus.class);
  recentChainData = MemoryOnlyRecentChainData.create(localEventBus);
  localChain = BeaconChainUtil.create(recentChainData, validatorKeys, false);
  localChain.initializeStorage();

  ForkChoice forkChoice = new ForkChoice(recentChainData, new StateTransition());
  blockImporter = new BlockImporter(recentChainData, forkChoice, localEventBus);
  blockIterator = BlockIO.createResourceReader(blocksFile).iterator();
  System.out.println("Importing blocks from " + blocksFile);
}
 
Example #21
Source File: ReporterTest.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Before
public final void initializeOutput() throws Exception  {
  reporter = new Reporter(new EventBus());
  out = new StringBuilder();
  outAppender = new AbstractEventHandler(EventKind.ERRORS) {
    @Override
    public void handle(Event event) {
      out.append(event.getMessage());
    }
  };
}
 
Example #22
Source File: BuildViewTestCase.java    From bazel with Apache License 2.0 5 votes vote down vote up
protected AnalysisResult update(List<String> targets,
    boolean keepGoing,
    int loadingPhaseThreads,
    boolean doAnalysis,
    EventBus eventBus) throws Exception {
  return update(
      targets, ImmutableList.<String>of(), keepGoing, loadingPhaseThreads, doAnalysis, eventBus);
}
 
Example #23
Source File: MetricsCatcherConfigOffTest.java    From micro-server with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    registry = new MetricRegistry();
    bus = new EventBus();
    config = new Configuration(
                               false, false, false, false, 5, 6, 7, 8, 10, "bob");
    catcher = new MetricsCatcher<>(
                                   registry, bus, config);
}
 
Example #24
Source File: MemoryLogTest.java    From xraft with MIT License 5 votes vote down vote up
@Test
public void testAppendEntriesFromLeaderSnapshot1() {
    MemoryLog log = new MemoryLog(
            new MemorySnapshot(3, 4),
            new MemoryEntrySequence(4),
            new EventBus()
    );
    Assert.assertTrue(log.appendEntriesFromLeader(3, 4, Collections.emptyList()));
}
 
Example #25
Source File: MemoryLogTest.java    From xraft with MIT License 5 votes vote down vote up
@Test(expected = EntryInSnapshotException.class)
public void testCreateAppendEntriesLogNotEmptyEntryInSnapshot() {
    MemoryLog log = new MemoryLog(
            new MemorySnapshot(3, 2),
            new MemoryEntrySequence(4),
            new EventBus()
    );
    log.appendEntry(1); // 4
    log.createAppendEntriesRpc(
            2, new NodeId("A"), 3, Log.ALL_ENTRIES
    );
}
 
Example #26
Source File: GenericEvent.java    From micro-server with Apache License 2.0 5 votes vote down vote up
public static <T> GenericEvent<T> trigger(String name, EventBus bus, T data, String[] subTypes) {
    GenericEvent<T> event = new GenericEvent<>(GenericEventData.<T>builder()
                                                       .name(name)
                                                       .data(data)
                                                       .subTypes(subTypes)
                                                       .build());
    bus.post(event);
    return event;
}
 
Example #27
Source File: FlushResource.java    From DataLink with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/reloadEs/{mediaSourceId}")
public void reloadEs(@PathParam("mediaSourceId") String mediaSourceId) throws Throwable {
    logger.info("Receive a request for reload es-media-source,with id " + mediaSourceId);

    MediaSourceInfo mediaSourceInfo = DataLinkFactory.getObject(MediaSourceService.class).getById(Long.valueOf(mediaSourceId));
    EventBus eventBus = EventBusFactory.getEventBus();
    EsConfigClearEvent event = new EsConfigClearEvent(new FutureCallback(), mediaSourceInfo);
    eventBus.post(event);
    event.getCallback().get();
    //清空相关Task的mapping缓存
    clearTaskMediaMappingCache(Long.valueOf(mediaSourceId));
}
 
Example #28
Source File: JobsBeingExecutedTest.java    From micro-server with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    data = SystemData.builder()
                     .dataMap(Maps.newHashMap())
                     .errors(1)
                     .processed(100)
                     .build();
    bus = new EventBus();
    bus.register(this);
    jobs = new JobsBeingExecuted(
                                 bus, 10, JobName.Types.SIMPLE);
    pjp = Mockito.mock(ProceedingJoinPoint.class);
}
 
Example #29
Source File: StarlarkJavaLiteProtoLibraryTest.java    From bazel with Apache License 2.0 5 votes vote down vote up
/**
 * Verify that a java_lite_proto_library exposes Starlark providers for the Java code it
 * generates.
 */
@Test
public void testJavaProtosExposeStarlarkProviders() throws Exception {
  scratch.file(
      "proto/extensions.bzl",
      "def _impl(ctx):",
      "  print (ctx.attr.dep[JavaInfo])",
      "custom_rule = rule(",
      "  implementation=_impl,",
      "  attrs={",
      "    'dep': attr.label()",
      "  },",
      ")");
  scratch.file(
      "proto/BUILD",
      "load('//proto:extensions.bzl', 'custom_rule')",
      "load('//tools/build_rules/java_lite_proto_library:java_lite_proto_library.bzl',",
      "      'java_lite_proto_library')",
      "proto_library(",
      "    name = 'proto',",
      "    srcs = [ 'file.proto' ],",
      ")",
      "java_lite_proto_library(name = 'lite_pb2', deps = [':proto'])",
      "custom_rule(name = 'custom', dep = ':lite_pb2')");
  update(
      ImmutableList.of("//proto:custom"),
      /* keepGoing= */ false,
      /* loadingPhaseThreads= */ 1,
      /* doAnalysis= */ true,
      new EventBus());
  // Implicitly check that `update()` above didn't throw an exception. This implicitly checks that
  // ctx.attr.dep.java.{transitive_deps, outputs}, above, is defined.
}
 
Example #30
Source File: EventBusTest.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Test
public void testEventBus(){
	EventBus eventBus = new EventBus();
	eventBus.register(new Object(){
		
		@Subscribe
		public void listener(TestEvent event){
			System.out.println("listener1:"+event.name);
		}
	});
	/*eventBus.register(new Object(){
		
		@Subscribe
		public void listener(TestEvent event){
			System.out.println("listener2:"+event.name);
			if(true)
				throw new BaseException("error");
		}
	});
	eventBus.register(new Object(){
		
		@Subscribe
		public void listener(TestEvent event){
			System.out.println("listener3:"+event.name);
			if(true)
				throw new BaseException("error");
		}
	});*/

	eventBus.post(new TestEvent("test"));
	eventBus.post(new TestEvent("test"));
}