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());
}
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());
}
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());
}
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 );
}
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);
}
Aggregations