Added a new constructor for employee extension.

This commit is contained in:
Ali Dehghani 2019-05-10 11:23:22 +04:30
parent 104b0d597f
commit 97022ca7d3
1 changed files with 12 additions and 2 deletions

View File

@ -15,10 +15,20 @@ import com.baeldung.helpers.JdbcConnectionUtil;
public class EmployeeDatabaseSetupExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
private Connection con = JdbcConnectionUtil.getConnection();
private EmployeeJdbcDao employeeDao = new EmployeeJdbcDao(con);
private Connection con;
private EmployeeJdbcDao employeeDao;
private Savepoint savepoint;
public EmployeeDatabaseSetupExtension() {
con = JdbcConnectionUtil.getConnection();
employeeDao = new EmployeeJdbcDao(con);
}
public EmployeeDatabaseSetupExtension(String jdbcUrl, String driver, String username, String password) {
con = JdbcConnectionUtil.getConnection(jdbcUrl, driver, username, password);
employeeDao = new EmployeeJdbcDao(con);
}
@Override
public void afterAll(ExtensionContext context) throws SQLException {
if (con != null) {