use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class BootstrapTest method testInitializeWithAllUserSpecifiedThingsInConfDirectory.
@Test
public void testInitializeWithAllUserSpecifiedThingsInConfDirectory() {
ninjaPropertiesImpl = new NinjaPropertiesImpl(NinjaMode.test);
Bootstrap bootstrap = new Bootstrap(ninjaPropertiesImpl);
bootstrap.boot();
assertThat("Ninja Boostrap process picks up user supplied conf.Ninja definition", bootstrap.getInjector().getInstance(ninja.Ninja.class), is(instanceOf(conf.Ninja.class)));
assertThat("Ninja Boostrap process picks up user supplied Guice module in conf.Module", bootstrap.getInjector().getInstance(conf.Module.DummyInterfaceForTesting.class), is(instanceOf(conf.Module.DummyClassForTesting.class)));
Router router = bootstrap.getInjector().getInstance(Router.class);
Route route = router.getRouteFor("GET", "/");
assertThat("conf.Routes initialized properly. We get back the class we defined by the route.", route.getControllerClass(), is(instanceOf(com.example.controllers.DummyApplication.class.getClass())));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class MigrationEngineProviderTest method missingImplementationThrowsExceptionOnUseNotCreate.
@Test
public void missingImplementationThrowsExceptionOnUseNotCreate() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(NinjaConstant.MIGRATION_ENGINE_IMPLEMENTATION, "not_existing_implementation");
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
Provider<MigrationEngine> provider = injector.getProvider(MigrationEngine.class);
// this will not work => we expect a runtime exception...
thrown.expect(RuntimeException.class);
MigrationEngine migrationEngine = injector.getInstance(MigrationEngine.class);
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class ControllerMethodInvokerWithDeprecatedValidationTest method setUp.
@Before
public void setUp() throws Exception {
this.ninjaProperties = Mockito.spy(new NinjaPropertiesImpl(NinjaMode.test));
this.lang = new LangImpl(this.ninjaProperties);
this.validation = new ValidationImpl();
when(this.context.getSession()).thenReturn(this.session);
when(this.context.getFlashScope()).thenReturn(this.flash);
when(this.context.getValidation()).thenReturn(this.validation);
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class PostofficeProviderTest method defaultImplementation.
@Test
public void defaultImplementation() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(PostofficeConstant.postofficeImplementation, null);
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
PostofficeProvider postofficeProvider = injector.getInstance(PostofficeProvider.class);
assertThat(postofficeProvider.get(), instanceOf(PostofficeMockImpl.class));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class CacheProviderTest method verifySingletonProviderAndInstance.
@Test
public void verifySingletonProviderAndInstance() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(NinjaConstant.CACHE_IMPLEMENTATION, CacheMockImpl.class.getCanonicalName());
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
CacheProvider cacheProvider = injector.getInstance(CacheProvider.class);
// cache provider should be a singleton
assertThat(cacheProvider, sameInstance(injector.getInstance(CacheProvider.class)));
assertThat(cacheProvider, sameInstance(injector.getInstance(CacheProvider.class)));
Cache cache = cacheProvider.get();
// cache should be a singleton
assertThat(cache, sameInstance(cacheProvider.get()));
assertThat(cache, sameInstance(injector.getInstance(Cache.class)));
}
Aggregations