Search in sources :

Example 1 with AggregateObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.

the class AggregateObjectFactoryTest method testCombined.

@Test
public void testCombined() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/solution/system/pentahoObjects.spring.xml");
    factory.init(null, context);
    StandaloneSpringPentahoObjectFactory factory2 = new StandaloneSpringPentahoObjectFactory();
    factory2.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
    StandaloneObjectFactory factory3 = new StandaloneObjectFactory();
    factory3.init(null, null);
    factory3.defineObject("MimeTypeListener", MimeTypeListener.class.getName(), IPentahoDefinableObjectFactory.Scope.GLOBAL);
    AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
    aggFactory.registerObjectFactory(factory3);
    List<MimeTypeListener> mimes = aggFactory.getAll(MimeTypeListener.class, session);
    assertEquals(6, mimes.size());
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory) 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 2 with AggregateObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.

the class AggregateObjectFactoryTest method testRegistration.

/**
 * Two Spring PentahoObjectFactories with the same underlying applicationContext should not be registered twice. This
 * case tests that the AggregateObjectFactory's set implementation is working properly.
 *
 * @throws Exception
 */
@Test
public void testRegistration() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/solution/system/pentahoObjects.spring.xml");
    factory.init(null, context);
    StandaloneSpringPentahoObjectFactory factory2 = new StandaloneSpringPentahoObjectFactory();
    factory2.init(null, context);
    AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
    aggFactory.registerObjectFactory(factory);
    aggFactory.registerObjectFactory(factory2);
    List<MimeTypeListener> mimes = aggFactory.getAll(MimeTypeListener.class, session);
    assertEquals(5, mimes.size());
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) 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 3 with AggregateObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.

the class AggregateObjectFactoryTest method testRegisteredButNotPublishingAnythingApplicationContext.

/**
 * Two Spring PentahoObjectFactories with the same underlying applicationContext should not be registered twice. This
 * case tests that the AggregateObjectFactory's set implementation is working properly.
 *
 * @throws Exception
 */
@Test
public void testRegisteredButNotPublishingAnythingApplicationContext() throws Exception {
    PublishedBeanRegistry.reset();
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/solution/system/registeredButNotPublishing.spring.xml");
    // this was causing an exception.
    factory.init(null, context);
    AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
    aggFactory.registerObjectFactory(factory);
    assertEquals(0, PublishedBeanRegistry.getRegisteredFactories().size());
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) FileSystemXmlApplicationContext(org.springframework.context.support.FileSystemXmlApplicationContext) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory) Test(org.junit.Test)

Example 4 with AggregateObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.

the class PentahoOSGIActivatorTest method testActivation.

@Test
public void testActivation() throws Exception {
    AggregateObjectFactory agg = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
    int originalSize = agg.getFactories().size();
    BundleContext context = Mockito.mock(BundleContext.class);
    PentahoOSGIActivator activator = new PentahoOSGIActivator();
    activator.setBundleContext(context);
    assertEquals(1, agg.getFactories().size() - originalSize);
// assertTrue( agg.getFactories()
// .toArray( new IPentahoObjectFactory[ agg.getFactories().size() ] )[ 1 ] instanceof OSGIObjectFactory );
}
Also used : AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 5 with AggregateObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory in project pentaho-platform by pentaho.

the class AggregateObjectFactoryTest method testByKey.

@Test
public void testByKey() throws Exception {
    StandaloneSession session = new StandaloneSession();
    StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
    factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
    AggregateObjectFactory aggFactory = new AggregateObjectFactory();
    aggFactory.registerObjectFactory(factory);
    GoodObject info = aggFactory.get(GoodObject.class, "GoodObject", session);
    assertNotNull(info);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) AggregateObjectFactory(org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory) Test(org.junit.Test)

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