add a Testcase for store&load user.
authorFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 22:32:24 +0000 (00:32 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 3 Jul 2014 22:32:24 +0000 (00:32 +0200)
tests/org/cacert/gigi/TestUser.java [new file with mode: 0644]

diff --git a/tests/org/cacert/gigi/TestUser.java b/tests/org/cacert/gigi/TestUser.java
new file mode 100644 (file)
index 0000000..b723630
--- /dev/null
@@ -0,0 +1,26 @@
+package org.cacert.gigi;
+
+import java.sql.SQLException;
+import org.cacert.gigi.testUtils.ManagedTest;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestUser extends ManagedTest {
+       @Test
+       public void testStoreAndLoad() throws SQLException {
+               User u = new User();
+               u.setFname("user");
+               u.setLname("last");
+               u.setMname("");
+               u.setSuffix("");
+               long dob = System.currentTimeMillis();
+               dob -= dob % (1000 * 60 * 60 * 24);
+               u.setDob(new java.sql.Date(dob));
+               u.setEmail(createUniqueName() + "a@email.org");
+               u.insert("password");
+               int id = u.getId();
+               User u2 = new User(id);
+               assertEquals(u, u2);
+       }
+}