Author: scottbw
Date: Thu Mar  1 14:06:39 2012
New Revision: 1295568

URL: http://svn.apache.org/viewvc?rev=1295568&view=rev
Log:
Re-enabled checking for multiple policy creation in /widgets functional tests. 
Also added teardown method to remove test widgets uploaded during testing

Modified:
    
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/PoliciesControllerTest.java
    
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java

Modified: 
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/PoliciesControllerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/PoliciesControllerTest.java?rev=1295568&r1=1295567&r2=1295568&view=diff
==============================================================================
--- 
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/PoliciesControllerTest.java
 (original)
+++ 
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/PoliciesControllerTest.java
 Thu Mar  1 14:06:39 2012
@@ -208,7 +208,7 @@ public class PoliciesControllerTest exte
     assertEquals(200, delete.getStatusCode());
   }
   
-  public Element processPolicies(InputStream in) throws JDOMException, 
IOException{
+  public static Element processPolicies(InputStream in) throws JDOMException, 
IOException{
     SAXBuilder builder = new SAXBuilder();
     Document doc = builder.build(in);
     Element policies = doc.getRootElement();

Modified: 
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java?rev=1295568&r1=1295567&r2=1295568&view=diff
==============================================================================
--- 
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
 (original)
+++ 
incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java
 Thu Mar  1 14:06:39 2012
@@ -28,12 +28,25 @@ import org.apache.commons.httpclient.met
 import org.apache.commons.httpclient.methods.multipart.FilePart;
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
 import org.apache.commons.httpclient.methods.multipart.Part;
+import org.jdom.JDOMException;
+import org.junit.AfterClass;
 import org.junit.Test;
 
 /**
  * Test cases for the Widget REST API
  */
 public class WidgetsControllerTest extends AbstractControllerTest {
+  
+  
+  @AfterClass
+  public static void tearDown() throws HttpException, IOException{
+    HttpClient client = new HttpClient();
+    setAuthenticationCredentials(client);
+    DeleteMethod delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + 
"/http%3A%2F%2Fwookie.apache.org%2Fwidgets%2Faccess-test");
+    client.executeMethod(delete);
+    delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + 
"/http%3A%2F%2Fuploadtest");
+    client.executeMethod(delete);
+  }
        
   /**
    * Test GET all widgets
@@ -260,9 +273,10 @@ public class WidgetsControllerTest exten
         * @throws HttpException
         * @throws IOException
         * @throws InterruptedException 
+        * @throws JDOMException 
         */
        @Test
-       public void checkForDuplicateAccessRequests() throws HttpException, 
IOException, InterruptedException{
+       public void checkForDuplicateAccessRequests() throws HttpException, 
IOException, InterruptedException, JDOMException{
 
            //
            // Add the test widget, and update it a few times
@@ -296,25 +310,17 @@ public class WidgetsControllerTest exten
              //
              client.executeMethod(post);   
              post.releaseConnection(); 
-             
-             //
-             // Wait a few seconds for Wookie to finish updating
-             //
-             Thread.sleep(5000);
-           }
+           } 
 
            //
            // Check that we only have one copy of the access request, not two
            //
-//         int policies = 0;
-//         final String POLICY_ORIGIN = 
"http://accesstest.incubator.apache.org:80";;
-//         Element[] policyElements = 
WidgetAccessRequestPolicyControllerTest.getPolicies();
-//         for (Element policy: policyElements){
-//           if 
(policy.getAttribute("origin").getValue().equals(POLICY_ORIGIN)) {
-//             policies ++;
-//           }
-//         }
-//         assertEquals(1, policies);
+      HttpClient client = new HttpClient();
+      setAuthenticationCredentials(client);
+           GetMethod get = new 
GetMethod(TEST_POLICIES_SERVICE_URL_VALID+"/http%3A%2F%2Fwookie.apache.org%2Fwidgets%2Faccess-test");
+           get.setRequestHeader("accepts","text/xml");
+           client.executeMethod(get);
+           
assertEquals(1,PoliciesControllerTest.processPolicies(get.getResponseBodyAsStream()).getChildren("policy").size());
 
        }
        


Reply via email to