Hello Christopher, maybe i'm a little bit slow here, but from what i see, we should mock the connection method
Connection connection= ds.getConnection(); something like Connection connection =(Connection) EasyMock.expect(ds. isvalid()).andReturn(true).anyTimes(); Problem is, the error happened during the validation of the PoolableConnection, below is the build error from the surefire Caused by: java.sql.SQLException: isValid() returned false at org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:283) at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:357) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2307) at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2290) so i think we should either override the validate() so the validation is always returning true( which i am reluctant to do, as the point is to test the whole thing) or enhancing the fake driver connection, so it always responding with a result set. something like private boolean isValid(int, int ) extend connection throws SQLException { execute ("select 1)); //another if else statment that we need / default result set return true; } Roy On Wed, Aug 10, 2016 at 5:43 PM, Christopher Schultz < ch...@christopherschultz.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Roy, > > On 8/10/16 11:11 AM, Roy Leonardus wrote: > > Hello Christopher, > > > > Thank you for the tip, i managed to test the code using the apache > > Derby now. > > > > it would be interesting to enhance the driver class to respond with > > some result set, but i need to review it again. > > > > and it will be another homework for me. > > Aren't you mocking-up the JDBC driver? Just add a return value for > that call... something like: > > mockDriver.expect("next").return(true); > mockDriver.expect("getInt", 1).return(0); > > You'll have to adapt that to your actual mocking framework, of course. > > - -chris > -----BEGIN PGP SIGNATURE----- > Comment: GPGTools - http://gpgtools.org > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQIcBAEBCAAGBQJXq0uOAAoJEBzwKT+lPKRY99gQAIw/khRNXErKjzoaqYFXjY4/ > GIdl8u2kH1V7AKePBK+o9EjggO+5qhHZOSFHsOGhiE0GbTIp3tRzRZ4/eBVit+cv > dprp6eY1DtRznq1QahzGmzg+8XG7P7STbG1dE6Kj+0rnRAlWlmqCuLtT3WyOyolD > FqfwedLJomQ+T6aFaY0MsdXHwfQ6m35EXHj5KrAOoFHWP7OLY/oXaFi2b1ztRRTB > 9EY9Y8fuD08emRiv4cUyDiO1rz0mLRtkTS+WTMjg6OUogHkWu0fjXn0YFZx1shkh > RrB7OyWTIc9EXOffp10enKv2LfoW71c+NbZY8GtiEswlkPrNIjR08xA5rzhzLm+q > KpJFRea+kXwm1XI7M2o+r3MeqTg9WEghvOB3T7ZwnaCQ0weB5B5dTYnredpaYXEC > 0PEmekF+69VuDbNYw6zAJVHtAbW5gSIEOl3mHKR2Em9PYKuleHpxpqABd5n/OBAG > bZb/pWWamaVOQ8W5Joo+SHhRwH9TdrSDxgTk2e54FGUgjNu+XNy/0Qd1XLbOL4IY > qaxzsnrHugHieUlw4dWeELr31wmX/BbQinIKK3XQQwKbTiK3fslP19NBpp0PbzY4 > SIBe+DxhKGygkyrj/FVYV+VrHtvc68zu2AH97RAOWlLrKB/KEqidCHdTGnRjQjUz > cdXH+GaFUBo/zvtT4jhq > =uDwn > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >