Search in sources :

Example 6 with EzyRequestCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.

the class EzyUserRequestAppSingletonControllerTest method test.

@Test
public void test() throws Exception {
    EzyRequestHandlerImplementer.setDebug(true);
    EzyExceptionHandlerImplementer.setDebug(true);
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    EzySimpleServerContext serverContext = new EzySimpleServerContext();
    serverContext.setServer(server);
    serverContext.init();
    EzySimpleZoneSetting zoneSetting = new EzySimpleZoneSetting();
    EzySimpleZone zone = new EzySimpleZone();
    zone.setSetting(zoneSetting);
    EzySimpleZoneContext zoneContext = new EzySimpleZoneContext();
    zoneContext.setZone(zone);
    zoneContext.init();
    zoneContext.setParent(serverContext);
    EzySimpleAppSetting appSetting = new EzySimpleAppSetting();
    appSetting.setName("test");
    EzyAppUserManager appUserManager = EzyAppUserManagerImpl.builder().build();
    EzyEventControllersSetting eventControllersSetting = new EzySimpleEventControllersSetting();
    EzyEventControllers eventControllers = EzyEventControllersImpl.create(eventControllersSetting);
    EzySimpleApplication application = new EzySimpleApplication();
    application.setSetting(appSetting);
    application.setUserManager(appUserManager);
    application.setEventControllers(eventControllers);
    ScheduledExecutorService appScheduledExecutorService = new EzyErrorScheduledExecutorService("not implement");
    EzySimpleAppContext appContext = new EzySimpleAppContext();
    appContext.setApp(application);
    appContext.setParent(zoneContext);
    appContext.setExecutorService(appScheduledExecutorService);
    appContext.init();
    EzySimpleAppEntry entry = new EzyAppEntryEx();
    entry.config(appContext);
    entry.start();
    handleClientRequest(appContext);
    EzyBeanContext beanContext = appContext.get(EzyBeanContext.class);
    EzyRequestCommandManager requestCommandManager = beanContext.getSingleton(EzyRequestCommandManager.class);
    EzyFeatureCommandManager featureCommandManager = beanContext.getSingleton(EzyFeatureCommandManager.class);
    Asserts.assertTrue(requestCommandManager.containsCommand("v1.2.2/hello"));
    Asserts.assertTrue(requestCommandManager.containsCommand("v122/listener/hello"));
    Asserts.assertTrue(requestCommandManager.isManagementCommand("v1.2.2/hello"));
    Asserts.assertTrue(requestCommandManager.isPaymentCommand("v1.2.2/hello"));
    Asserts.assertEquals(featureCommandManager.getFeatureByCommand("v1.2.2/hello"), "hello.world");
    entry.destroy();
}
Also used : EzyErrorScheduledExecutorService(com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyErrorScheduledExecutorService(com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzySimpleZoneContext(com.tvd12.ezyfoxserver.context.EzySimpleZoneContext) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzySimpleZone(com.tvd12.ezyfoxserver.EzySimpleZone) EzySimpleApplication(com.tvd12.ezyfoxserver.EzySimpleApplication) EzyEventControllers(com.tvd12.ezyfoxserver.wrapper.EzyEventControllers) EzyAppUserManager(com.tvd12.ezyfoxserver.wrapper.EzyAppUserManager) EzySimpleAppContext(com.tvd12.ezyfoxserver.context.EzySimpleAppContext) EzySimpleAppEntry(com.tvd12.ezyfoxserver.support.entry.EzySimpleAppEntry) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 7 with EzyRequestCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.

the class EzyRequestHandlersImplementerTest method testImplementDuplicateCommandButAllowOverride.

@Test
public void testImplementDuplicateCommandButAllowOverride() {
    EzyRequestHandlerImplementer.setDebug(true);
    EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
    EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
    EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
    implementer.setFeatureCommandManager(featureCommandManager);
    implementer.setRequestCommandManager(requestCommandManager);
    implementer.setAllowOverrideCommand(true);
    implementer.implement(Arrays.asList(new HelloController(), new HelloController()));
}
Also used : HelloController(com.tvd12.ezyfoxserver.support.test.controller.HelloController) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzyRequestHandlersImplementer(com.tvd12.ezyfoxserver.support.asm.EzyRequestHandlersImplementer) Test(org.testng.annotations.Test)

Example 8 with EzyRequestCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.

the class EzyRequestHandlersImplementerTest method testImplementFailedCase3.

@Test(expectedExceptions = EzyDuplicateRequestHandlerException.class)
public void testImplementFailedCase3() {
    EzyRequestHandlerImplementer.setDebug(true);
    EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
    EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
    EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
    implementer.setFeatureCommandManager(featureCommandManager);
    implementer.setRequestCommandManager(requestCommandManager);
    implementer.implement(Arrays.asList(new HelloController(), new HelloController()));
}
Also used : HelloController(com.tvd12.ezyfoxserver.support.test.controller.HelloController) EzyFeatureCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager) EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) EzyRequestHandlersImplementer(com.tvd12.ezyfoxserver.support.asm.EzyRequestHandlersImplementer) Test(org.testng.annotations.Test)

Example 9 with EzyRequestCommandManager

use of com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager in project ezyfox-server by youngmonkeys.

the class EzyRequestCommandManagerTest method test.

@Test
public void test() {
    // given
    EzyRequestCommandManager sut = new EzyRequestCommandManager();
    sut.addCommand("a");
    sut.addPaymentCommand("d");
    sut.addManagementCommand("e");
    // when
    // then
    Asserts.assertTrue(sut.containsCommand("a"));
    Asserts.assertEquals(sut.getCommands(), Collections.singletonList("a"), false);
    Assert.assertTrue(sut.isPaymentCommand("d"));
    Asserts.assertEquals(sut.getPaymentCommands(), Collections.singletonList("d"), false);
    Assert.assertTrue(sut.isManagementCommand("e"));
    Asserts.assertEquals(sut.getManagementCommands(), Collections.singletonList("e"), false);
    sut.destroy();
}
Also used : EzyRequestCommandManager(com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager) Test(org.testng.annotations.Test)

Aggregations

EzyRequestCommandManager (com.tvd12.ezyfoxserver.support.manager.EzyRequestCommandManager)9 EzyFeatureCommandManager (com.tvd12.ezyfoxserver.support.manager.EzyFeatureCommandManager)8 Test (org.testng.annotations.Test)7 EzyRequestHandlersImplementer (com.tvd12.ezyfoxserver.support.asm.EzyRequestHandlersImplementer)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)4 EzyResponseFactory (com.tvd12.ezyfoxserver.support.factory.EzyResponseFactory)3 HelloController (com.tvd12.ezyfoxserver.support.test.controller.HelloController)3 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)2 EzyBeanContextBuilder (com.tvd12.ezyfox.bean.EzyBeanContextBuilder)2 EzyBindingContext (com.tvd12.ezyfox.binding.EzyBindingContext)2 EzyMarshaller (com.tvd12.ezyfox.binding.EzyMarshaller)2 EzyUnmarshaller (com.tvd12.ezyfox.binding.EzyUnmarshaller)2 EzyErrorScheduledExecutorService (com.tvd12.ezyfox.concurrent.EzyErrorScheduledExecutorService)2 EzyReflection (com.tvd12.ezyfox.reflect.EzyReflection)2 EzyReflectionProxy (com.tvd12.ezyfox.reflect.EzyReflectionProxy)2 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)2 EzySimpleZone (com.tvd12.ezyfoxserver.EzySimpleZone)2 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)2 EzySimpleZoneContext (com.tvd12.ezyfoxserver.context.EzySimpleZoneContext)2 EzyEventControllers (com.tvd12.ezyfoxserver.wrapper.EzyEventControllers)2