Search in sources :

Example 6 with Support_ASimpleReader

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

the class OldReaderTest method test_ready.

public void test_ready() throws IOException {
    Support_ASimpleReader simple = new Support_ASimpleReader("Bla bla, what else?");
    simple.throwExceptionOnNextUse = true;
    try {
        simple.ready();
        fail("IOException not thrown!");
    } catch (IOException expected) {
    }
}
Also used : Support_ASimpleReader(tests.support.Support_ASimpleReader) IOException(java.io.IOException)

Example 7 with Support_ASimpleReader

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

the class OldReaderTest method test_read.

public void test_read() throws IOException {
    Support_ASimpleReader simple = new Support_ASimpleReader("Bla bla, what else?");
    int res = simple.read();
    assertEquals("Wrong stuff read!", 'B', res);
    res = simple.read();
    assertEquals("Wrong stuff read!", 'l', res);
    simple.throwExceptionOnNextUse = true;
    try {
        simple.read();
        fail("IOException not thrown!");
    } catch (IOException expected) {
    }
}
Also used : Support_ASimpleReader(tests.support.Support_ASimpleReader) IOException(java.io.IOException)

Example 8 with Support_ASimpleReader

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

the class OldReaderTest method test_Read_$C.

public void test_Read_$C() throws IOException {
    Support_ASimpleReader simple;
    simple = new Support_ASimpleReader("Bla bla, what else?");
    char[] buf = new char[4];
    assertEquals("Wrong return value!", 4, simple.read(buf));
    assertEquals("Wrong stuff read!", "Bla ", new String(buf));
    simple.read(buf);
    assertEquals("Wrong stuff read!", "bla,", new String(buf));
    simple.throwExceptionOnNextUse = true;
    try {
        simple.read(buf);
        fail("IOException not thrown!");
    } catch (IOException expected) {
    }
}
Also used : Support_ASimpleReader(tests.support.Support_ASimpleReader) IOException(java.io.IOException)

Example 9 with Support_ASimpleReader

use of tests.support.Support_ASimpleReader 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 10 with Support_ASimpleReader

use of tests.support.Support_ASimpleReader in project j2objc by google.

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)

Aggregations

IOException (java.io.IOException)18 Support_ASimpleReader (tests.support.Support_ASimpleReader)18 BufferedReader (java.io.BufferedReader)8 Support_StringReader (tests.support.Support_StringReader)8 CharArrayReader (java.io.CharArrayReader)2 InputStreamReader (java.io.InputStreamReader)2 PipedReader (java.io.PipedReader)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 CharBuffer (java.nio.CharBuffer)2 ThrowingReader (tests.support.ThrowingReader)2