Ensure the ApiKeys test restores the original state of the keys file after it executes, as otherwise it can cause other tests to fail
git-svn-id: https://svn.apache.org/repos/asf/wookie/trunk@1576636 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java b/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java
index 7106c0e..bca737f 100644
--- a/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java
+++ b/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java
@@ -21,7 +21,9 @@
import org.apache.wookie.exceptions.ResourceDuplicationException;
import org.apache.wookie.exceptions.ResourceNotFoundException;
+import org.apache.wookie.server.security.ApiKey;
import org.apache.wookie.server.security.ApiKeys;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -29,13 +31,27 @@
*
*/
public class ApiKeysTest {
+
+ private static ApiKey[] keys;
@BeforeClass
public static void setup() throws ResourceDuplicationException{
+ keys = ApiKeys.getInstance().getKeys();
ApiKeys.getInstance().clear();
ApiKeys.getInstance().addKey("KEYS_TEST_1", "test@apache.org");
}
+ //
+ // Restore state from before the tests
+ //
+ @AfterClass
+ public static void teardown() throws ResourceDuplicationException{
+ ApiKeys.getInstance().clear();
+ for (ApiKey key:keys){
+ ApiKeys.getInstance().addKey(key.getValue(), key.getSecret());
+ }
+ }
+
@Test
public void getInstance(){
assertNotNull(ApiKeys.getInstance());