use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class CacheProviderTest method defaultImplementation.
@Test
public void defaultImplementation() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(NinjaConstant.CACHE_IMPLEMENTATION, null);
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
CacheProvider cacheProvider = injector.getInstance(CacheProvider.class);
assertThat(cacheProvider.get(), instanceOf(CacheEhCacheImpl.class));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class CacheProviderTest method configuredImplementation.
@Test
public void configuredImplementation() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(NinjaConstant.CACHE_IMPLEMENTATION, CacheMemcachedImpl.class.getName());
// just a dummy to test that loading works
ninjaProperties.setProperty(NinjaConstant.MEMCACHED_HOST, "127.0.0.1:1234");
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
Provider<Cache> cacheProvider = injector.getProvider(Cache.class);
assertThat(cacheProvider.get(), instanceOf(CacheMemcachedImpl.class));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class NinjaServletListenerTest method testCreatingInjectorWithCustomModulesPackageWorks.
@Test
public void testCreatingInjectorWithCustomModulesPackageWorks() {
// setup stuff
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(NinjaConstant.APPLICATION_MODULES_BASE_PACKAGE, "ninja.servlet");
NinjaServletListener ninjaServletListener = new NinjaServletListener();
ninjaServletListener.setNinjaProperties(ninjaProperties);
// start the injector:
ninjaServletListener.contextInitialized(servletContextEvent);
// test stuff
Injector injector = ninjaServletListener.getInjector();
Router router = injector.getInstance((Router.class));
//router is initialized otherwise there will be exception that routes isn't compiled
router.getRouteFor("GET", "/");
//validate that main application module is initialized
Boolean mainModuleConstant = injector.getInstance(Key.get(Boolean.class, Names.named(Module.TEST_CONSTANT_NAME)));
assertThat(mainModuleConstant, is(true));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class NinjaServletListenerTest method testCreatingInjectorWithCustomNinjaPropertiesWorks.
@Test
public void testCreatingInjectorWithCustomNinjaPropertiesWorks() {
// setup stuff
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty("key!", "value!");
NinjaServletListener ninjaServletListener = new NinjaServletListener();
ninjaServletListener.setNinjaProperties(ninjaProperties);
// start the injector:
ninjaServletListener.contextInitialized(servletContextEvent);
// test stuff
Injector injector = ninjaServletListener.getInjector();
NinjaProperties ninjaPropertiesFromServer = injector.getInstance(NinjaProperties.class);
assertThat(ninjaPropertiesFromServer.get("key!"), equalTo("value!"));
// make sure we are using the context path from the serveltcontext here
assertThat(ninjaProperties.getContextPath(), equalTo(CONTEXT_PATH));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class NinjaDaoTestBase method initialize.
@Before
public final void initialize() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(ninjaMode);
injector = Guice.createInjector(new JpaModule(ninjaProperties));
jpaInitializer = injector.getInstance(JpaInitializer.class);
jpaInitializer.start();
}
Aggregations