use of org.olat.core.util.event.GenericEventListener in project OpenOLAT by OpenOLAT.
the class JMSTest method testSendReceive.
@Test
public void testSendReceive() {
// enable test only if we have the cluster configuration enabled.
// this test requires that an JMS Provider is running
// (see file serviceconfig/org/olat/core/_spring/coreextconfig.xml)
EventBus bus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
if (bus instanceof ClusterEventBus) {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("jms");
// send and wait some time until a message should arrive at the latest.
final OLATResourceable ores = OresHelper.createOLATResourceableInstance("hellojms", new Long(123));
final CountDownLatch doneSignal = new CountDownLatch(1);
bus.registerFor(new GenericEventListener() {
@Override
public void event(Event event) {
log.audit("Event received: " + event);
doneSignal.countDown();
}
}, id, ores);
MultiUserEvent mue = new MultiUserEvent("amuecommand");
bus.fireEventToListenersOf(mue, ores);
try {
boolean interrupt = doneSignal.await(5, TimeUnit.SECONDS);
assertTrue("Test takes too long (more than 5s)", interrupt);
} catch (InterruptedException e) {
fail("" + e.getMessage());
}
}
}
use of org.olat.core.util.event.GenericEventListener in project openolat by klemens.
the class JMSTest method testSendReceive.
@Test
public void testSendReceive() {
// enable test only if we have the cluster configuration enabled.
// this test requires that an JMS Provider is running
// (see file serviceconfig/org/olat/core/_spring/coreextconfig.xml)
EventBus bus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
if (bus instanceof ClusterEventBus) {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("jms");
// send and wait some time until a message should arrive at the latest.
final OLATResourceable ores = OresHelper.createOLATResourceableInstance("hellojms", new Long(123));
final CountDownLatch doneSignal = new CountDownLatch(1);
bus.registerFor(new GenericEventListener() {
@Override
public void event(Event event) {
log.audit("Event received: " + event);
doneSignal.countDown();
}
}, id, ores);
MultiUserEvent mue = new MultiUserEvent("amuecommand");
bus.fireEventToListenersOf(mue, ores);
try {
boolean interrupt = doneSignal.await(5, TimeUnit.SECONDS);
assertTrue("Test takes too long (more than 5s)", interrupt);
} catch (InterruptedException e) {
fail("" + e.getMessage());
}
}
}
Aggregations