Author: kkolinko
Date: Sun Nov 6 21:04:49 2011
New Revision: 1198554
URL: http://svn.apache.org/viewvc?rev=1198554&view=rev
Log:
Porting r1187806 - whitespace cleanup in /test
Modified:
tomcat/tc7.0.x/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java
tomcat/tc7.0.x/trunk/test/javax/el/TestCompositeELResolver.java
tomcat/tc7.0.x/trunk/test/javax/servlet/jsp/TestPageContext.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestConnector.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestMaxConnections.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestRequest.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponse.java
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
Modified:
tomcat/tc7.0.x/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java
(original)
+++ tomcat/tc7.0.x/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java
Sun Nov 6 21:04:49 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Modified: tomcat/tc7.0.x/trunk/test/javax/el/TestCompositeELResolver.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/javax/el/TestCompositeELResolver.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/javax/el/TestCompositeELResolver.java (original)
+++ tomcat/tc7.0.x/trunk/test/javax/el/TestCompositeELResolver.java Sun Nov 6
21:04:49 2011
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,16 +39,16 @@ public class TestCompositeELResolver ext
// app dir is relative to server home
StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
"/test", appDir.getAbsolutePath());
-
+
// This test needs the JSTL libraries
File lib = new File("webapps/examples/WEB-INF/lib");
ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());
-
+
tomcat.start();
int rc = getUrl("http://localhost:" + getPort() +
"/test/bug50408.jsp", new ByteChunk(), null);
-
+
assertEquals(HttpServletResponse.SC_OK, rc);
}
}
Modified: tomcat/tc7.0.x/trunk/test/javax/servlet/jsp/TestPageContext.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/javax/servlet/jsp/TestPageContext.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/javax/servlet/jsp/TestPageContext.java (original)
+++ tomcat/tc7.0.x/trunk/test/javax/servlet/jsp/TestPageContext.java Sun Nov 6
21:04:49 2011
@@ -36,12 +36,12 @@ public class TestPageContext extends Tom
File appDir = new File("test/webapp-3.0");
// app dir is relative to server home
tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
-
+
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() +
"/test/bug49nnn/bug49196.jsp");
-
+
String result = res.toString();
assertTrue(result.contains("OK"));
}
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
Sun Nov 6 21:04:49 2011
@@ -184,8 +184,8 @@ public class TestDigestAuthenticator ext
Map<String,List<String>> respHeaders =
new HashMap<String,List<String>>();
-
- // The first request will fail - but we need to extract the nonce
+
+ // The first request will fail - but we need to extract the nonce
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + uri, bc, reqHeaders,
respHeaders);
@@ -209,7 +209,7 @@ public class TestDigestAuthenticator ext
}
rc = getUrl("http://localhost:" + getPort() + uri, bc, reqHeaders,
null);
-
+
if (req2expect200) {
assertEquals(200, rc);
assertEquals("OK", bc.toString());
@@ -217,7 +217,7 @@ public class TestDigestAuthenticator ext
assertEquals(401, rc);
assertNull(bc.toString());
}
-
+
// Third request should succeed if we increment nc
auth.clear();
bc.recycle();
@@ -227,7 +227,7 @@ public class TestDigestAuthenticator ext
qop));
rc = getUrl("http://localhost:" + getPort() + uri, bc, reqHeaders,
null);
-
+
if (req3expect200) {
assertEquals(200, rc);
assertEquals("OK", bc.toString());
@@ -243,11 +243,11 @@ public class TestDigestAuthenticator ext
// Configure a context with digest auth and a single protected resource
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
Context ctxt = tomcat.addContext(CONTEXT_PATH,
System.getProperty("java.io.tmpdir"));
-
+
// Add protected servlet
Tomcat.addServlet(ctxt, "TesterServlet", new TesterServlet());
ctxt.addServletMapping(URI, "TesterServlet");
@@ -257,13 +257,13 @@ public class TestDigestAuthenticator ext
sc.addAuthRole(ROLE);
sc.addCollection(collection);
ctxt.addConstraint(sc);
-
+
// Configure the Realm
MapRealm realm = new MapRealm();
realm.addUser(USER, PWD);
realm.addUserRole(USER, ROLE);
ctxt.setRealm(realm);
-
+
// Configure the authenticator
LoginConfig lc = new LoginConfig();
lc.setAuthMethod("DIGEST");
@@ -271,13 +271,13 @@ public class TestDigestAuthenticator ext
ctxt.setLoginConfig(lc);
ctxt.getPipeline().addValve(new DigestAuthenticator());
}
-
+
protected static String getNonce(Map<String,List<String>> respHeaders) {
List<String> authHeaders =
respHeaders.get(AuthenticatorBase.AUTH_HEADER_NAME);
// Assume there is only one
String authHeader = authHeaders.iterator().next();
-
+
int start = authHeader.indexOf("nonce=\"") + 7;
int end = authHeader.indexOf("\"", start);
return authHeader.substring(start, end);
@@ -288,7 +288,7 @@ public class TestDigestAuthenticator ext
respHeaders.get(AuthenticatorBase.AUTH_HEADER_NAME);
// Assume there is only one
String authHeader = authHeaders.iterator().next();
-
+
int start = authHeader.indexOf("opaque=\"") + 8;
int end = authHeader.indexOf("\"", start);
return authHeader.substring(start, end);
@@ -313,10 +313,10 @@ public class TestDigestAuthenticator ext
String a1 = user + ":" + realm + ":" + pwd;
String a2 = "GET:" + uri;
-
+
String md5a1 = digest(a1);
String md5a2 = digest(a2);
-
+
String response;
if (qop == null) {
response = md5a1 + ":" + nonce + ":" + md5a2;
@@ -326,7 +326,7 @@ public class TestDigestAuthenticator ext
}
String md5response = digest(response);
-
+
StringBuilder auth = new StringBuilder();
auth.append("Digest username=\"");
auth.append(user);
@@ -359,7 +359,7 @@ public class TestDigestAuthenticator ext
return auth.toString();
}
-
+
private static String digest(String input) throws NoSuchAlgorithmException
{
// This is slow but should be OK as this is only a test
MessageDigest md5 = MessageDigest.getInstance("MD5");
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
Sun Nov 6 21:04:49 2011
@@ -48,18 +48,18 @@ public class TesterDigestAuthenticatorPe
private static String QOP = "auth";
private DigestAuthenticator authenticator = new DigestAuthenticator();
-
-
+
+
@Test
public void testSimple() throws Exception {
doTest(100, 1000000);
}
public void doTest(int threadCount, int requestCount) throws Exception {
-
+
TesterRunnable runnables[] = new TesterRunnable[threadCount];
Thread threads[] = new Thread[threadCount];
-
+
// Create the runnables & threads
for (int i = 0; i < threadCount; i++) {
runnables[i] = new TesterRunnable(requestCount);
@@ -72,13 +72,13 @@ public class TesterDigestAuthenticatorPe
for (int i = 0; i < threadCount; i++) {
threads[i].start();
}
-
+
// Wait for the threads to finish
for (int i = 0; i < threadCount; i++) {
threads[i].join();
}
- double wallTime = System.currentTimeMillis() - start;
-
+ double wallTime = System.currentTimeMillis() - start;
+
// Gather the results...
double totalTime = 0;
int totalSuccess = 0;
@@ -88,12 +88,12 @@ public class TesterDigestAuthenticatorPe
totalSuccess = totalSuccess + runnables[i].getSuccess();
totalTime = totalTime + runnables[i].getTime();
}
-
+
System.out.println("Average time per request (user): " +
totalTime/(threadCount * requestCount));
System.out.println("Average time per request (wall): " +
wallTime/(threadCount * requestCount));
-
+
assertEquals(requestCount * threadCount, totalSuccess);
}
@@ -109,28 +109,28 @@ public class TesterDigestAuthenticatorPe
Context context = new StandardContext();
context.setName(CONTEXT_PATH);
context.setRealm(realm);
-
+
// Make the Context and Realm visible to the Authenticator
authenticator.setContainer(context);
-
+
// Prevent caching of cnonces so we can the same one for all requests
authenticator.setCnonceCacheSize(0);
authenticator.start();
}
-
+
private class TesterRunnable implements Runnable {
// Number of valid requests required
private int requestCount;
-
+
private int success = 0;
private long time = 0;
private TesterDigestRequest request;
private HttpServletResponse response;
private LoginConfig config;
-
+
// All init code should be in here. run() needs to be quick
public TesterRunnable(int requestCount) throws Exception {
this.requestCount = requestCount;
@@ -159,7 +159,7 @@ public class TesterDigestAuthenticatorPe
}
time = System.currentTimeMillis() - start;
}
-
+
public int getSuccess() {
return success;
}
@@ -170,13 +170,13 @@ public class TesterDigestAuthenticatorPe
private String buildDigestResponse(String nonce)
throws NoSuchAlgorithmException {
-
+
String ncString = "00000001";
String cnonce = "cnonce";
-
+
String a1 = USER + ":" + REALM + ":" + PWD;
String a2 = METHOD + ":" + CONTEXT_PATH + URI;
-
+
MessageDigest digester = MessageDigest.getInstance("MD5");
MD5Encoder encoder = new MD5Encoder();
@@ -188,7 +188,7 @@ public class TesterDigestAuthenticatorPe
String md5response =
encoder.encode(digester.digest(response.getBytes()));
-
+
StringBuilder auth = new StringBuilder();
auth.append("Digest username=\"");
auth.append(USER);
@@ -217,16 +217,16 @@ public class TesterDigestAuthenticatorPe
}
}
-
+
private static class TesterDigestRequest extends Request {
private String authHeader = null;
-
+
@Override
public String getRemoteAddr() {
return "127.0.0.1";
}
-
+
public void setAuthHeader(String authHeader) {
this.authHeader = authHeader;
}
@@ -254,6 +254,6 @@ public class TesterDigestAuthenticatorPe
public String getRequestURI() {
return CONTEXT_PATH + URI;
}
-
+
}
}
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestConnector.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestConnector.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestConnector.java
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestConnector.java
Sun Nov 6 21:04:49 2011
@@ -30,14 +30,14 @@ import org.apache.catalina.startup.Tomca
import org.apache.tomcat.util.buf.ByteChunk;
/**
- * Test cases for {@link Connector}.
+ * Test cases for {@link Connector}.
*/
public class TestConnector extends TomcatBaseTest {
@Test
public void testStop() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
Context root = tomcat.addContext("", TEMP_DIR);
Wrapper w =
Tomcat.addServlet(root, "tester", new TesterServlet());
@@ -45,15 +45,15 @@ public class TestConnector extends Tomca
root.addServletMapping("/", "tester");
Connector connector = tomcat.getConnector();
-
+
tomcat.start();
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/", bc, null, null);
-
+
assertEquals(200, rc);
assertEquals("OK", bc.toString());
-
+
rc = -1;
bc.recycle();
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
Sun Nov 6 21:04:49 2011
@@ -81,17 +81,17 @@ public class TestCoyoteAdapter extends T
public void testPathParamsRedirect() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
File docBase = new File(System.getProperty("java.io.tmpdir"));
-
+
// Create the folder that will trigger the redirect
File foo = new File(docBase, "foo");
addDeleteOnTearDown(foo);
if (!foo.mkdirs() && !foo.isDirectory()) {
fail("Unable to create foo directory in docBase");
}
-
+
Context ctx = tomcat.addContext("", docBase.getAbsolutePath());
Tomcat.addServlet(ctx, "servlet", new PathParamServlet());
@@ -113,7 +113,7 @@ public class TestCoyoteAdapter extends T
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
- Context ctx =
+ Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
Tomcat.addServlet(ctx, "servlet", new PathParamServlet());
@@ -134,7 +134,7 @@ public class TestCoyoteAdapter extends T
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain");
PrintWriter pw = resp.getWriter();
@@ -167,7 +167,7 @@ public class TestCoyoteAdapter extends T
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
- Context ctx =
+ Context ctx =
tomcat.addContext("/testapp",
System.getProperty("java.io.tmpdir"));
Tomcat.addServlet(ctx, "servlet", new PathParamServlet());
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java
Sun Nov 6 21:04:49 2011
@@ -45,16 +45,16 @@ public class TestKeepAliveCount extends
TestKeepAliveClient client = new TestKeepAliveClient();
client.doHttp11Request();
}
-
-
+
+
private class TestKeepAliveClient extends SimpleHttpClient {
private boolean init;
-
+
private synchronized void init() {
if (init) return;
-
+
Tomcat tomcat = getTomcatInstance();
Context root = tomcat.addContext("", TEMP_DIR);
Tomcat.addServlet(root, "Simple", new SimpleServlet());
@@ -65,14 +65,14 @@ public class TestKeepAliveCount extends
tomcat.getConnector().setProperty("port", "8080");
init = true;
}
-
+
private void doHttp10Request() throws Exception {
Tomcat tomcat = getTomcatInstance();
init();
tomcat.start();
// Open connection
connect();
-
+
// Send request in two parts
String[] request = new String[1];
request[0] =
@@ -86,24 +86,24 @@ public class TestKeepAliveCount extends
tomcat.stop();
assertTrue(passed);
}
-
+
private void doHttp11Request() throws Exception {
Tomcat tomcat = getTomcatInstance();
init();
tomcat.start();
// Open connection
connect();
-
+
// Send request in two parts
String[] request = new String[1];
request[0] =
- "GET /test HTTP/1.1" + CRLF +
+ "GET /test HTTP/1.1" + CRLF +
"Host: localhost" + CRLF +
"Connection: Keep-Alive" + CRLF+
"Keep-Alive: 300"+ CRLF+ CRLF;
-
+
setRequest(request);
-
+
for (int i=0; i<5; i++) {
processRequest(false); // blocks until response has been read
assertTrue(getResponseLine()!=null &&
getResponseLine().trim().startsWith("HTTP/1.1 200"));
@@ -115,15 +115,15 @@ public class TestKeepAliveCount extends
tomcat.stop();
assertTrue(passed);
}
-
+
@Override
public boolean isResponseBodyOK() {
return true;
}
-
+
}
-
-
+
+
private static class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -133,7 +133,7 @@ public class TestKeepAliveCount extends
resp.setContentLength(0);
resp.flushBuffer();
}
-
+
}
-
+
}
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestMaxConnections.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestMaxConnections.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestMaxConnections.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestMaxConnections.java
Sun Nov 6 21:04:49 2011
@@ -58,7 +58,7 @@ public class TestMaxConnections extends
if (t[i].passed) passcount++;
if (t[i].connectfailed) connectfail++;
}
-
+
assertTrue("The number of successful requests should have been 4-5,
actual "+passcount,4==passcount || 5==passcount);
System.out.println("There were [" + connectfail + "] connection
failures");
}
@@ -79,7 +79,7 @@ public class TestMaxConnections extends
}
}
-
+
private synchronized void init() throws Exception {
Tomcat tomcat = getTomcatInstance();
Context root = tomcat.addContext("", SimpleHttpClient.TEMP_DIR);
@@ -98,11 +98,11 @@ public class TestMaxConnections extends
private static class TestClient extends SimpleHttpClient {
private void doHttp10Request() throws Exception {
-
+
long start = System.currentTimeMillis();
// Open connection
connect(connectTimeout,soTimeout);
-
+
// Send request in two parts
String[] request = new String[1];
request[0] =
@@ -118,15 +118,15 @@ public class TestMaxConnections extends
reset();
assertTrue(passed);
}
-
+
@Override
public boolean isResponseBodyOK() {
return true;
}
-
+
}
-
-
+
+
private static class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -136,12 +136,12 @@ public class TestMaxConnections extends
try {
Thread.sleep(TestMaxConnections.soTimeout*4/5);
}catch (InterruptedException x) {
-
+
}
resp.setContentLength(0);
resp.flushBuffer();
}
-
+
}
-
+
}
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestRequest.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestRequest.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestRequest.java
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestRequest.java
Sun Nov 6 21:04:49 2011
@@ -46,13 +46,13 @@ import org.apache.catalina.startup.Tomca
import org.apache.tomcat.util.buf.ByteChunk;
/**
- * Test case for {@link Request}.
+ * Test case for {@link Request}.
*/
public class TestRequest extends TomcatBaseTest {
/**
* Test case for https://issues.apache.org/bugzilla/show_bug.cgi?id=37794
- * POST parameters are not returned from a call to
+ * POST parameters are not returned from a call to
* any of the {@link HttpServletRequest} getParameterXXX() methods if the
* request is chunked.
*/
@@ -72,9 +72,9 @@ public class TestRequest extends TomcatB
client.reset();
client.doRequest(1, false); // 1 byte - too small should fail
assertTrue(client.isResponse500());
-
+
client.reset();
-
+
// Edge cases around actual content length
client.reset();
client.doRequest(6, false); // Too small should fail
@@ -87,7 +87,7 @@ public class TestRequest extends TomcatB
client.doRequest(8, false); // 1 extra - should pass
assertTrue(client.isResponse200());
assertTrue(client.isResponseBodyOK());
-
+
// Much larger
client.reset();
client.doRequest(8096, false); // Plenty of space - should pass
@@ -100,9 +100,9 @@ public class TestRequest extends TomcatB
assertTrue(client.isResponse200());
assertTrue(client.isResponseBodyOK());
}
-
+
private static class Bug37794Servlet extends HttpServlet {
-
+
private static final long serialVersionUID = 1L;
/**
@@ -113,9 +113,9 @@ public class TestRequest extends TomcatB
throws ServletException, IOException {
// Just echo the parameters and values back as plain text
resp.setContentType("text/plain");
-
+
PrintWriter out = resp.getWriter();
-
+
// Assume one value per attribute
Enumeration<String> names = req.getParameterNames();
while (names.hasMoreElements()) {
@@ -124,36 +124,36 @@ public class TestRequest extends TomcatB
}
}
}
-
+
/**
* Bug 37794 test client.
*/
private class Bug37794Client extends SimpleHttpClient {
-
+
private boolean init;
-
+
private synchronized void init() throws Exception {
if (init) return;
-
+
Tomcat tomcat = getTomcatInstance();
Context root = tomcat.addContext("", TEMP_DIR);
Tomcat.addServlet(root, "Bug37794", new Bug37794Servlet());
root.addServletMapping("/test", "Bug37794");
tomcat.start();
-
+
init = true;
}
-
+
private Exception doRequest(int postLimit, boolean ucChunkedHead) {
Tomcat tomcat = getTomcatInstance();
-
+
try {
init();
tomcat.getConnector().setMaxPostSize(postLimit);
-
+
// Open connection
connect();
-
+
// Send request in two parts
String[] request = new String[2];
if (ucChunkedHead) {
@@ -180,10 +180,10 @@ public class TestRequest extends TomcatB
"&b=2" + CRLF +
"0" + CRLF +
CRLF;
-
+
setRequest(request);
processRequest(); // blocks until response has been read
-
+
// Close the connection
disconnect();
} catch (Exception e) {
@@ -205,7 +205,7 @@ public class TestRequest extends TomcatB
}
return true;
}
-
+
}
/**
@@ -217,21 +217,21 @@ public class TestRequest extends TomcatB
public void testBug38113() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
- Context ctx =
+ Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Add the Servlet
Tomcat.addServlet(ctx, "servlet", new EchoQueryStringServlet());
ctx.addServletMapping("/", "servlet");
-
+
tomcat.start();
// No query string
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("QueryString=null", res.toString());
-
+
// Query string
res = getUrl("http://localhost:" + getPort() + "/?a=b");
assertEquals("QueryString=a=b", res.toString());
@@ -240,7 +240,7 @@ public class TestRequest extends TomcatB
res = getUrl("http://localhost:" + getPort() + "/?");
assertEquals("QueryString=", res.toString());
}
-
+
private static final class EchoQueryStringServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -262,56 +262,56 @@ public class TestRequest extends TomcatB
public void testLoginLogout() throws Exception{
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
- Context ctx =
+ Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
LoginConfig config = new LoginConfig();
config.setAuthMethod("BASIC");
ctx.setLoginConfig(config);
ctx.getPipeline().addValve(new BasicAuthenticator());
-
+
Tomcat.addServlet(ctx, "servlet", new LoginLogoutServlet());
ctx.addServletMapping("/", "servlet");
-
+
MapRealm realm = new MapRealm();
realm.addUser(LoginLogoutServlet.USER, LoginLogoutServlet.PWD);
ctx.setRealm(realm);
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals(LoginLogoutServlet.OK, res.toString());
}
-
+
private static final class LoginLogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String USER = "user";
private static final String PWD = "pwd";
private static final String OK = "OK";
-
+
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
-
+
req.login(USER, PWD);
-
+
if (!req.getRemoteUser().equals(USER))
throw new ServletException();
if (!req.getUserPrincipal().getName().equals(USER))
throw new ServletException();
-
+
req.logout();
-
+
if (req.getRemoteUser() != null)
throw new ServletException();
if (req.getUserPrincipal() != null)
throw new ServletException();
-
+
resp.getWriter().write(OK);
}
-
+
}
@Test
@@ -336,7 +336,7 @@ public class TestRequest extends TomcatB
Tomcat.addServlet(root, "Bug37794", new Bug37794Servlet());
root.addServletMapping("/", "Bug37794");
tomcat.start();
-
+
HttpURLConnection conn = getConnection();
conn.setChunkedStreamingMode(8 * 1024);
InputStream is = conn.getInputStream();
@@ -425,7 +425,7 @@ public class TestRequest extends TomcatB
*
*/
private static class EchoParametersServlet extends HttpServlet {
-
+
private static final long serialVersionUID = 1L;
/**
@@ -440,11 +440,11 @@ public class TestRequest extends TomcatB
resp.setCharacterEncoding("UTF-8");
PrintWriter out = resp.getWriter();
-
+
TreeMap<String,String[]> parameters = new
TreeMap<String,String[]>(req.getParameterMap());
boolean first = true;
-
+
for(String name: parameters.keySet()) {
String[] values = req.getParameterValues(name);
@@ -469,26 +469,26 @@ public class TestRequest extends TomcatB
private class Bug48692Client extends SimpleHttpClient {
private boolean init;
-
+
private synchronized void init() throws Exception {
if (init) return;
-
+
Tomcat tomcat = getTomcatInstance();
Context root = tomcat.addContext("", TEMP_DIR);
Tomcat.addServlet(root, "EchoParameters", new
EchoParametersServlet());
root.addServletMapping("/echo", "EchoParameters");
tomcat.start();
-
+
init = true;
}
-
+
private Exception doRequest(String method,
String queryString,
String contentType,
String requestBody,
boolean allowBody) {
Tomcat tomcat = getTomcatInstance();
-
+
try {
init();
if(allowBody)
@@ -521,7 +521,7 @@ public class TestRequest extends TomcatB
setRequest(request);
processRequest(); // blocks until response has been read
-
+
// Close the connection
disconnect();
} catch (Exception e) {
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponse.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponse.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponse.java
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponse.java
Sun Nov 6 21:04:49 2011
@@ -40,7 +40,7 @@ import org.apache.catalina.startup.Tomca
import org.apache.tomcat.util.buf.ByteChunk;
/**
- * Test case for {@link Request}.
+ * Test case for {@link Request}.
*/
public class TestResponse extends TomcatBaseTest {
@@ -48,7 +48,7 @@ public class TestResponse extends Tomcat
public void testBug49598() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
File docBase = new File(System.getProperty("java.io.tmpdir"));
Context ctx = tomcat.addContext("", docBase.getAbsolutePath());
@@ -57,10 +57,10 @@ public class TestResponse extends Tomcat
ctx.addServletMapping("/", "servlet");
tomcat.start();
-
+
Map<String,List<String>> headers = new HashMap<String,List<String>>();
getUrl("http://localhost:" + getPort() + "/", new ByteChunk(),
headers);
-
+
// Check for headers without a name
for (Map.Entry<String,List<String>> header : headers.entrySet()) {
if (header.getKey() == null) {
@@ -73,7 +73,7 @@ public class TestResponse extends Tomcat
fail("Null header name detected for value " + values);
}
}
-
+
// Check for exactly one Set-Cookie header
int count = 0;
for (String headerName : headers.keySet()) {
@@ -83,7 +83,7 @@ public class TestResponse extends Tomcat
}
assertEquals(1, count);
}
-
+
private static final class Bug49598Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -94,6 +94,6 @@ public class TestResponse extends Tomcat
session.invalidate();
req.getSession(true);
}
-
+
}
}
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java?rev=1198554&r1=1198553&r2=1198554&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
Sun Nov 6 21:04:49 2011
@@ -27,26 +27,26 @@ public class TestResponsePerformance {
Request req = new TesterToAbsoluteRequest();
Response resp = new Response();
resp.setRequest(req);
-
+
long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
resp.toAbsolute("bar.html");
}
long homebrew = System.currentTimeMillis() - start;
-
+
start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
URI base = URI.create("http://localhost:8080/foo.html");
base.resolve(URI.create("bar.html")).toASCIIString();
}
long uri = System.currentTimeMillis() - start;
-
+
System.out.println("Current 'home-brew': " + homebrew +
"ms, Using URI: " + uri + "ms");
assertTrue(homebrew < uri);
}
-
+
private static class TesterToAbsoluteRequest extends Request {
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]