@@ -0,0 +1,2244 @@
+%0A/*%0A * Copyright (C) 2011 Archie L. Cobbs. All rights reserved.%0A *%0A * $Id$%0A */%0A%0Apackage org.dellroad.stuff.io;%0A%0Aimport java.io.DataInputStream;%0Aimport java.io.DataOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.util.Arrays;%0A%0Aimport org.dellroad.stuff.TestSupport;%0Aimport org.testng.annotations.Test;%0A%0Apublic class NullModemTest extends TestSupport implements NullModemOutputStream.ReadCallback, NullModemInputStream.WriteCallback %7B%0A%0A    private byte%5B%5D inputData;%0A    private byte%5B%5D outputData;%0A%0A// NullModemOutputStream%0A%0A    @Test%0A    public synchronized void testOutput() throws Exception %7B%0A%0A        // Create data%0A        byte%5B%5D data = new byte%5Bthis.random.nextInt(1000)%5D;%0A        this.random.nextBytes(data);%0A%0A        // Write data%0A        NullModemOutputStream output = new NullModemOutputStream(this, %22Null Output%22);%0A        DataOutputStream dataOutput = new DataOutputStream(output);%0A        dataOutput.write(data);%0A        dataOutput.close();%0A%0A        // Wait for reader to finish reading%0A        synchronized (this) %7B%0A            while (this.outputData == null)%0A                this.wait();%0A        %7D%0A%0A        // Check%0A        assert Arrays.equals(this.outputData, data);%0A    %7D%0A%0A    @Override%0A    public void readFrom(InputStream input) throws IOException %7B%0A        this.outputData = StreamsTest.readAll(input);%0A        synchronized (this) %7B%0A            this.notifyAll();%0A        %7D%0A    %7D%0A%0A// NullModemInputStream%0A%0A    @Test%0A    public synchronized void testInput() throws IOException %7B%0A%0A        // Create data%0A        this.inputData = new byte%5Bthis.random.nextInt(1000)%5D;%0A        this.random.nextBytes(this.inputData);%0A%0A        // Read data%0A        NullModemInputStream input = new NullModemInputStream(this, %22Null Input%22);%0A        DataInputStream dataInput = new DataInputStream(input);%0A        byte%5B%5D data = StreamsTest.readAll(dataInput);%0A        dataInput.close();%0A%0A        // Check%0A        assert Arrays.equals(data, this.inputData);%0A    %7D%0A%0A    @Override%0A    public void writeTo(OutputStream output) throws IOException %7B%0A        DataOutputStream dataOutput = new DataOutputStream(output);%0A        dataOutput.write(this.inputData);%0A        dataOutput.flush();%0A    %7D%0A%7D%0A%0A

Add new unit test.