incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1003926 - /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletVersionableTest.java
Date Sun, 03 Oct 2010 07:45:54 GMT
Author: fmeschbe
Date: Sun Oct  3 07:45:53 2010
New Revision: 1003926

URL: http://svn.apache.org/viewvc?rev=1003926&view=rev
Log:
SLING-1796 Ensure autoCheckout is enabled for versioning support integration tests by supplying
configuration

Modified:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletVersionableTest.java

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletVersionableTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletVersionableTest.java?rev=1003926&r1=1003925&r2=1003926&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletVersionableTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletVersionableTest.java
Sun Oct  3 07:45:53 2010
@@ -17,6 +17,7 @@
 package org.apache.sling.launchpad.webapp.integrationtest.servlets.post;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -30,16 +31,41 @@ import org.apache.sling.servlets.post.Sl
 
 /** Test node creation via the PostServlet and versionable nodes */
 public class PostServletVersionableTest extends HttpTestBase {
+
+    // the URL to configure the POST servlet with
+    private static final String CFG_URL = HTTP_BASE_URL + "/system/console/configMgr/org.apache.sling.servlets.post.impl.SlingPostServlet";
+
     public static final String TEST_BASE_PATH = "/sling-tests";
     private String postUrl;
     private Map<String,String> params;
 
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis();
         params = new HashMap<String,String>();
         params.put("jcr:mixinTypes", "mix:versionable");
+
+        // enable autoCheckout for the tests
+        ArrayList<NameValuePair> config = new ArrayList<NameValuePair>();
+        config.add(new NameValuePair("apply", "true"));
+        config.add(new NameValuePair("propertylist",
+            "servlet.post.autoCheckout"));
+        config.add(new NameValuePair("servlet.post.autoCheckout", "true"));
+        assertPostStatus(CFG_URL, 302, config, null);
+        Thread.sleep(500); // give async config update some time
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        // remove configuration after test
+        ArrayList<NameValuePair> config = new ArrayList<NameValuePair>();
+        config.add(new NameValuePair("apply", "true"));
+        config.add(new NameValuePair("delete", "true"));
+        assertPostStatus(CFG_URL, 200, config, null);
+
+        super.tearDown();
     }
 
    public void testPostPathIsUnique() throws IOException {
@@ -422,14 +448,14 @@ public class PostServletVersionableTest 
                 content.contains("jcr:isCheckedOut: false"));
         assertTrue("Node (" + location + ") has a test property.",
                 content.contains("testprop: testvalue"));
-        
+
         List<NameValuePair> testParams = Arrays.asList(new NameValuePair(":autoCheckout",
"false"),
                 new NameValuePair("testprop@Delete", ""));
-        
+
         assertPostStatus(location, 500, testParams, "Attempted modification with :autoCheckout=false
should fail.");
 
     }
-    
+
     public void testMovingAPropertyOfACheckedInNodeToANewVersionableNode() throws IOException
{
         params.put(":checkinNewVersionableNodes", "true");
         params.put("text", "Hello");
@@ -458,7 +484,7 @@ public class PostServletVersionableTest 
         assertJavascript("undefined", oldContent, "out.println(typeof(data.text))");
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
+
     public void testMovingAPropertyOfACheckedInNodeToACheckedInNode() throws IOException
{
         params.put(":checkinNewVersionableNodes", "true");
         params.put("text", "Hello");
@@ -475,7 +501,7 @@ public class PostServletVersionableTest 
         params.put("jcr:mixinTypes", "mix:versionable");
         params.put(":checkinNewVersionableNodes", "true");
         testClient.createNode(HTTP_BASE_URL + testPath + "/dest", params);
-        
+
         // assert content at new location
         String content = getContent(HTTP_BASE_URL + testPath + "/dest.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
@@ -495,7 +521,7 @@ public class PostServletVersionableTest 
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
 
     }
-    
+
     public void testCopyingAPropertyToACheckedInNode() throws IOException {
         params.put(":checkinNewVersionableNodes", "true");
         params.put("text", "Hello");
@@ -511,10 +537,10 @@ public class PostServletVersionableTest 
         params.put("jcr:mixinTypes", "mix:versionable");
         params.put(":checkinNewVersionableNodes", "true");
         testClient.createNode(HTTP_BASE_URL + testPath + "/dest", params);
-        
+
         String content = getContent(HTTP_BASE_URL + testPath + "/dest.json", CONTENT_TYPE_JSON);
         assertJavascript("false", content, "out.println(data['jcr:isCheckedOut'])");
-        
+
         // copy text from src/text
         params.clear();
         params.put("text@CopyFrom", testPath + "/src/text");
@@ -530,12 +556,12 @@ public class PostServletVersionableTest 
         assertJavascript("Hello", oldContent, "out.println(data.text)");
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
+
     public void testMovingAChildNodeOfACheckedInNodeToANewVersionableNode() throws IOException
{
         params.put(":checkinNewVersionableNodes", "true");
         final String testPath = TEST_BASE_PATH + "/abs/" + System.currentTimeMillis();
         testClient.createNode(HTTP_BASE_URL + testPath + "/src", params);
-        
+
         params.clear();
         params.put("text", "Hello");
         testClient.createNode(HTTP_BASE_URL + testPath + "/src/child", params);
@@ -563,12 +589,12 @@ public class PostServletVersionableTest 
         oldContent = getContent(HTTP_BASE_URL + testPath + "/src.-1.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
+
     public void testMovingAChildNodeOfACheckedInNodeToACheckedInNode() throws IOException
{
         params.put(":checkinNewVersionableNodes", "true");
         final String testPath = TEST_BASE_PATH + "/abs/" + System.currentTimeMillis();
         testClient.createNode(HTTP_BASE_URL + testPath + "/src", params);
-        
+
         params.clear();
         params.put("text", "Hello");
         testClient.createNode(HTTP_BASE_URL + testPath + "/src/child", params);
@@ -583,10 +609,10 @@ public class PostServletVersionableTest 
         params.put("jcr:mixinTypes", "mix:versionable");
         params.put(":checkinNewVersionableNodes", "true");
         testClient.createNode(HTTP_BASE_URL + testPath + "/dest", params);
-        
+
         String content = getContent(HTTP_BASE_URL + testPath + "/dest.json", CONTENT_TYPE_JSON);
         assertJavascript("false", content, "out.println(data['jcr:isCheckedOut'])");
-        
+
         // move src child
         params.clear();
         params.put("src@MoveFrom", testPath + "/src/child");
@@ -603,12 +629,12 @@ public class PostServletVersionableTest 
         oldContent = getContent(HTTP_BASE_URL + testPath + "/src.-1.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
+
     public void testCopyingANodeToACheckedInNode() throws IOException {
         params.put(":checkinNewVersionableNodes", "true");
         final String testPath = TEST_BASE_PATH + "/abs/" + System.currentTimeMillis();
         testClient.createNode(HTTP_BASE_URL + testPath + "/src", params);
-        
+
         params.clear();
         params.put("text", "Hello");
         testClient.createNode(HTTP_BASE_URL + testPath + "/src/child", params);
@@ -617,15 +643,15 @@ public class PostServletVersionableTest 
         String oldContent = getContent(HTTP_BASE_URL + testPath + "/src.-1.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
         assertJavascript("Hello", oldContent, "out.println(data.child.text)");
-        
+
         // create dest as empty
         params.put("jcr:mixinTypes", "mix:versionable");
         params.put(":checkinNewVersionableNodes", "true");
         testClient.createNode(HTTP_BASE_URL + testPath + "/dest", params);
-        
+
         String content = getContent(HTTP_BASE_URL + testPath + "/dest.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
-        
+
         // copy text from src/text
         params.clear();
         params.put("src@CopyFrom", testPath + "/src/child");
@@ -641,12 +667,12 @@ public class PostServletVersionableTest 
         assertJavascript("Hello", oldContent, "out.println(data.child.text)");
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
+
     public void testMovingAChildNodeOfACheckedInNodeToACheckedInNodeByOp() throws IOException
{
         params.put(":checkinNewVersionableNodes", "true");
         final String testPath = TEST_BASE_PATH + "/abs/" + System.currentTimeMillis();
         testClient.createNode(HTTP_BASE_URL + testPath + "/src", params);
-        
+
         params.clear();
         params.put("text", "Hello");
         testClient.createNode(HTTP_BASE_URL + testPath + "/src/child", params);
@@ -661,10 +687,10 @@ public class PostServletVersionableTest 
         params.put("jcr:mixinTypes", "mix:versionable");
         params.put(":checkinNewVersionableNodes", "true");
         testClient.createNode(HTTP_BASE_URL + testPath + "/dest", params);
-        
+
         String content = getContent(HTTP_BASE_URL + testPath + "/dest.json", CONTENT_TYPE_JSON);
         assertJavascript("false", content, "out.println(data['jcr:isCheckedOut'])");
-        
+
         // move src child
         params.clear();
         params.put(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_MOVE);
@@ -682,12 +708,12 @@ public class PostServletVersionableTest 
         oldContent = getContent(HTTP_BASE_URL + testPath + "/src.-1.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
+
     public void testCopyingANodeToACheckedInNodeByOp() throws IOException {
         params.put(":checkinNewVersionableNodes", "true");
         final String testPath = TEST_BASE_PATH + "/abs/" + System.currentTimeMillis();
         testClient.createNode(HTTP_BASE_URL + testPath + "/src", params);
-        
+
         params.clear();
         params.put("text", "Hello");
         testClient.createNode(HTTP_BASE_URL + testPath + "/src/child", params);
@@ -696,15 +722,15 @@ public class PostServletVersionableTest 
         String oldContent = getContent(HTTP_BASE_URL + testPath + "/src.-1.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
         assertJavascript("Hello", oldContent, "out.println(data.child.text)");
-        
+
         // create dest as empty
         params.put("jcr:mixinTypes", "mix:versionable");
         params.put(":checkinNewVersionableNodes", "true");
         testClient.createNode(HTTP_BASE_URL + testPath + "/dest", params);
-        
+
         String content = getContent(HTTP_BASE_URL + testPath + "/dest.json", CONTENT_TYPE_JSON);
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
-        
+
         // copy child from src
         params.clear();
         params.put(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_COPY);
@@ -721,6 +747,6 @@ public class PostServletVersionableTest 
         assertJavascript("Hello", oldContent, "out.println(data.child.text)");
         assertJavascript("false", oldContent, "out.println(data['jcr:isCheckedOut'])");
     }
-    
-    
+
+
  }
\ No newline at end of file



Mime
View raw message