use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest 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 FstSerializationTest method test_Long.
@Test
public void test_Long() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeLong(123L);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals(123L, deserialize.readLong());
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_BytesRange.
@Test
public void test_BytesRange() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeBytes("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, 9);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
byte[] expectedArray = new byte[9];
System.arraycopy("123中华人民共和国-新疆维吾尔自治区".getBytes(), 1, expectedArray, 0, expectedArray.length);
assertArrayEquals(expectedArray, deserialize.readBytes());
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_longArray.
@Test
public void test_longArray() throws Exception {
long[] data = new long[] { 234, 0, -1 };
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, (long[]) deserialize.readObject());
try {
deserialize.readObject();
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class FstSerializationTest method test_doubleArray_withType.
@Test
public void test_doubleArray_withType() 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(double[].class), 0.0001);
try {
deserialize.readObject(double[].class);
fail();
} catch (IOException expected) {
}
}
Aggregations