[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit HttpUnitTest.java,1.18,1.19 PseudoServer
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-01-28 18:43:28
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv28744/test/com/meterware/httpunit
Modified Files:
HttpUnitTest.java PseudoServerTest.java WebFrameTest.java
Log Message:
Clean up handling of disabled auto-redirect
Index: HttpUnitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HttpUnitTest.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- HttpUnitTest.java 2002/01/14 18:13:45 1.18
+++ HttpUnitTest.java 2002/01/28 18:43:25 1.19
@@ -68,6 +68,11 @@
}
+ protected void defineResource( String resourceName, String value, int statusCode ) {
+ _server.setErrorResource( resourceName, statusCode, value );
+ }
+
+
protected void defineResource( String resourceName, String value, String contentType ) {
_server.setResource( resourceName, value, contentType );
}
Index: PseudoServerTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/PseudoServerTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- PseudoServerTest.java 2002/01/10 22:18:14 1.19
+++ PseudoServerTest.java 2002/01/28 18:43:25 1.20
@@ -172,7 +172,7 @@
PseudoServer ps = new PseudoServer();
int port = ps.getConnectedPort();
ps.setResource( resourceName, resourceValue );
- ps.setResource( redirectName, "" );
+ ps.setErrorResource( redirectName, HttpURLConnection.HTTP_MOVED_PERM, "" );
ps.addResourceHeader( redirectName, "Location: http://localhost:" + port + '/' + resourceName );
try {
@@ -186,6 +186,32 @@
}
}
+
+ public void testDisabledRedirect() throws Exception {
+ String resourceName = "something/redirected";
+ String resourceValue = "the desired content";
+
+ String redirectName = "anOldOne";
+ String redirectValue = "old content";
+
+ PseudoServer ps = new PseudoServer();
+ int port = ps.getConnectedPort();
+ ps.setResource( resourceName, resourceValue );
+ ps.setErrorResource( redirectName, HttpURLConnection.HTTP_MOVED_PERM, redirectValue );
+ ps.addResourceHeader( redirectName, "Location: http://localhost:" + port + '/' + resourceName );
+
+ try {
+ HttpUnitOptions.setAutoRedirect( false );
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest( "http://localhost:" + port + '/' + redirectName );
+ WebResponse response = wc.getResponse( request );
+ assertEquals( "requested resource", redirectValue, response.getText().trim() );
+ assertEquals( "content type", "text/html", response.getContentType() );
+ } finally {
+ HttpUnitOptions.setAutoRedirect( true );
+ ps.shutDown();
+ }
+ }
public void testCookies() throws Exception {
Index: WebFrameTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebFrameTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- WebFrameTest.java 2002/01/17 19:38:09 1.9
+++ WebFrameTest.java 2002/01/28 18:43:25 1.10
@@ -20,6 +20,7 @@
*
*******************************************************************************************************************/
import java.net.URL;
+import java.net.HttpURLConnection;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -262,7 +263,7 @@
public void testSelfTargetForm() throws Exception {
defineWebPage( "Linker", "<form action=redirect.html target=_self><input type=text name=sample value=z></form>" );
- defineResource( "redirect.html?sample=z", "" );
+ defineResource( "redirect.html?sample=z", "", HttpURLConnection.HTTP_MOVED_PERM );
addResourceHeader( "redirect.html?sample=z", "Location: " + getHostPath() + "/Target.html" );
_wc.getResponse( getHostPath() + "/Frames.html" );
@@ -274,7 +275,7 @@
public void testSubFrameRedirect() throws Exception {
- defineResource( "Linker.html", "" );
+ defineResource( "Linker.html", "", HttpURLConnection.HTTP_MOVED_PERM );
addResourceHeader( "Linker.html", "Location: " + getHostPath() + "/Target.html" );
_wc.getResponse( getHostPath() + "/Frames.html" );
|