use of ninja.cache.Cache 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"));
}
}
use of ninja.cache.Cache in project ninja by ninjaframework.
the class NinjaClassicModule method configure.
@Override
public void configure() {
// NOTE: these are grouped to line up with third-party dependencies
// (e.g. jackson supports templates & body parsers)
// Text & post require no 3rd party libs
bind(TemplateEngineText.class);
bind(BodyParserEnginePost.class);
// Freemarker
if (freemarker) {
bind(TemplateEngineFreemarker.class);
}
// Jackson json support
if (json) {
OptionalBinder.newOptionalBinder(binder(), ObjectMapper.class).setDefault().toProvider(ObjectMapperProvider.class).in(Singleton.class);
bind(TemplateEngineJson.class);
bind(TemplateEngineJsonP.class);
bind(BodyParserEngineJson.class);
}
// Jackson xml support
if (xml) {
OptionalBinder.newOptionalBinder(binder(), XmlMapper.class).setDefault().toProvider(XmlMapperProvider.class).in(Singleton.class);
bind(TemplateEngineXml.class);
bind(BodyParserEngineXml.class);
}
// Postoffice
if (postoffice) {
bind(Postoffice.class).toProvider(PostofficeProvider.class);
}
// Cache
if (cache) {
bind(Cache.class).toProvider(CacheProvider.class);
}
// Migrations
if (migrations) {
bind(MigrationEngine.class).toProvider(MigrationEngineProvider.class);
bind(MigrationInitializer.class).asEagerSingleton();
}
// JPA
if (jpa) {
install(new JpaModule(ninjaProperties));
}
}
Aggregations