use of tests.support.Support_OutputStream in project j2objc by google.
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 j2objc by google.
the class DigestOutputStreamTest method test_write$BII_7.
/**
* java.io.DigestOutputStream#write(byte[], int, int)
*/
public void test_write$BII_7() throws IOException, NoSuchAlgorithmException {
Support_OutputStream sos = new Support_OutputStream(MY_MESSAGE_LEN);
MessageDigest md = MessageDigest.getInstance(algorithmName[0]);
DigestOutputStream dos = new DigestOutputStream(sos, md);
dos.write(myMessage, 0, MY_MESSAGE_LEN);
try {
// Support_OutputStream throws an IOException if the internal
// buffer is full, which it should be now.
dos.write(myMessage, 0, MY_MESSAGE_LEN);
fail("Test 1: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldBufferedOutputStreamTest method test_write$BII.
public void test_write$BII() throws IOException {
os = new java.io.BufferedOutputStream(baos = new java.io.ByteArrayOutputStream(), 512);
os.write(fileString.getBytes(), 0, 500);
bais = new java.io.ByteArrayInputStream(baos.toByteArray());
assertEquals("Test 1: Bytes written, not buffered;", 0, bais.available());
os.flush();
bais = new java.io.ByteArrayInputStream(baos.toByteArray());
assertEquals("Test 2: Bytes not written after flush;", 500, bais.available());
os.write(fileString.getBytes(), 500, 513);
bais = new java.io.ByteArrayInputStream(baos.toByteArray());
assertTrue("Test 3: Bytes not written when buffer full.", bais.available() >= 1000);
byte[] wbytes = new byte[1013];
bais.read(wbytes, 0, 1013);
assertTrue("Test 4: Incorrect bytes written or read.", fileString.substring(0, 1013).equals(new String(wbytes, 0, wbytes.length)));
os.close();
sos = new Support_OutputStream(true);
os = new BufferedOutputStream(sos, 10);
try {
os.write(fileString.getBytes(), 0, 500);
fail("Test 5: 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 OldObjectInputOutputStreamTest method setUp.
protected void setUp() throws IOException {
sos = new Support_OutputStream(256);
os = new ObjectOutputStream(sos);
}
use of tests.support.Support_OutputStream in project robovm by robovm.
the class OldDataOutputStreamTest method setUp.
protected void setUp() {
sos = new Support_OutputStream(true);
bos = new ByteArrayOutputStream();
os = new DataOutputStream(bos);
}
Aggregations