use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class BaseTest method getOutputHandler.
public IOutputHandler getOutputHandler(OutputStream stream) {
SimpleOutputHandler outputHandler = new SimpleOutputHandler(stream, false);
outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
return outputHandler;
}
use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class BaseTest method getOutputHandler.
public IOutputHandler getOutputHandler(IContentItem contentItem) {
SimpleOutputHandler outputHandler = new SimpleOutputHandler(contentItem, false);
outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
return outputHandler;
}
use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class SimpleOutputHandlerTest method test2.
public void test2() throws Exception {
StandaloneSession session = new StandaloneSession();
OutputStream out = new MockExceptionOutputStream();
IContentItem content = new SimpleContentItem(out);
SimpleOutputHandler handler = new SimpleOutputHandler(content, true);
assertTrue(handler.allowFeedback());
assertFalse(handler.contentDone());
assertNotNull(handler.getFeedbackContentItem());
assertTrue(handler.contentDone());
IContentItem content2 = handler.getFeedbackContentItem();
assertEquals(content.getOutputStream(null), content2.getOutputStream(null));
IContentItem content3 = new BufferedContentItem(null);
content3.getOutputStream(null).write("test data".getBytes());
content3.closeOutputStream();
try {
handler.setOutput(IOutputHandler.CONTENT, content3);
fail("Exception not detected.");
} catch (Exception ex) {
// Test passed.
}
}
use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class SimpleOutputHandlerTest method test4.
public void test4() throws Exception {
StandaloneSession session = new StandaloneSession();
OutputStream out = new ByteArrayOutputStream();
SimpleOutputHandler handler = new SimpleOutputHandler(out, true);
assertTrue(handler.allowFeedback());
assertNotNull(handler.getFeedbackContentItem());
IContentItem content2 = handler.getFeedbackContentItem();
assertEquals(out, content2.getOutputStream(null));
OutputStream out3 = new ByteArrayOutputStream();
handler.setOutputStream(out3, IOutputHandler.RESPONSE, IOutputHandler.CONTENT);
IContentItem content3 = handler.getOutputContentItem(IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null);
assertEquals(out3, content3.getOutputStream(null));
}
use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.
the class SimpleOutputHandlerTest method test1.
public void test1() throws Exception {
StandaloneObjectFactory factory = new StandaloneObjectFactory();
TestOutputHandler.contentItem = new SimpleContentItem();
factory.defineObject("testoutut", TestOutputHandler.class.getName(), StandaloneObjectFactory.Scope.LOCAL);
PentahoSystem.registerObjectFactory(factory);
StandaloneSession session = new StandaloneSession();
ByteArrayOutputStream out = new ByteArrayOutputStream();
SimpleOutputHandler handler = new SimpleOutputHandler(out, false);
MimeTypeListener listener = new MimeTypeListener();
handler.setMimeTypeListener(listener);
assertEquals(listener, handler.getMimeTypeListener());
assertFalse(handler.allowFeedback());
handler.setSession(session);
assertEquals(session, handler.getSession());
handler.setContentItem(new SimpleContentItem(), null, null);
IContentItem content2 = handler.getOutputContentItem("bogus", "testoutut:bogus", null, null);
assertEquals(TestOutputHandler.contentItem, content2);
content2 = handler.getOutputContentItem("bogus", "bogus", null, null);
assertNull(content2);
content2 = handler.getOutputContentItem(IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null);
assertEquals(out, content2.getOutputStream(null));
assertFalse(handler.contentDone());
assertNull(handler.getFeedbackContentItem());
assertFalse(handler.contentDone());
handler.setOutputPreference(-1);
assertEquals(-1, handler.getOutputPreference());
handler.setMimeType("test/test");
assertEquals("test/test", handler.getMimeType());
handler.setOutput("bogus", null);
handler.setOutput("file:bogus", null);
IContentItem content3 = new BufferedContentItem(null);
OutputStream os = content3.getOutputStream(null);
os.write("test data".getBytes());
content3.closeOutputStream();
handler.setOutput(IOutputHandler.CONTENT, content3);
assertEquals("test data", new String(out.toByteArray()));
handler.setOutput(IOutputHandler.CONTENT, "+test data2");
assertEquals("test data+test data2", new String(out.toByteArray()));
}
Aggregations