assertTrue(proxy instanceof ConnectionFactoryExtension);
assertEquals("SomethingElse", ((ConnectionFactoryExtension)proxy).doSomethingElse());
}
public void testSerialization() throws Exception {
ConnectionFactory proxy = (ConnectionFactory) kernel.invoke(managedConnectionFactoryName, "$getResource");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(proxy);
oos.flush();
byte[] bytes = baos.toByteArray();
oos.close();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
Object proxy2 = ois.readObject();
assertNotNull(proxy2);
assertTrue(proxy instanceof ConnectionFactory);
Connection connection = proxy.getConnection();
assertNotNull(connection);
kernel.stopGBean(managedConnectionFactoryName);
ObjectInputStream ois2 = new ObjectInputStream(new ByteArrayInputStream(bytes));
ConnectionFactory proxy3 = (ConnectionFactory) ois2.readObject();
try {
proxy3.getConnection();
fail();
} catch (IllegalStateException ise) {
}
kernel.startGBean(managedConnectionFactoryName);
proxy3.getConnection();
}