use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class NinjaServletListenerTest method testThatSettingNinjaPropertiesTwiceDoesNotWork.
@Test
public void testThatSettingNinjaPropertiesTwiceDoesNotWork() {
NinjaServletListener ninjaServletListener = new NinjaServletListener();
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
// first setting works
ninjaServletListener.setNinjaProperties(ninjaProperties);
boolean gotException = false;
try {
//setting the properties a second time does not work...
ninjaServletListener.setNinjaProperties(ninjaProperties);
} catch (IllegalStateException illegalStateException) {
gotException = true;
}
assertThat(gotException, equalTo(true));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class PostofficeProviderTest method verifySingletonProviderAndInstance.
@Test
public void verifySingletonProviderAndInstance() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(PostofficeConstant.postofficeImplementation, null);
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
PostofficeProvider provider = injector.getInstance(PostofficeProvider.class);
// cache provider should be a singleton
assertThat(provider, sameInstance(injector.getInstance(PostofficeProvider.class)));
assertThat(provider, sameInstance(injector.getInstance(PostofficeProvider.class)));
Postoffice postoffice = provider.get();
// cache should be a singleton
assertThat(postoffice, sameInstance(provider.get()));
assertThat(postoffice, sameInstance(injector.getInstance(Postoffice.class)));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class PostofficeProviderTest method missingImplementationThrowsExceptionOnUseNotCreate.
@Test
public void missingImplementationThrowsExceptionOnUseNotCreate() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(PostofficeConstant.postofficeImplementation, "not_existing_implementation");
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
Provider<Postoffice> provider = injector.getProvider(Postoffice.class);
// this will not work => we expect a runtime exception...
thrown.expect(RuntimeException.class);
Postoffice postoffice = injector.getInstance(Postoffice.class);
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class MigrationEngineProviderTest method defaultImplementation.
@Test
public void defaultImplementation() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty(NinjaConstant.MIGRATION_ENGINE_IMPLEMENTATION, null);
Injector injector = Guice.createInjector(new BaseAndClassicModules(ninjaProperties));
Provider<MigrationEngine> provider = injector.getProvider(MigrationEngine.class);
assertThat(provider.get(), instanceOf(MigrationEngineFlyway.class));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class ControllerMethodInvokerTest 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);
}
Aggregations