You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2008/02/28 14:11:00 UTC
svn commit: r631953 -
/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
Author: cziegeler
Date: Thu Feb 28 05:10:57 2008
New Revision: 631953
URL: http://svn.apache.org/viewvc?rev=631953&view=rev
Log:
Remove unused import.
Modified:
incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
Modified: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java?rev=631953&r1=631952&r2=631953&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java (original)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/RedirectTest.java Thu Feb 28 05:10:57 2008
@@ -20,8 +20,6 @@
import java.util.HashMap;
import java.util.Map;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
@@ -45,60 +43,60 @@
/** 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);
-
+
// 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);
-
+
// ... to */index.html
String location = get.getResponseHeader("Location").getValue();
assertNotNull(location);
assertTrue(location.endsWith("/index.html"));
-
+
// get the created node without following redirects
get = new GetMethod(redirNodeUrl + ".html");
get.setFollowRedirects(false);
status = httpClient.executeMethod(get);
-
+
// expect temporary redirect ...
assertEquals(302, status);
-
+
// ... to */index.html
location = get.getResponseHeader("Location").getValue();
assertNotNull(location);
assertTrue(location.endsWith("/index.html.html"));
}
-
+
/** test 404 response when sling:target is missing */
public void testRedirect404() throws IOException {
// create a sling:redirect node without a target
Map<String, String> props = new HashMap<String, String>();
props.put("sling:resourceType", "sling:redirect");
String redirNodeUrl = testClient.createNode(postUrl, props);
-
+
// get the created node without following redirects
GetMethod get = new GetMethod(redirNodeUrl);
get.setFollowRedirects(false);
int status = httpClient.executeMethod(get);
-
+
// expect 404 not found
assertEquals(404, status);
-
+
// get the created node without following redirects
get = new GetMethod(redirNodeUrl + ".html");
get.setFollowRedirects(false);
status = httpClient.executeMethod(get);
-
+
// expect 404 not found
assertEquals(404, status);
}
@@ -110,44 +108,44 @@
props.put("sling:resourceType", "sling:redirect");
props.put("sling:target", "/index.html");
String redirNodeUrl = testClient.createNode(postUrl, props);
-
+
// get the created node without following redirects
final GetMethod get = new GetMethod(redirNodeUrl + ".json");
get.setFollowRedirects(false);
final int status = httpClient.executeMethod(get);
-
+
// expect 200 OK with the JSON data
assertEquals(200, status);
assertTrue(get.getResponseHeader("Content-Type").getValue().startsWith(CONTENT_TYPE_JSON));
-
+
// the json data
String jsonString = get.getResponseBodyAsString();
JSONObject json = new JSONObject(jsonString);
-
+
assertEquals("sling:redirect", json.get("sling:resourceType"));
assertEquals("/index.html", json.get("sling:target"));
}
-
+
/** test JSON result for .json requests with sling:target */
public void testRedirectJson2() throws JSONException, IOException {
// create a sling:redirect node without a target
Map<String, String> props = new HashMap<String, String>();
props.put("sling:resourceType", "sling:redirect");
String redirNodeUrl = testClient.createNode(postUrl, props);
-
+
// get the created node without following redirects
final GetMethod get = new GetMethod(redirNodeUrl + ".json");
get.setFollowRedirects(false);
final int status = httpClient.executeMethod(get);
-
+
// expect 200 OK with the JSON data
assertEquals(200, status);
assertTrue(get.getResponseHeader("Content-Type").getValue().startsWith(CONTENT_TYPE_JSON));
-
+
// the json data
String jsonString = get.getResponseBodyAsString();
JSONObject json = new JSONObject(jsonString);
-
+
assertEquals("sling:redirect", json.get("sling:resourceType"));
}