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 2012/10/09 16:22:06 UTC

svn commit: r1396042 - in /incubator/wookie/trunk/src-tests: org/apache/wookie/tests/functional/WidgetsControllerTest.java testdata/upload-test-noid.wgt

Author: scottbw
Date: Tue Oct  9 14:22:06 2012
New Revision: 1396042

URL: http://svn.apache.org/viewvc?rev=1396042&view=rev
Log:
Added test case for updating widgets with no identifier

Added:
    incubator/wookie/trunk/src-tests/testdata/upload-test-noid.wgt   (with props)
Modified:
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetsControllerTest.java

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=1396042&r1=1396041&r2=1396042&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 Tue Oct  9 14:22:06 2012
@@ -608,6 +608,66 @@ public class WidgetsControllerTest exten
     assertEquals(1,PoliciesControllerTest.processPolicies(get.getResponseBodyAsStream()).getChildren("policy").size());
 
   }
+  
+  @Test
+  public void workingWithUnidentifiedWidgets() throws HttpException, IOException, JDOMException{
+      HttpClient client = new HttpClient();
+      //
+      // Use admin credentials
+      //
+      setAuthenticationCredentials(client);
+
+      PostMethod post = new PostMethod(TEST_WIDGETS_SERVICE_URL_VALID);
+
+      //
+      // Add the access test widget. This just has a single access request
+      // for the origin "http://accesstest.incubator.apache.org"
+      //
+      File file = new File("src-tests/testdata/upload-test-noid.wgt");
+      assertTrue(file.exists());
+
+      //
+      // Add test wgt file to POST
+      //
+      Part[] parts = { new FilePart(file.getName(), file) };
+      post.setRequestEntity(new MultipartRequestEntity(parts, post
+          .getParams()));
+
+      //
+      // POST the file to /widgets 
+      //
+      client.executeMethod(post);   
+      SAXBuilder builder = new SAXBuilder();
+      Document doc = builder.build(post.getResponseBodyAsStream());
+      String id = doc.getRootElement().getAttributeValue("id");
+      post.releaseConnection(); 
+      
+      //
+      // Now we'll update it
+      //
+      PutMethod put = new PutMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + id));
+
+      //
+      // Add test wgt file to PUT
+      //
+      Part[] updateparts = { new FilePart(file.getName(), file) };
+      put.setRequestEntity(new MultipartRequestEntity(updateparts, put
+          .getParams()));
+
+      //
+      // PUT the file to /widgets and check we get 200 (Updated)
+      //
+      client.executeMethod(put);   
+      int code = put.getStatusCode();
+      assertEquals(200,code);
+      put.releaseConnection();    
+      
+      //
+      // DELETE the widget
+      //
+      DeleteMethod delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + id));
+      client.executeMethod(delete);
+  }
 
   /**
    * Download a widget using the Accept type of ("Accept","application/widget")

Added: incubator/wookie/trunk/src-tests/testdata/upload-test-noid.wgt
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/testdata/upload-test-noid.wgt?rev=1396042&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/wookie/trunk/src-tests/testdata/upload-test-noid.wgt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream