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:org.apache.hadoop.util.TestClasspath.java

@Before
public void setUp() {
    assertTrue(FileUtil.fullyDelete(TEST_DIR));
    assertTrue(TEST_DIR.mkdirs());//from  www  .  ja  v  a2  s  . c om
    oldStdout = System.out;
    oldStderr = System.err;

    stdout = new ByteArrayOutputStream();
    printStdout = new PrintStream(stdout);
    System.setOut(printStdout);

    stderr = new ByteArrayOutputStream();
    printStderr = new PrintStream(stderr);
    System.setErr(printStderr);
}

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

@Before
public void setup() throws Exception {
    tempOutputDir = Files.createTempDirectory("tika-cli-test-batch-");
    outBuffer = new ByteArrayOutputStream();
    PrintStream outWriter = new PrintStream(outBuffer, true, UTF_8.name());
    ByteArrayOutputStream errBuffer = new ByteArrayOutputStream();
    PrintStream errWriter = new PrintStream(errBuffer, true, UTF_8.name());
    out = System.out;// ww  w  . j  ava 2  s.  c  o  m
    err = System.err;
    System.setOut(outWriter);
    System.setErr(errWriter);
    testInputDirForCommandLine = testInputDir.toAbsolutePath().toString();
    tempOutputDirForCommandLine = tempOutputDir.toAbsolutePath().toString();
}

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

/**
 * Sets up System.out and System.err print streams before each test
 *///from   ww  w . j  a v a2  s.c  o m
@Before
public void setUpStreams() {
    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));
}

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

protected void setUp() throws Exception {
    outStream = new AssertivePrintStream(new NullOutputStream());
    errStream = new AssertivePrintStream(new NullOutputStream());
    System.setErr(errStream);
    System.setOut(outStream);// w ww  .j a  v a  2s.c om

    simpleLogger = new SimpleLogger();
    object = new Object();
    throwable = new MyThrowable();
}

From source file:flow.visibility.tapping.OpenDayLightUtils.java

/** Creating the Pane for Flow Entry */

public OpenDayLightUtils() {
    super("Installed Flow");

    FlowtextArea = new JTextArea(50, 10);
    FlowtextArea.setEditable(false);/*from w w  w .j a  va2 s  .co  m*/
    FlowtextArea.setFont(new Font("Courier New", Font.BOLD, 12));
    PrintStream FlowprintStream = new PrintStream(new CustomOutputStream(FlowtextArea));

    // re-assigns standard output stream and error output stream
    System.setOut(FlowprintStream);
    System.setErr(FlowprintStream);

    // creates the GUI
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.insets = new Insets(10, 10, 10, 10);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;

    /** Adding the Pane into Frame */

    scrollPane = new JScrollPane(FlowtextArea);
    this.add(scrollPane, constraints);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setSize(400, 600);
    setLocationRelativeTo(null); // centers on screen
}

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

public static void redirectToDevNull() {
    System.setOut(NULL);
    System.setErr(NULL);
}

From source file:bridge.toolkit.ControllerJFrame.java

/** Creates new form NewJFrame */
public ControllerJFrame() {
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
    Date date = new Date();

    currentTime = dateFormat.format(date);

    parser = new ConfigParser();
    Controller loader = new Controller();
    sampleCatalog = loader.createCatalog();

    ctx = new ContextBase();
    initComponents();//from  ww w  . ja v a 2 s  .c  om
    System.setOut(aPrintStream); // catches System.out messages
    System.setErr(aPrintStream); // catches error messages

}

From source file:fi.jumi.test.JumiBootstrapTest.java

@Test
public void will_not_close_stderr_when_debug_output_is_enabled() throws Exception {
    PrintStream originalErr = System.err;
    try {// w  ww . j  a  v  a2 s.  c om
        ByteArrayOutputStream printed = new ByteArrayOutputStream();
        PrintStream spiedErr = spy(new PrintStream(printed));
        System.setErr(spiedErr);

        JumiBootstrap bootstrap = new JumiBootstrap();
        bootstrap.suite.setTestClasses(OnePassingTest.class);
        bootstrap.daemon.setIdleTimeout(0); // we want the daemon process to exit quickly
        bootstrap.setTextUiOutput(new NullWriter());
        bootstrap.enableDebugMode(); // <-- the thing we are testing
        bootstrap.runSuite();

        Thread.sleep(50); // wait for the daemon process to exit, and our printer thread to notice it
        assertThat("this test has a problem; daemon printed nothing", printed.size(), is(not(0)));
        verify(spiedErr, never()).close(); // <-- the thing we are testing

    } finally {
        System.setErr(originalErr);
    }
}

From source file:org.apache.hadoop.util.TestClasspath.java

@After
public void tearDown() {
    System.setOut(oldStdout);
    System.setErr(oldStderr);
    IOUtils.cleanup(LOG, printStdout, printStderr);
    assertTrue(FileUtil.fullyDelete(TEST_DIR));
}

From source file:org.apache.flink.yarn.CliFrontendYarnAddressConfigurationTest.java

@BeforeClass
public static void disableStdOutErr() {
    class NullPrint extends OutputStream {
        @Override/*from   w  ww  .j  a  v a2  s .  c o  m*/
        public void write(int b) {
        }
    }

    PrintStream nullPrinter = new PrintStream(new NullPrint());
    System.setOut(nullPrinter);
    System.setErr(nullPrinter);

    // Unset FLINK_CONF_DIR, as this is a precondition for this test to work properly
    Map<String, String> map = new HashMap<>(System.getenv());
    map.remove(ConfigConstants.ENV_FLINK_CONF_DIR);
    TestBaseUtils.setEnv(map);
}