Search in sources :

Example 1 with Support_StringReader

use of tests.support.Support_StringReader in project robovm by robovm.

the class OldStreamTokenizerTest method test_nextToken.

public void test_nextToken() throws IOException {
    st = new StreamTokenizer(new Support_StringReader("\n \r\n#"));
    // make \n ordinary
    st.ordinaryChar('\n');
    st.eolIsSignificant(true);
    assertTrue("Wrong token 2,1", st.nextToken() == '\n');
    assertTrue("Wrong token 2,2", st.nextToken() == '\n');
    assertEquals("Wrong token 2,3", '#', st.nextToken());
    Support_ASimpleInputStream sis = new Support_ASimpleInputStream();
    sis.throwExceptionOnNextUse = true;
    st = new StreamTokenizer(sis);
    try {
        st.nextToken();
        fail("IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
}
Also used : Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream) IOException(java.io.IOException) StreamTokenizer(java.io.StreamTokenizer) Support_StringReader(tests.support.Support_StringReader)

Example 2 with Support_StringReader

use of tests.support.Support_StringReader in project robovm by robovm.

the class OldBufferedReaderTest method test_ConstructorLjava_io_ReaderI.

public void test_ConstructorLjava_io_ReaderI() {
    // Illegal negative size argument test.
    try {
        br = new BufferedReader(new Support_StringReader(testString), 0);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException expected) {
    }
    br = new BufferedReader(new Support_StringReader(testString), 1024);
    assertNotNull(br);
}
Also used : BufferedReader(java.io.BufferedReader) Support_StringReader(tests.support.Support_StringReader)

Example 3 with Support_StringReader

use of tests.support.Support_StringReader in project robovm by robovm.

the class OldBufferedReaderTest method test_close.

public void test_close() {
    Support_ASimpleReader ssr = new Support_ASimpleReader(true);
    try {
        br = new BufferedReader(new Support_StringReader(testString));
        br.close();
        br.read();
        fail("Test 1: Read on closed stream.");
    } catch (IOException x) {
    // Expected.
    } catch (Exception e) {
        fail("Exception during close test " + e.toString());
    }
    br = new BufferedReader(ssr);
    try {
        br.close();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    // Avoid IOException in tearDown().
    ssr.throwExceptionOnNextUse = false;
}
Also used : Support_ASimpleReader(tests.support.Support_ASimpleReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) IOException(java.io.IOException) Support_StringReader(tests.support.Support_StringReader)

Example 4 with Support_StringReader

use of tests.support.Support_StringReader in project robovm by robovm.

the class OldBufferedReaderTest method test_read$CII_Exception.

public void test_read$CII_Exception() throws Exception {
    br = new BufferedReader(new Support_StringReader(testString));
    try {
        br.read(new char[10], -1, 1);
        fail("should throw IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    try {
        br.read(new char[10], 0, -1);
        fail("should throw IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    try {
        br.read(new char[10], 10, 1);
        fail("should throw IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    //regression for HARMONY-831
    try {
        new BufferedReader(new PipedReader(), 9).read(new char[] {}, 7, 0);
        fail("should throw IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    }
}
Also used : BufferedReader(java.io.BufferedReader) PipedReader(java.io.PipedReader) Support_StringReader(tests.support.Support_StringReader)

Example 5 with Support_StringReader

use of tests.support.Support_StringReader in project robovm by robovm.

the class OldBufferedReaderTest method test_ConstructorLjava_io_Reader.

public void test_ConstructorLjava_io_Reader() {
    // Test for method java.io.BufferedReader(java.io.Reader)
    br = new BufferedReader(new Support_StringReader(testString));
    assertNotNull(br);
}
Also used : BufferedReader(java.io.BufferedReader) Support_StringReader(tests.support.Support_StringReader)

Aggregations

Support_StringReader (tests.support.Support_StringReader)36 BufferedReader (java.io.BufferedReader)34 IOException (java.io.IOException)24 Support_ASimpleReader (tests.support.Support_ASimpleReader)10 PipedReader (java.io.PipedReader)9 CharArrayReader (java.io.CharArrayReader)7 InputStreamReader (java.io.InputStreamReader)7 Reader (java.io.Reader)7 StringReader (java.io.StringReader)7 ThrowingReader (tests.support.ThrowingReader)4 StreamTokenizer (java.io.StreamTokenizer)2 Support_ASimpleInputStream (tests.support.Support_ASimpleInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1