Package java.io

Examples of java.io.PipedOutputStream


    private DataInputStreamExtended inputImpl;

    @Before
    public void setUp() throws Exception {
        final PipedInputStream pipedInputStream = new PipedInputStream();
        final PipedOutputStream pipedOutputStream = new PipedOutputStream(pipedInputStream);
        outputImpl = new DataOutputStreamExtended(pipedOutputStream);
        inputImpl = new DataInputStreamExtended(pipedInputStream);
    }
View Full Code Here


     * Regression test for HARMONY-4638
     */
    public void test_readClassDescriptor_1() throws IOException, ClassNotFoundException {
        A a = new A();
        a.name = "It's a test";
        PipedOutputStream pout = new PipedOutputStream();
        PipedInputStream pin = new PipedInputStream(pout);
        ObjectOutputStream out = new ObjectOutputStream(pout);
        ObjectInputStream in = new ObjectIutputStreamWithReadDesc2(pin, A.class);

        // test single object
View Full Code Here

         .equals("Hello World"));
    st.nextToken();
    assertTrue("Wrong Token type8: " + st.ttype, st.ttype == -1);

    final PipedInputStream pin = new PipedInputStream();
    PipedOutputStream pout = new PipedOutputStream(pin);
    pout.write("hello\n\r\r".getBytes());
    StreamTokenizer s = new StreamTokenizer(pin);
    s.eolIsSignificant(true);
    assertTrue("Wrong token 1,1",
         s.nextToken() == StreamTokenizer.TT_WORD
         && s.sval.equals("hello"));
    assertTrue("Wrong token 1,2", s.nextToken() == '\n');
    assertTrue("Wrong token 1,3", s.nextToken() == '\n');
    assertTrue("Wrong token 1,4", s.nextToken() == '\n');
    pout.close();
    assertTrue("Wrong token 1,5",
         s.nextToken() == StreamTokenizer.TT_EOF);
    StreamTokenizer tokenizer = new StreamTokenizer(
                new Support_StringReader("\n \r\n#"));
    tokenizer.ordinaryChar('\n'); // make \n ordinary
View Full Code Here

   */
  public void test_ConstructorLjava_io_PipedInputStream() {
    // Test for method java.io.PipedOutputStream(java.io.PipedInputStream)

    try {
      out = new PipedOutputStream(new PipedInputStream());
      out.write('b');
    } catch (Exception e) {
      fail("Exception during constructor test : " + e.getMessage());
    }
  }
View Full Code Here

   * @tests java.io.PipedOutputStream#close()
   */
  public void test_close() {
    // Test for method void java.io.PipedOutputStream.close()
    try {
      out = new PipedOutputStream();
      rt = new Thread(reader = new PReader(out));
      rt.start();
      out.close();
    } catch (IOException e) {
      fail("Exception during close : " + e.getMessage());
View Full Code Here

   
    /**
     * @tests java.io.PipedOutputStream#connect(java.io.PipedInputStream)
     */
    public void test_connectLjava_io_PipedInputStream_Exception() throws IOException {
        out = new PipedOutputStream();
        out.connect(new PipedInputStream());
        try {
            out.connect(null);
            fail("should throw NullPointerException"); //$NON-NLS-1$
        } catch (NullPointerException e) {
View Full Code Here

   */
  public void test_connectLjava_io_PipedInputStream() {
    // Test for method void
    // java.io.PipedOutputStream.connect(java.io.PipedInputStream)
    try {
      out = new PipedOutputStream();
      rt = new Thread(reader = new PReader(out));
      rt.start();
      out.connect(new PipedInputStream());
    } catch (IOException e) {
      // Correct
View Full Code Here

   * @tests java.io.PipedOutputStream#flush()
   */
  public void test_flush() {
    // Test for method void java.io.PipedOutputStream.flush()
    try {
      out = new PipedOutputStream();
      rt = new Thread(reader = new PReader(out));
      rt.start();
      out.write("HelloWorld".getBytes(), 0, 10);
      assertTrue("Bytes written before flush", reader.available() != 0);
      out.flush();
View Full Code Here

   */
  public void test_write$BII() {
    // Test for method void java.io.PipedOutputStream.write(byte [], int,
    // int)
    try {
      out = new PipedOutputStream();
      rt = new Thread(reader = new PReader(out));
      rt.start();
      out.write("HelloWorld".getBytes(), 0, 10);
      out.flush();
      assertEquals("Wrote incorrect bytes",
View Full Code Here

     * @tests java.io.PipedOutputStream#write(byte[], int, int)
     * Regression for HARMONY-387
     */
    public void test_write$BII_2() throws IOException {
        PipedInputStream pis = new PipedInputStream();
        PipedOutputStream pos = null;
        try{
            pos = new PipedOutputStream(pis);
            pos.write(new byte[0], -1, -1);
            fail("IndexOutOfBoundsException expected");
        } catch (IndexOutOfBoundsException t) {
            assertEquals(
                    "IndexOutOfBoundsException rather than a subclass expected",
                    IndexOutOfBoundsException.class, t.getClass());
        }
       
        // Regression for HARMONY-4311
        try {
            pis = new PipedInputStream();
            PipedOutputStream out = new PipedOutputStream(pis);
            out.write(null, -10, 10);
            fail("should throw NullPointerException.");
        } catch (NullPointerException e) {
            // expected
        }
    }
View Full Code Here

TOP

Related Classes of java.io.PipedOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.