Search in sources :

Example 1 with EzyHttpApplication

use of com.tvd12.ezyhttp.server.core.EzyHttpApplication in project ezyhttp by youngmonkeys.

the class EzyHttpApplicationTest method startWith2Params.

@Test
public void startWith2Params() throws Exception {
    // given
    EzyHttpApplication sut = EzyHttpApplication.start(EzyHttpApplicationTest.class, getClass());
    ApplicationContext applicationContext = sut.getApplicationContext();
    EzyBeanContext beanContext = applicationContext.getBeanContext();
    // when
    int actualOneProp = beanContext.getProperty("one", int.class);
    boolean managementEnable = beanContext.getProperty("management.enable", boolean.class);
    UserService userService = applicationContext.getSingleton(UserService.class);
    ViewContextBuilder viewContextBuilder = beanContext.getSingleton(ViewContextBuilder.class);
    ResourceResolver resourceResolver = beanContext.getSingleton(ResourceResolver.class);
    ResourceDownloadManager resourceDownloadManager = beanContext.getSingleton(ResourceDownloadManager.class);
    List<Object> bootstraps = applicationContext.getSingletons(ApplicationBootstrap.class);
    // then
    Asserts.assertEquals(1, actualOneProp);
    Asserts.assertTrue(managementEnable);
    Asserts.assertNotNull(userService);
    Asserts.assertNotNull(viewContextBuilder);
    Asserts.assertNotNull(resourceDownloadManager);
    Asserts.assertEquals(4, resourceResolver.getResources().size());
    Asserts.assertFalse(bootstraps.isEmpty());
    sut.stop();
}
Also used : ApplicationContext(com.tvd12.ezyhttp.server.core.ApplicationContext) ResourceDownloadManager(com.tvd12.ezyhttp.core.resources.ResourceDownloadManager) EzyHttpApplication(com.tvd12.ezyhttp.server.core.EzyHttpApplication) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) UserService(com.tvd12.ezyhttp.server.core.test.service.UserService) ResourceResolver(com.tvd12.ezyhttp.server.core.resources.ResourceResolver) ViewContextBuilder(com.tvd12.ezyhttp.server.core.view.ViewContextBuilder) Test(org.testng.annotations.Test)

Example 2 with EzyHttpApplication

use of com.tvd12.ezyhttp.server.core.EzyHttpApplication in project ezyhttp by youngmonkeys.

the class EzyHttpApplicationTest method testDisablePrintBanner.

@Test
public void testDisablePrintBanner() throws Exception {
    // given
    System.setProperty(EzyBeanContext.ACTIVE_PROFILES_KEY, "disable");
    EzyHttpApplication sut = EzyHttpApplication.start(EzyHttpApplicationTest.class);
    System.setProperty(EzyBeanContext.ACTIVE_PROFILES_KEY, "enable");
    ApplicationContext applicationContext = sut.getApplicationContext();
    EzyBeanContext beanContext = applicationContext.getBeanContext();
    // when
    boolean bannerPrintable = beanContext.getProperty("banner.printable", boolean.class);
    // then
    Asserts.assertFalse(bannerPrintable);
    sut.stop();
}
Also used : ApplicationContext(com.tvd12.ezyhttp.server.core.ApplicationContext) EzyHttpApplication(com.tvd12.ezyhttp.server.core.EzyHttpApplication) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) Test(org.testng.annotations.Test)

Example 3 with EzyHttpApplication

use of com.tvd12.ezyhttp.server.core.EzyHttpApplication in project ezyhttp by youngmonkeys.

the class JettyApp method testDisable.

@Test
public void testDisable() throws Exception {
    // given
    System.setProperty(EzyBeanContext.ACTIVE_PROFILES_KEY, "disable");
    // when
    EzyHttpApplication app = EzyHttpApplication.start(JettyApp.class);
    // then
    app.stop();
}
Also used : EzyHttpApplication(com.tvd12.ezyhttp.server.core.EzyHttpApplication) Test(org.testng.annotations.Test)

Example 4 with EzyHttpApplication

use of com.tvd12.ezyhttp.server.core.EzyHttpApplication in project ezyhttp by youngmonkeys.

the class JettyApp method testEnable.

@Test
public void testEnable() throws Exception {
    // given
    System.setProperty(EzyBeanContext.ACTIVE_PROFILES_KEY, "enable");
    // when
    EzyHttpApplication app = EzyHttpApplication.start(JettyApp.class);
    // then
    app.stop();
}
Also used : EzyHttpApplication(com.tvd12.ezyhttp.server.core.EzyHttpApplication) Test(org.testng.annotations.Test)

Example 5 with EzyHttpApplication

use of com.tvd12.ezyhttp.server.core.EzyHttpApplication in project ezyhttp by youngmonkeys.

the class EzyHttpApplicationTest method test.

@Test
public void test() throws Exception {
    // given
    EzyHttpApplication sut = EzyHttpApplication.start(EzyHttpApplicationTest.class);
    ApplicationContext applicationContext = sut.getApplicationContext();
    EzyBeanContext beanContext = applicationContext.getBeanContext();
    // when
    int actualOneProp = beanContext.getProperty("one", int.class);
    boolean managementEnable = beanContext.getProperty("management.enable", boolean.class);
    UserService userService = beanContext.getSingleton(UserService.class);
    ViewContextBuilder viewContextBuilder = beanContext.getSingleton(ViewContextBuilder.class);
    ResourceResolver resourceResolver = beanContext.getSingleton(ResourceResolver.class);
    ResourceDownloadManager resourceDownloadManager = beanContext.getSingleton(ResourceDownloadManager.class);
    // then
    Asserts.assertEquals(1, actualOneProp);
    Asserts.assertTrue(managementEnable);
    Asserts.assertNotNull(userService);
    Asserts.assertNotNull(viewContextBuilder);
    Asserts.assertNotNull(resourceDownloadManager);
    Asserts.assertEquals(4, resourceResolver.getResources().size());
    sut.stop();
}
Also used : ApplicationContext(com.tvd12.ezyhttp.server.core.ApplicationContext) ResourceDownloadManager(com.tvd12.ezyhttp.core.resources.ResourceDownloadManager) EzyHttpApplication(com.tvd12.ezyhttp.server.core.EzyHttpApplication) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) UserService(com.tvd12.ezyhttp.server.core.test.service.UserService) ResourceResolver(com.tvd12.ezyhttp.server.core.resources.ResourceResolver) ViewContextBuilder(com.tvd12.ezyhttp.server.core.view.ViewContextBuilder) Test(org.testng.annotations.Test)

Aggregations

EzyHttpApplication (com.tvd12.ezyhttp.server.core.EzyHttpApplication)6 Test (org.testng.annotations.Test)6 ApplicationContext (com.tvd12.ezyhttp.server.core.ApplicationContext)4 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)3 ResourceDownloadManager (com.tvd12.ezyhttp.core.resources.ResourceDownloadManager)2 ResourceResolver (com.tvd12.ezyhttp.server.core.resources.ResourceResolver)2 UserService (com.tvd12.ezyhttp.server.core.test.service.UserService)2 ViewContextBuilder (com.tvd12.ezyhttp.server.core.view.ViewContextBuilder)2