diff --git a/tests/Partitioning/swen90006/passbook/PartitioningTests.java b/tests/Partitioning/swen90006/passbook/PartitioningTests.java index 64d5eb86efb827d86f4296b82055ce11afe4e01b..5dc1d450fa19853c7845c37a4182fdd558b3b5ab 100755 --- a/tests/Partitioning/swen90006/passbook/PartitioningTests.java +++ b/tests/Partitioning/swen90006/passbook/PartitioningTests.java @@ -293,6 +293,43 @@ public class PartitioningTests } assertTrue(NoSuchUserException); } + // user has login + @Test public void AlreadyLoggedInException() throws NoSuchUserException, IncorrectPassphraseException, WeakPassphraseException, DuplicateUserException { + boolean AlreadyLoggedInException = false; + String passbookUsername = "AlexTina"; + String passbookphrase = "Abc234hg"; + String passbookUsername2 = "AlexTina"; + String passbookphrase2 = "Abc234hg"; + try{ + pb.addUser(passbookUsername,passbookphrase); + pb.loginUser(passbookUsername,passbookphrase); + pb.loginUser(passbookUsername2,passbookphrase2); + } + catch (AlreadyLoggedInException e){ + AlreadyLoggedInException = true; + } + assertTrue(AlreadyLoggedInException); + } + + //user has not login + @Test public void AlreadyLoggedInException2() throws NoSuchUserException, IncorrectPassphraseException, WeakPassphraseException, DuplicateUserException { + boolean AlreadyLoggedInException = false; + String passbookUsername = "AlexTina"; + String passbookphrase = "Abc234hg"; + + try{ + pb.addUser(passbookUsername,passbookphrase); + + pb.loginUser(passbookUsername,passbookphrase); + + + + } + catch (AlreadyLoggedInException e){ + AlreadyLoggedInException = true; + } + assertFalse(AlreadyLoggedInException); + } //passphrase is not equale to the saved one @Test public void IncorrectPassphraseException() throws WeakPassphraseException, DuplicateUserException, AlreadyLoggedInException, IncorrectPassphraseException, NoSuchUserException { @@ -657,16 +694,7 @@ public class PartitioningTests assertEquals(expected, actual); } - @Test public void anotherTest() - throws DuplicateUserException, WeakPassphraseException - { - pb.addUser("passbookUsername", "properPassphrase1"); - //the assertTrue method is used to check whether something holds. - assertTrue(pb.isUser("passbookUsername")); - assertFalse(pb.isUser("nonUser")); - } - //To test an exception, specify the expected exception after the @Test @Test(expected = java.io.IOException.class) public void anExceptionTest()