use of nl.nn.adapterframework.jndi.JndiDataSourceFactory in project iaf by ibissource.
the class MessageStoreListenerTest method createListener.
@Override
public MessageStoreListener<M> createListener() throws Exception {
MessageStoreListener listener = spy(new MessageStoreListener() {
@Override
protected Object getRawMessage(Connection conn, Map threadContext) throws ListenerException {
// super class JdbcListener always wraps this in a MessageWrapper
MessageWrapper<Object> mw = new MessageWrapper<>();
mw.setMessage(Message.asMessage(threadContext.get(STUB_RESULT_KEY)));
mw.setId("" + threadContext.get(PipeLineSession.originalMessageIdKey));
return mw;
}
});
DatabaseMetaData md = mock(DatabaseMetaData.class);
doReturn("product").when(md).getDatabaseProductName();
doReturn("version").when(md).getDatabaseProductVersion();
Connection conn = mock(Connection.class);
doReturn(md).when(conn).getMetaData();
JndiDataSourceFactory factory = new JndiDataSourceFactory();
DataSource dataSource = mock(DataSource.class);
String dataSourceName = "myDummyDataSource";
factory.add(dataSource, dataSourceName);
listener.setDataSourceFactory(factory);
doReturn(conn).when(dataSource).getConnection();
listener.setConnectionsArePooled(false);
listener.setDatasourceName(dataSourceName);
doReturn(new GenericDbmsSupport()).when(listener).getDbmsSupport();
return listener;
}
Aggregations