diff --git a/tests/Partitioning/swen90006/passbook/PartitioningTests.java b/tests/Partitioning/swen90006/passbook/PartitioningTests.java index 4e951029c21281472dc43a9b938cf8ba30ec4f55..4bb51ddda521419489d049ece8eae62c60f050f4 100755 --- a/tests/Partitioning/swen90006/passbook/PartitioningTests.java +++ b/tests/Partitioning/swen90006/passbook/PartitioningTests.java @@ -269,17 +269,23 @@ public class PartitioningTests assertTrue(WeakPassphraseException); } //passphrase.length >=8 containsNumCase - @Test public void containNumCase() throws DuplicateUserException { - boolean WeakPassphraseException = false; + @Test public void containNumCase() throws DuplicateUserException, swen90006.passbook.AlreadyLoggedInException, swen90006.passbook.IncorrectPassphraseException { + boolean NoSuchUserException = false; + boolean WeakPassphraseException = false; String passbookUsername = "AlexTina"; String passbookphrase = "abABCD12"; try { pb.addUser(passbookUsername, passbookphrase); + pb.loginUser(passbookUsername, passbookphrase); } catch(WeakPassphraseException e) { WeakPassphraseException = true; } + catch(NoSuchUserException e) { + NoSuchUserException = true; + } assertFalse(WeakPassphraseException); + assertFalse(NoSuchUserException); } //------------------------------loginUser Test Cases------------------------------------- @@ -359,20 +365,27 @@ public class PartitioningTests } //passphrase is equale to the saved one - @Test public void IncorrectPassphraseException2() throws WeakPassphraseException, DuplicateUserException, AlreadyLoggedInException, IncorrectPassphraseException, NoSuchUserException { + @Test public void IncorrectPassphraseException2() throws WeakPassphraseException, DuplicateUserException, AlreadyLoggedInException, IncorrectPassphraseException, NoSuchUserException, MalformedURLException, InvalidSessionIDException { boolean IncorrectPassphraseException = false; + boolean InvalidSessionIDException = false; String passbookUsername = "AlexTina"; String passbookphrase = "Abc234hg"; - String passbookUsername2 = "AlexTina"; - String passbookphrase2 = "Abc234hg"; + URL url = new URL ("http:AlexTinaAbc234hg"); + String urlUsername = "AlexTina"; + String urlPassword = "Abc234hg"; try { + pb.addUser(passbookUsername,passbookphrase); - pb.loginUser(passbookUsername2,passbookphrase2); + pb.updateDetails( pb.loginUser(passbookUsername,passbookphrase), url, urlUsername, urlPassword); } catch (IncorrectPassphraseException e){ IncorrectPassphraseException = true; } + catch (InvalidSessionIDException e) { + InvalidSessionIDException = true; + } assertFalse(IncorrectPassphraseException); + assertFalse(InvalidSessionIDException); } @@ -448,7 +461,8 @@ public class PartitioningTests //urlUsername != null && urlPassword !=null @Test public void checkRemove() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException { - boolean NoSuchUserException = false; + boolean InvalidSessionIDException = false; + boolean NoSuchUserException = false; Integer sessionID ; String Username = "AlexTina"; String Password = "Abc234hg"; @@ -464,12 +478,17 @@ public class PartitioningTests catch (NoSuchURLException e){ NoSuchUserException = true; } + catch(InvalidSessionIDException e) { + InvalidSessionIDException = true; + } assertFalse(NoSuchUserException); + assertFalse(InvalidSessionIDException); } //urlUsername = null || urlPassword !=null @Test public void checkRemove2() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException { - boolean NoSuchUserException = false; + boolean InvalidSessionIDException = false; + boolean NoSuchUserException = false; Integer sessionID ; String Username = "AlexTina"; String Password = "Abc234hg"; @@ -485,11 +504,17 @@ public class PartitioningTests catch (NoSuchURLException e){ NoSuchUserException = true; } + catch(InvalidSessionIDException e) { + InvalidSessionIDException = true; + } + + assertFalse(InvalidSessionIDException); assertTrue(NoSuchUserException); } //urlUsername != null || urlPassword =null @Test public void checkRemove3() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException { - boolean NoSuchUserException = false; + boolean InvalidSessionIDException = false; + boolean NoSuchUserException = false; Integer sessionID ; String Username = "AlexTina"; String Password = "Abc234hg"; @@ -505,11 +530,17 @@ public class PartitioningTests catch (NoSuchURLException e){ NoSuchUserException = true; } + catch(InvalidSessionIDException e) { + InvalidSessionIDException = true; + } + + assertFalse(InvalidSessionIDException); assertTrue(NoSuchUserException); } //urlUsername != null || urlPassword !=null @Test public void checkRemove4() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException { - boolean NoSuchUserException = false; + boolean InvalidSessionIDException = false; + boolean NoSuchUserException = false; Integer sessionID ; String Username = "AlexTina"; String Password = "Abc234hg"; @@ -525,6 +556,10 @@ public class PartitioningTests catch (NoSuchURLException e){ NoSuchUserException = true; } + catch(InvalidSessionIDException e) { + InvalidSessionIDException = true; + } + assertFalse(InvalidSessionIDException); assertTrue(NoSuchUserException); }