aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/at/ac/tuwien/sepm
diff options
context:
space:
mode:
authorDominic Rogetzer <e1627756@student.tuwien.ac.at>2018-06-11 15:03:15 +0200
committerTharre <tharre3@gmail.com>2018-06-11 18:15:42 +0200
commit31abe77439c1424c1ea290d55df0a6c54a5d7724 (patch)
tree5f6d47ad6a8a1a8b2580b68b8e0d73eef52efd12 /src/test/java/at/ac/tuwien/sepm
parent80e1aaf4a0eba29a7dd304aa52c1116d76c417fc (diff)
downloadsepm-groupproject-31abe77439c1424c1ea290d55df0a6c54a5d7724.tar.gz
sepm-groupproject-31abe77439c1424c1ea290d55df0a6c54a5d7724.tar.xz
sepm-groupproject-31abe77439c1424c1ea290d55df0a6c54a5d7724.zip
Refactor RegistrationDAOTest to make use of DB-unit [#27302]
Diffstat (limited to 'src/test/java/at/ac/tuwien/sepm')
-rw-r--r--src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java73
1 files changed, 8 insertions, 65 deletions
diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java
index e8ea809..289a0ae 100644
--- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java
+++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java
@@ -6,77 +6,30 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee;
import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel;
import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration;
import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException;
-import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager;
-import java.nio.charset.Charset;
-import java.sql.SQLException;
+import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase;
import java.time.Instant;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
-import org.h2.tools.RunScript;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.dbunit.dataset.IDataSet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-public class RegistrationDAOTest {
-
- // Base taken from EmployeeDAOTest
-
- private static final String JDBC_DRIVER = org.h2.Driver.class.getName();
- private static final String JDBC_URL = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1";
- private static final String USER = "";
- private static final String PASSWORD = "";
+public class RegistrationDAOTest extends JdbcTestCase {
private RegistrationDAO registrationDAO;
public RegistrationDAOTest() throws PersistenceException {
- JDBCConnectionManager jdbcConnectionManager = new JDBCConnectionManager(JDBC_URL);
this.registrationDAO =
new RegistrationDatabaseDAO(
- jdbcConnectionManager, new EmployeeDatabaseDAO(jdbcConnectionManager));
- // TODO: Use Spring Dependency Injection here!
+ getJdbcConnectionManager(),
+ new EmployeeDatabaseDAO(getJdbcConnectionManager()));
}
- @BeforeClass
- public static void setupDatabase() throws SQLException {
- RunScript.execute(
- JDBC_URL,
- USER,
- PASSWORD,
- "classpath:sql/database.sql",
- Charset.forName("UTF8"),
- false);
- RunScript.execute(
- JDBC_URL,
- USER,
- PASSWORD,
- "classpath:sql/H2RegistrationDAOTest_populate.sql",
- Charset.forName("UTF8"),
- false);
- }
- /*
- @Before
- public void setUp() throws SQLException {
- RunScript.execute(
- JDBC_URL,
- USER,
- PASSWORD,
- "classpath:sql/H2RegistrationDAOTest_populate.sql",
- Charset.forName("UTF8"),
- false);
- }
- */
- @AfterClass
- public static void tearDown() throws SQLException {
- RunScript.execute(
- JDBC_URL,
- USER,
- PASSWORD,
- "classpath:sql/H2RegistrationDAOTest_depopulate.sql",
- Charset.forName("UTF8"),
- false);
+ @Override
+ protected IDataSet getDataSet() throws Exception {
+ return getDataSet("registrationTestBaseData.xml");
}
@Rule public ExpectedException thrown = ExpectedException.none();
@@ -84,16 +37,6 @@ public class RegistrationDAOTest {
@Test
public void addRegistrationsShouldSucceed() throws PersistenceException {
Set<Registration> registrations = new HashSet<>();
- /*
- Vehicle vehicle = Vehicle.builder()
- .id(1)
- .name("RTW-1")
- .constructionType(ConstructionType.HOCHDACH)
- .type(VehicleType.RTW)
- .status(Status.ABGEMELDET)
- .hasNef(true)
- .build();
- */
Employee employee1 =
Employee.builder()
.id(1)