I reorganized the code from my question until I finished the next method for the critical part, i.e. those Class.forName("some.class.name")challenges:
Statement createStatement() throws SQLException, ClassNotFoundException {
Connection connection = dataSource.getConnection();
((org.postgresql.PGConnection) connection).addDataType("geometry", Class.forName("org.postgis.PGgeometry"));
((org.postgresql.PGConnection) connection).addDataType("box3d", Class.forName("org.postgis.PGbox3d"));
return connection.createStatement();
}
In my unit tests, I then used
when(dao.createStatement()).thenThrow(ClassNotFoundException.class);
who finally solved my problem.
source
share