use of com.mockrunner.mock.jdbc.MockDataSource in project cayenne by apache.
the class JNDIDataSourceFactoryIT method testGetDataSource_NameBound.
@Test
public void testGetDataSource_NameBound() throws Exception {
DataNodeDescriptor descriptor = new DataNodeDescriptor();
descriptor.setParameters("jdbc/TestDS");
JNDISetup.doSetup();
MockDataSource dataSource = new MockDataSource();
InitialContext context = new InitialContext();
context.bind(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(descriptor.getParameters());
}
}
Aggregations