use of com.tvd12.ezyhttp.server.core.ApplicationContext 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();
}
use of com.tvd12.ezyhttp.server.core.ApplicationContext in project ezyhttp by youngmonkeys.
the class EzyHttpApplicationTest method testFailedDueToNoApplicationEntry.
@Test
public void testFailedDueToNoApplicationEntry() {
// given
ApplicationContext context = mock(ApplicationContext.class);
EzyHttpApplication sut = new EzyHttpApplication(context);
// when
Throwable e = Asserts.assertThrows(sut::start);
// then
Asserts.assertThat(e).isEqualsType(IllegalStateException.class);
verify(context, times(1)).getAnnotatedSingleton(ApplicationBootstrap.class);
}
use of com.tvd12.ezyhttp.server.core.ApplicationContext in project java-examples by tvd12.
the class MyApplicationStartup method main.
public static void main(String[] args) {
ApplicationContext appContext = SpringApplication.run(MyApplicationStartup.class, args);
BookService bookService = appContext.getBean(BookService.class);
bookService.saveBook(new Book(1, "youngmonkeys.org"));
}
Aggregations