use of org.pentaho.platform.engine.core.output.MultiOutputStream in project pentaho-platform by pentaho.
the class CommandLineProcessorTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
OutputStream multiOut = new MultiOutputStream(new OutputStream[] { CONSOLE_BUFFER, CONSOLE_OUT });
PrintStream ps = new PrintStream(multiOut);
System.setOut(ps);
MockUp<CommandLineProcessor> mock = new MockUp<CommandLineProcessor>() {
@Mock
public void $init(String[] args) {
}
};
clpMock = new CommandLineProcessor(null);
mock.tearDown();
}
use of org.pentaho.platform.engine.core.output.MultiOutputStream in project pentaho-platform by pentaho.
the class OutputTest method testMultiStreamErrors.
public void testMultiStreamErrors() {
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
MockExceptionOutputStream out2 = new MockExceptionOutputStream();
ByteArrayOutputStream out3 = new ByteArrayOutputStream();
OutputStream[] outs = new OutputStream[] { out1, out2, out3 };
MultiOutputStream multi = new MultiOutputStream(outs);
byte[] in = "abcd".getBytes();
String outStr1 = "";
String outStr2 = "";
try {
multi.write('a');
} catch (IOException e) {
// we expect to get here
assertEquals("IOException", "Test Exception", e.getMessage());
}
try {
multi.write(in, 1, 2);
} catch (IOException e) {
// we expect to get here
assertEquals("IOException", "Test Exception", e.getMessage());
}
try {
multi.write(in);
} catch (IOException e) {
// we expect to get here
assertEquals("IOException", "Test Exception", e.getMessage());
}
try {
multi.close();
} catch (IOException e) {
// we expect to get here
assertEquals("IOException", "Test Exception", e.getMessage());
}
outStr1 = new String(out1.toByteArray());
outStr2 = new String(out3.toByteArray());
assertEquals("Output stream 1", "abcabcd", outStr1);
assertEquals("Output stream 2", "abcabcd", outStr2);
}
use of org.pentaho.platform.engine.core.output.MultiOutputStream in project pentaho-platform by pentaho.
the class OutputTest method testMultiStream.
public void testMultiStream() {
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
ByteArrayOutputStream[] outs = new ByteArrayOutputStream[] { out1, out2 };
MultiOutputStream multi = new MultiOutputStream(outs);
byte[] in = "abcd".getBytes();
String outStr1 = "";
String outStr2 = "";
try {
multi.write('a');
multi.write(in, 1, 2);
multi.write(in);
multi.close();
} catch (IOException e) {
// we should not get here
assertEquals("IOException", null, e);
}
outStr1 = new String(out1.toByteArray());
outStr2 = new String(out2.toByteArray());
assertEquals("Output stream 1", "abcabcd", outStr1);
assertEquals("Output stream 2", "abcabcd", outStr2);
}
Aggregations