use of java.io.DataInput in project geode by apache.
the class DataSerializableJUnitTest method testObjectArrayObject.
/**
* Tests data serializing a <code>Object</code> array using {@link DataSerializer#writeObject}.
*/
@Test
public void testObjectArrayObject() throws Exception {
Random random = getRandom();
SerializableImpl[] array = new SerializableImpl[] { new SerializableImpl(random), new SerializableImpl(random), new SerializableImpl(random) };
DataOutputStream out = getDataOutput();
DataSerializer.writeObject(array, out);
out.flush();
DataInput in = getDataInput();
SerializableImpl[] array2 = (SerializableImpl[]) DataSerializer.readObject(in);
assertEquals(array.length, array2.length);
for (int i = 0; i < array.length; i++) {
assertEquals(array[i], array2[i]);
}
}
use of java.io.DataInput in project geode by apache.
the class DataSerializableJUnitTest method testFileObject.
/**
* Tests data serializing a {@link File} using {@link DataSerializer#writeObject}.
*/
@Test
public void testFileObject() throws Exception {
File file = new File(System.getProperty("user.dir"));
DataOutputStream out = getDataOutput();
DataSerializer.writeObject(file, out);
out.flush();
DataInput in = getDataInput();
File file2 = (File) DataSerializer.readObject(in);
assertEquals(file, file2);
}
use of java.io.DataInput in project geode by apache.
the class DataSerializableJUnitTest method testClass.
/**
* Tests data serializing a {@link Class}
*/
@Test
public void testClass() throws Exception {
Class c = this.getClass();
DataOutputStream out = getDataOutput();
DataSerializer.writeClass(c, out);
out.flush();
DataInput in = getDataInput();
Class c2 = DataSerializer.readClass(in);
assertEquals(c, c2);
}
use of java.io.DataInput in project geode by apache.
the class DataSerializableJUnitTest method testInteger.
/**
* Tests data serializing a {@link Integer}
*/
@Test
public void testInteger() throws Exception {
Integer value = new Integer(getRandom().nextInt());
DataOutputStream out = getDataOutput();
DataSerializer.writeInteger(value, out);
out.flush();
DataInput in = getDataInput();
Integer value2 = DataSerializer.readInteger(in);
assertEquals(value, value2);
}
use of java.io.DataInput in project geode by apache.
the class DataSerializableJUnitTest method testBooleanObject.
/**
* Tests data serializing a {@link Boolean} using {@link DataSerializer#writeObject}.
*/
@Test
public void testBooleanObject() throws Exception {
Boolean value = new Boolean(getRandom().nextInt() % 2 == 0);
DataOutputStream out = getDataOutput();
DataSerializer.writeObject(value, out);
out.flush();
DataInput in = getDataInput();
Boolean value2 = (Boolean) DataSerializer.readObject(in);
assertEquals(value, value2);
}
Aggregations