use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.
the class AggregateObjectFactoryTest method testGetById.
@Test
public void testGetById() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
MimeTypeListener info = aggFactory.get(MimeTypeListener.class, session, Collections.singletonMap("id", "someID"));
assertNotNull(info);
}
use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.
the class SessionCachingMetadataDomainRepositoryIT method testCannotCreateCache.
public void testCannotCreateCache() throws Exception {
SimpleObjectFactory factory = new SimpleObjectFactory();
// $NON-NLS-1$
factory.defineObject("ICacheManager", MockDisabledCacheManager.class.getName());
// Swap in an object factory with a cache manager that doesn't allow creating new caches
Set<IPentahoObjectFactory> facts = ((AggregateObjectFactory) PentahoSystem.getObjectFactory()).getFactories();
PentahoSystem.clearObjectFactory();
PentahoSystem.registerObjectFactory(factory);
try {
try {
new SessionCachingMetadataDomainRepository(new MockSessionAwareMetadataDomainRepository());
// $NON-NLS-1$
fail("Should not be able to create a Session Caching Repository without an enabled cache");
} catch (IllegalStateException ex) {
// $NON-NLS-1$
assertTrue(ex.getMessage().contains("cannot be initialized"));
// expected
}
} finally {
// Replace the original object factory so the rest of the tests work
PentahoSystem.clearObjectFactory();
for (IPentahoObjectFactory fact : facts) {
PentahoSystem.registerObjectFactory(fact);
}
}
}
Aggregations