use of java.io.NotSerializableException in project orientdb by orientechnologies.
the class TrackedListTest method testSerialization.
/**
* Test that {@link OTrackedList} is serialised correctly.
*/
@Test
public void testSerialization() throws Exception {
class NotSerializableDocument extends ODocument {
private static final long serialVersionUID = 1L;
private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException();
}
}
final OTrackedList<String> beforeSerialization = new OTrackedList<String>(new NotSerializableDocument());
beforeSerialization.add("firstVal");
beforeSerialization.add("secondVal");
final OMemoryStream memoryStream = new OMemoryStream();
ObjectOutputStream out = new ObjectOutputStream(memoryStream);
out.writeObject(beforeSerialization);
out.close();
final ObjectInputStream input = new ObjectInputStream(new OMemoryInputStream(memoryStream.copy()));
@SuppressWarnings("unchecked") final List<String> afterSerialization = (List<String>) input.readObject();
Assert.assertEquals(afterSerialization.size(), beforeSerialization.size(), "List size");
for (int i = 0; i < afterSerialization.size(); i++) {
Assert.assertEquals(afterSerialization.get(i), beforeSerialization.get(i));
}
}
use of java.io.NotSerializableException in project orientdb by orientechnologies.
the class TrackedSetTest method testSetSerialization.
/**
* Test that {@link OTrackedSet} is serialised correctly.
*/
@Test
public void testSetSerialization() throws Exception {
class NotSerializableDocument extends ODocument {
private static final long serialVersionUID = 1L;
private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException();
}
}
final OTrackedSet<String> beforeSerialization = new OTrackedSet<String>(new NotSerializableDocument());
beforeSerialization.add("firstVal");
beforeSerialization.add("secondVal");
final OMemoryStream memoryStream = new OMemoryStream();
ObjectOutputStream out = new ObjectOutputStream(memoryStream);
out.writeObject(beforeSerialization);
out.close();
final ObjectInputStream input = new ObjectInputStream(new OMemoryInputStream(memoryStream.copy()));
@SuppressWarnings("unchecked") final Set<String> afterSerialization = (Set<String>) input.readObject();
Assert.assertEquals(afterSerialization.size(), beforeSerialization.size(), "Set size");
Assert.assertTrue(beforeSerialization.containsAll(afterSerialization));
}
use of java.io.NotSerializableException in project flink by apache.
the class FailedCheckpointStatsTest method testIsJavaSerializable.
@Test
public void testIsJavaSerializable() throws Exception {
long duration = 123912931293L;
long triggerTimestamp = 10123;
long failureTimestamp = triggerTimestamp + duration;
Map<JobVertexID, TaskStateStats> taskStats = new HashMap<>();
JobVertexID jobVertexId = new JobVertexID();
taskStats.put(jobVertexId, new TaskStateStats(jobVertexId, 1));
FailedCheckpointStats failed = new FailedCheckpointStats(123123123L, triggerTimestamp, CheckpointProperties.forStandardCheckpoint(), 1337, taskStats, 3, 190890123, 0, failureTimestamp, null, new NotSerializableException("message"));
FailedCheckpointStats copy = CommonTestUtils.createCopySerializable(failed);
assertEquals(failed.getCheckpointId(), copy.getCheckpointId());
assertEquals(failed.getTriggerTimestamp(), copy.getTriggerTimestamp());
assertEquals(failed.getProperties(), copy.getProperties());
assertEquals(failed.getNumberOfSubtasks(), copy.getNumberOfSubtasks());
assertEquals(failed.getNumberOfAcknowledgedSubtasks(), copy.getNumberOfAcknowledgedSubtasks());
assertEquals(failed.getEndToEndDuration(), copy.getEndToEndDuration());
assertEquals(failed.getStateSize(), copy.getStateSize());
assertEquals(failed.getLatestAcknowledgedSubtaskStats(), copy.getLatestAcknowledgedSubtaskStats());
assertEquals(failed.getStatus(), copy.getStatus());
assertEquals(failed.getFailureMessage(), copy.getFailureMessage());
}
use of java.io.NotSerializableException in project dubbo by alibaba.
the class AbstractSerializationPersionFailTest method test_PersonListList.
@Test
public void test_PersonListList() throws Exception {
List<List<Person>> args = new ArrayList<List<Person>>();
List<Person> sublist = new ArrayList<Person>();
sublist.add(new Person());
args.add(sublist);
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 dubbo by alibaba.
the class AbstractSerializationPersionFailTest 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("Serialized class com.alibaba.dubbo.common.model.Person must implement java.io.Serializable"));
}
}
Aggregations