use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class StandaloneSpringPentahoObjectFactoryTest method testInitFromXml.
public void testInitFromXml() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSession session2 = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
GoodObject goodObject = factory.get(GoodObject.class, session);
assertNotNull(goodObject);
try {
factory.get(BadObject.class, null);
assertFalse(true);
} catch (ObjectFactoryException e) {
// ignored
}
GoodObject goodObject1 = factory.get(GoodObject.class, session);
GoodObject goodObject2 = factory.get(GoodObject.class, session);
assertEquals(goodObject1, goodObject2);
assertEquals(session, goodObject1.initSession);
GoodObject goodObject3 = factory.get(GoodObject.class, session2);
assertNotSame(goodObject1, goodObject3);
assertEquals(session2, goodObject3.initSession);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class StandaloneSpringPentahoObjectFactoryTest method testBadInit.
public void testBadInit() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
try {
factory.init(null, "bogus");
assertFalse(true);
} catch (IllegalArgumentException e) {
assertTrue(true);
}
try {
GoodObject obj = factory.get(GoodObject.class, session);
assertNotNull(obj);
assertFalse(true);
} catch (ObjectFactoryException e) {
assertTrue(true);
}
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class StandaloneSpringPentahoObjectFactoryTest method testSessionProperties.
public void testSessionProperties() throws Exception {
StandaloneSession session = new StandaloneSession();
PentahoSessionHolder.setSession(session);
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
PentahoSystem.registerObjectFactory(factory);
IContentInfo obj = PentahoSystem.get(IContentInfo.class, session);
assertEquals("Test Session", obj.getTitle());
IContentInfo obj_again = PentahoSystem.get(IContentInfo.class, session);
assertSame(obj_again, obj);
session = new StandaloneSession();
PentahoSessionHolder.setSession(session);
IContentInfo obj_newer = PentahoSystem.get(IContentInfo.class, session);
assertNotSame(obj, obj_newer);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class ApplicationContextPentahoSystemRegisterer method setApplicationContext.
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
safeAddBeanScopePostProcessors(applicationContext);
StandaloneSpringPentahoObjectFactory objFact = StandaloneSpringPentahoObjectFactory.getInstance(applicationContext);
PentahoSystem.registerObjectFactory(objFact);
PublishedBeanRegistry.registerFactory(applicationContext);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class AggregateObjectFactoryTest method testRePublishAttributes.
@Test
public void testRePublishAttributes() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
factory.init("src/test/resources/solution/system/republish.spring.xml", null);
PentahoSystem.registerObjectFactory(factory);
MimeTypeListener republished = PentahoSystem.get(MimeTypeListener.class, session, Collections.singletonMap("someKey", "someValue"));
assertNotNull(republished);
assertEquals("Higher Priority MimeTypeListener", republished.name);
}
Aggregations