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);
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class ApplicationControllerTest method testRouteOrdering.
@Test
public void testRouteOrdering() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
Provider<RouteBuilderImpl> routeBuilderImplProvider = Mockito.mock(Provider.class);
when(routeBuilderImplProvider.get()).thenAnswer((invocation) -> new RouteBuilderImpl(ninjaProperties, ninjaBaseDirectoryResolver));
RouterImpl router = new RouterImpl(injector, ninjaProperties, routeBuilderImplProvider);
Routes routes = new Routes(ninjaProperties);
routes.init(router);
router.compileRoutes();
Route route0 = router.getRoutes().get(0);
Assert.assertThat(route0.getUri(), CoreMatchers.equalTo("/base/middle/app/get"));
Route route8 = router.getRoutes().get(8);
Assert.assertThat(route8.getUri(), CoreMatchers.equalTo("/base/middle/app/put"));
Route route16 = router.getRoutes().get(16);
Assert.assertThat(route16.getUri(), CoreMatchers.equalTo("/base/middle/app/post"));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class ApplicationControllerTest method testHasKeyedRoute.
@Test
public void testHasKeyedRoute() {
NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(NinjaMode.test);
ninjaProperties.setProperty("testkey", "true");
Provider<RouteBuilderImpl> routeBuilderImplProvider = Mockito.mock(Provider.class);
when(routeBuilderImplProvider.get()).thenAnswer((invocation) -> new RouteBuilderImpl(ninjaProperties, ninjaBaseDirectoryResolver));
RouterImpl router = new RouterImpl(injector, ninjaProperties, routeBuilderImplProvider);
Routes routes = new Routes(ninjaProperties);
routes.init(router);
router.compileRoutes();
String route = router.getReverseRoute(ApplicationController.class, "testKeyedRoute");
Assert.assertThat(route, CoreMatchers.equalTo("/base/middle/app/keyTest"));
}
use of ninja.utils.NinjaPropertiesImpl in project ninja by ninjaframework.
the class BootstrapTest method frameworkModuleSkipsNinjaClassicModule.
@Test
public void frameworkModuleSkipsNinjaClassicModule() {
ninjaPropertiesImpl = Mockito.spy(new NinjaPropertiesImpl(NinjaMode.test));
Mockito.when(ninjaPropertiesImpl.get(NinjaConstant.APPLICATION_MODULES_BASE_PACKAGE)).thenReturn("com.example.frameworkmodule");
Bootstrap bootstrap = new Bootstrap(ninjaPropertiesImpl);
bootstrap.boot();
try {
Cache cache = bootstrap.getInjector().getInstance(Cache.class);
fail("cache should not have been found");
} catch (Exception e) {
assertThat(e.getMessage(), containsString("No implementation for ninja.cache.Cache was bound"));
}
}
Aggregations