Search in sources :

Example 26 with StandaloneSpringPentahoObjectFactory

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

Example 27 with StandaloneSpringPentahoObjectFactory

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

Example 28 with StandaloneSpringPentahoObjectFactory

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

Example 29 with StandaloneSpringPentahoObjectFactory

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

Example 30 with StandaloneSpringPentahoObjectFactory

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);
}
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) Test(org.junit.Test)

Aggregations

StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)35 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)10 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)9 Test (org.junit.Test)8 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)8 PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)7 File (java.io.File)5 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)5 AggregateObjectFactory (org.pentaho.platform.engine.core.system.objfac.AggregateObjectFactory)5 HashMap (java.util.HashMap)3 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)3 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)3 ApplicationContext (org.springframework.context.ApplicationContext)3 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)3 FileSystemXmlApplicationContext (org.springframework.context.support.FileSystemXmlApplicationContext)3 BeforeClass (org.junit.BeforeClass)2 IPentahoObjectRegistration (org.pentaho.platform.api.engine.IPentahoObjectRegistration)2 IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)2 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)2