use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldBufferedOutputStreamTest method test_flush.
public void test_flush() throws IOException {
baos = new ByteArrayOutputStream();
os = new java.io.BufferedOutputStream(baos, 600);
os.write(fileString.getBytes(), 0, 500);
os.flush();
assertEquals("Test 1: Bytes not written after flush;", 500, ((ByteArrayOutputStream) baos).size());
os.close();
sos = new Support_OutputStream(true);
os = new BufferedOutputStream(sos, 10);
try {
os.flush();
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
// To avoid exception during tearDown().
sos.setThrowsException(false);
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldBufferedOutputStreamTest method test_writeI.
public void test_writeI() throws IOException {
baos = new java.io.ByteArrayOutputStream();
os = new java.io.BufferedOutputStream(baos);
os.write('t');
bais = new java.io.ByteArrayInputStream(baos.toByteArray());
assertEquals("Test 1: Byte written, not buffered;", 0, bais.available());
os.flush();
bais = new java.io.ByteArrayInputStream(baos.toByteArray());
assertEquals("Test 2: Byte not written after flush;", 1, bais.available());
byte[] wbytes = new byte[1];
bais.read(wbytes, 0, 1);
assertEquals("Test 3: Incorrect byte written or read;", 't', wbytes[0]);
os.close();
sos = new Support_OutputStream(true);
os = new BufferedOutputStream(sos, 1);
os.write('t');
try {
// Exception is only thrown when the buffer is flushed.
os.write('e');
fail("Test 4: IOException expected.");
} catch (IOException e) {
// Expected.
}
// To avoid exception during tearDown().
sos.setThrowsException(false);
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldDataInputOutputStreamTest method setUp.
protected void setUp() {
sos = new Support_OutputStream(256);
os = new DataOutputStream(sos);
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldByteArrayOutputStreamTest method test_writeToLjava_io_OutputStream.
public void test_writeToLjava_io_OutputStream() throws Exception {
Support_OutputStream sos = new Support_OutputStream();
bos = new java.io.ByteArrayOutputStream();
bos.write(fileString.getBytes(), 0, 10);
bos.writeTo(sos);
assertTrue("Test 1: Incorrect string written.", sos.toString().equals(fileString.substring(0, 10)));
sos.setThrowsException(true);
try {
bos.writeTo(sos);
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldOutputStreamWriterTest method test_ConstructorLjava_io_OutputStream.
public void test_ConstructorLjava_io_OutputStream() throws IOException {
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(null);
fail("Test 1: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected
}
try {
writer = new OutputStreamWriter(new Support_OutputStream());
} catch (Exception e) {
fail("Test 2: Unexpected exception: " + e.getMessage());
}
// Test that the default encoding has been used.
assertEquals("Test 3: Incorrect default encoding used.", Charset.defaultCharset(), Charset.forName(writer.getEncoding()));
if (writer != null)
writer.close();
}
Aggregations