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.ibm.sbt.services.client.connections.activities.ActivityEntryPerformanceTest.java

@Test
@org.junit.Ignore("Issue with Mime Depdency")
public void testCreateActivityEntries() throws ClientServicesException {

    System.setErr(new PrintStream(new ByteArrayOutputStream()));

    Activity activity = createActivity();
    String activityUuid = activity.getActivityUuid();
    String title = activity.getThemeId();

    FileField fileField = new FileField();
    fileField.setName("test_file");
    fileField.setHidden(true);/*w w w.j a va 2s.  c  o m*/
    fileField.setPosition(2000);

    byte[] bytes = new byte[Integer.valueOf(1024)];
    Arrays.fill(bytes, (byte) 0);

    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);
    writer.println("#,NodeUUID,Time(ms)");
    for (int i = 0; i < 500; i++) {
        try {
            long start = System.currentTimeMillis();

            System.out.print(i + " ");

            ActivityNode activityNode = new ActivityNode();
            activityNode.setActivityUuid(activityUuid);
            activityNode.setTitle(title + " - " + i);
            activityNode.setType(ActivityNode.TYPE_ENTRY);
            for (int j = 0; j < 5; j++) {
                TextField textField = new TextField();
                textField.setName("test_text" + j);
                textField.setPosition(1000);
                textField.setSummary("Test_Text_Field");
                activityNode.addField(textField);
            }
            activityNode.addField(fileField);
            activityNode.addAttachment(new ActivityAttachment("test_file", new String(bytes), "text/plain"));

            activityNode = activityService.createActivityNode(activityNode);

            long duration = System.currentTimeMillis() - start;
            writer.println(i + "," + activityNode.getActivityNodeUuid() + "," + duration);
        } catch (Exception e) {
        }
    }

    System.out.println(stringWriter.toString());

    /*
    long start = System.currentTimeMillis();
    Map<String, String> params = new HashMap<String, String>();
    params.put("page", "1");
    params.put("ps", "1");
    activityService.getActivityNodeDescendants(activityUuid, params);
    long duration = System.currentTimeMillis() - start;
    System.out.println("Reading all activity descendants took "+duration+"(ms)");
            
    start = System.currentTimeMillis();
    params.put("tag", "personal");
    activityService.getActivityNodeChildren(activityUuid, params);
    duration = System.currentTimeMillis() - start;
    System.out.println("Reading all activity children took "+duration+"(ms)");
    */
}

From source file:com.microsoft.windowsazure.core.tracing.util.JavaTracingInterceptorTest.java

@Test
public void testInformationSendRequest() {
    // Arrange/*from w w w. j a  v a2 s . c  om*/
    logContent = new ByteArrayOutputStream();
    System.setErr(new PrintStream(logContent));

    CloudTracing.addTracingInterceptor(new JavaTracingInterceptor());

    HttpRequest httpRequest = new HttpPost("http://www.bing.com");

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/xml");
    httpRequest.setHeader("x-ms-version", "2012-03-01");

    // Act
    CloudTracing.sendRequest("test", httpRequest);

    // Assert
    String result = logContent.toString();
    assertTrue(result.contains("INFO: invocationId: test\r\nrequest: POST http://www.bing.com HTTP/1.1"));

    CloudTracing.information("hello there");
    result = logContent.toString();
    assertTrue(result.contains("INFO: hello there"));
}

From source file:test.Tester.java

public void setUpStreams() {
    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));
}

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: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:net.officefloor.tutorial.exceptionhttpserver.ExceptionHttpServerTest.java

public void testExceptionHandling() throws Exception {

    // Override stderr
    ByteArrayOutputStream error = new ByteArrayOutputStream();
    System.setErr(new PrintStream(error, true));

    // Start server
    WoofOfficeFloorSource.start();//from  w  ww . j a v  a  2 s  .c o  m

    // Clear setup log
    error.reset();

    // Submit to trigger the exception
    this.client.execute(new HttpGet("http://localhost:7878/template-submit.woof"));

    // Ensure handling by logging the failure
    String log = new String(error.toByteArray()).trim();
    assertEquals("Should log error", "Test", log);
}

From source file:net.jperf.LoggingStopWatchTest.java

protected void tearDown() throws Exception {
    System.setErr(realErr);
}

From source file:test.Tester.java

public void cleanUpStreams() {
    System.setOut(null);
    System.setErr(null);
}

From source file:org.apache.geronimo.gshell.io.StreamPair.java

/**
 * Install the given stream pair as the System streams.
 *//*from  w ww  .j  a va  2  s . com*/
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);/*from   w w  w.ja v a  2 s  .  c om*/
    help.addOption(o);

    outContent = new ByteArrayOutputStream();
    errContent = new ByteArrayOutputStream();

    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));

}