use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class StandaloneSpringPentahoObjectFactoryTest method testInitFromObject.
public void testInitFromObject() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
File f = new File("src/test/resources/solution/system/pentahoObjects.spring.xml");
FileSystemResource fsr = new FileSystemResource(f);
GenericApplicationContext appCtx = new GenericApplicationContext();
appCtx.refresh();
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
xmlReader.loadBeanDefinitions(fsr);
factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", appCtx);
GoodObject obj = factory.get(GoodObject.class, session);
assertNotNull(obj);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class StandaloneSpringPentahoObjectFactoryTest method testReferenceList.
public void testReferenceList() throws Exception {
PentahoSystem.shutdown();
StandaloneSession session = new StandaloneSession();
PentahoSessionHolder.setSession(session);
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
factory.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
PentahoSystem.registerObjectFactory(factory);
MimeListenerCollection collection = PentahoSystem.get(MimeListenerCollection.class, session);
assertNotNull(collection);
assertEquals(5, collection.getListeners().size());
// Highest priorty first?
assertEquals("Higher Priority MimeTypeListener", collection.getListeners().get(0).name);
// Queried list has only one match
assertEquals(1, collection.getQueriedList().size());
// queried list returned correct impl #3
assertEquals("Test Attr3", collection.getQueriedList().get(0).name);
// Check the bean that was injected is the highest priority one available.
assertEquals("Higher Priority MimeTypeListener", collection.getHighestListener().name);
// Check that the bean injected is based on the query for #2
assertEquals("Test Attr2", collection.getQueriedBean().name);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class PentahoSessionHolderTest method testStandaloneSessionLifecycle.
@Test
public void testStandaloneSessionLifecycle() {
PentahoSessionHolder.removeSession();
assertNull("session should be null at first", PentahoSessionHolder.getSession());
StandaloneSession session = new StandaloneSession();
PentahoSessionHolder.setSession(session);
assertSame("StandaloneSession was not set as the thread-bound session", session, PentahoSessionHolder.getSession());
PentahoSessionHolder.removeSession();
assertNull("session should be null after a remove", PentahoSessionHolder.getSession());
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class SimpleOutputHandlerTest method test3.
public void test3() throws Exception {
StandaloneSession session = new StandaloneSession();
OutputStream out = new MockExceptionOutputStream();
SimpleOutputHandler handler = new SimpleOutputHandler(out, false);
assertFalse(handler.allowFeedback());
handler.setSession(session);
assertEquals(session, handler.getSession());
IContentItem content2 = handler.getOutputContentItem(IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null);
assertEquals(out, content2.getOutputStream(null));
assertNull(handler.getFeedbackContentItem());
try {
handler.setOutput(IOutputHandler.CONTENT, "test data");
fail("Exception not detected.");
} catch (Exception ex) {
// Test passed.
}
}
use of org.pentaho.platform.engine.core.system.StandaloneSession 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);
}
Aggregations