use of java.io.ObjectOutputStream in project j2objc by google.
the class OldObjectInputOutputStreamTest method setUp.
protected void setUp() throws IOException {
sos = new Support_OutputStream(256);
os = new ObjectOutputStream(sos);
}
use of java.io.ObjectOutputStream 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 java.io.ObjectOutputStream in project j2objc by google.
the class DecimalFormatSymbolsTest method testSerializationOfMultiCharNegativeAndPercentage.
// https://code.google.com/p/android/issues/detail?id=170718
public void testSerializationOfMultiCharNegativeAndPercentage() throws Exception {
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.forLanguageTag("ar-AR"));
// TODO(user): Investigate.
// assertTrue(dfs.getMinusSignString().length() > 1);
// assertTrue(dfs.getPercentString().length() > 1);
// Serialize...
ByteArrayOutputStream out = new ByteArrayOutputStream();
new ObjectOutputStream(out).writeObject(dfs);
byte[] bytes = out.toByteArray();
// Deserialize...
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
DecimalFormatSymbols deserializedDfs = (DecimalFormatSymbols) in.readObject();
assertEquals(-1, in.read());
assertEquals(dfs.getMinusSign(), deserializedDfs.getMinusSign());
assertEquals(dfs.getPercent(), deserializedDfs.getPercent());
}
use of java.io.ObjectOutputStream in project guice by google.
the class Asserts method reserialize.
public static <E> E reserialize(E original) throws IOException {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
new ObjectOutputStream(out).writeObject(original);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
// the reserialized type is assignable
@SuppressWarnings("unchecked") E reserialized = (E) new ObjectInputStream(in).readObject();
return reserialized;
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
use of java.io.ObjectOutputStream in project j2objc by google.
the class SerializationTester method serialize.
private static byte[] serialize(Object object) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
new ObjectOutputStream(out).writeObject(object);
return out.toByteArray();
}
Aggregations