Search in sources :

Example 11 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testLocalObject1.

public void testLocalObject1() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.LOCAL);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    Object1 obj1 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj1);
    Object1 obj2 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj2);
    // $NON-NLS-1$
    assertTrue("Objects are same", obj1 != obj2);
    Object1 obj3 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertTrue("Objects are same", obj1 != obj3);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)

Example 12 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testNoCreator.

public void testNoCreator() {
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    try {
        factory.get(Object1.class, session1);
        // $NON-NLS-1$
        assertFalse("exception expected", true);
    } catch (ObjectFactoryException e) {
        // $NON-NLS-1$
        assertTrue("exception expected", true);
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)

Example 13 with StandaloneObjectFactory

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

the class SimpleOutputHandlerTest method testGetOutputContentItemObjectNameImportant.

public void testGetOutputContentItemObjectNameImportant() throws Exception {
    OutputStream out = new ByteArrayOutputStream();
    TestOutputHandler.contentItem = new SimpleContentItem(out);
    SimpleOutputHandler handler = new SimpleOutputHandler(out, false);
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject("contentrepo", TestOutputHandler.class.getName(), StandaloneObjectFactory.Scope.GLOBAL);
    PentahoSystem.registerObjectFactory(factory);
    IContentItem contentItem = handler.getOutputContentItem("contentrepo", "myreport:contentrepo", null, null);
    assertNotNull(contentItem);
    assertEquals(out, contentItem.getOutputStream(null));
    contentItem = handler.getOutputContentItem("", "myreport:contentrepo", null, null);
    assertNull(contentItem);
}
Also used : SimpleContentItem(org.pentaho.platform.engine.core.output.SimpleContentItem) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory) IContentItem(org.pentaho.platform.api.repository.IContentItem) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 14 with StandaloneObjectFactory

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

the class AuditHelperTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    session = new StandaloneSession(SESSION_NAME);
    factory = new StandaloneObjectFactory();
    PentahoSystem.registerObjectFactory(factory);
    factory.defineObject(IAuditEntry.class.getSimpleName(), TestAuditEntry.class.getName(), StandaloneObjectFactory.Scope.GLOBAL);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory) IAuditEntry(org.pentaho.platform.api.engine.IAuditEntry) Before(org.junit.Before)

Example 15 with StandaloneObjectFactory

use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory 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)

Aggregations

StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)27 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)18 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)7 SimpleContentItem (org.pentaho.platform.engine.core.output.SimpleContentItem)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 IAuditEntry (org.pentaho.platform.api.engine.IAuditEntry)2 IContentItem (org.pentaho.platform.api.repository.IContentItem)2 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)2 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 Before (org.junit.Before)1 Test (org.junit.Test)1 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)1 AuditEntry (org.pentaho.platform.engine.core.audit.AuditEntry)1 AuditHelper (org.pentaho.platform.engine.core.audit.AuditHelper)1 MessageTypes (org.pentaho.platform.engine.core.audit.MessageTypes)1 NullAuditEntry (org.pentaho.platform.engine.core.audit.NullAuditEntry)1 BufferedContentItem (org.pentaho.platform.engine.core.output.BufferedContentItem)1