use of tests.support.Support_ASimpleInputStream in project j2objc by google.
the class OldDataInputStreamTest method test_read$BII.
public void test_read$BII() throws IOException {
byte[] rbytes = new byte[testLength - 5];
Support_ASimpleInputStream sis = new Support_ASimpleInputStream();
int r;
os.write(fileString.getBytes());
os.close();
openDataInputStream();
r = dis.read(rbytes, 1, testLength - 10);
assertEquals("Test 1: Incorrect number of bytes read;", testLength - 10, r);
assertEquals("Test 2: Incorrect data read.", 0, rbytes[0]);
assertTrue("Test 3: Incorrect data written or read.", new String(rbytes, 1, r).equals(fileString.substring(0, r)));
r = dis.read(rbytes, 0, 15);
assertEquals("Test 3: Incorrect number of bytes read;", 10, r);
assertTrue("Test 4: Incorrect data written or read.", new String(rbytes, 0, r).equals(fileString.substring(testLength - 10)));
dis.close();
sis.throwExceptionOnNextUse = true;
dis = new DataInputStream(sis);
try {
dis.read(rbytes, 1, 5);
fail("Test 5: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_ASimpleInputStream in project j2objc by google.
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 j2objc by google.
the class OldInputStreamReaderTest method test_close.
public void test_close() {
// Test for method void java.io.InputStreamReader.close()
try {
is.close();
} catch (IOException e) {
fail("Failed to close reader : " + e.getMessage());
}
try {
is.read();
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Exception means read failed due to close
}
is = new InputStreamReader(new Support_ASimpleInputStream(true));
try {
is.read();
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_ASimpleInputStream in project j2objc by google.
the class OldSequenceInputStreamTest method setUp.
protected void setUp() {
simple1 = new Support_ASimpleInputStream(s1);
simple2 = new Support_ASimpleInputStream(s2);
si = new SequenceInputStream(simple1, simple2);
}
use of tests.support.Support_ASimpleInputStream in project j2objc by google.
the class OldDataInputStreamTest method test_read$B.
public void test_read$B() throws IOException {
byte[] rbytes = new byte[testLength - 5];
Support_ASimpleInputStream sis = new Support_ASimpleInputStream();
int r;
os.write(fileString.getBytes());
os.close();
openDataInputStream();
r = dis.read(rbytes);
assertEquals("Test 1: Incorrect number of bytes read;", testLength - 5, r);
assertTrue("Test 2: Incorrect data written or read.", new String(rbytes).equals(fileString.substring(0, testLength - 5)));
r = dis.read(rbytes);
assertEquals("Test 3: Incorrect number of bytes read;", 5, r);
assertTrue("Test 4: Incorrect data written or read.", new String(rbytes, 0, 5).equals(fileString.substring(testLength - 5)));
dis.close();
sis.throwExceptionOnNextUse = true;
dis = new DataInputStream(sis);
try {
dis.read(rbytes);
fail("Test 5: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
Aggregations