use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcConnectionPoolValidatorTest method createMock.
private JdbcConnectionPool createMock() {
final JdbcConnectionPool pool = createNiceMock(JdbcConnectionPool.class);
expect(pool.getName()).andStubReturn("MyPoolName");
expect(pool.getWrapJdbcObjects()).andStubReturn("true");
// fictive wrapper, validator does not check if it can work
expect(pool.getSqlTraceListeners()).andStubReturn(SQLTraceListener.class.getName());
expect(pool.getStatementCacheSize()).andStubReturn("10");
expect(pool.getStatementLeakTimeoutInSeconds()).andStubReturn("30");
expect(pool.getStatementLeakReclaim()).andStubReturn("true");
expect(pool.getSteadyPoolSize()).andStubReturn("0");
expect(pool.getMaxPoolSize()).andStubReturn("16");
expect(pool.getIsConnectionValidationRequired()).andStubReturn("false");
expect(pool.getConnectionValidationMethod()).andStubReturn(null);
expect(pool.getValidationTableName()).andStubReturn(null);
expect(pool.getValidationClassname()).andStubReturn(null);
expect(pool.getResType()).andStubReturn(DataSource.class.getName());
// fictive, validator does not check if it is a really usable impl
expect(pool.getDatasourceClassname()).andStubReturn(DataSource.class.getName());
expect(pool.getDriverClassname()).andStubReturn(null);
replay(pool);
return pool;
}
use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.
the class JdbcConnectionPoolValidatorTest method tableNameConnectionValidation.
@Test
public void tableNameConnectionValidation() {
this.validator.initialize(createAnnotation(TABLE_NAME_MANDATORY));
final JdbcConnectionPool pool = createMock();
assertTrue("everything OK", this.validator.isValid(pool, null));
updateMock(pool, p -> {
expect(p.getIsConnectionValidationRequired()).andStubReturn("true");
expect(p.getConnectionValidationMethod()).andStubReturn("table");
expect(p.getValidationTableName()).andStubReturn("MY-TABLE");
});
assertTrue("validation by table enabled, everything is set", this.validator.isValid(pool, null));
updateMock(pool, p -> {
expect(p.getIsConnectionValidationRequired()).andStubReturn("true");
// is this alright?
expect(p.getConnectionValidationMethod()).andStubReturn("somethingelse");
expect(p.getValidationTableName()).andStubReturn(null);
});
assertTrue("validation by table is not set", this.validator.isValid(pool, null));
updateMock(pool, p -> {
expect(p.getIsConnectionValidationRequired()).andStubReturn("true");
expect(p.getConnectionValidationMethod()).andStubReturn("table");
expect(p.getValidationTableName()).andStubReturn(null);
});
assertFalse("validation by table set, but no table name", this.validator.isValid(pool, null));
}
Aggregations