Package java.io

Examples of java.io.PipedReader


    /**
     * @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");
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
                }
            }
        }
        WriteRunnable writeRunnable = new WriteRunnable();
        Thread writeThread = new Thread(writeRunnable);
        class ReadRunnable implements Runnable {
            boolean pass;
            public void run() {
                try {
                    pr.read();
                    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
                }
            }
        }
        WriteRunnable writeRunnable = new WriteRunnable();
        Thread writeThread = new Thread(writeRunnable);
        class ReadRunnable implements Runnable {
            boolean pass;

            public void run() {
                try {
                    pr.read();
                    pass = true;
                } catch (IOException e) {
                  //ignore
                }
            }
View Full Code Here

     * @throws RatException
     */
    public static ClaimStatistic report(Writer out, IReportable base, final InputStream style,
            ReportConfiguration pConfiguration)
    throws IOException, TransformerConfigurationException, FileNotFoundException, InterruptedException, RatException {
        PipedReader reader = new PipedReader();
        PipedWriter writer = new PipedWriter(reader);
        ReportTransformer transformer = new ReportTransformer(out, style, reader);
        Thread transformerThread = new Thread(transformer);
        transformerThread.start();
        final ClaimStatistic statistic = report(base, writer, pConfiguration);
View Full Code Here

      fail("Unexpected: " + e);
    }
       
        //regression for HARMONY-831
        try{
            new BufferedReader(new PipedReader(), 9).read(new char[] {}, 7, 0);
            fail("should throw IndexOutOfBoundsException");
        }catch(IndexOutOfBoundsException e){
        }
       
        // Regression for HARMONY-54
View Full Code Here

    public char[] buf = new char[10];

    public PReader(PipedWriter pw) {
      try {
        pr = new PipedReader(pw);
      } catch (IOException e) {
        System.out.println("Exception setting up reader: "
            + e.toString());
      }
    }
View Full Code Here

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

     */
    public void test_close() throws Exception {
        // Test for method void java.io.PipedWriter.close()
        char[] buf = new char[10];
        "HelloWorld".getChars(0, 10, buf, 0);
        PipedReader rd = new PipedReader();
        pw = new PipedWriter(rd);
        reader = new PReader(rd);
        pw.close();
        try {
            pw.write(buf);
View Full Code Here

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

     * @tests java.io.PipedWriter#flush()
     * Regression HARMONY-6293
     */
    public void test_flushAfterClose() throws Exception {
     
        PipedReader pr = new PipedReader();
        pw = new PipedWriter(pr);
      pw.close();
      try {
            pw.flush();
            fail("should throw IOException");
        } catch (IOException e) {
            // expected
        }
     
        pr = new PipedReader();
        pw = new PipedWriter(pr);
        pr.close();
 
        try {
            pw.flush();
            fail("should throw IOException");
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of java.io.PipedReader

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.