use of java.io.ObjectInputStream in project robovm by robovm.
the class Test method test_readFloat.
/**
* java.io.ObjectInputStream#readFloat()
*/
public void test_readFloat() throws IOException {
oos.writeFloat(Float.MAX_VALUE);
oos.close();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
assertTrue("Read incorrect float value", ois.readFloat() == Float.MAX_VALUE);
ois.close();
}
use of java.io.ObjectInputStream in project robovm by robovm.
the class Test method test_ConstructorLjava_io_InputStream.
/**
* java.io.ObjectInputStream#ObjectInputStream(java.io.InputStream)
*/
public void test_ConstructorLjava_io_InputStream() throws IOException {
oos.writeDouble(Double.MAX_VALUE);
oos.close();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
ois.close();
oos.close();
try {
ois = new ObjectInputStream(new ByteArrayInputStream(new byte[90]));
fail("StreamCorruptedException expected");
} catch (StreamCorruptedException e) {
// Expected
}
}
use of java.io.ObjectInputStream in project robovm by robovm.
the class Test method test_readByte.
/**
* java.io.ObjectInputStream#readByte()
*/
public void test_readByte() throws IOException {
oos.writeByte(127);
oos.close();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
assertEquals("Read incorrect byte value", 127, ois.readByte());
ois.close();
}
use of java.io.ObjectInputStream in project robovm by robovm.
the class Test method test_readObjectCorrupt.
/**
* java.io.ObjectInputStream#readObject()
*/
public void test_readObjectCorrupt() throws IOException, ClassNotFoundException {
byte[] bytes = { 00, 00, 00, 0x64, 0x43, 0x48, (byte) 0xFD, 0x71, 00, 00, 0x0B, (byte) 0xB8, 0x4D, 0x65 };
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
try {
ObjectInputStream in = new ObjectInputStream(bin);
in.readObject();
fail("Unexpected read of corrupted stream");
} catch (StreamCorruptedException e) {
// Expected
}
}
use of java.io.ObjectInputStream in project robovm by robovm.
the class Test method test_read.
/**
* java.io.ObjectInputStream#read()
*/
public void test_read() throws IOException {
oos.write('T');
oos.close();
ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
assertEquals("Read incorrect byte value", 'T', ois.read());
ois.close();
}
Aggregations