use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory 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);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory 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);
}
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory 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);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory in project pentaho-platform by pentaho.
the class StandaloneObjectFactoryTest method testGlobalObject1.
public void testGlobalObject1() throws Exception {
StandaloneObjectFactory factory = new StandaloneObjectFactory();
factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.GLOBAL);
factory.defineObject(BadObjectRuntime.class.getSimpleName(), BadObjectRuntime.class.getName(), Scope.GLOBAL);
factory.defineObject(BadObject.class.getSimpleName(), BadObject.class.getName(), Scope.GLOBAL);
// $NON-NLS-1$
IPentahoSession session1 = new StandaloneSession("test user 1");
// $NON-NLS-1$
IPentahoSession session2 = new StandaloneSession("test user 2");
Object1 obj1 = factory.get(Object1.class, session1);
// $NON-NLS-1$
assertNotNull("Object is null", obj1);
Object1 obj2 = factory.get(Object1.class, session2);
// $NON-NLS-1$
assertNotNull("Object is null", obj2);
// $NON-NLS-1$
assertTrue("Objects are not same", obj1 == obj2);
try {
factory.get(BadObjectRuntime.class, session1);
assertFalse(true);
} catch (RuntimeException e) {
assertTrue(true);
}
try {
factory.get(BadObject.class, session1);
assertFalse(true);
} catch (ObjectFactoryException e) {
assertTrue(true);
}
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory in project pentaho-platform by pentaho.
the class StandaloneObjectFactoryTest method testSessionObjectFail2.
public void testSessionObjectFail2() throws Exception {
StandaloneObjectFactory factory = new StandaloneObjectFactory();
factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.SESSION);
try {
factory.get(Object1.class, null);
// $NON-NLS-1$
assertFalse("exception expected", true);
} catch (IllegalArgumentException e) {
// $NON-NLS-1$
assertTrue("exception expected", true);
}
}
Aggregations