Code example for PipedInputStream

Methods: close, connect, read, sleep

0
        worker.start();
        Thread.sleep(2000);
        assertEquals("Should read 20.", 20, in.read());
        worker.join();
        assertEquals("Write end is closed, should return -1", -1, in.read());
        byte[] buf = new byte[1];
        assertEquals("Write end is closed, should return -1", -1, in.read(buf, 0, 1));
        assertEquals("Buf len 0 should return first", 0, in.read(buf, 0, 0));
        in.close();
        out.close();
    } 
 
	/** 
	 * Tears down the fixture, for example, close a network connection. This 
	 * method is called after a test is executed. 
	 */ 
	protected void tearDown() throws Exception { 
		try { 
			if (t != null) {
				t.interrupt();
            } 
		} catch (Exception ignore) {
		}