Example usage for java.lang System setOut

List of usage examples for java.lang System setOut

Introduction

In this page you can find the example usage for java.lang System setOut.

Prototype

public static void setOut(PrintStream out) 

Source Link

Document

Reassigns the "standard" output stream.

Usage

From source file:org.apache.tika.cli.TikaCLIBatchIntegrationTest.java

@After
public void tearDown() throws Exception {
    System.setOut(new PrintStream(out, true, UTF_8.name()));
    System.setErr(new PrintStream(err, true, UTF_8.name()));
    //TODO: refactor to use our deleteDirectory with straight path
    FileUtils.deleteDirectory(tempOutputDir.toFile());
}

From source file:org.apache.hadoop.hbase.backup.TestBackupStatusProgress.java

@Test
public void testBackupStatusProgressCommand() throws Exception {

    LOG.info("test backup status/progress on a single table with data: command-line");

    List<TableName> tableList = Lists.newArrayList(table1);
    String backupId = fullTableBackup(tableList);
    LOG.info("backup complete");
    assertTrue(checkSucceeded(backupId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    System.setOut(new PrintStream(baos));

    String[] args = new String[] { "describe", backupId };
    int ret = ToolRunner.run(conf1, new BackupDriver(), args);
    assertTrue(ret == 0);// w w  w .ja v a2 s  .co m
    String responce = baos.toString();
    assertTrue(responce.indexOf(backupId) > 0);
    assertTrue(responce.indexOf("COMPLETE") > 0);

    baos = new ByteArrayOutputStream();
    System.setOut(new PrintStream(baos));

    args = new String[] { "progress", backupId };
    ret = ToolRunner.run(conf1, new BackupDriver(), args);
    assertTrue(ret == 0);
    responce = baos.toString();
    assertTrue(responce.indexOf(backupId) >= 0);
    assertTrue(responce.indexOf("progress") > 0);
    assertTrue(responce.indexOf("100") > 0);

}

From source file:org.apache.hadoop.mapreduce.TestMRJobClient.java

public static int runTool(Configuration conf, Tool tool, String[] args, OutputStream out) throws Exception {
    PrintStream oldOut = System.out;
    PrintStream newOut = new PrintStream(out, true);
    try {/*from   ww w  . j  av  a 2  s  .c om*/
        System.setOut(newOut);
        return ToolRunner.run(conf, tool, args);
    } finally {
        System.setOut(oldOut);
    }
}

From source file:ai.grakn.test.graql.shell.GraqlShellIT.java

@AfterClass
public static void resetIO() {
    System.setIn(trueIn);
    System.setOut(trueOut);
    System.setErr(trueErr);
}

From source file:org.eclipse.gemini.blueprint.util.SimpleLoggerTest.java

protected void tearDown() throws Exception {
    System.setErr(null);
    System.setOut(null);
    simpleLogger = null;
    object = null;
    throwable = null;
}

From source file:org.echocat.jomon.maven.boot.ArtifactFactory.java

private static void hackToPreventUselessWagonDebugOutputOnStdout() {
    try {/*from   www . ja  v  a  2s.c  o  m*/
        // noinspection UseOfSystemOutOrSystemErr
        final PrintStream old = System.out;
        try {
            System.setOut(new PrintStream(new ByteArrayOutputStream()));
            new AbstractHttpClientWagon() {
            };
        } finally {
            System.setOut(old);
        }
    } catch (final Exception ignored) {
    }
}

From source file:org.arquillian.spacelift.task.os.ProcessNameTest.java

@Test
public void outputNoPrefix() throws UnsupportedEncodingException {

    // run only on linux
    Assume.assumeThat(SystemUtils.IS_OS_LINUX, is(true));

    final ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
    System.setOut(new PrintStream(errorOutput));
    exception = ExpectedException.none();

    try {//from ww  w .j  ava  2s . c  o  m
        exception.expectMessage(containsString("java -bar -baz"));

        Spacelift.task(CommandTool.class).programName("java").parameters("-bar", "-baz")
                .interaction(new ProcessInteractionBuilder().outputPrefix("").when(".*").printToOut()).execute()
                .await();
    } catch (ExecutionException e) {
        // ignore
    }
    String output = errorOutput.toString(Charset.defaultCharset().name());
    Assert.assertThat(output, startsWith("Unrecognized option: -bar"));
}

From source file:org.meresco.triplestore.TransactionLogTest.java

@Before
public void setUp() throws Exception {
    tempdir = createTempDirectory();// w w  w .j av  a2s.  c o m
    stdout = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(stdout);
    orig_stdout = System.out;
    System.setOut(ps);
    setTransactionLog();
}

From source file:org.apache.hive.hplsql.TestHplsqlOffline.java

/**
 * Run a test file/*from   w  w  w .j av  a2  s .  c  o m*/
 */
void run(String testFile) throws Exception {
    System.setOut(new PrintStream(out));
    Exec exec = new Exec();
    String[] args = { "-f", "src/test/queries/offline/" + testFile + ".sql", "-trace", "-offline" };
    exec.run(args);
    String s = getTestOutput(out.toString()).trim();
    FileUtils.writeStringToFile(new java.io.File("target/tmp/log/" + testFile + ".out.txt"), s);
    String t = FileUtils
            .readFileToString(new java.io.File("src/test/results/offline/" + testFile + ".out.txt"), "utf-8")
            .trim();
    System.setOut(null);
    Assert.assertEquals(s, t);
}

From source file:org.apache.tika.cli.TikaCLIIT.java

@Before
public void setUp() throws Exception {
    builder = new ProcessBuilder();
    builder.directory(new File("target"));
    outContent = new ByteArrayOutputStream();
    errContent = new ByteArrayOutputStream();
    resourcePrefix = testInputDir.toAbsolutePath().toString() + "/";
    stdout = System.out;// w ww .  ja v a  2 s .c  o  m
    errout = System.err;
    System.setOut(new PrintStream(outContent, true, UTF_8.name()));
    System.setErr(new PrintStream(errContent, true, UTF_8.name()));
}