Package java.io

Examples of java.io.PipedWriter


     */
    public void test_flush() throws Exception {
        // Test for method void java.io.PipedWriter.flush()
        char[] buf = new char[10];
        "HelloWorld".getChars(0, 10, buf, 0);
        pw = new PipedWriter();
        rdrThread = new Thread(reader = new PReader(pw), "flush");
        rdrThread.start();
        pw.write(buf);
        pw.flush();
        rdrThread.join(700);
View Full Code Here


     */
    public void test_write$CII() throws Exception {
        // Test for method void java.io.PipedWriter.write(char [], int, int)
        char[] buf = new char[10];
        "HelloWorld".getChars(0, 10, buf, 0);
        pw = new PipedWriter();
        rdrThread = new Thread(reader = new PReader(pw), "writeCII");
        rdrThread.start();
        pw.write(buf, 0, 10);
        pw.close();
        rdrThread.join(1000);
View Full Code Here

     * @tests java.io.PipedWriter#write(char[], int, int) Regression for
     *        HARMONY-387
     */
    public void test_write$CII_2() throws IOException {
        PipedReader pr = new PipedReader();
        PipedWriter obj = null;
        try {
            obj = new java.io.PipedWriter(pr);
            obj.write(new char[0], (int) 0, (int) -1);
            fail("IndexOutOfBoundsException expected");
        } catch (IndexOutOfBoundsException t) {
            assertEquals(
                    "IndexOutOfBoundsException rather than a subclass expected",
                    IndexOutOfBoundsException.class, t.getClass());
View Full Code Here

    /**
     * @tests java.io.PipedWriter#write(char[], int, int)
     */
    public void test_write$CII_3() throws IOException {
        PipedReader pr = new PipedReader();
        PipedWriter obj = null;
        try {
            obj = new java.io.PipedWriter(pr);
            obj.write(new char[0], (int) -1, (int) 0);
            fail("IndexOutOfBoundsException expected");
        } catch (ArrayIndexOutOfBoundsException t) {
            fail("IndexOutOfBoundsException expected");
        } catch (IndexOutOfBoundsException t) {}
    }
View Full Code Here

    /**
     * @tests java.io.PipedWriter#write(char[], int, int)
     */
    public void test_write$CII_4() throws IOException {
        PipedReader pr = new PipedReader();
        PipedWriter obj = null;
        try {
            obj = new java.io.PipedWriter(pr);
            obj.write(new char[0], (int) -1, (int) -1);
            fail("IndexOutOfBoundsException expected");
        } catch (ArrayIndexOutOfBoundsException t) {
            fail("IndexOutOfBoundsException expected");
        } catch (IndexOutOfBoundsException t) {}
    }
View Full Code Here

    /**
     * @tests java.io.PipedWriter#write(char[], int, int)
     */
    public void test_write$CII_5() throws IOException {
        PipedReader pr = new PipedReader();
        PipedWriter obj = null;
        try {
            obj = new PipedWriter(pr);
            obj.write((char[]) null, (int) -1, (int) 0);
            fail("NullPointerException expected");
        } catch (IndexOutOfBoundsException t) {
            fail("NullPointerException expected");
        } catch (NullPointerException t) {}
    }
View Full Code Here

    /**
     * @tests java.io.PipedWriter#write(char[], int, int)
     */
    public void test_write$CII_6() throws IOException {
        PipedReader pr = new PipedReader();
        PipedWriter obj = null;
        try {
            obj = new PipedWriter(pr);
            obj.write((char[]) null, (int) -1, (int) -1);
            fail("NullPointerException expected");
        } catch (IndexOutOfBoundsException t) {
            fail("NullPointerException expected");
        } catch (NullPointerException t) {}
    }
View Full Code Here

     * @tests java.io.PipedWriter#write(char[], int, int)
     */
    public void test_write$CII_notConnected() throws IOException {
        // Regression test for Harmony-2404
        // create not connected pipe
        PipedWriter obj = new PipedWriter();

        // char array is null
        try {
            obj.write((char[]) null, 0, 1);
            fail("IOException expected");
        } catch (IOException ioe) {
            // expected
        }

        // negative offset
        try {
            obj.write( new char[] { 1 }, -10, 1);
            fail("IOException expected");
        } catch (IOException ioe) {
            // expected
        }

        // wrong offset
        try {
            obj.write( new char[] { 1 }, 10, 1);
            fail("IOException expected");
        } catch (IOException ioe) {
            // expected
        }

        // negative length
        try {
            obj.write( new char[] { 1 }, 0, -10);
            fail("IOException expected");
        } catch (IOException ioe) {
            // expected
        }

        // all valid params
        try {
            obj.write( new char[] { 1, 1 }, 0, 1);
            fail("IOException expected");
        } catch (IOException ioe) {
            // expected
        }
    }
View Full Code Here

    /**
     * @tests java.io.PipedWriter#write(int)
     */
    public void test_write_I_MultiThread() throws IOException {
        final PipedReader pr = new PipedReader();
        final PipedWriter pw = new PipedWriter();
        // test if writer recognizes dead reader
        pr.connect(pw);

        class WriteRunnable implements Runnable {
            boolean pass = false;
            boolean readerAlive = true;
            public void run() {
                try {
                    pw.write(1);
                    while (readerAlive) {
                    // wait the reader thread dead
                    }
                    try {
                        // should throw exception since reader thread
                        // is now dead
                        pw.write(1);
                    } catch (IOException e) {
                        pass = true;
                    }
                } catch (IOException e) {
                  //ignore
View Full Code Here

    /**
     * @tests java.io.PipedWriter#write(char[],int,int)
     */
    public void test_write_$CII_MultiThread() throws Exception {
        final PipedReader pr = new PipedReader();
        final PipedWriter pw = new PipedWriter();

        // test if writer recognizes dead reader
        pr.connect(pw);

        class WriteRunnable implements Runnable {
            boolean pass = false;

            boolean readerAlive = true;

            public void run() {
                try {
                    pw.write(1);
                    while (readerAlive) {
                    // wait the reader thread dead
                    }
                    try {
                        // should throw exception since reader thread
                        // is now dead
                        char[] buf = new char[10];
                        pw.write(buf, 0, 10);
                    } catch (IOException e) {
                        pass = true;
                    }
                } catch (IOException e) {
                  //ignore
View Full Code Here

TOP

Related Classes of java.io.PipedWriter

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.