mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-02 09:09:37 +00:00
enabled more SecurityService operations for replication; added serialization test for fields declared of non-serializable type
This commit is contained in:
1 parent
ea6ce41f2a
commit
5b1e725849
3 files changed
+79
-5
No files matched your search
+19
@@ -6,9 +6,11 @@ import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.NotSerializableException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
@@ -232,4 +234,21 @@ public class OfflineSerializationTest extends AbstractSerializationTest {
|
||||
logger.info("Caught expected exception "+nse);
|
||||
}
|
||||
}
|
||||
|
||||
private static class NonSerializableFieldDeclaration implements Serializable {
|
||||
private static final long serialVersionUID = 1806419236999145531L;
|
||||
public Object nonSerializable;
|
||||
}
|
||||
@Test
|
||||
public void testSerializingSerializableFieldValueOfNonSerializableDeclaredType() throws IOException, ClassNotFoundException {
|
||||
final NonSerializableFieldDeclaration o = new NonSerializableFieldDeclaration();
|
||||
o.nonSerializable = "A serializable String object";
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||
oos.writeObject(o);
|
||||
oos.close();
|
||||
final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
|
||||
NonSerializableFieldDeclaration o2 = (NonSerializableFieldDeclaration) ois.readObject();
|
||||
assertEquals(o.nonSerializable, o2.nonSerializable);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user