Search in sources :

Example 21 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testImplementingClass.

public void testImplementingClass() throws Exception {
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.GLOBAL);
    // $NON-NLS-1$ //$NON-NLS-2$
    factory.defineObject("bogus2", "bogus", Scope.GLOBAL);
    Object1 obj = factory.get(Object1.class, session1);
    assertNotNull(obj);
    assertEquals(Object1.class.getName(), factory.getImplementingClass(Object1.class.getSimpleName()).getName());
}
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 22 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testThreadObjectFail1.

public void testThreadObjectFail1() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    // $NON-NLS-1$
    factory.defineObject(Object1.class.getSimpleName(), "bogus", Scope.THREAD);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    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 23 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testGlobalObjectFail2.

public void testGlobalObjectFail2() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object2.class.getSimpleName(), Object2.class.getName(), Scope.GLOBAL, null);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    try {
        factory.get(Object2.class, session1);
        // $NON-NLS-1$
        assertTrue("Exception expected", false);
    } catch (NullPointerException e) {
        // $NON-NLS-1$
        assertFalse("Exception expected", false);
    }
}
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 24 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testInit.

public void testInit() throws Exception {
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.GLOBAL);
    // $NON-NLS-1$
    assertTrue("Object is not defined", factory.objectDefined(Object1.class.getSimpleName()));
    Object1 obj1 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj1);
    factory.init(null, null);
    // $NON-NLS-1$
    assertFalse("Object is defined", factory.objectDefined(Object1.class.getSimpleName()));
    assertNull(factory.getImplementingClass(Object1.class.getSimpleName()));
    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 25 with StandaloneObjectFactory

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

the class StandaloneObjectFactoryTest method testSessionObjectFail1.

public void testSessionObjectFail1() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    // $NON-NLS-1$
    factory.defineObject(Object1.class.getSimpleName(), "bogus", Scope.SESSION);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    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)

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