[Httpunit-commit] CVS: httpunit/test/com/meterware/pseudoserver PseudoServerTest.java,1.8,1.9
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-06-24 22:39:44
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver
In directory sc8-pr-cvs1:/tmp/cvs-serv25279/test/com/meterware/pseudoserver
Modified Files:
PseudoServerTest.java
Log Message:
Add protocol throttling
Index: PseudoServerTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/pseudoserver/PseudoServerTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PseudoServerTest.java 18 Mar 2003 19:35:34 -0000 1.8
+++ PseudoServerTest.java 24 Jun 2003 22:39:41 -0000 1.9
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2000-2002, Russell Gold
+ * Copyright (c) 2000-2003, Russell Gold
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -179,7 +179,6 @@
sendHTTPLine( os, "GET /sample HTTP/1.1" );
sendHTTPLine( os, "Host: meterware.com" );
- sendHTTPLine( os, "Connection: close" );
sendHTTPLine( os, "" );
StringBuffer sb = new StringBuffer();
@@ -187,6 +186,32 @@
while (-1 != (b = is.read())) sb.append( (char) b );
String result = sb.toString();
assertTrue( "Did not find matching protocol", result.startsWith( "HTTP/1.1" ) );
+ assertTrue( "Did not find expected text", result.indexOf( "Get this" ) > 0 );
+ }
+
+
+
+
+ /**
+ * This verifies that the PseudoServer can be restricted to a HTTP/1.0.
+ */
+ public void testProtocolThrottling() throws Exception {
+ getServer().setMaxProtocolLevel( 1, 0 );
+ defineResource( "sample", "Get this", "text/plain" );
+ Socket socket = new Socket( "localhost", getHostPort() );
+ OutputStream os = socket.getOutputStream();
+ InputStream is = new BufferedInputStream( socket.getInputStream() );
+
+ sendHTTPLine( os, "GET /sample HTTP/1.1" );
+ sendHTTPLine( os, "Host: meterware.com" );
+ sendHTTPLine( os, "Connection: close" );
+ sendHTTPLine( os, "" );
+
+ StringBuffer sb = new StringBuffer();
+ int b;
+ while (-1 != (b = is.read())) sb.append( (char) b );
+ String result = sb.toString();
+ assertTrue( "Did not find matching protocol", result.startsWith( "HTTP/1.0" ) );
assertTrue( "Did not find expected text", result.indexOf( "Get this" ) > 0 );
}
|