Code example for PrintStream

0
public final class QuickReferenceWriterTest { 
 
    private final ByteArrayOutputStream actualBuffer = new ByteArrayOutputStream();
    private final ByteArrayOutputStream expectedBuffer = new ByteArrayOutputStream();
    private final PrintStream expected = new PrintStream(expectedBuffer);
    private final QuickReferenceWriter writer = new QuickReferenceWriter(new PrintStream(actualBuffer));
 
    @Test public void 
    writesSimplifiedSummaryOfMatchers() throws IOException { 
        FactoryMethod namedMethod = new FactoryMethod("SomeClass", "someMethod", "unusedReturnType");
        namedMethod.addParameter("Cheese", "a");
        namedMethod.addParameter("int", "b");
        namedMethod.setGenerifiedType("String");
        writer.writeMethod("namedMethod", namedMethod);
 
        FactoryMethod anotherMethod = new FactoryMethod("SomeClass", "anotherMethod", "unusedReturnType");
        anotherMethod.setGenerifiedType("int");
        writer.writeMethod("anotherMethod", anotherMethod);
 
        expected.println("        [String] namedMethod(Cheese a, int b)");
        expected.println("           [int] anotherMethod()");