Search in sources :

Example 6 with AggregateObjectFactory

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);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory) Test(org.junit.Test)

Example 7 with AggregateObjectFactory

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);
        }
    }
}
Also used : SimpleObjectFactory(org.pentaho.test.platform.engine.core.SimpleObjectFactory) IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) SessionCachingMetadataDomainRepository(org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository) AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory)

Aggregations

AggregateObjectFactory (org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory)7 Test (org.junit.Test)6 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)5 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)5 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)3 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)3 BundleContext (org.osgi.framework.BundleContext)1 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)1 StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)1 SessionCachingMetadataDomainRepository (org.pentaho.platform.plugin.services.metadata.SessionCachingMetadataDomainRepository)1 SimpleObjectFactory (org.pentaho.test.platform.engine.core.SimpleObjectFactory)1