incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r726016 - in /incubator/sling/trunk: commons/testing/src/main/java/org/apache/sling/commons/testing/integration/ extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/ launchpad/testing/src/test/java/or...
Date Fri, 12 Dec 2008 14:32:33 GMT
Author: bdelacretaz
Date: Fri Dec 12 06:32:32 2008
New Revision: 726016

URL: http://svn.apache.org/viewvc?rev=726016&view=rev
Log:
SLING-770 - fix tests due to change in default rendering semantics

Modified:
    incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
    incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
    incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/HttpPingTest.java
    incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java
    incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/MkdirTest.java
    incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletCreateTest.java
    incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletDeleteTest.java

Modified: incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
(original)
+++ incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Fri Dec 12 06:32:32 2008
@@ -59,6 +59,7 @@
     public static final String SLING_RESOURCE_TYPE = "sling:resourceType";
     
     public static final String SLING_POST_SERVLET_CREATE_SUFFIX = "/";
+	public static final String DEFAULT_EXT = ".txt";
 
     protected SlingIntegrationTestClient testClient;
     protected HttpClient httpClient;
@@ -197,7 +198,7 @@
         // POST, get URL of created node and get content
         {
             final String urlOfNewNode = testClient.createNode(url, props, null, true);
-            final GetMethod get = new GetMethod(urlOfNewNode + ".txt");
+            final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
             final int status = httpClient.executeMethod(get);
             if(status!=200) {
                 throw new HttpStatusCodeException(200, status, "GET", urlOfNewNode);

Modified: incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
(original)
+++ incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/SlingIntegrationTestClient.java
Fri Dec 12 06:32:32 2008
@@ -89,7 +89,7 @@
         }
 
         final String url = baseUrl + path;
-        final int status = httpClient.executeMethod(new GetMethod(url));
+        final int status = httpClient.executeMethod(new GetMethod(url + ".txt"));
         if(status!=200) {
             throw new HttpStatusCodeException(200, status, "GET", url);
         }
@@ -115,7 +115,7 @@
         Map<String, String> nodeProperties = new HashMap<String, String>();
 
         // add sling specific properties
-        nodeProperties.put(":redirect", url);
+        nodeProperties.put(":redirect", "*");
         nodeProperties.put(":displayExtension", "");
         nodeProperties.put(":status", "browser");
 

Modified: incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/HttpPingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/HttpPingTest.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/HttpPingTest.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/testing/src/test/java/org/apache/sling/jcr/jcrinstall/integrationtest/HttpPingTest.java
Fri Dec 12 06:32:32 2008
@@ -25,12 +25,8 @@
     
     public void testWebServerRoot() throws Exception
     {
-        // by default, the Launchpad default servlet redirects / to index.html
         final String url = HTTP_BASE_URL + "/";
-        final GetMethod get = new GetMethod(url);
-        get.setFollowRedirects(false);
-        final int status = httpClient.executeMethod(get);
-        assertEquals("Status must be 200 for " + url, 200, status);
+        assertHttpStatus(url, 403, "Root should return 403 as no redirect is setup in the
repository");
     }
     
     public void test404() throws Exception

Modified: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java
(original)
+++ incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/CreateNodeTest.java
Fri Dec 12 06:32:32 2008
@@ -43,7 +43,7 @@
         }
 
         // get and check URL of created node
-        final GetMethod get = new GetMethod(urlOfNewNode);
+        final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
         final int status = httpClient.executeMethod(get);
         assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
         final String responseBodyStr = get.getResponseBodyAsString();
@@ -51,15 +51,15 @@
         assertTrue(responseBodyStr.contains("value2"));
 
         // test default txt and html renderings
-        getContent(urlOfNewNode, CONTENT_TYPE_PLAIN);
+        getContent(urlOfNewNode + DEFAULT_EXT, CONTENT_TYPE_PLAIN);
         getContent(urlOfNewNode + ".txt", CONTENT_TYPE_PLAIN);
         getContent(urlOfNewNode + ".html", CONTENT_TYPE_HTML);
         getContent(urlOfNewNode + ".json", CONTENT_TYPE_JSON);
         getContent(urlOfNewNode + ".xml", CONTENT_TYPE_XML);
 
         // And extensions for which we have no renderer fail
-        assertHttpStatus(urlOfNewNode + ".pdf", 500);
-        assertHttpStatus(urlOfNewNode + ".someWeirdExtension", 500);
+        assertHttpStatus(urlOfNewNode + ".pdf", 403);
+        assertHttpStatus(urlOfNewNode + ".someWeirdExtension", 403);
     }
 
     public void testCreateNodeMultipart() throws IOException {
@@ -79,7 +79,7 @@
         }
 
         // check node contents (not all renderings - those are tested above)
-        final GetMethod get = new GetMethod(urlOfNewNode);
+        final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
         final int status = httpClient.executeMethod(get);
         assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
         final String responseBodyStr = get.getResponseBodyAsString();
@@ -163,7 +163,7 @@
         }
 
         // get and check URL of created node
-        final GetMethod get = new GetMethod(urlOfNewNode);
+        final GetMethod get = new GetMethod(urlOfNewNode + DEFAULT_EXT);
         final int status = httpClient.executeMethod(get);
         assertEquals(urlOfNewNode + " must be accessible after createNode",200,status);
     }

Modified: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/MkdirTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/MkdirTest.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/MkdirTest.java
(original)
+++ incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/MkdirTest.java
Fri Dec 12 06:32:32 2008
@@ -35,7 +35,7 @@
             fail(ioe.getMessage());
         }
         
-        assertHttpStatus(testDirUrl, 200, testDirUrl);
+        assertHttpStatus(testDirUrl + DEFAULT_EXT, 200, testDirUrl);
         
         try {
             testClient.mkdir(testDirUrl);
@@ -43,7 +43,7 @@
             fail("mkdir must succeed on an existing directory, got IOException:" + ioe);
         }
         
-        assertHttpStatus(testDirUrl, 200, testDirUrl);
+        assertHttpStatus(testDirUrl + DEFAULT_EXT, 200, testDirUrl);
         
         testClient.delete(testDirUrl);
         assertHttpStatus(testDirUrl, 404, testDirUrl + " must be gone after DELETE");
@@ -59,6 +59,6 @@
         } catch(IOException ioe) {
             fail("mkdirs failed:" + ioe);
         }
-        assertHttpStatus(url,200,url + " must exist after test");
+        assertHttpStatus(url + DEFAULT_EXT,200,url + " must exist after test");
     }
 }

Modified: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletCreateTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletCreateTest.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletCreateTest.java
(original)
+++ incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletCreateTest.java
Fri Dec 12 06:32:32 2008
@@ -43,7 +43,7 @@
 
     public void testCreateNode() throws IOException {
         final String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
null);
-        assertHttpStatus(location, HttpServletResponse.SC_OK,
+        assertHttpStatus(location + DEFAULT_EXT, HttpServletResponse.SC_OK,
                 "POST must redirect to created resource (" + location + ")");
         assertTrue("Node (" + location + ") must have generated name",
                 !location.endsWith("/*"));
@@ -53,7 +53,7 @@
 
     public void testCreateNodeWithExtension() throws IOException {
         final String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX
+ ".html", null);
-        assertHttpStatus(location, HttpServletResponse.SC_OK,
+        assertHttpStatus(location + DEFAULT_EXT, HttpServletResponse.SC_OK,
                 "POST must redirect to created resource (" + location + ")");
         assertTrue("Node (" + location + ") must have generated name",
                 !location.endsWith("/*"));
@@ -64,7 +64,7 @@
     public void testCreateNodeAtSpecificUrl() throws IOException {
         final String specifiedLocation = postUrl + "/specified-location";
         final String location = testClient.createNode(specifiedLocation, null);
-        assertHttpStatus(location, HttpServletResponse.SC_OK,
+        assertHttpStatus(location + DEFAULT_EXT, HttpServletResponse.SC_OK,
                 "POST must redirect to created resource (" + location + ")");
         assertTrue("Node (" + location + ") must be created at given URL (" + specifiedLocation
+ ")",
                 location.equals(specifiedLocation));
@@ -74,7 +74,7 @@
         final long id = System.currentTimeMillis();
         final String specifiedLocation = postUrl + "/specified-location" + id + "/deepA/deepB/"
+ id;
         final String location = testClient.createNode(specifiedLocation, null);
-        assertHttpStatus(location, HttpServletResponse.SC_OK,
+        assertHttpStatus(location + DEFAULT_EXT, HttpServletResponse.SC_OK,
                 "POST must redirect to created resource (" + location + ")");
         assertTrue("Node (" + location + ") must be created (deep) at given URL (" + specifiedLocation
+ ")",
                 location.equals(specifiedLocation));

Modified: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletDeleteTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletDeleteTest.java?rev=726016&r1=726015&r2=726016&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletDeleteTest.java
(original)
+++ incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletDeleteTest.java
Fri Dec 12 06:32:32 2008
@@ -47,28 +47,28 @@
         final String urlD = testClient.createNode(postUrl + "/specific-location/for-delete",
null);
         
         // initially all nodes must be found
-        assertHttpStatus(urlA, HttpServletResponse.SC_OK, "A must initially exist");
-        assertHttpStatus(urlB, HttpServletResponse.SC_OK, "B must initially exist");
-        assertHttpStatus(urlC, HttpServletResponse.SC_OK, "C must initially exist");
-        assertHttpStatus(urlD, HttpServletResponse.SC_OK, "D must initially exist");
+        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_OK, "A must initially
exist");
+        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must initially
exist");
+        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must initially
exist");
+        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must initially
exist");
         
         // delete one and check
         final List <NameValuePair> params = new LinkedList<NameValuePair> ();
         params.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_DELETE));
         assertPostStatus(urlA,HttpServletResponse.SC_OK,params,"Delete must return expected
status (3)");
-        assertHttpStatus(urlA, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (1)");
-        assertHttpStatus(urlB, HttpServletResponse.SC_OK, "B must still exist");
-        assertHttpStatus(urlC, HttpServletResponse.SC_OK, "C must still exist");
-        assertHttpStatus(urlD, HttpServletResponse.SC_OK, "D must still exist");
+        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be
deleted (1)");
+        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must still exist");
+        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must still exist");
+        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must still exist");
         
         // delete the others with successive requests
         assertPostStatus(urlB,HttpServletResponse.SC_OK,params,"Delete must return expected
status (2)");
         assertPostStatus(urlC,HttpServletResponse.SC_OK,params,"Delete must return expected
status (2)");
         assertPostStatus(urlD,HttpServletResponse.SC_OK,params,"Delete must return expected
status (2)");
-        assertHttpStatus(urlA, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (2)");
-        assertHttpStatus(urlB, HttpServletResponse.SC_NOT_FOUND, "B must be deleted (2)");
-        assertHttpStatus(urlC, HttpServletResponse.SC_NOT_FOUND, "C must be deleted (2)");
-        assertHttpStatus(urlD, HttpServletResponse.SC_NOT_FOUND, "D must be deleted (2)");
+        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be
deleted (2)");
+        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be
deleted (2)");
+        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "C must be
deleted (2)");
+        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "D must be
deleted (2)");
         
         // attempting to delete non-existing nodes is ok
         assertPostStatus(postUrl,HttpServletResponse.SC_OK,params,"Delete must return expected
status (2)");
@@ -81,10 +81,10 @@
         final String urlD = testClient.createNode(postUrl + "/specific-location/for-delete",
null);
 
         // initially all nodes must be found
-        assertHttpStatus(urlA, HttpServletResponse.SC_OK, "A must initially exist");
-        assertHttpStatus(urlB, HttpServletResponse.SC_OK, "B must initially exist");
-        assertHttpStatus(urlC, HttpServletResponse.SC_OK, "C must initially exist");
-        assertHttpStatus(urlD, HttpServletResponse.SC_OK, "D must initially exist");
+        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_OK, "A must initially
exist");
+        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_OK, "B must initially
exist");
+        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must initially
exist");
+        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must initially
exist");
 
         // delete one and check
         final List <NameValuePair> params = new LinkedList<NameValuePair> ();
@@ -92,10 +92,10 @@
         params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlA.substring(HTTP_BASE_URL.length())));
         params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlB.substring(HTTP_BASE_URL.length())));
         assertPostStatus(urlC,HttpServletResponse.SC_OK,params,"Delete must return expected
status (3)");
-        assertHttpStatus(urlA, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (1)");
-        assertHttpStatus(urlB, HttpServletResponse.SC_NOT_FOUND, "B must be deleted (1)");
-        assertHttpStatus(urlC, HttpServletResponse.SC_OK, "C must still exist");
-        assertHttpStatus(urlD, HttpServletResponse.SC_OK, "D must still exist");
+        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be
deleted (1)");
+        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be
deleted (1)");
+        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_OK, "C must still exist");
+        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_OK, "D must still exist");
 
         // delete the others with successive requests
         params.clear();
@@ -105,9 +105,9 @@
         params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlC.substring(HTTP_BASE_URL.length())));
         params.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, urlD.substring(HTTP_BASE_URL.length())));
         assertPostStatus(urlC,HttpServletResponse.SC_OK,params,"Delete must return expected
status (3)");
-        assertHttpStatus(urlA, HttpServletResponse.SC_NOT_FOUND, "A must be deleted (2)");
-        assertHttpStatus(urlB, HttpServletResponse.SC_NOT_FOUND, "B must be deleted (2)");
-        assertHttpStatus(urlC, HttpServletResponse.SC_NOT_FOUND, "C must be deleted (2)");
-        assertHttpStatus(urlD, HttpServletResponse.SC_NOT_FOUND, "D must be deleted (2)");
+        assertHttpStatus(urlA + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "A must be
deleted (2)");
+        assertHttpStatus(urlB + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "B must be
deleted (2)");
+        assertHttpStatus(urlC + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "C must be
deleted (2)");
+        assertHttpStatus(urlD + DEFAULT_EXT, HttpServletResponse.SC_NOT_FOUND, "D must be
deleted (2)");
     }
 }
\ No newline at end of file



Mime
View raw message