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);
}
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);
}
}
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);
}
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);
}
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());
}
Aggregations