use of com.tvd12.ezyfoxserver.wrapper.impl.EzyEventControllersImpl in project ezyfox-server by youngmonkeys.
the class EzyEventControllersImplTest method multiThreadTest.
@SuppressWarnings("unchecked")
@Test
public void multiThreadTest() {
EzyEventControllersImpl sut = new EzyEventControllersImpl();
ExecutorService executorService = Executors.newFixedThreadPool(12);
AtomicBoolean active = new AtomicBoolean(true);
executorService.execute(() -> {
while (active.get()) {
for (EzyEventType eventType : EzyEventType.values()) {
sut.addController(eventType, mock(EzyEventController.class));
}
EzyThreads.sleep(1);
}
});
executorService.execute(() -> {
while (active.get()) {
for (EzyEventType eventType : EzyEventType.values()) {
for (EzyEventController controller : sut.getControllers(eventType)) {
controller.handle(null, null);
}
}
EzyThreads.sleep(1);
}
});
EzyThreads.sleep(1000);
executorService.shutdown();
}
use of com.tvd12.ezyfoxserver.wrapper.impl.EzyEventControllersImpl in project ezyfox-server by youngmonkeys.
the class EzyEventControllersImplTest method getListControllerTest.
@Test
public void getListControllerTest() {
// given
EzyEventControllersImpl sut = new EzyEventControllersImpl();
EzyEventController c1 = mock(EzyEventController.class);
EzyEventController c2 = mock(EzyEventController.class);
sut.addController(EzyEventType.SERVER_INITIALIZING, c1);
sut.addController(EzyEventType.SERVER_INITIALIZING, c2);
// when
List<EzyEventController> controllers = sut.getControllers(EzyEventType.SERVER_INITIALIZING);
// then
Asserts.assertEquals(controllers, Arrays.asList(c1, c2), false);
Asserts.assertEmpty(sut.getControllers(EzyEventType.USER_ACCESS_APP));
}
use of com.tvd12.ezyfoxserver.wrapper.impl.EzyEventControllersImpl in project ezyfox-server by youngmonkeys.
the class EzyAppFireEventImplTest method test.
@Test
public void test() {
EzySimpleAppSetting app = mock(EzySimpleAppSetting.class);
EzyAppContext context = mock(EzyAppContext.class);
EzySimpleApplication application = new EzySimpleApplication();
application.setEventControllers(new EzyEventControllersImpl());
application.setSetting(app);
when(context.getApp()).thenReturn(application);
}
Aggregations