* Test serialization.
*/
public void testSerialization()
{
// Create the role info
RoleInfo roleInfo = null;
RoleInfo roleInfo2 = null;
try
{
roleInfo = new RoleInfo("RoleName", RelationSupport.class.getName(),
false, false, 23, 25, "Description");
// Serialize it
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(roleInfo);
// Deserialize it
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
roleInfo2 = (RoleInfo) ois.readObject();
}
catch (Exception e)
{
fail(e.toString());
}
// Did it work?
assertEquals(roleInfo.getName(), roleInfo2.getName());
assertEquals(roleInfo.getRefMBeanClassName(), roleInfo2.getRefMBeanClassName());
assertEquals(roleInfo.isReadable(), roleInfo2.isReadable());
assertEquals(roleInfo.isWritable(), roleInfo2.isWritable());
assertEquals(roleInfo.getMinDegree(), roleInfo2.getMinDegree());
assertEquals(roleInfo.getMaxDegree(), roleInfo2.getMaxDegree());
assertEquals(roleInfo.getDescription(), roleInfo2.getDescription());
}