/** * Test serialization code of RPClass by serializing it and then deserializing the stream again * and checking that it is the same RPClass. * * @throws IOException */ @Test public void testSerialization() throws IOException { RPClass expected = new RPClass("RPClassTest::I"); assertEquals(expected, RPClass.getRPClass("RPClassTest::I")); expected.add(DefinitionClass.ATTRIBUTE, "a", Type.INT, Definition.STANDARD); expected.add(DefinitionClass.ATTRIBUTE, "b", Type.FLAG, Definition.HIDDEN); expected.add( DefinitionClass.ATTRIBUTE, "c", Type.STRING, (byte) (Definition.PRIVATE | Definition.VOLATILE)); expected.add(DefinitionClass.RPSLOT, "d", 1, Definition.HIDDEN); ByteArrayOutputStream out = new ByteArrayOutputStream(); OutputSerializer os = new OutputSerializer(out); os.write(expected); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); InputSerializer is = new InputSerializer(in); RPClass result = (RPClass) is.readObject(new RPClass()); assertEquals(expected, result); }
@Override public void writeObject(marauroa.common.net.OutputSerializer out) throws IOException { super.writeObject(out); out.write((byte) reason.ordinal()); }