use of tests.support.Support_ASimpleInputStream in project j2objc by google.
the class OldSequenceInputStreamTest method test_read$BII_Excpetion.
public void test_read$BII_Excpetion() throws IOException {
byte[] buf = new byte[4];
si.read(buf, 0, 2);
si.read(buf, 2, 1);
simple2.throwExceptionOnNextUse = true;
si.read(buf, 3, 1);
assertEquals("Wrong stuff read!", "Hell", new String(buf));
simple1.throwExceptionOnNextUse = true;
try {
si.read(buf, 3, 1);
fail("IOException not thrown!");
} catch (IOException e) {
// expected
}
buf = new byte[10];
simple1 = new Support_ASimpleInputStream(s1);
simple2 = new Support_ASimpleInputStream(s2);
si = new SequenceInputStream(simple1, simple2);
try {
si.read(buf, -1, 1);
fail("IndexOutOfBoundsException was not thrown");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
si.read(buf, 0, -1);
fail("IndexOutOfBoundsException was not thrown");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
si.read(buf, 1, 10);
fail("IndexOutOfBoundsException was not thrown");
} catch (IndexOutOfBoundsException e) {
// Expected
}
}
use of tests.support.Support_ASimpleInputStream in project j2objc by google.
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.
}
}
use of tests.support.Support_ASimpleInputStream in project robovm by robovm.
the class OldBufferedInputStreamTest method test_close.
public void test_close() throws IOException {
is.close();
try {
is.read();
fail("Test 1: IOException expected when reading after closing " + "the stream.");
} catch (IOException e) {
// Expected.
}
Support_ASimpleInputStream sis = new Support_ASimpleInputStream(true);
is = new BufferedInputStream(sis);
try {
is.close();
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
sis.throwExceptionOnNextUse = false;
}
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();
}
Aggregations