* two objects should be equal.
*/
public void testSerializable_Simple() throws ClassNotFoundException,
IOException, InvalidNameException {
NoInitialContextException exception = new NoInitialContextException(
"Test exception Serializable: NoInitialContextException");
exception.setRemainingName(new CompositeName(
"www.apache.org/foundation"));
exception.setResolvedName(new CompositeName(
"http://www.apache.org/index.html"));
exception.setResolvedObj("This is a string object.");
exception.setRootCause(new NullPointerException("null pointer"));
// write to byte array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(exception);
byte[] buffer = baos.toByteArray();
oos.close();
baos.close();
// read from byte array
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
ObjectInputStream ois = new ObjectInputStream(bais);
NoInitialContextException exception2 = (NoInitialContextException) ois
.readObject();
ois.close();
bais.close();
assertEquals(exception.getExplanation(), exception2.getExplanation());
assertEquals(exception.getResolvedObj(), exception2.getResolvedObj());
assertEquals(exception.getRemainingName(), exception2
.getRemainingName());
assertEquals(exception.getResolvedName(), exception2.getResolvedName());
assertEquals(exception.getRootCause().getMessage(), exception2
.getRootCause().getMessage());
assertEquals(exception.getRootCause().getClass(), exception2
.getRootCause().getClass());
}