Example usage for java.lang System setErr

List of usage examples for java.lang System setErr

Introduction

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

Prototype

public static void setErr(PrintStream err) 

Source Link

Document

Reassigns the "standard" error output stream.

Usage

From source file:com.yahoo.validatar.OutputCaptor.java

public static void redirectToStandard() {
    System.setOut(OUT);
    System.setErr(ERR);
}

From source file:org.apache.tika.parser.mock.MockParserTest.java

@Test
public void testExample() throws Exception {
    Metadata m = new Metadata();
    PrintStream out = System.out;
    PrintStream err = System.err;
    ByteArrayOutputStream outBos = new ByteArrayOutputStream();
    ByteArrayOutputStream errBos = new ByteArrayOutputStream();
    PrintStream tmpOut = new PrintStream(outBos, true, UTF_8.toString());
    PrintStream tmpErr = new PrintStream(errBos, true, UTF_8.toString());
    System.setOut(tmpOut);/*  w  w w . java  2  s  .  co m*/
    System.setErr(tmpErr);
    try {
        assertThrowable("example.xml", m, IOException.class, "not another IOException");
        assertMockParser(m);
    } finally {
        System.setOut(out);
        System.setErr(err);
    }
    String outString = new String(outBos.toByteArray(), UTF_8);
    assertContains("writing to System.out", outString);

    String errString = new String(errBos.toByteArray(), UTF_8);
    assertContains("writing to System.err", errString);

}

From source file:gov.nih.nci.ncicb.tcga.dcc.QCLiveTestDataGeneratorSlowTest.java

/**
 * Cleans up System.out and System.err print streams after each test
 */
@After
public void cleanUpStreams() {
    System.setOut(null);
    System.setErr(null);
}

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.apache.tika.cli.TikaCLIBatchIT.java

@Before
public void setup() throws Exception {
    builder = new ProcessBuilder();
    builder.directory(new File("target"));
    tempOutputDir = Files.createTempDirectory("tika-cli-test-batch-");
    ByteArrayOutputStream errBuffer = new ByteArrayOutputStream();
    outContent = new ByteArrayOutputStream();
    out = System.out;// w  w  w .  j  ava 2 s  .  c  o m
    err = System.err;

    PrintStream outWriter = new PrintStream(outContent, true, UTF_8.name());
    PrintStream errWriter = new PrintStream(errBuffer, true, UTF_8.name());

    System.setOut(outWriter);
    System.setErr(errWriter);
    testInputDirForCommandLine = testResourcesDir.toAbsolutePath().toString() + File.separator + "test-data";
    tempOutputDirForCommandLine = tempOutputDir.toAbsolutePath().toString();
}

From source file:org.xwiki.test.CaptureConsoleRunListener.java

@Override
public void testRunStarted(Description description) throws Exception {
    if (SKIP) {//from www  . j  a  va 2s.com
        return;
    }

    this.savedOut = System.out;
    this.savedErr = System.err;
    this.collectingContentStream = new ByteArrayOutputStream();

    // Capture stdout but continue sending data to it at the same time
    System.setOut(new PrintStream(new TeeOutputStream(this.collectingContentStream, this.savedOut)));

    // Capture stderr but continue sending data to it at the same time
    System.setErr(new PrintStream(new TeeOutputStream(this.collectingContentStream, this.savedErr)));
}

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:ai.grakn.test.graql.shell.GraqlShellIT.java

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

From source file:Log.java

/**
 * Initializes the log./*from  w  ww .j  a  v a  2  s.  c o m*/
 * @param stdio If true, standard output and error will be
 * sent to the log
 * @param level Messages with this log level or higher will
 * be printed to the system console
 * @since jEdit 3.2pre4
 */
public static void init(boolean stdio, int level) {
    if (stdio) {
        if (System.out == realOut && System.err == realErr) {
            System.setOut(createPrintStream(NOTICE, null));
            System.setErr(createPrintStream(ERROR, null));
        }
    }

    Log.level = level;

    // Log some stuff
    log(MESSAGE, Log.class, "When reporting bugs, please" + " include the following information:");
    String[] props = { "java.version", "java.vm.version", "java.runtime.version", "java.vendor",
            "java.compiler", "os.name", "os.version", "os.arch", "user.home", "java.home", "java.class.path", };
    for (int i = 0; i < props.length; i++) {
        log(MESSAGE, Log.class, props[i] + '=' + System.getProperty(props[i]));
    }
}

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;/*from w ww . j a  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()));
}