InitialContext context = new InitialContext();
context.bind("java:comp/env/" + descriptor.getParameters(), dataSource);
try {
JNDIDataSourceFactory factory = new JNDIDataSourceFactory();
injector.injectMembers(factory);
assertSame(dataSource, factory.getDataSource(descriptor));
}
finally {
// since the context is shared, must clear it after the test
context.unbind("java:comp/env/" + descriptor.getParameters());
}