SessionController added/updated
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / controller / UserControllerTest.java
index 26b9436..46831ed 100644 (file)
@@ -31,8 +31,6 @@ import ch.bfh.ti.srs.dataschema.User;
  * @author Michael Grossen\r
  */\r
 public class UserControllerTest {\r
-\r
-       /*\r
        @Test\r
        public void addUserTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -55,179 +53,7 @@ public class UserControllerTest {
 \r
                uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
        }\r
-\r
-       @Test\r
-       public void logInTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               SessionController sc = new SessionController();\r
-               UserController uc = new UserController(dh,sc);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
-               uc.addUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
-\r
-               uc.logIn("TestUser3", "pass3");\r
-       }\r
-\r
-       @Test(expected = Exception.class)\r
-       public void logInException1Test() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-               uc.setDataHandler(null);\r
-               uc.logIn("TestUser3", "pass3");\r
-       }\r
-\r
-       @Test(expected = Exception.class)\r
-       public void logInException2Test() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-\r
-               uc.logIn("TestUser1", "pass1");\r
-               uc.logIn("TestUser2", "pass2");\r
-       }\r
-\r
-       @Test\r
-       public void logInInvalidCredetialsTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-\r
-               assertFalse(uc.logIn("TestUser3", "pass3"));\r
-               assertFalse(uc.logIn("TestUser1", "pass2"));\r
-               assertTrue(uc.logIn("TestUser1", "pass1"));\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test\r
-       public void getLoggedUserNameTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
-               uc.addUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
-\r
-               uc.logIn("TestUser1", "pass1");\r
-               assertEquals("TestUser1", uc.getLoggedUserName());\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test(expected = Exception.class)\r
-       public void getLoggedUserNameExceptionTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-               uc.setDataHandler(null);\r
-               uc.getLoggedUserName();\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test\r
-       public void getLoggedUserMailTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "hanfli@bfh.ch", null, null);\r
-               uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
-               uc.addUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
-\r
-               uc.logIn("TestUser2", "pass2");\r
-               assertEquals("hanfli@bfh.ch", uc.getLoggedMail());\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test(expected = Exception.class)\r
-       public void getLoggedMailExceptionTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-               uc.setDataHandler(null);\r
-               uc.getLoggedMail();\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test\r
-       public void getLoggedNameTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Hanfli", null);\r
-               uc.addUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
-\r
-               uc.logIn("TestUser3", "pass3");\r
-               assertEquals("Hanfli", uc.getLoggedName());\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test(expected = Exception.class)\r
-       public void getLoggedNameExceptionTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-               uc.setDataHandler(null);\r
-               uc.getLoggedName();\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test\r
-       public void getLoggedLastnameTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
-               uc.addUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
-\r
-               uc.logIn("TestUser4", "pass4");\r
-               assertEquals("User", uc.getLoggedLastname());\r
-       }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test(expected = Exception.class)\r
-       public void getLoggedLastnameExceptionTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-               uc.setDataHandler(null);\r
-               uc.getLoggedLastname();\r
-       }\r
-\r
-       @Test\r
-       public void getLoggedUserTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               assertEquals(null, uc.getLoggedUser());\r
-               uc.logIn("TestUser1", "pass1");\r
-               assertEquals("TestUser1", uc.getLoggedUser().getUserName());\r
-       }\r
-\r
-       // @Test(expected=Exception.class)\r
-       // public void getLoggedUserExceptionTest() throws Exception{\r
-       // DataHandler dh = new DataHandlerForTests();\r
-       // UserController uc = new UserController(dh);\r
-       //\r
-       // uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-       // uc.logIn("TestUser1", "pass1");\r
-       // assertEquals("TestUser1", uc.getLoggedUser().getUserName());\r
-       // }\r
-\r
+       \r
        @Test\r
        public void getUserTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -249,42 +75,7 @@ public class UserControllerTest {
                uc.logIn("TestUser1", "pass1");\r
                assertEquals("grosm9@bfh.ch", uc.getUser("TestUser1").getMail());\r
        }\r
-\r
-       @SuppressWarnings("deprecation")\r
-       @Test\r
-       public void logOutTest() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.addUser("TestUser1", "pass1", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser2", "pass2", "grosm9@bfh.ch", null, null);\r
-               uc.addUser("TestUser3", "pass3", "grosm9@bfh.ch", "Test", null);\r
-               uc.addUser("TestUser4", "pass4", "grosm9@bfh.ch", "Test", "User");\r
-\r
-               uc.logIn("TestUser1", "pass1");\r
-               assertEquals("TestUser1", uc.getLoggedUserName());\r
-               uc.logOut();\r
-       }\r
-\r
-       @Test(expected = Exception.class)\r
-       public void logOutException1Test() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-               uc.setDataHandler(null);\r
-\r
-               uc.logOut();\r
-       }\r
-\r
-       @Test(expected = Exception.class)\r
-       public void logOutException2Test() throws Exception {\r
-               DataHandler dh = new DataHandlerForTests();\r
-               UserController uc = new UserController(dh);\r
-\r
-               //uc.setDataHandler(dh);\r
-               uc.logOut();\r
-       }\r
-\r
+       \r
        @Test(expected = Exception.class)\r
        public void getUserExpectionTest() throws Exception {\r
                DataHandler dh = new DataHandlerForTests();\r
@@ -292,7 +83,7 @@ public class UserControllerTest {
                uc.setDataHandler(null);\r
                uc.getUser(null);\r
        }\r
-\r
+       \r
        @SuppressWarnings("deprecation")\r
        @Test\r
        public void getReservationTests() throws Exception {\r
@@ -947,5 +738,4 @@ public class UserControllerTest {
 \r
                assertEquals(3, resList.size());\r
        }\r
-       */\r
 }\r