use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method test_boolArray.
@Test
public void test_boolArray() throws Exception {
boolean[] data = new boolean[] { true, false, true };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertTrue(Arrays.equals(data, (boolean[]) deserialize.readObject()));
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method test_doubleArray.
@Test
public void test_doubleArray() throws Exception {
double[] data = new double[] { 37D, -3.14D, 123456.7D };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, (double[]) deserialize.readObject(), 0.0001);
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method test_UtfString.
@Test
public void test_UtfString() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeUTF("123中华人民共和国");
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals("123中华人民共和国", deserialize.readUTF());
try {
deserialize.readUTF();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method test_floatArray.
@Test
public void test_floatArray() throws Exception {
float[] data = new float[] { 37F, -3.14F, 123456.7F };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, (float[]) deserialize.readObject(), 0.0001F);
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method test_floatArray_withType.
@Test
public void test_floatArray_withType() throws Exception {
float[] data = new float[] { 37F, -3.14F, 123456.7F };
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(data);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertArrayEquals(data, (float[]) deserialize.readObject(float[].class), 0.0001F);
try {
deserialize.readObject(float[].class);
fail();
} catch (IOException expected) {
}
}
Aggregations