use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_Byte_Multi.
@Test
public void test_Byte_Multi() throws Exception {
byte[] array = new byte[100];
random.nextBytes(array);
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
for (byte b : array) {
objectOutput.writeByte(b);
}
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
for (byte b : array) {
assertEquals(b, deserialize.readByte());
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_intArray_withType.
@Test
public void test_intArray_withType() throws Exception {
int[] data = new int[] { 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, (int[]) deserialize.readObject(int[].class));
try {
deserialize.readObject(int[].class);
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest 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.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_charArray_withType.
@Test
public void test_charArray_withType() throws Exception {
char[] data = new char[] { 'a', '中', '无' };
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, (char[]) deserialize.readObject(char[].class));
try {
deserialize.readObject(char[].class);
fail();
} catch (IOException expected) {
}
}
use of com.alibaba.dubbo.common.serialize.ObjectInput in project dubbo by alibaba.
the class FstSerializationTest method test_Short.
@Test
public void test_Short() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeShort((short) 123);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals((short) 123, deserialize.readShort());
// try {
// deserialize.readShort();
// fail();
// } catch (IOException expected) {
// }
}
Aggregations