Search in sources :

Example 51 with IPentahoSession

use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testThreadObject1.

public void testThreadObject1() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.THREAD);
    // $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 not same", obj1 == obj2);
    Object1 obj3 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertTrue("Objects are not 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 52 with IPentahoSession

use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testBadScope.

public void testBadScope() throws Exception {
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), null);
    Object obj = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertNull("object should be null", obj);
}
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 53 with IPentahoSession

use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testGlobalObject2.

public void testGlobalObject2() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object2.class.getSimpleName(), Object2.class.getName(), Scope.GLOBAL);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    // $NON-NLS-1$
    IPentahoSession session2 = new StandaloneSession("test user 2");
    Object2 obj1 = factory.get(Object2.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj1);
    Object2 obj2 = factory.get(Object2.class, session2);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj2);
    // $NON-NLS-1$
    assertTrue("Objects are not same", obj1 == obj2);
}
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 54 with IPentahoSession

use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testLocalObjectFail1.

public void testLocalObjectFail1() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    // $NON-NLS-1$
    factory.defineObject(Object1.class.getSimpleName(), "bogus", Scope.LOCAL);
    // $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 55 with IPentahoSession

use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testSessionObject2.

public void testSessionObject2() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object2.class.getSimpleName(), Object2.class.getName(), Scope.SESSION);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    // $NON-NLS-1$
    IPentahoSession session2 = new StandaloneSession("test user 2");
    Object2 obj1 = factory.get(Object2.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj1);
    Object2 obj2 = factory.get(Object2.class, session2);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj2);
    // $NON-NLS-1$
    assertTrue("Objects are same", obj1 != obj2);
}
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)

Aggregations

IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)231 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)76 Test (org.junit.Test)70 Matchers.anyString (org.mockito.Matchers.anyString)40 ArrayList (java.util.ArrayList)32 ITenant (org.pentaho.platform.api.mt.ITenant)22 IOException (java.io.IOException)20 StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)18 File (java.io.File)17 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)16 Before (org.junit.Before)14 OutputStream (java.io.OutputStream)13 HashMap (java.util.HashMap)13 InputStream (java.io.InputStream)12 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)12 ModelInfo (org.pentaho.platform.dataaccess.datasource.wizard.models.ModelInfo)12 Domain (org.pentaho.metadata.model.Domain)11 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)11 List (java.util.List)10 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)10