You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 23:23:12 UTC
svn commit: r1187806 [1/5] - in /tomcat/trunk/test: javax/el/
javax/servlet/jsp/ org/apache/catalina/authenticator/
org/apache/catalina/connector/ org/apache/catalina/core/
org/apache/catalina/deploy/ org/apache/catalina/filters/
org/apache/catalina/ha...
Author: markt
Date: Sat Oct 22 21:23:07 2011
New Revision: 1187806
URL: http://svn.apache.org/viewvc?rev=1187806&view=rev
Log:
Whitespace removal from remaining /test
Modified:
tomcat/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java
tomcat/trunk/test/javax/el/TestCompositeELResolver.java
tomcat/trunk/test/javax/servlet/jsp/TestPageContext.java
tomcat/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
tomcat/trunk/test/org/apache/catalina/connector/TestConnector.java
tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
tomcat/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java
tomcat/trunk/test/org/apache/catalina/connector/TestMaxConnections.java
tomcat/trunk/test/org/apache/catalina/connector/TestRequest.java
tomcat/trunk/test/org/apache/catalina/connector/TestResponse.java
tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
tomcat/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java
tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextValve.java
tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
tomcat/trunk/test/org/apache/catalina/deploy/TestSecurityConstraint.java
tomcat/trunk/test/org/apache/catalina/deploy/TestWebXml.java
tomcat/trunk/test/org/apache/catalina/deploy/TestWebXmlOrdering.java
tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java
tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java
tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter2.java
tomcat/trunk/test/org/apache/catalina/filters/TesterResponse.java
tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java
tomcat/trunk/test/org/apache/catalina/ha/session/TesterPrincipal.java
tomcat/trunk/test/org/apache/catalina/loader/TestVirtualWebappLoader.java
tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderMemoryLeak.java
tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java
tomcat/trunk/test/org/apache/catalina/servlets/TestDefaultServlet.java
tomcat/trunk/test/org/apache/catalina/servlets/TestWebdavServlet.java
tomcat/trunk/test/org/apache/catalina/session/Benchmarks.java
tomcat/trunk/test/org/apache/catalina/session/Threading.java
tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java
tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java
tomcat/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java
tomcat/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java
tomcat/trunk/test/org/apache/catalina/startup/ParamFilter.java
tomcat/trunk/test/org/apache/catalina/startup/ParamServlet.java
tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
tomcat/trunk/test/org/apache/catalina/startup/TestContextConfig.java
tomcat/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java
tomcat/trunk/test/org/apache/catalina/startup/TestListener.java
tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
tomcat/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java
tomcat/trunk/test/org/apache/catalina/startup/TesterServlet.java
tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/CoordinationDemo.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/LoadTest.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/MapDemo.java
tomcat/trunk/test/org/apache/catalina/tribes/demos/MembersWithProperties.java
tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelOptionFlag.java
tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
tomcat/trunk/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
tomcat/trunk/test/org/apache/catalina/tribes/membership/TestMemberImplSerialization.java
tomcat/trunk/test/org/apache/catalina/tribes/test/NioSenderTest.java
tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestMulticastPackages.java
tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestRemoteProcessException.java
tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestUdpPackages.java
tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioReceive.java
tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketNioValidateSend.java
tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketReceive.java
tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketSend.java
tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketTribesReceive.java
tomcat/trunk/test/org/apache/catalina/tribes/test/transport/SocketValidateReceive.java
tomcat/trunk/test/org/apache/catalina/util/TestContextName.java
tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java
tomcat/trunk/test/org/apache/catalina/util/TestServerInfo.java
tomcat/trunk/test/org/apache/catalina/valves/Benchmarks.java
tomcat/trunk/test/org/apache/catalina/valves/TestRemoteIpValve.java
tomcat/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java
tomcat/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java
tomcat/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java
tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java
tomcat/trunk/test/org/apache/coyote/http11/TestGzipOutputFilter.java
tomcat/trunk/test/org/apache/coyote/http11/TestInternalInputBuffer.java
tomcat/trunk/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java
tomcat/trunk/test/org/apache/el/TestELEvaluation.java
tomcat/trunk/test/org/apache/el/TestELInJsp.java
tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java
tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java
tomcat/trunk/test/org/apache/el/TesterBeanA.java
tomcat/trunk/test/org/apache/el/TesterBeanB.java
tomcat/trunk/test/org/apache/el/TesterEnum.java
tomcat/trunk/test/org/apache/el/TesterFunctions.java
tomcat/trunk/test/org/apache/el/lang/TestELSupport.java
tomcat/trunk/test/org/apache/el/parser/TestELParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestCompiler.java
tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java
tomcat/trunk/test/org/apache/jasper/compiler/TestJspConfig.java
tomcat/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestParserNoStrictWhitespace.java
tomcat/trunk/test/org/apache/jasper/compiler/TestScriptingVariabler.java
tomcat/trunk/test/org/apache/jasper/compiler/TestValidator.java
tomcat/trunk/test/org/apache/naming/resources/TestDirContextURLStreamHandlerFactory.java
tomcat/trunk/test/org/apache/naming/resources/TestNamingContext.java
tomcat/trunk/test/org/apache/naming/resources/TestProxyDirContext.java
tomcat/trunk/test/org/apache/naming/resources/TestWarDirContext.java
tomcat/trunk/test/org/apache/naming/resources/TesterFactory.java
tomcat/trunk/test/org/apache/naming/resources/TesterObject.java
tomcat/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java
tomcat/trunk/test/org/apache/tomcat/util/http/CookiesBaseTest.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestBug49158.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesAllowEquals.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesAllowHttpSeps.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesAllowNameOnly.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesDefaultSysProps.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesDisallowEquals.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesNoFwdStrictSysProps.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesNoStrictNamingSysProps.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookiesStrictSysProps.java
tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java
tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapperWelcomeFiles.java
tomcat/trunk/test/org/apache/tomcat/util/net/TestClientCert.java
tomcat/trunk/test/org/apache/tomcat/util/net/TestCustomSsl.java
tomcat/trunk/test/org/apache/tomcat/util/net/TestSsl.java
tomcat/trunk/test/org/apache/tomcat/util/net/TestXxxEndpoint.java
tomcat/trunk/test/org/apache/tomcat/util/net/TesterSupport.java
tomcat/trunk/test/org/apache/tomcat/util/net/jsse/TesterBug50640SslImpl.java
tomcat/trunk/test/org/apache/tomcat/util/res/TestStringManager.java
tomcat/trunk/test/org/apache/tomcat/util/threads/DedicatedThreadExecutorTest.java
tomcat/trunk/test/org/apache/tomcat/util/threads/TestLimitLatch.java
tomcat/trunk/test/webapp-2.3/WEB-INF/web.xml
tomcat/trunk/test/webapp-2.4/WEB-INF/web.xml
tomcat/trunk/test/webapp-2.5/WEB-INF/web.xml
tomcat/trunk/test/webapp-3.0-fragments/WEB-INF/web.xml
tomcat/trunk/test/webapp-3.0-servletsecurity/WEB-INF/web.xml
tomcat/trunk/test/webapp-3.0-servletsecurity2/WEB-INF/web.xml
tomcat/trunk/test/webapp-3.0/WEB-INF/bugs.tld
tomcat/trunk/test/webapp-3.0/WEB-INF/test.tld
tomcat/trunk/test/webapp-3.0/WEB-INF/web.xml
tomcat/trunk/test/webapp-3.0/bug47413.jsp
tomcat/trunk/test/webapp-3.0/echo-params.jsp
Modified: tomcat/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java (original)
+++ tomcat/trunk/test/javax/el/TestBeanELResolverVarargsInvocation.java Sat Oct 22 21:23:07 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/trunk/test/javax/el/TestCompositeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestCompositeELResolver.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/javax/el/TestCompositeELResolver.java (original)
+++ tomcat/trunk/test/javax/el/TestCompositeELResolver.java Sat Oct 22 21:23:07 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/trunk/test/javax/servlet/jsp/TestPageContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/servlet/jsp/TestPageContext.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/javax/servlet/jsp/TestPageContext.java (original)
+++ tomcat/trunk/test/javax/servlet/jsp/TestPageContext.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java (original)
+++ tomcat/trunk/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java (original)
+++ tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestConnector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestConnector.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestConnector.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestConnector.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestKeepAliveCount.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestMaxConnections.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestMaxConnections.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestMaxConnections.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestMaxConnections.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestRequest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestRequest.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestRequest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestRequest.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestResponse.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestResponse.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestResponse.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestResponse.java Sat Oct 22 21:23:07 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/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java (original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestResponsePerformance.java Sat Oct 22 21:23:07 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
Modified: tomcat/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestDefaultInstanceManager.java Sat Oct 22 21:23:07 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.
@@ -30,7 +30,7 @@ public class TestDefaultInstanceManager
@Test
public void testClassUnloading() throws Exception {
-
+
DefaultInstanceManager instanceManager = doClassUnloadingPrep();
// Request a JSP page (that doesn't load any tag libraries etc.)
@@ -39,13 +39,13 @@ public class TestDefaultInstanceManager
getUrl("http://localhost:" + getPort() + "/test/annotations.jsp");
// Request a second JSP (again, no tag libraries etc.)
getUrl("http://localhost:" + getPort() + "/test/bug36923.jsp");
-
+
// Check the number of classes in the cache
int count = instanceManager.getAnnotationCacheSize();
// Request a third JSP (again, no tag libraries etc.)
getUrl("http://localhost:" + getPort() + "/test/bug51544.jsp");
-
+
// Force a GC to clear out unloaded class (first JSP)
System.gc();
@@ -66,21 +66,21 @@ public class TestDefaultInstanceManager
private DefaultInstanceManager doClassUnloadingPrep() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
// Create the context (don't use addWebapp as we want to modify the
// JSP Servlet settings).
File appDir = new File("test/webapp-3.0");
StandardContext ctxt = (StandardContext) tomcat.addContext(
null, "/test", appDir.getAbsolutePath());
-
+
// Configure the defaults and then tweak the JSP servlet settings
// Note: Min value for maxLoadedJsps is 2
Tomcat.initWebappDefaults(ctxt);
Wrapper w = (Wrapper) ctxt.findChild("jsp");
w.addInitParameter("maxLoadedJsps", "2");
-
+
tomcat.start();
-
+
return (DefaultInstanceManager) ctxt.getInstanceManager();
}
}
Modified: tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestNamingContextListener.java Sat Oct 22 21:23:07 2011
@@ -36,17 +36,17 @@ public class TestNamingContextListener e
private static final String JNDI_NAME = "TestName";
private static final String JNDI_VALUE= "Test Value";
- /**
+ /**
* Test JNDI is available to ServletContextListeners.
*/
@Test
public void testBug49132() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
- org.apache.catalina.Context ctx =
+ org.apache.catalina.Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
@@ -55,9 +55,9 @@ public class TestNamingContextListener e
environment.setName(JNDI_NAME);
environment.setValue(JNDI_VALUE);
ctx.getNamingResources().addEnvironment(environment);
-
+
ctx.addApplicationListener(Bug49132Listener.class.getName());
-
+
tomcat.start();
assertEquals(LifecycleState.STARTED, ctx.getState());
Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContext.java Sat Oct 22 21:23:07 2011
@@ -71,17 +71,17 @@ public class TestStandardContext extends
@Test
public void testBug46243() throws Exception {
-
+
// Set up a container
Tomcat tomcat = getTomcatInstance();
-
+
File docBase = new File(tomcat.getHost().getAppBaseFile(), "ROOT");
if (!docBase.mkdirs() && !docBase.isDirectory()) {
fail("Unable to create docBase");
}
-
+
Context root = tomcat.addContext("", "ROOT");
-
+
// Add test a filter that fails
FilterDef filterDef = new FilterDef();
filterDef.setFilterClass(Bug46243Filter.class.getName());
@@ -96,9 +96,9 @@ public class TestStandardContext extends
// it works (although it shouldn't)
Tomcat.addServlet(root, "Bug46243", new HelloWorldServlet());
root.addServletMapping("/", "Bug46243");
-
+
tomcat.start();
-
+
// Configure the client
Bug46243Client client = new Bug46243Client();
client.setPort(getPort());
@@ -108,7 +108,7 @@ public class TestStandardContext extends
client.processRequest();
assertTrue(client.isResponse404());
}
-
+
private static final class Bug46243Client extends SimpleHttpClient {
@Override
public boolean isResponseBodyOK() {
@@ -116,9 +116,9 @@ public class TestStandardContext extends
return true;
}
}
-
+
public static final class Bug46243Filter implements Filter {
-
+
@Override
public void destroy() {
// NOOP
@@ -135,18 +135,18 @@ public class TestStandardContext extends
public void init(FilterConfig filterConfig) throws ServletException {
throw new ServletException("Init fail", new ClassNotFoundException());
}
-
+
}
@Test
public void testBug49922() throws Exception {
-
+
// Set up a container
Tomcat tomcat = getTomcatInstance();
-
+
File root = new File("test/webapp-3.0");
tomcat.addWebapp("", root.getAbsolutePath());
-
+
tomcat.start();
ByteChunk result;
@@ -187,9 +187,9 @@ public class TestStandardContext extends
assertEquals("IncludeFilterTarget", result.toString());
}
-
+
public static final class Bug49922Filter implements Filter {
-
+
@Override
public void destroy() {
// NOOP
@@ -208,7 +208,7 @@ public class TestStandardContext extends
// NOOP
}
}
-
+
public static final class Bug49922ForwardServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -218,7 +218,7 @@ public class TestStandardContext extends
throws ServletException, IOException {
req.getRequestDispatcher("/bug49922/target").forward(req, resp);
}
-
+
}
public static final class Bug49922IncludeServlet extends HttpServlet {
@@ -232,7 +232,7 @@ public class TestStandardContext extends
resp.getWriter().print("Include");
req.getRequestDispatcher("/bug49922/target").include(req, resp);
}
-
+
}
public static final class Bug49922TargetServlet extends HttpServlet {
@@ -245,7 +245,7 @@ public class TestStandardContext extends
resp.setContentType("text/plain");
resp.getWriter().print("Target");
}
-
+
}
public static final class Bug49922Servlet extends HttpServlet {
@@ -258,7 +258,7 @@ public class TestStandardContext extends
resp.setContentType("text/plain");
resp.getWriter().print("Servlet");
}
-
+
}
@Test
@@ -285,20 +285,20 @@ public class TestStandardContext extends
// Add ServletContainerInitializer
ServletContainerInitializer sci = new Bug50015SCI();
ctx.addServletContainerInitializer(sci, null);
-
+
// Start the context
tomcat.start();
-
+
// Request the first servlet
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/bug50015",
bc, null);
-
+
// Check for a 401
assertNotSame("OK", bc.toString());
assertEquals(401, rc);
}
-
+
public static final class Bug50015SCI
implements ServletContainerInitializer {
@@ -309,7 +309,7 @@ public class TestStandardContext extends
Servlet s = new Bug50015Servlet();
ServletRegistration.Dynamic sr = ctx.addServlet("bug50015", s);
sr.addMapping("/bug50015");
-
+
// Limit access to users in the Tomcat role
HttpConstraintElement hce = new HttpConstraintElement(
TransportGuarantee.NONE, "tomcat");
@@ -317,7 +317,7 @@ public class TestStandardContext extends
sr.setServletSecurity(sse);
}
}
-
+
public static final class Bug50015Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -328,7 +328,7 @@ public class TestStandardContext extends
resp.setContentType("text/plain");
resp.getWriter().write("OK");
}
-
+
}
@Test
@@ -353,17 +353,17 @@ public class TestStandardContext extends
// Add ServletContainerInitializer
Bug51376SCI sci = new Bug51376SCI(loadOnStartUp);
ctx.addServletContainerInitializer(sci, null);
-
+
// Start the context
tomcat.start();
-
+
// Stop the context
ctx.stop();
-
+
// Make sure that init() and destroy() were called correctly
assertTrue(sci.getServlet().isOk());
}
-
+
public static final class Bug51376SCI
implements ServletContainerInitializer {
@@ -390,14 +390,14 @@ public class TestStandardContext extends
}
}
}
-
+
public static final class Bug51376Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private Boolean initOk = null;
private Boolean destoryOk = null;
-
+
@Override
public void init() {
if (initOk == null && destoryOk == null) {
@@ -422,7 +422,7 @@ public class TestStandardContext extends
resp.setContentType("text/plain");
resp.getWriter().write("OK");
}
-
+
protected boolean isOk() {
if (initOk != null && initOk.booleanValue() && destoryOk != null &&
destoryOk.booleanValue()) {
@@ -495,7 +495,7 @@ public class TestStandardContext extends
resp.setCharacterEncoding("UTF-8");
PrintWriter out = resp.getWriter();
-
+
out.println("parts=" + (null == req.getParts()
? "null"
: Integer.valueOf(req.getParts().size())));
@@ -517,7 +517,7 @@ public class TestStandardContext extends
private synchronized void init() throws Exception {
if (init) return;
-
+
Tomcat tomcat = getTomcatInstance();
context = tomcat.addContext("", TEMP_DIR);
Tomcat.addServlet(context, "regular", new Bug49711Servlet());
@@ -530,10 +530,10 @@ public class TestStandardContext extends
context.addServletMapping("/regular", "regular");
context.addServletMapping("/multipart", "multipart");
tomcat.start();
-
+
init = true;
}
-
+
private Exception doRequest(String uri,
boolean allowCasualMultipart,
boolean makeMultipartRequest) {
@@ -582,7 +582,7 @@ public class TestStandardContext extends
setRequest(request);
processRequest(); // blocks until response has been read
-
+
// Close the connection
disconnect();
} catch (Exception e) {
Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContextAliases.java Sat Oct 22 21:23:07 2011
@@ -43,21 +43,21 @@ public class TestStandardContextAliases
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
- StandardContext ctx = (StandardContext)
+ StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
File lib = new File("webapps/examples/WEB-INF/lib");
ctx.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());
-
+
Tomcat.addServlet(ctx, "test", new TestServlet());
ctx.addServletMapping("/", "test");
-
+
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
String result = res.toString();
-
+
assertTrue(result.indexOf("00-PASS") > -1);
assertTrue(result.indexOf("01-PASS") > -1);
assertTrue(result.indexOf("02-PASS") > -1);
@@ -74,28 +74,28 @@ public class TestStandardContextAliases
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
-
+
resp.setContentType("text/plain");
-
+
ServletContext context = getServletContext();
-
+
// Check resources individually
URL url = context.getResource("/WEB-INF/lib/jstl.jar");
if (url != null) {
resp.getWriter().write("00-PASS\n");
}
-
+
url = context.getResource("/WEB-INF/lib/standard.jar");
if (url != null) {
resp.getWriter().write("01-PASS\n");
}
-
+
// Check a directory listing
Set<String> libs = context.getResourcePaths("/WEB-INF/lib");
if (libs == null) {
return;
}
-
+
if (!libs.contains("/WEB-INF/lib/jstl.jar")) {
return;
}
@@ -105,6 +105,6 @@ public class TestStandardContextAliases
resp.getWriter().write("02-PASS\n");
}
-
+
}
}
Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java Sat Oct 22 21:23:07 2011
@@ -145,7 +145,7 @@ public class TestStandardContextResource
"<p>resourceB.jsp in resources.jar</p>");
ctx.stop();
-
+
LifecycleListener[] listener1 = ctx.findLifecycleListeners();
// change ordering and reload
ContextConfig config1 = new ContextConfig() {
@@ -167,12 +167,12 @@ public class TestStandardContextResource
ctx.addServletMapping("/getresource", "getresource");
ctx.start();
-
+
assertPageContains("/test/getresource?path=/resourceF.jsp",
"<p>resourceF.jsp in resources2.jar</p>");
assertPageContains("/test/getresource?path=/resourceB.jsp",
"<p>resourceB.jsp in resources2.jar</p>");
-
+
}
@Test
@@ -183,7 +183,7 @@ public class TestStandardContextResource
// app dir is relative to server home
StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test",
appDir.getAbsolutePath());
-
+
Tomcat.addServlet(ctx, "getresource", new GetResourceServlet());
ctx.addServletMapping("/getresource", "getresource");
@@ -252,7 +252,7 @@ public class TestStandardContextResource
int sc = getUrl("http://localhost:" + getPort() + pageUrl, res, null);
assertEquals(expectedStatus, sc);
-
+
if (expectedStatus == 200) {
String result = res.toString();
assertTrue(result, result.indexOf(expectedBody) > 0);
Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardContextValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContextValve.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardContextValve.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardContextValve.java Sat Oct 22 21:23:07 2011
@@ -49,7 +49,7 @@ public class TestStandardContextValve ex
// Traces order of events across multiple components
StringBuilder trace = new StringBuilder();
-
+
//Add the error page
Tomcat.addServlet(ctx, "errorPage", new Bug51653ErrorPage(trace));
ctx.addServletMapping("/error", "errorPage");
@@ -96,7 +96,7 @@ public class TestStandardContextValve ex
// Traces order of events across multiple components
StringBuilder trace = new StringBuilder();
-
+
// Add the page that generates the error
Tomcat.addServlet(ctx, "test", new Bug51653ErrorTrigger());
ctx.addServletMapping("/test", "test");
@@ -159,7 +159,7 @@ public class TestStandardContextValve ex
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
sb.append("Error");
-
+
resp.setContentType("text/plain");
resp.getWriter().write("Error");
}
@@ -178,7 +178,7 @@ public class TestStandardContextValve ex
public void requestInitialized(ServletRequestEvent sre) {
sb.append("Init");
}
-
+
@Override
public void requestDestroyed(ServletRequestEvent sre) {
sb.append("Destroy");
Modified: tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestStandardWrapper.java Sat Oct 22 21:23:07 2011
@@ -101,18 +101,18 @@ public class TestStandardWrapper extends
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
File appDir = new File("test/webapp-3.0-fragments");
tomcat.addWebapp(null, "", appDir.getAbsolutePath());
-
+
tomcat.start();
-
+
ByteChunk bc = new ByteChunk();
int rc;
rc = getUrl("http://localhost:" + getPort() +
"/testStandardWrapper/securityAnnotationsWebXmlPriority",
bc, null, null);
-
+
assertNull(bc.toString());
assertEquals(403, rc);
}
@@ -122,18 +122,18 @@ public class TestStandardWrapper extends
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
File appDir = new File("test/webapp-3.0");
tomcat.addWebapp(null, "", appDir.getAbsolutePath());
-
+
tomcat.start();
-
+
ByteChunk bc = new ByteChunk();
int rc;
rc = getUrl("http://localhost:" + getPort() +
"/testStandardWrapper/securityAnnotationsMetaDataPriority",
bc, null, null);
-
+
assertEquals("OK", bc.toString());
assertEquals(200, rc);
}
@@ -152,17 +152,17 @@ public class TestStandardWrapper extends
public void testSecurityAnnotationsNoWebXmlConstraints() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
File appDir = new File("test/webapp-3.0-servletsecurity");
tomcat.addWebapp(null, "", appDir.getAbsolutePath());
-
+
tomcat.start();
-
+
ByteChunk bc = new ByteChunk();
int rc;
rc = getUrl("http://localhost:" + getPort() + "/",
bc, null, null);
-
+
assertNull(bc.toString());
assertEquals(403, rc);
}
@@ -171,23 +171,23 @@ public class TestStandardWrapper extends
public void testSecurityAnnotationsNoWebXmlLoginConfig() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
File appDir = new File("test/webapp-3.0-servletsecurity2");
tomcat.addWebapp(null, "", appDir.getAbsolutePath());
-
+
tomcat.start();
-
+
ByteChunk bc = new ByteChunk();
int rc;
rc = getUrl("http://localhost:" + getPort() + "/protected.jsp",
bc, null, null);
-
+
assertNull(bc.toString());
assertEquals(403, rc);
rc = getUrl("http://localhost:" + getPort() + "/unprotected.jsp",
bc, null, null);
-
+
assertEquals(200, rc);
assertTrue(bc.toString().contains("00-OK"));
}
@@ -197,21 +197,21 @@ public class TestStandardWrapper extends
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
Servlet s = new DenyAllServlet();
ServletContainerInitializer sci = new SCI(s, useCreateServlet);
ctx.addServletContainerInitializer(sci, null);
-
+
tomcat.start();
-
+
ByteChunk bc = new ByteChunk();
int rc;
rc = getUrl("http://localhost:" + getPort() + "/", bc, null, null);
-
+
if (useCreateServlet) {
assertNull(bc.toString());
assertEquals(403, rc);
@@ -226,27 +226,27 @@ public class TestStandardWrapper extends
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
Wrapper wrapper = Tomcat.addServlet(ctx, "servlet", servletClassName);
wrapper.setAsyncSupported(true);
ctx.addServletMapping("/", "servlet");
-
+
if (useRole) {
MapRealm realm = new MapRealm();
realm.addUser("testUser", "testPwd");
realm.addUserRole("testUser", "testRole");
ctx.setRealm(realm);
-
+
ctx.setLoginConfig(new LoginConfig("BASIC", null, null, null));
ctx.getPipeline().addValve(new BasicAuthenticator());
}
tomcat.start();
-
+
ByteChunk bc = new ByteChunk();
Map<String,List<String>> reqHeaders = null;
if (useRole) {
@@ -265,7 +265,7 @@ public class TestStandardWrapper extends
rc = getUrl("http://localhost:" + getPort() + "/", bc, reqHeaders,
null);
}
-
+
if (expect200) {
assertEquals("OK", bc.toString());
assertEquals(200, rc);
@@ -281,27 +281,27 @@ public class TestStandardWrapper extends
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
-
+
resp.setContentType("text/plain");
resp.getWriter().print("OK");
}
-
+
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req, resp);
}
}
-
+
@ServletSecurity(@HttpConstraint(EmptyRoleSemantic.DENY))
public static class DenyAllServlet extends TestServlet {
private static final long serialVersionUID = 1L;
}
-
+
public static class SubclassDenyAllServlet extends DenyAllServlet {
private static final long serialVersionUID = 1L;
}
-
+
@ServletSecurity(@HttpConstraint(EmptyRoleSemantic.PERMIT))
public static class SubclassAllowAllServlet extends DenyAllServlet {
private static final long serialVersionUID = 1L;
@@ -316,7 +316,7 @@ public class TestStandardWrapper extends
public static class MethodConstraintServlet extends TestServlet {
private static final long serialVersionUID = 1L;
}
-
+
@ServletSecurity(@HttpConstraint(rolesAllowed = "testRole"))
public static class RoleAllowServlet extends TestServlet {
private static final long serialVersionUID = 1L;
@@ -331,7 +331,7 @@ public class TestStandardWrapper extends
private Servlet servlet;
private boolean createServlet;
-
+
public SCI(Servlet servlet, boolean createServlet) {
this.servlet = servlet;
this.createServlet = createServlet;
@@ -341,7 +341,7 @@ public class TestStandardWrapper extends
public void onStartup(Set<Class<?>> c, ServletContext ctx)
throws ServletException {
Servlet s;
-
+
if (createServlet) {
s = ctx.createServlet(servlet.getClass());
} else {
@@ -354,7 +354,7 @@ public class TestStandardWrapper extends
public static final int BUG51445_THREAD_COUNT = 5;
-
+
public static CountDownLatch latch = null;
public static AtomicInteger counter = new AtomicInteger(0);
@@ -366,12 +366,12 @@ public class TestStandardWrapper extends
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
- StandardContext ctx = (StandardContext)
+ StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
Tomcat.addServlet(ctx, "Bug51445", new Bug51445Servlet());
ctx.addServletMapping("/", "Bug51445");
-
+
tomcat.start();
// Start the threads
@@ -391,7 +391,7 @@ public class TestStandardWrapper extends
for (int i = 0; i < BUG51445_THREAD_COUNT; i ++) {
System.out.println(threads[i].getResult());
}
-
+
// Check the result
for (int i = 0; i < BUG51445_THREAD_COUNT; i ++) {
String[] results = threads[i].getResult().split(",");
@@ -404,21 +404,21 @@ public class TestStandardWrapper extends
@Test
public void testBug51445AddChild() throws Exception {
-
+
latch = new CountDownLatch(BUG51445_THREAD_COUNT);
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
- StandardContext ctx = (StandardContext)
+ StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
StandardWrapper wrapper = new StandardWrapper();
wrapper.setServletName("Bug51445");
wrapper.setServletClass(Bug51445Servlet.class.getName());
ctx.addChild(wrapper);
ctx.addServletMapping("/", "Bug51445");
-
+
tomcat.start();
// Start the threads
@@ -484,7 +484,7 @@ public class TestStandardWrapper extends
private int data = 0;
private int counter;
-
+
public Bug51445Servlet() {
// Use this rather than hashCode since in some environments,
// multiple instances of this object were created with the same
@@ -497,7 +497,7 @@ public class TestStandardWrapper extends
throws ServletException, IOException {
boolean latchAwaitResult = false;
-
+
// Ensure all threads have their own instance of the servlet
latch.countDown();
try {
Modified: tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestSwallowAbortedUploads.java Sat Oct 22 21:23:07 2011
@@ -291,12 +291,12 @@ public class TestSwallowAbortedUploads e
String content = new String(sb.toString().getBytes("UTF-8"),
"ASCII");
- request = new String[] { "POST http://localhost:" + getPort() + URI + " HTTP/1.1" + CRLF
+ request = new String[] { "POST http://localhost:" + getPort() + URI + " HTTP/1.1" + CRLF
+ "Host: localhost" + CRLF
+ "Connection: close" + CRLF
- + "Content-Type: multipart/form-data; boundary=" + boundary + CRLF
- + "Content-Length: " + content.length() + CRLF
- + CRLF
+ + "Content-Type: multipart/form-data; boundary=" + boundary + CRLF
+ + "Content-Length: " + content.length() + CRLF
+ + CRLF
+ content + CRLF };
setRequest(request);
@@ -321,11 +321,11 @@ public class TestSwallowAbortedUploads e
private static final long serialVersionUID = 1L;
private int status = 200;
-
+
public void setStatus(int status) {
this.status = status;
}
-
+
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Modified: tomcat/trunk/test/org/apache/catalina/deploy/TestSecurityConstraint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/deploy/TestSecurityConstraint.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/deploy/TestSecurityConstraint.java (original)
+++ tomcat/trunk/test/org/apache/catalina/deploy/TestSecurityConstraint.java Sat Oct 22 21:23:07 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.
@@ -42,14 +42,14 @@ public class TestSecurityConstraint {
*/
@Test
public void testCreateConstraints() {
-
+
ServletSecurityElement element;
SecurityConstraint[] result;
Set<HttpMethodConstraintElement> hmces =
new HashSet<HttpMethodConstraintElement>();
-
+
// Example 13-1
- // @ServletSecurity
+ // @ServletSecurity
element = new ServletSecurityElement();
result = SecurityConstraint.createConstraints(element, URL_PATTERN);
@@ -70,9 +70,9 @@ public class TestSecurityConstraint {
assertEquals(0, result[0].findCollections()[0].findMethods().length);
assertEquals(ServletSecurity.TransportGuarantee.CONFIDENTIAL.name(),
result[0].getUserConstraint());
-
+
// Example 13-3
- // @ServletSecurity(@HttpConstraint(EmptyRoleSemantic.DENY))
+ // @ServletSecurity(@HttpConstraint(EmptyRoleSemantic.DENY))
element = new ServletSecurityElement(
new HttpConstraintElement(EmptyRoleSemantic.DENY));
result = SecurityConstraint.createConstraints(element, URL_PATTERN);
@@ -83,9 +83,9 @@ public class TestSecurityConstraint {
assertEquals(0, result[0].findCollections()[0].findMethods().length);
assertEquals(ServletSecurity.TransportGuarantee.NONE.name(),
result[0].getUserConstraint());
-
+
// Example 13-4
- // @ServletSecurity(@HttpConstraint(rolesAllowed = "R1"))
+ // @ServletSecurity(@HttpConstraint(rolesAllowed = "R1"))
element = new ServletSecurityElement(new HttpConstraintElement(
ServletSecurity.TransportGuarantee.NONE, ROLE1));
result = SecurityConstraint.createConstraints(element, URL_PATTERN);
@@ -100,10 +100,10 @@ public class TestSecurityConstraint {
result[0].getUserConstraint());
// Example 13-5
- // @ServletSecurity((httpMethodConstraints = {
- // @HttpMethodConstraint(value = "GET", rolesAllowed = "R1"),
- // @HttpMethodConstraint(value = "POST", rolesAllowed = "R1",
- // transportGuarantee = TransportGuarantee.CONFIDENTIAL)
+ // @ServletSecurity((httpMethodConstraints = {
+ // @HttpMethodConstraint(value = "GET", rolesAllowed = "R1"),
+ // @HttpMethodConstraint(value = "POST", rolesAllowed = "R1",
+ // transportGuarantee = TransportGuarantee.CONFIDENTIAL)
// })
hmces.clear();
hmces.add(new HttpMethodConstraintElement("GET",
@@ -115,7 +115,7 @@ public class TestSecurityConstraint {
ROLE1)));
element = new ServletSecurityElement(hmces);
result = SecurityConstraint.createConstraints(element, URL_PATTERN);
-
+
assertEquals(2, result.length);
for (int i = 0; i < 2; i++) {
assertTrue(result[i].getAuthConstraint());
@@ -134,9 +134,9 @@ public class TestSecurityConstraint {
fail("Unexpected method :[" + method + "]");
}
}
-
+
// Example 13-6
- // @ServletSecurity(value = @HttpConstraint(rolesAllowed = "R1"),
+ // @ServletSecurity(value = @HttpConstraint(rolesAllowed = "R1"),
// httpMethodConstraints = @HttpMethodConstraint("GET"))
hmces.clear();
hmces.add(new HttpMethodConstraintElement("GET"));
@@ -146,7 +146,7 @@ public class TestSecurityConstraint {
ROLE1),
hmces);
result = SecurityConstraint.createConstraints(element, URL_PATTERN);
-
+
assertEquals(2, result.length);
for (int i = 0; i < 2; i++) {
assertTrue(result[i].findCollections()[0].findPattern(URL_PATTERN));
@@ -166,10 +166,10 @@ public class TestSecurityConstraint {
assertEquals(ServletSecurity.TransportGuarantee.NONE.name(),
result[i].getUserConstraint());
}
-
+
// Example 13-7
- // @ServletSecurity(value = @HttpConstraint(rolesAllowed = "R1"),
- // httpMethodConstraints = @HttpMethodConstraint(value="TRACE",
+ // @ServletSecurity(value = @HttpConstraint(rolesAllowed = "R1"),
+ // httpMethodConstraints = @HttpMethodConstraint(value="TRACE",
// emptyRoleSemantic = EmptyRoleSemantic.DENY))
hmces.clear();
hmces.add(new HttpMethodConstraintElement("TRACE",
@@ -180,7 +180,7 @@ public class TestSecurityConstraint {
ROLE1),
hmces);
result = SecurityConstraint.createConstraints(element, URL_PATTERN);
-
+
assertEquals(2, result.length);
for (int i = 0; i < 2; i++) {
assertTrue(result[i].findCollections()[0].findPattern(URL_PATTERN));
@@ -201,7 +201,7 @@ public class TestSecurityConstraint {
assertEquals(ServletSecurity.TransportGuarantee.NONE.name(),
result[i].getUserConstraint());
}
-
+
// Example 13-8 is the same as 13-4
// Example 13-9 is the same as 13-7
}
Modified: tomcat/trunk/test/org/apache/catalina/deploy/TestWebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/deploy/TestWebXml.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/deploy/TestWebXml.java (original)
+++ tomcat/trunk/test/org/apache/catalina/deploy/TestWebXml.java Sat Oct 22 21:23:07 2011
@@ -28,45 +28,45 @@ public class TestWebXml {
@Test
public void testParseVersion() {
-
+
WebXml webxml = new WebXml();
-
+
// Defaults
assertEquals(3, webxml.getMajorVersion());
assertEquals(0, webxml.getMinorVersion());
-
+
// Both get changed
webxml.setVersion("2.5");
assertEquals(2, webxml.getMajorVersion());
assertEquals(5, webxml.getMinorVersion());
-
+
// Reset
webxml.setVersion("0.0");
assertEquals(0, webxml.getMajorVersion());
assertEquals(0, webxml.getMinorVersion());
-
+
// null input should be ignored
webxml.setVersion(null);
assertEquals(0, webxml.getMajorVersion());
assertEquals(0, webxml.getMinorVersion());
-
+
// major only
webxml.setVersion("3");
assertEquals(3, webxml.getMajorVersion());
assertEquals(0, webxml.getMinorVersion());
-
+
// no minor digit
webxml.setVersion("0.0"); // reset
webxml.setVersion("3.");
assertEquals(3, webxml.getMajorVersion());
assertEquals(0, webxml.getMinorVersion());
-
+
// minor only
webxml.setVersion("0.0"); // reset
webxml.setVersion(".5");
assertEquals(0, webxml.getMajorVersion());
assertEquals(5, webxml.getMinorVersion());
-
+
// leading & training zeros
webxml.setVersion("0.0"); // reset
webxml.setVersion("002.500");
@@ -76,9 +76,9 @@ public class TestWebXml {
@Test
public void testParsePublicIdVersion22() {
-
+
WebXml webxml = new WebXml();
-
+
webxml.setPublicId(
org.apache.catalina.startup.Constants.WebDtdPublicId_22);
assertEquals(2, webxml.getMajorVersion());
@@ -88,9 +88,9 @@ public class TestWebXml {
@Test
public void testParsePublicIdVersion23() {
-
+
WebXml webxml = new WebXml();
-
+
webxml.setPublicId(
org.apache.catalina.startup.Constants.WebDtdPublicId_23);
assertEquals(2, webxml.getMajorVersion());
@@ -100,9 +100,9 @@ public class TestWebXml {
@Test
public void testParsePublicIdVersion24() {
-
+
WebXml webxml = new WebXml();
-
+
webxml.setPublicId(
org.apache.catalina.startup.Constants.WebSchemaPublicId_24);
assertEquals(2, webxml.getMajorVersion());
@@ -112,9 +112,9 @@ public class TestWebXml {
@Test
public void testParsePublicIdVersion25() {
-
+
WebXml webxml = new WebXml();
-
+
webxml.setPublicId(
org.apache.catalina.startup.Constants.WebSchemaPublicId_25);
assertEquals(2, webxml.getMajorVersion());
@@ -124,9 +124,9 @@ public class TestWebXml {
@Test
public void testParsePublicIdVersion30() {
-
+
WebXml webxml = new WebXml();
-
+
webxml.setPublicId(
org.apache.catalina.startup.Constants.WebSchemaPublicId_30);
assertEquals(3, webxml.getMajorVersion());
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org