use of tests.support.Support_ASimpleInputStream in project robovm by robovm.
the class DigestInputStream2Test method test_read$BII_Exception.
/**
* java.security.DigestInputStream#read(byte[], int, int)
*/
public void test_read$BII_Exception() throws IOException {
DigestInputStream is = new DigestInputStream(inStream, digest);
byte[] buf = null;
try {
is.read(buf, -1, 0);
fail("Test 1: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected.
}
buf = new byte[1000];
try {
is.read(buf, -1, 0);
fail("Test 2: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
is.read(buf, 0, -1);
fail("Test 3: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
is.read(buf, -1, -1);
fail("Test 4: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
is.read(buf, 0, 1001);
fail("Test 5: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
is.read(buf, 1001, 0);
fail("Test 6: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
is.read(buf, 500, 501);
fail("Test 7: IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
is.close();
Support_ASimpleInputStream sis = new Support_ASimpleInputStream(true);
is = new DigestInputStream(sis, digest);
try {
is.read(buf, 0, 100);
fail("Test 9: IOException expected.");
} catch (IOException e) {
// Expected.
}
sis.throwExceptionOnNextUse = false;
is.close();
}
use of tests.support.Support_ASimpleInputStream in project robovm by robovm.
the class Test method test_available.
public void test_available() throws IOException {
// Test for method int java.io.ObjectInputStream.available()
oos.writeBytes(testString);
oos.close();
Support_ASimpleInputStream sis = new Support_ASimpleInputStream(bao.toByteArray());
ois = new ObjectInputStream(sis);
assertEquals("Test 1: Incorrect number of bytes;", testLength, ois.available());
ois.close();
}
use of tests.support.Support_ASimpleInputStream in project robovm by robovm.
the class Test method test_readFully$BII_Exception.
public void test_readFully$BII_Exception() throws IOException {
byte[] buf = new byte[testLength];
oos.writeObject(testString);
oos.close();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
try {
ois.readFully(buf, 0, -1);
fail("IndexOutOfBoundsException was not thrown.");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
ois.readFully(buf, -1, 1);
fail("IndexOutOfBoundsException was not thrown.");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
ois.readFully(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.readFully(buf, 0, 1);
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Expected.
}
sis.throwExceptionOnNextUse = false;
ois.close();
}
use of tests.support.Support_ASimpleInputStream in project robovm by robovm.
the class Test method test_read_IOException.
public void test_read_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.read();
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Expected.
}
sis.throwExceptionOnNextUse = false;
ois.close();
}
use of tests.support.Support_ASimpleInputStream in project robovm by robovm.
the class Test method test_close.
public void test_close() throws Exception {
// Test for method void java.io.ObjectInputStream.close()
oos.writeObject(testString);
oos.close();
Support_ASimpleInputStream sis = new Support_ASimpleInputStream(bao.toByteArray());
ois = new ObjectInputStream(sis);
sis.throwExceptionOnNextUse = true;
try {
ois.close();
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Expected.
}
sis.throwExceptionOnNextUse = false;
ois.close();
}
Aggregations