public void run() throws Exception {
// create test infrastructure
ObjectEndpoint oe = new FakeObjectEndpoint();
FakeMethodConstraints fakeMethodConstraints =
new FakeMethodConstraints(null);
BasicILFactory factory = new BasicILFactory(
fakeMethodConstraints,ExportPermission.class);
FakeServerCapabilities sc = new FakeServerCapabilities(null);
int counter = 1;
logger.log(Level.FINE,"=================================");
logger.log(Level.FINE,"test case " + (counter++)
+ ": createInstances(null,null,null)");
logger.log(Level.FINE,"");
// null parameter tests
try {
factory.createInstances(null, null, null);
assertion(false);
} catch (NullPointerException npe) {}
logger.log(Level.FINE,"=================================");
logger.log(Level.FINE,"test case " + (counter++)
+ ": createInstances(Remote,null,null)");
logger.log(Level.FINE,"");
try {
factory.createInstances(new Remote() {}, null, null);
assertion(false);
} catch (NullPointerException npe) {}
logger.log(Level.FINE,"=================================");
logger.log(Level.FINE,"test case " + (counter++) + ": "
+ "createInstances(null,ObjectEndpoint,null)");
logger.log(Level.FINE,"");
try {
factory.createInstances(null, oe, null);
assertion(false);
} catch (NullPointerException npe) {}
logger.log(Level.FINE,"=================================");
logger.log(Level.FINE,"test case " + (counter++) + ": "
+ "createInstances(null,null,ServerCapabilities)");
logger.log(Level.FINE,"");
try {
factory.createInstances(null, null, sc);
assertion(false);
} catch (NullPointerException npe) {}
for (int i = 0; i < cases.length; i++) {
Class[] interfaces = (Class[])cases[i][0];
boolean legal = ((Boolean)cases[i][1]).booleanValue();
Class[] expectedInterfaces = (Class[])cases[i][2];
logger.log(Level.FINE,"=================================");
logger.log(Level.FINE,"test case " + (counter++) + ": "
+ "legal:" + legal + ", interfaces:" + interfaces);
logger.log(Level.FINE,"");
Remote impl = createImpl(interfaces, oe);
// verify createInstances behavior using legal and illegal
// parameters
if (legal) {
Object proxy =
factory.createInstances(impl,oe,sc).getProxy();
InvocationHandler handler =
Proxy.getInvocationHandler(proxy);
assertion(proxy.getClass().getClassLoader() ==
impl.getClass().getClassLoader());
assertion(handler instanceof BasicInvocationHandler);
assertion(((BasicInvocationHandler)handler).
getObjectEndpoint() == oe);
assertion(((BasicInvocationHandler)handler).
getServerConstraints() == fakeMethodConstraints);
assertion(Arrays.equals(expectedInterfaces,
proxy.getClass().getInterfaces()));
} else {
try {
factory.createInstances(impl,oe,sc);
assertion(false);
} catch (ExportException ignore) { }
}
}
}