List of usage examples for java.lang System setOut
public static void setOut(PrintStream out)
From source file:cz.muni.fi.mir.mathmlunificator.MathMLUnificatorCommandLineToolTest.java
@Test public void testMain_multiple_formulae_non_operators() throws Exception { String testFile = "multiple-formulae"; String[] argv = { getTestResourceAsFilepath(testFile + ".input.xml") }; ByteArrayOutputStream stdoutContent = new ByteArrayOutputStream(); PrintStream stdout = System.out; System.setOut(new PrintStream(stdoutContent)); MathMLUnificatorCommandLineTool.main(argv); System.setOut(stdout);//w ww .j a v a 2 s . c o m String output = stdoutContent.toString(StandardCharsets.UTF_8.toString()); System.out.println("testMain_multiple_formulae_non_operators non-operators output:\n" + output); assertEquals( IOUtils.toString(getExpectedXMLTestResource(testFile + ".non-operator"), StandardCharsets.UTF_8), output); }
From source file:org.moe.cli.ParameterParserTest.java
@BeforeClass public static void init() { out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); err = new ByteArrayOutputStream(); System.setErr(new PrintStream(err)); }
From source file:javancss.JavancssTest.java
private Javancss measureWithArgs(String[] args) throws IOException { // turn stdout off PrintStream psStdout = System.out; try {//www . ja v a 2 s . c om System.setOut(new PrintStream(new ByteArrayOutputStream())); return new Javancss(args); } finally { // turn stdout back on System.setOut(psStdout); } }
From source file:org.apache.maven.index.cli.NexusIndexerCliTest.java
@Override protected void setUp() throws Exception { super.setUp(); cli = new NexusIndexerCli(); System.setOut(new PrintStream(out)); System.setErr(new PrintStream(out)); }
From source file:org.apache.kylin.tool.KylinConfigCLITest.java
@Test public void testGetProperty() throws IOException { PrintStream o = System.out; File f = File.createTempFile("cfg", ".tmp"); PrintStream tmpOut = new PrintStream(new FileOutputStream(f)); System.setOut(tmpOut); KylinConfigCLI.main(new String[] { "kylin.storage.url" }); String val = FileUtils.readFileToString(f, Charset.defaultCharset()).trim(); assertEquals("hbase", val); tmpOut.close();//from w w w .j a va2s .c o m FileUtils.forceDelete(f); System.setOut(o); }
From source file:org.apache.wiki.util.CryptoUtilTest.java
public void testCommandLineHash() throws Exception { // Save old printstream PrintStream oldOut = System.out; // Swallow System out and get command output OutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); CryptoUtil.main(new String[] { "--hash", "password" }); String output = new String(out.toString()); // Restore old printstream System.setOut(oldOut);//from w w w. j a va 2 s. com // Run our tests assertTrue(output.startsWith("{SSHA}")); }
From source file:org.apache.geronimo.gshell.io.StreamPair.java
/** * Install the given stream pair as the System streams. *//* ww w . j av a 2 s. c om*/ public static void system(final StreamPair streams) { assert streams != null; System.setOut(streams.out); System.setErr(streams.err); }
From source file:org.apache.metron.dataloads.bulk.ElasticsearchDataPrunerRunnerTest.java
@Before public void setUp() { options = ElasticsearchDataPrunerRunner.buildOptions(); help = new Options(); Option o = new Option("h", "help", false, "This screen"); o.setRequired(false);// ww w.j a v a 2 s . c o m help.addOption(o); outContent = new ByteArrayOutputStream(); errContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); }
From source file:org.g_node.srv.CtrlCheckServiceTest.java
/** * Create a test folder and the main test file in the java temp directory. * @throws Exception//from w ww . j ava2 s .c o m */ @Before public void setUp() throws Exception { this.stdout = System.out; this.outStream = new ByteArrayOutputStream(); System.setOut(new PrintStream(this.outStream)); final File currTestFile = this.testFileFolder.resolve(this.testFileName).toFile(); FileUtils.write(currTestFile, "This is a normal test file"); }
From source file:org.datacleaner.job.runner.ErrorAwareAnalysisListenerTest.java
@Override protected void setUp() throws Exception { super.setUp(); // the logging config of this project logs to system out. to get those // log messages, we replace System.out baos = new ByteArrayOutputStream(); oldOut = System.out;//from w w w . j a v a 2 s. co m newOut = new PrintStream(baos); System.setOut(newOut); DOMConfigurator.configure("src/test/resources/log4j.xml"); }