use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_write$BII_Exception.
public void test_write$BII_Exception() throws IOException {
Support_OutputStream sos = new Support_OutputStream(testLength);
os = new FilterOutputStream(sos);
byte[] buf = new byte[10];
try {
os.write(buf, -1, 1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
os.write(buf, 0, -1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
os.write(buf, 10, 1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_write$BII.
public void test_write$BII() throws IOException {
Support_OutputStream sos = new Support_OutputStream(testLength);
os = new FilterOutputStream(sos);
os.write(fileString.getBytes(), 10, testLength - 10);
bis = new ByteArrayInputStream(sos.toByteArray());
assertTrue("Test 1: Bytes have not been written.", bis.available() == testLength - 10);
byte[] wbytes = new byte[testLength - 10];
bis.read(wbytes);
assertTrue("Test 2: Incorrect bytes written or read.", fileString.substring(10).equals(new String(wbytes)));
try {
// Support_OutputStream throws an IOException if the internal
// buffer is full, which it should be eventually.
os.write(fileString.getBytes());
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_writeI.
public void test_writeI() throws IOException {
Support_OutputStream sos = new Support_OutputStream(1);
os = new FilterOutputStream(sos);
os.write(42);
bis = new ByteArrayInputStream(sos.toByteArray());
assertTrue("Test 1: Byte has not been written.", bis.available() == 1);
assertEquals("Test 2: Incorrect byte written or read;", 42, bis.read());
try {
// Support_OutputStream throws an IOException if the internal
// buffer is full, which it should be now.
os.write(42);
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldObjectOutputStreamTest method setUp.
/**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
*/
protected void setUp() throws Exception {
super.setUp();
oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
oos_ioe = new ObjectOutputStream(sos = new Support_OutputStream());
sos.setThrowsException(true);
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldOutputStreamWriterTest method test_getEncoding.
public void test_getEncoding() throws IOException {
OutputStreamWriter writer;
writer = new OutputStreamWriter(new Support_OutputStream(), "utf-8");
assertEquals("Test 1: Incorrect encoding returned.", Charset.forName("utf-8"), Charset.forName(writer.getEncoding()));
writer.close();
assertNull("Test 2: getEncoding() did not return null for a closed writer.", writer.getEncoding());
}
Aggregations