You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2014/03/12 09:41:27 UTC

svn commit: r1576636 - /wookie/trunk/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java

Author: scottbw
Date: Wed Mar 12 08:41:27 2014
New Revision: 1576636

URL: http://svn.apache.org/r1576636
Log:
Ensure the ApiKeys test restores the original state of the keys file after it executes, as otherwise it can cause other tests to fail

Modified:
    wookie/trunk/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java

Modified: wookie/trunk/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java
URL: http://svn.apache.org/viewvc/wookie/trunk/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java?rev=1576636&r1=1576635&r2=1576636&view=diff
==============================================================================
--- wookie/trunk/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java (original)
+++ wookie/trunk/wookie-server/src/test/java/org/apache/wookie/tests/server/security/ApiKeysTest.java Wed Mar 12 08:41:27 2014
@@ -21,7 +21,9 @@ import static org.junit.Assert.*;
 
 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 @@ import org.junit.Test;
  *
  */
 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());