From 5a6c00ebc1583e0505fb795b3483f8937e7b8eb4 Mon Sep 17 00:00:00 2001
From: Felix Kehrer <felix.kehrer@gmail.com>
Date: Sun, 6 May 2018 16:01:10 +0200
Subject: Added groundwork for DAO tests

---
 .../dao/H2RegistrationDAOTest.java                 | 65 ++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java

(limited to 'src/test/java/at')

diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java
new file mode 100644
index 0000000..03b70b1
--- /dev/null
+++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java
@@ -0,0 +1,65 @@
+package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao;
+
+import static org.junit.Assert.*;
+
+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 org.h2.tools.RunScript;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class H2RegistrationDAOTest {
+
+    // Base taken from EmployeePersistenceTest
+
+    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 = "";
+
+    private RegistrationDAO registrationDAO;
+
+    public H2RegistrationDAOTest() throws PersistenceException {
+        this.registrationDAO = new H2RegistrationDAO(new JDBCConnectionManager(JDBC_URL));
+    }
+
+    @BeforeClass
+    public static void setupDatabase() throws SQLException {
+        RunScript.execute(
+                JDBC_URL,
+                USER,
+                PASSWORD,
+                "classpath:sql/database.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);
+    }
+
+    @After
+    public void tearDown() throws SQLException {
+        RunScript.execute(
+                JDBC_URL,
+                USER,
+                PASSWORD,
+                "classpath:sql/H2RegistrationDAOTest_depopulate.sql",
+                Charset.forName("UTF8"),
+                false);
+    }
+
+    @Test
+    public void add() {}
+}
-- 
cgit v1.2.3-70-g09d2