use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldOutputStreamWriterTest method setUp.
protected void setUp() throws Exception {
super.setUp();
fos = new Support_OutputStream(500);
osw = new OutputStreamWriter(fos, "UTF-8");
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldOutputStreamWriterTest method test_ConstructorLjava_io_OutputStreamLjava_nio_charset_Charset.
public void test_ConstructorLjava_io_OutputStreamLjava_nio_charset_Charset() throws IOException {
OutputStreamWriter writer;
Support_OutputStream out = new Support_OutputStream();
Charset cs = Charset.forName("ascii");
try {
writer = new OutputStreamWriter(null, cs);
fail("Test 1: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected
}
try {
writer = new OutputStreamWriter(out, (Charset) null);
fail("Test 2: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected
}
writer = new OutputStreamWriter(out, cs);
assertEquals("Test 3: Encoding not set correctly. ", cs, Charset.forName(writer.getEncoding()));
writer.close();
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_write$B.
public void test_write$B() throws IOException {
Support_OutputStream sos = new Support_OutputStream(testLength);
os = new FilterOutputStream(sos);
os.write(fileString.getBytes());
bis = new ByteArrayInputStream(sos.toByteArray());
assertTrue("Test 1: Bytes have not been written.", bis.available() == testLength);
byte[] wbytes = new byte[testLength];
bis.read(wbytes, 0, testLength);
assertTrue("Test 2: Incorrect bytes written or read.", fileString.equals(new String(wbytes)));
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 OldFilterOutputStreamTest method test_close.
public void test_close() throws IOException {
Support_OutputStream sos = new Support_OutputStream();
os = new FilterOutputStream(sos);
os.close();
try {
os.write(42);
} catch (java.io.IOException e) {
fail("Test 1: Unexpected IOException.");
}
sos.setThrowsException(true);
try {
os.write(42);
fail("Test 2: IOException expected.");
} catch (java.io.IOException e) {
// Expected.
}
os = new FilterOutputStream(sos);
try {
os.close();
fail("Test 3: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_flush.
public void test_flush() throws IOException {
Support_OutputStream sos = new Support_OutputStream(550);
os = new FilterOutputStream(sos);
os.write(fileString.getBytes(), 0, 500);
os.flush();
assertEquals("Test 1: Bytes not written after flush;", 500, sos.size());
sos.setThrowsException(true);
try {
os.flush();
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
sos.setThrowsException(false);
}
Aggregations