sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1607635 - /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
Date Thu, 03 Jul 2014 13:10:00 GMT
Author: bdelacretaz
Date: Thu Jul  3 13:10:00 2014
New Revision: 1607635

URL: http://svn.apache.org/r1607635
Log:
Add sling:status test

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

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java?rev=1607635&r1=1607634&r2=1607635&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
Thu Jul  3 13:10:00 2014
@@ -41,23 +41,16 @@ public class RedirectTest extends HttpTe
             + System.currentTimeMillis()
             + SlingPostConstants.DEFAULT_CREATE_SUFFIX;
     }
-
-    /** test 302 response with existing sling:target */
-    public void testRedirect302() throws IOException {
-
-        // create a node redirecting to /index
-        Map<String, String> props = new HashMap<String, String>();
-        props.put("sling:resourceType", "sling:redirect");
-        props.put("sling:target", "/index.html");
-        String redirNodeUrl = testClient.createNode(postUrl, props);
+    
+    private void testRedirectToIndexHtml(String redirNodeUrl, int statusCode) throws IOException
{
 
         // get the created node without following redirects
         GetMethod get = new GetMethod(redirNodeUrl);
         get.setFollowRedirects(false);
         int status = httpClient.executeMethod(get);
 
-        // expect temporary redirect ...
-        assertEquals(302, status);
+        // expect redirect ...
+        assertEquals(statusCode, status);
 
         // ... to */index.html
         String location = get.getResponseHeader("Location").getValue();
@@ -69,8 +62,8 @@ public class RedirectTest extends HttpTe
         get.setFollowRedirects(false);
         status = httpClient.executeMethod(get);
 
-        // expect temporary redirect ...
-        assertEquals(302, status);
+        // expect redirect ...
+        assertEquals(statusCode, status);
 
         // ... to */index.html
         location = get.getResponseHeader("Location").getValue();
@@ -82,8 +75,8 @@ public class RedirectTest extends HttpTe
         get.setFollowRedirects(false);
         status = httpClient.executeMethod(get);
 
-        // expect temporary redirect ...
-        assertEquals(302, status);
+        // expect redirect ...
+        assertEquals(statusCode, status);
 
         // ... to */index.html
         location = get.getResponseHeader("Location").getValue();
@@ -91,6 +84,31 @@ public class RedirectTest extends HttpTe
         assertTrue(location.endsWith("/index.html?param=value"));
     }
 
+    /** test 302 as the default redirect */
+    public void testRedirect302() throws IOException {
+
+        // create a node redirecting to /index with default status code
+        Map<String, String> props = new HashMap<String, String>();
+        props.put("sling:resourceType", "sling:redirect");
+        props.put("sling:target", "/index.html");
+        String redirNodeUrl = testClient.createNode(postUrl, props);
+        
+        testRedirectToIndexHtml(redirNodeUrl, 302);
+    }
+
+    /** test 301 specified by sling:status */
+    public void testRedirect301() throws IOException {
+
+        // create a node redirecting to /index with default status code
+        Map<String, String> props = new HashMap<String, String>();
+        props.put("sling:resourceType", "sling:redirect");
+        props.put("sling:target", "/index.html");
+        props.put("sling:status", "301");
+        String redirNodeUrl = testClient.createNode(postUrl, props);
+        
+        testRedirectToIndexHtml(redirNodeUrl, 301);
+    }
+    
     /** test 302 response with existing sling:target */
     public void testRedirect302_absolute() throws IOException {
 



Mime
View raw message