Search in sources :

Example 56 with PrintStream

use of java.io.PrintStream in project Cloud9 by lintool.

the class ExceptionUtils method getStackTrace.

public static String getStackTrace(Exception e) {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    PrintStream stream = new PrintStream(bytes);
    e.printStackTrace(stream);
    return new String(bytes.toByteArray());
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 57 with PrintStream

use of java.io.PrintStream in project camel by apache.

the class StreamSystemOutTest method testStringContent.

// START SNIPPET: e1
@Test
public void testStringContent() throws Exception {
    try {
        // Given
        System.setOut(new PrintStream(mockOut));
        // When
        template.sendBody("direct:in", message);
        // Then
        assertEquals(message + System.lineSeparator(), new String(mockOut.toByteArray()));
    } finally {
        System.setOut(stdOut);
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 58 with PrintStream

use of java.io.PrintStream in project camel by apache.

the class StreamSystemOutTest method shouldSkipNullBody.

@Test
public void shouldSkipNullBody() {
    try {
        // Given
        System.setOut(new PrintStream(mockOut));
        // When
        template.sendBody("direct:in", null);
        // Then
        assertEquals(0, mockOut.toByteArray().length);
    } finally {
        System.setOut(stdOut);
    }
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 59 with PrintStream

use of java.io.PrintStream in project byte-buddy by raphw.

the class AgentBuilderListenerTest method testStreamWritingOnIgnore.

@Test
public void testStreamWritingOnIgnore() throws Exception {
    PrintStream printStream = mock(PrintStream.class);
    AgentBuilder.Listener listener = new AgentBuilder.Listener.StreamWriting(printStream);
    listener.onIgnored(typeDescription, classLoader, module, LOADED);
    verify(printStream).printf("[Byte Buddy] IGNORE %s [%s, %s, loaded=%b]%n", FOO, classLoader, module, LOADED);
    verifyNoMoreInteractions(printStream);
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Example 60 with PrintStream

use of java.io.PrintStream in project byte-buddy by raphw.

the class AgentBuilderListenerTest method testStreamWritingOnComplete.

@Test
public void testStreamWritingOnComplete() throws Exception {
    PrintStream printStream = mock(PrintStream.class);
    AgentBuilder.Listener listener = new AgentBuilder.Listener.StreamWriting(printStream);
    listener.onComplete(FOO, classLoader, module, LOADED);
    verify(printStream).printf("[Byte Buddy] COMPLETE %s [%s, %s, loaded=%b]%n", FOO, classLoader, module, LOADED);
    verifyNoMoreInteractions(printStream);
}
Also used : PrintStream(java.io.PrintStream) Test(org.junit.Test)

Aggregations

PrintStream (java.io.PrintStream)1828 ByteArrayOutputStream (java.io.ByteArrayOutputStream)805 Test (org.junit.Test)583 File (java.io.File)331 IOException (java.io.IOException)295 FileOutputStream (java.io.FileOutputStream)207 ArrayList (java.util.ArrayList)89 FileNotFoundException (java.io.FileNotFoundException)83 OutputStream (java.io.OutputStream)81 Before (org.junit.Before)66 BufferedReader (java.io.BufferedReader)53 BufferedOutputStream (java.io.BufferedOutputStream)49 Map (java.util.Map)49 Date (java.util.Date)46 Path (org.apache.hadoop.fs.Path)42 UnsupportedEncodingException (java.io.UnsupportedEncodingException)41 InputStreamReader (java.io.InputStreamReader)38 Matchers.anyString (org.mockito.Matchers.anyString)38 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)36 List (java.util.List)35