From 17f87efd98bc7dfd35379972b37c4a3410e5e240 Mon Sep 17 00:00:00 2001
From: CONGRANLI <907112284@qq.com>
Date: Fri, 6 Sep 2019 00:19:54 +1000
Subject: [PATCH] add a new partation
---
.../swen90006/passbook/PartitioningTests.java | 46 +++++++++++++++----
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/tests/Partitioning/swen90006/passbook/PartitioningTests.java b/tests/Partitioning/swen90006/passbook/PartitioningTests.java
index 64d5eb8..5dc1d45 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()
--
GitLab