assertEquals(el, xmlDecoder.getExceptionListener());
assertEquals(this, xmlDecoder.getOwner());
}
public void testConstructor_ClassLoader() {
XMLDecoder dec;
final Vector<Exception> exceptions = new Vector<Exception>();
ExceptionListener el = new ExceptionListener() {
public void exceptionThrown(Exception e) {
exceptions.addElement(e);
}
};
dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el,
Thread.currentThread().getContextClassLoader());
assertEquals(Integer.valueOf("1"), dec.readObject());
assertEquals(0, exceptions.size());
dec.close();
dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el,
new MockClassLoader());
try {
dec.readObject();
assertTrue(exceptions.size() > 0);
} catch (ArrayIndexOutOfBoundsException e) {
// also valid
}
dec.close();
}