use of com.oracle.bedrock.runtime.concurrent.RemoteEvent in project oracle-bedrock by coherence-community.
the class AbstractJavaApplicationTest method shouldReceiveEventFromApplication.
@Test
public void shouldReceiveEventFromApplication() throws Exception {
EventListener listener1 = new EventListener(1);
EventListener listener2 = new EventListener(1);
String name = "Foo";
RemoteEvent event = new EventingApplication.Event(19);
try (JavaApplication application = getPlatform().launch(JavaApplication.class, ClassName.of(EventingApplication.class), IPv4Preferred.yes())) {
application.addListener(listener1, StreamName.of(name));
application.addListener(listener2, StreamName.of(name));
EventingApplication.fireEvent(application, name, event);
assertThat(listener1.await(1, TimeUnit.MINUTES), is(true));
assertThat(listener2.await(1, TimeUnit.MINUTES), is(true));
assertThat(listener1.getEvents().size(), is(1));
assertThat(listener1.getEvents().get(0), is(event));
assertThat(listener2.getEvents().size(), is(1));
assertThat(listener2.getEvents().get(0), is(event));
}
}
use of com.oracle.bedrock.runtime.concurrent.RemoteEvent in project oracle-bedrock by coherence-community.
the class AbstractCoherenceCacheServerTest method shouldSendEventsFromCustomServer.
@Test
public void shouldSendEventsFromCustomServer() throws Exception {
Platform platform = getPlatform();
EventListener listener = new EventListener(1);
String name = "Foo";
RemoteEvent event = new CustomServer.Event(19);
try (CoherenceCacheServer server = platform.launch(CoherenceCacheServer.class, ClassName.of(CustomServer.class), ClusterPort.automatic(), LocalHost.only(), Console.system())) {
server.addListener(listener, StreamName.of(name));
CustomServer.fireEvent(server, name, event);
assertThat(listener.await(1, TimeUnit.MINUTES), is(true));
assertThat(listener.getEvents().get(0), is(event));
server.close();
}
}
Aggregations