Search in sources :

Example 6 with Support_ASimpleInputStream

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

the class Test method test_skipBytesI_IOException.

public void test_skipBytesI_IOException() throws IOException {
    oos.writeObject(testString);
    oos.close();
    Support_ASimpleInputStream sis = new Support_ASimpleInputStream(bao.toByteArray());
    ois = new ObjectInputStream(sis);
    sis.throwExceptionOnNextUse = true;
    try {
        ois.skipBytes(5);
        fail("Test 1: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    sis.throwExceptionOnNextUse = false;
    ois.close();
}
Also used : Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Example 7 with Support_ASimpleInputStream

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

the class Test method test_read$BII_Exception.

public void test_read$BII_Exception() throws IOException {
    byte[] buf = new byte[testLength];
    oos.writeObject(testString);
    oos.close();
    ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
    try {
        ois.read(buf, 0, -1);
        fail("IndexOutOfBoundsException was not thrown.");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    try {
        ois.read(buf, -1, 1);
        fail("IndexOutOfBoundsException was not thrown.");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    try {
        ois.read(buf, testLength, 1);
        fail("IndexOutOfBoundsException was not thrown.");
    } catch (IndexOutOfBoundsException e) {
    // Expected
    }
    ois.close();
    Support_ASimpleInputStream sis = new Support_ASimpleInputStream(bao.toByteArray());
    ois = new ObjectInputStream(sis);
    sis.throwExceptionOnNextUse = true;
    try {
        ois.read(buf, 0, testLength);
        fail("Test 1: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    sis.throwExceptionOnNextUse = false;
    ois.close();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Example 8 with Support_ASimpleInputStream

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

the class Test method test_available_IOException.

public void test_available_IOException() throws IOException {
    oos.writeObject(testString);
    oos.close();
    Support_ASimpleInputStream sis = new Support_ASimpleInputStream(bao.toByteArray());
    ois = new ObjectInputStream(sis);
    sis.throwExceptionOnNextUse = true;
    try {
        ois.available();
        fail("Test 1: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    sis.throwExceptionOnNextUse = false;
    ois.close();
}
Also used : Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Example 9 with Support_ASimpleInputStream

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

the class Test method test_readFully$B_Exception.

public void test_readFully$B_Exception() throws IOException {
    byte[] buf = new byte[testLength];
    oos.writeObject(testString);
    oos.close();
    Support_ASimpleInputStream sis = new Support_ASimpleInputStream(bao.toByteArray());
    ois = new ObjectInputStream(sis);
    sis.throwExceptionOnNextUse = true;
    try {
        ois.readFully(buf);
        fail("Test 1: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    sis.throwExceptionOnNextUse = false;
    ois.close();
}
Also used : Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Example 10 with Support_ASimpleInputStream

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

the class OldFilterInputStreamTest method test_close.

public void test_close() throws IOException {
    is.close();
    try {
        is.read();
        fail("Test 1: Read from closed stream succeeded.");
    } catch (IOException e) {
    // Expected.
    }
    Support_ASimpleInputStream sis = new Support_ASimpleInputStream(true);
    is = new MyFilterInputStream(sis);
    try {
        is.close();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    sis.throwExceptionOnNextUse = false;
}
Also used : Support_ASimpleInputStream(tests.support.Support_ASimpleInputStream) IOException(java.io.IOException)

Aggregations

Support_ASimpleInputStream (tests.support.Support_ASimpleInputStream)27 IOException (java.io.IOException)24 ObjectInputStream (java.io.ObjectInputStream)10 DataInputStream (java.io.DataInputStream)4 SequenceInputStream (java.io.SequenceInputStream)4 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 StreamTokenizer (java.io.StreamTokenizer)2 Support_StringReader (tests.support.Support_StringReader)2 DigestInputStream (java.security.DigestInputStream)1