use of java.io.NotSerializableException in project dubbo by alibaba.
the class AbstractSerializationPersionFailTest method test_PersonSet.
@Test
public void test_PersonSet() throws Exception {
Set<Person> args = new HashSet<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("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
}
}
use of java.io.NotSerializableException in project orientdb by orientechnologies.
the class TrackedMapTest method testMapSerialization.
/**
* Test that {@link OTrackedMap} is serialised correctly.
*/
@Test
public void testMapSerialization() throws Exception {
class NotSerializableDocument extends ODocument {
private static final long serialVersionUID = 1L;
private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException();
}
}
final OTrackedMap<String> beforeSerialization = new OTrackedMap<String>(new NotSerializableDocument());
beforeSerialization.put(0, "firstVal");
beforeSerialization.put(1, "secondVal");
final OMemoryStream memoryStream = new OMemoryStream();
final ObjectOutputStream out = new ObjectOutputStream(memoryStream);
out.writeObject(beforeSerialization);
out.close();
final ObjectInputStream input = new ObjectInputStream(new OMemoryInputStream(memoryStream.copy()));
@SuppressWarnings("unchecked") final Map<Object, String> afterSerialization = (Map<Object, String>) input.readObject();
Assert.assertEquals(afterSerialization.size(), beforeSerialization.size(), "Map size");
for (int i = 0; i < afterSerialization.size(); i++) {
Assert.assertEquals(afterSerialization.get(i), beforeSerialization.get(i));
}
}
use of java.io.NotSerializableException in project robovm by robovm.
the class AnnotationTypeMismatchExceptionTest method testSerialization.
public void testSerialization() throws Exception {
Method m = String.class.getMethod("length");
AnnotationTypeMismatchException original = new AnnotationTypeMismatchException(m, "poop");
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// AnnotationTypeMismatchException is broken: it's Serializable but has a non-transient
// non-serializable field of type Method.
new ObjectOutputStream(out).writeObject(original);
fail();
} catch (NotSerializableException expected) {
}
}
use of java.io.NotSerializableException in project spring-framework by spring-projects.
the class SerializationConverterTests method nonSerializableField.
@Test
public void nonSerializableField() {
SerializingConverter toBytes = new SerializingConverter();
try {
toBytes.convert(new UnSerializable());
fail("Expected SerializationFailureException");
} catch (SerializationFailedException e) {
assertNotNull(e.getCause());
assertTrue(e.getCause() instanceof NotSerializableException);
}
}
use of java.io.NotSerializableException in project j2objc by google.
the class AnnotationTypeMismatchExceptionTest method testSerialization.
public void testSerialization() throws Exception {
Method m = String.class.getMethod("length");
AnnotationTypeMismatchException original = new AnnotationTypeMismatchException(m, "poop");
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
// AnnotationTypeMismatchException is broken: it's Serializable but has a non-transient
// non-serializable field of type Method.
new ObjectOutputStream(out).writeObject(original);
fail();
} catch (NotSerializableException expected) {
}
}
Aggregations