use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationTest method test_Double.
// ================== Util methods ==================
@Test
public void test_Double() throws Exception {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeDouble(1.28);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals(1.28, deserialize.readDouble());
try {
deserialize.readDouble();
fail();
} catch (IOException expected) {
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class KryoSerialization2Test method testObjectWithAttachments.
@Test
public void testObjectWithAttachments() throws IOException, ClassNotFoundException {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(bigPerson);
Map<String, Object> attachments = new HashMap<>();
attachments.put("attachments", "attachments");
objectOutput.writeObject(attachments);
objectOutput.flushBuffer();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
assertEquals(bigPerson, BigPerson.class.cast(deserialize.readObject(BigPerson.class)));
assertEquals(attachments, deserialize.readAttachments());
try {
deserialize.readObject(BigPerson.class);
fail();
} catch (IOException expected) {
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest method test_IntPersonMap.
@Test
public void test_IntPersonMap() throws Exception {
Map<Integer, Person> args = new HashMap<Integer, Person>();
args.put(1, new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest method test_PersonList.
@Test
public void test_PersonList() throws Exception {
List<Person> args = new ArrayList<Person>();
args.add(new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString(FAIL_STRING));
}
}
use of org.apache.dubbo.common.serialize.ObjectOutput in project dubbo by alibaba.
the class AbstractSerializationPersonFailTest method test_StringPersonMap.
@Test
public void test_StringPersonMap() throws Exception {
Map<String, Person> args = new HashMap<String, Person>();
args.put("1", new Person());
try {
ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
objectOutput.writeObject(args);
fail();
} catch (NotSerializableException expected) {
} catch (IllegalStateException expected) {
assertThat(expected.getMessage(), containsString(FAIL_STRING));
}
}
Aggregations