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 [2/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...
Modified: tomcat/trunk/test/org/apache/catalina/deploy/TestWebXmlOrdering.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/deploy/TestWebXmlOrdering.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/deploy/TestWebXmlOrdering.java (original)
+++ tomcat/trunk/test/org/apache/catalina/deploy/TestWebXmlOrdering.java Sat Oct 22 21:23:07 2011
@@ -74,9 +74,9 @@ public class TestWebXmlOrdering {
app.addAbsoluteOrdering("b");
app.addAbsoluteOrdering("e");
app.addAbsoluteOrdering("d");
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
-
+
Iterator<WebXml> iter = ordered.iterator();
assertEquals(c,iter.next());
assertEquals(a,iter.next());
@@ -90,9 +90,9 @@ public class TestWebXmlOrdering {
public void testOrderWebFragmentsAbsolutePartial() {
app.addAbsoluteOrdering("c");
app.addAbsoluteOrdering("a");
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
-
+
Iterator<WebXml> iter = ordered.iterator();
assertEquals(c,iter.next());
assertEquals(a,iter.next());
@@ -104,15 +104,15 @@ public class TestWebXmlOrdering {
app.addAbsoluteOrdering(WebXml.ORDER_OTHERS);
app.addAbsoluteOrdering("b");
app.addAbsoluteOrdering("d");
-
+
Set<WebXml> others = new HashSet<WebXml>();
others.add(a);
others.add(c);
others.add(e);
others.add(f);
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
-
+
Iterator<WebXml> iter = ordered.iterator();
while (others.size() > 0) {
WebXml o = iter.next();
@@ -129,13 +129,13 @@ public class TestWebXmlOrdering {
app.addAbsoluteOrdering("b");
app.addAbsoluteOrdering(WebXml.ORDER_OTHERS);
app.addAbsoluteOrdering("d");
-
+
Set<WebXml> others = new HashSet<WebXml>();
others.add(a);
others.add(c);
others.add(e);
others.add(f);
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
Iterator<WebXml> iter = ordered.iterator();
@@ -164,13 +164,13 @@ public class TestWebXmlOrdering {
app.addAbsoluteOrdering("b");
app.addAbsoluteOrdering("d");
app.addAbsoluteOrdering(WebXml.ORDER_OTHERS);
-
+
Set<WebXml> others = new HashSet<WebXml>();
others.add(a);
others.add(c);
others.add(e);
others.add(f);
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
Iterator<WebXml> iter = ordered.iterator();
@@ -194,9 +194,9 @@ public class TestWebXmlOrdering {
c.addAfterOrderingOthers();
f.addBeforeOrderingOthers();
f.addBeforeOrdering("b");
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
-
+
Iterator<WebXml> iter = ordered.iterator();
assertEquals(f,iter.next());
assertEquals(b,iter.next());
@@ -214,9 +214,9 @@ public class TestWebXmlOrdering {
b.addBeforeOrderingOthers();
d.addAfterOrderingOthers();
e.addBeforeOrderingOthers();
-
+
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
-
+
Iterator<WebXml> iter = ordered.iterator();
// A number of orders are possible but the algorithm is deterministic
// and this order is valid. If this fails after a change to the
@@ -238,7 +238,7 @@ public class TestWebXmlOrdering {
fragments.remove("f");
Set<WebXml> ordered = WebXml.orderWebFragments(app, fragments);
-
+
Iterator<WebXml> iter = ordered.iterator();
// A number of orders are possible but the algorithm is deterministic
// and this order is valid. If this fails after a change to the
@@ -253,15 +253,15 @@ public class TestWebXmlOrdering {
public void testOrderWebFragmentsrelativeCircular() {
a.addBeforeOrdering("b");
b.addBeforeOrdering("a");
-
+
Exception exception = null;
-
+
try {
WebXml.orderWebFragments(app, fragments);
} catch (Exception e1) {
exception = e1;
}
-
+
assertTrue(exception instanceof IllegalArgumentException);
}
}
Modified: tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestAddCharSetFilter.java Sat Oct 22 21:23:07 2011
@@ -85,21 +85,21 @@ public class TestAddCharSetFilter extend
private void doTest(String encoding, String expected) throws Exception {
doTest(encoding, expected, 1);
}
-
+
private void doTest(String encoding, String expected, int mode)
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
CharsetServlet servlet = new CharsetServlet(mode);
Tomcat.addServlet(ctx, "servlet", servlet);
ctx.addServletMapping("/", "servlet");
-
+
// Add the Filter
FilterDef filterDef = new FilterDef();
filterDef.setFilterClass(AddDefaultCharsetFilter.class.getName());
@@ -112,12 +112,12 @@ public class TestAddCharSetFilter extend
filterMap.setFilterName("filter");
filterMap.addServletName("servlet");
ctx.addFilterMap(filterMap);
-
+
tomcat.start();
Map<String, List<String>> headers = new HashMap<String, List<String>>();
getUrl("http://localhost:" + getPort() + "/", new ByteChunk(), headers);
-
+
List<String> ctHeaders = headers.get("Content-Type");
assertEquals(1, ctHeaders.size());
String ct = ctHeaders.get(0);
@@ -127,9 +127,9 @@ public class TestAddCharSetFilter extend
private static class CharsetServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String OUTPUT = "OK";
-
+
private final int mode;
-
+
public CharsetServlet(int mode) {
this.mode = mode;
}
@@ -137,13 +137,13 @@ public class TestAddCharSetFilter extend
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
-
+
switch (mode) {
case 1:
resp.setContentType("text/plain");
break;
case 2:
- resp.setContentType("text/plain;charset=ISO-8859-2");
+ resp.setContentType("text/plain;charset=ISO-8859-2");
break;
case 3:
resp.setContentType("text/plain");
Modified: tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter.java Sat Oct 22 21:23:07 2011
@@ -75,17 +75,17 @@ public class TestCsrfPreventionFilter ex
cache.add("key4");
cache.add("key5");
cache.add("key6");
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(cache);
-
+
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
@SuppressWarnings("unchecked")
LruCache<String> cache2 = (LruCache<String>) ois.readObject();
-
+
cache2.add("key7");
assertFalse(cache2.contains("key1"));
assertFalse(cache2.contains("key2"));
Modified: tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter2.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter2.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter2.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TestCsrfPreventionFilter2.java Sat Oct 22 21:23:07 2011
@@ -33,16 +33,16 @@ public class TestCsrfPreventionFilter2 {
public void testLruCacheConcurrency() throws Exception {
int threadCount = 2;
long iterationCount = 100000L;
-
+
assertTrue(threadCount > 1);
LruCache<String> cache = new LruCache<String>(threadCount - 1);
-
+
LruTestThread[] threads = new LruTestThread[threadCount];
for (int i = 0; i < threadCount; i++) {
threads[i] = new LruTestThread(cache, iterationCount);
}
-
+
for (int i = 0; i < threadCount; i++) {
threads[i].start();
}
Modified: tomcat/trunk/test/org/apache/catalina/filters/TesterResponse.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/filters/TesterResponse.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/filters/TesterResponse.java (original)
+++ tomcat/trunk/test/org/apache/catalina/filters/TesterResponse.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.
@@ -82,7 +82,7 @@ public class TesterResponse
public void setError() {/* NOOP */}
public boolean isError() { return false; }
/**
- *
+ *
* @return
* @throws IOException
*/
@@ -90,7 +90,7 @@ public class TesterResponse
return null;
}
/**
- *
+ *
* @throws IOException
*/
public void finishResponse() throws IOException {/* NOOP */}
@@ -100,7 +100,7 @@ public class TesterResponse
public PrintWriter getReporter() { return null; }
public void recycle() {/* NOOP */}
/**
- *
+ *
* @param b
* @throws IOException
*/
@@ -108,7 +108,7 @@ public class TesterResponse
// NOOP
}
/**
- *
+ *
* @param b
* @throws IOException
*/
@@ -116,7 +116,7 @@ public class TesterResponse
// NOOP
}
/**
- *
+ *
* @param b
* @param off
* @param len
@@ -189,7 +189,7 @@ public class TesterResponse
@Deprecated
public String encodeUrl(String url) { return null; }
/**
- *
+ *
* @throws IOException
*/
public void sendAcknowledgement() throws IOException {/* NOOP */}
Modified: tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java (original)
+++ tomcat/trunk/test/org/apache/catalina/ha/session/TestSerializablePrincipal.java Sat Oct 22 21:23:07 2011
@@ -53,7 +53,7 @@ public class TestSerializablePrincipal
e.printStackTrace();
fail("ioe creating temporary file");
}
-
+
// Create the Principal to serialize
List<String> roles = new ArrayList<String>();
roles.add("RoleA");
@@ -61,7 +61,7 @@ public class TestSerializablePrincipal
TesterPrincipal tpOriginal = new TesterPrincipal("inner");
GenericPrincipal gpOriginal =
new GenericPrincipal("usr", "pwd", roles, tpOriginal);
-
+
// Do the serialization
try {
FileOutputStream fos = new FileOutputStream(file);
@@ -76,7 +76,7 @@ public class TestSerializablePrincipal
e.printStackTrace();
fail("ioe serializing principal");
}
-
+
// De-serialize the Principal
GenericPrincipal gpNew = null;
try {
@@ -93,7 +93,7 @@ public class TestSerializablePrincipal
e.printStackTrace();
fail("cnfe de-serializing principal");
}
-
+
// Now test how similar original and de-serialized versions are
assertEquals("User names different", gpOriginal.getName(),
gpNew.getName());
Modified: tomcat/trunk/test/org/apache/catalina/ha/session/TesterPrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/ha/session/TesterPrincipal.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/ha/session/TesterPrincipal.java (original)
+++ tomcat/trunk/test/org/apache/catalina/ha/session/TesterPrincipal.java Sat Oct 22 21:23:07 2011
@@ -21,7 +21,7 @@ import java.io.Serializable;
import java.security.Principal;
public class TesterPrincipal implements Principal, Serializable {
-
+
private static final long serialVersionUID = 1L;
private String name;
@@ -29,10 +29,10 @@ public class TesterPrincipal implements
public TesterPrincipal(String theName) {
name = theName;
}
-
+
@Override
public String getName() {
return name;
}
-
+
}
\ No newline at end of file
Modified: tomcat/trunk/test/org/apache/catalina/loader/TestVirtualWebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/loader/TestVirtualWebappLoader.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/loader/TestVirtualWebappLoader.java (original)
+++ tomcat/trunk/test/org/apache/catalina/loader/TestVirtualWebappLoader.java Sat Oct 22 21:23:07 2011
@@ -41,13 +41,13 @@ public class TestVirtualWebappLoader ext
@Test
public void testStartInternal() throws Exception {
Tomcat tomcat = getTomcatInstance();
- File appDir = new File("test/webapp-3.0");
+ File appDir = new File("test/webapp-3.0");
// Must have a real docBase - just use temp
- StandardContext ctx =
+ StandardContext ctx =
(StandardContext)tomcat.addContext("", appDir.getAbsolutePath());
VirtualWebappLoader loader = new VirtualWebappLoader();
-
+
loader.setContainer(ctx);
ctx.setLoader(loader);
ctx.setResources(new FileDirContext());
@@ -61,12 +61,12 @@ public class TestVirtualWebappLoader ext
// ToDo: Why doesn't remove repositories?
repos = loader.getRepositories();
assertEquals(2, repos.length);
-
+
// no leak
loader.start();
repos = loader.getRepositories();
assertEquals(2,repos.length);
-
+
// clear loader
ctx.setLoader(null);
// see tearDown()!
Modified: tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderMemoryLeak.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderMemoryLeak.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderMemoryLeak.java (original)
+++ tomcat/trunk/test/org/apache/catalina/loader/TestWebappClassLoaderMemoryLeak.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,26 +39,26 @@ public class TestWebappClassLoaderMemory
@Test
public void testTimerThreadLeak() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
// Must have a real docBase - just use temp
- Context ctx =
+ Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
if (ctx instanceof StandardContext) {
((StandardContext) ctx).setClearReferencesStopTimerThreads(true);
}
-
+
Tomcat.addServlet(ctx, "taskServlet", new TaskServlet());
ctx.addServletMapping("/", "taskServlet");
-
+
tomcat.start();
// This will trigger the timer & thread creation
getUrl("http://localhost:" + getPort() + "/");
-
+
// Stop the context
ctx.stop();
-
+
// If the thread still exists, we have a thread/memory leak
try {
Thread.sleep(10);
@@ -73,19 +73,19 @@ public class TestWebappClassLoaderMemory
}
}
}
-
+
/*
* Get the set of current threads as an array.
* Copied from WebappClassLoader
*/
private Thread[] getThreads() {
- // Get the current thread group
+ // Get the current thread group
ThreadGroup tg = Thread.currentThread( ).getThreadGroup( );
// Find the root thread group
while (tg.getParent() != null) {
tg = tg.getParent();
}
-
+
int threadCountGuess = tg.activeCount() + 50;
Thread[] threads = new Thread[threadCountGuess];
int threadCountActual = tg.enumerate(threads);
@@ -94,10 +94,10 @@ public class TestWebappClassLoaderMemory
threadCountGuess *=2;
threads = new Thread[threadCountGuess];
// Note tg.enumerate(Thread[]) silently ignores any threads that
- // can't fit into the array
+ // can't fit into the array
threadCountActual = tg.enumerate(threads);
}
-
+
return threads;
}
@@ -112,7 +112,7 @@ public class TestWebappClassLoaderMemory
Timer timer = new Timer(TIMER_THREAD_NAME);
timer.schedule(new LocalTask(), 0, 10000);
}
-
+
}
private static final class LocalTask extends TimerTask {
@@ -121,6 +121,6 @@ public class TestWebappClassLoaderMemory
public void run() {
// Doesn't actually need to do anything.
}
-
+
}
}
Modified: tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java (original)
+++ tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.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.
@@ -122,7 +122,7 @@ public class TestRegistration extends To
}
tomcat.addContext(contextName, contextDir.getAbsolutePath());
tomcat.start();
-
+
// Verify there are no Catalina MBeans
onames = mbeanServer.queryNames(new ObjectName("Catalina:*"), null);
assertEquals("Found: " + onames, 0, onames.size());
@@ -177,7 +177,7 @@ public class TestRegistration extends To
fail("Failed to create: [" + contextDir2.toString() + "]");
}
tomcat.addContext(host, contextName + "2", contextDir2.getAbsolutePath());
-
+
tomcat.start();
tomcat.stop();
tomcat.destroy();
@@ -188,5 +188,5 @@ public class TestRegistration extends To
onames = mbeanServer.queryNames(new ObjectName("Tomcat:*"), null);
assertEquals("Remaining: " + onames, 0, onames.size());
}
-
+
}
Modified: tomcat/trunk/test/org/apache/catalina/servlets/TestDefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/servlets/TestDefaultServlet.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/servlets/TestDefaultServlet.java (original)
+++ tomcat/trunk/test/org/apache/catalina/servlets/TestDefaultServlet.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.
@@ -48,42 +48,42 @@ public class TestDefaultServlet extends
/**
* Test attempting to access special paths (WEB-INF/META-INF) using
- * DefaultServlet.
+ * DefaultServlet.
*/
@Test
public void testGetSpecials() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
String contextPath = "/examples";
-
+
File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
// app dir is relative to server home
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
tomcat.start();
-
+
final ByteChunk res = new ByteChunk();
-
+
int rc =getUrl("http://localhost:" + getPort() + contextPath +
"/WEB-INF/web.xml", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/WEB-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/WEB-INF/", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/META-INF/MANIFEST.MF", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/META-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
}
/**
@@ -93,67 +93,67 @@ public class TestDefaultServlet extends
@Test
public void testGetWithSubpathmount() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
String contextPath = "/examples";
-
+
File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
// app dir is relative to server home
org.apache.catalina.Context ctx =
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
// Override the default servlet with our own mappings
Tomcat.addServlet(ctx, "default2", new DefaultServlet());
ctx.addServletMapping("/", "default2");
ctx.addServletMapping("/servlets/*", "default2");
ctx.addServletMapping("/static/*", "default2");
-
+
tomcat.start();
-
+
final ByteChunk res = new ByteChunk();
-
+
// Make sure DefaultServlet isn't exposing special directories
// by remounting the webapp under a sub-path
-
+
int rc =getUrl("http://localhost:" + getPort() + contextPath +
"/static/WEB-INF/web.xml", res, null);
-
+
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/static/WEB-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/static/WEB-INF/", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/static/META-INF/MANIFEST.MF", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/static/META-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
- // Make sure DefaultServlet is serving resources relative to the
+
+ // Make sure DefaultServlet is serving resources relative to the
// context root regardless of where the it is mapped
-
+
final ByteChunk rootResource = new ByteChunk();
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/index.html", rootResource, null);
assertEquals(HttpServletResponse.SC_OK, rc);
-
+
final ByteChunk subpathResource = new ByteChunk();
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/servlets/index.html", subpathResource, null);
assertEquals(HttpServletResponse.SC_OK, rc);
-
+
assertFalse(rootResource.toString().equals(subpathResource.toString()));
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/static/index.html", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
}
/**
Modified: tomcat/trunk/test/org/apache/catalina/servlets/TestWebdavServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/servlets/TestWebdavServlet.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/servlets/TestWebdavServlet.java (original)
+++ tomcat/trunk/test/org/apache/catalina/servlets/TestWebdavServlet.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.
@@ -34,46 +34,46 @@ import org.apache.tomcat.util.buf.ByteCh
public class TestWebdavServlet extends TomcatBaseTest {
/**
- * Test attempting to access special paths (WEB-INF/META-INF) using WebdavServlet
+ * Test attempting to access special paths (WEB-INF/META-INF) using WebdavServlet
*/
@Test
public void testGetSpecials() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
String contextPath = "/examples";
-
+
File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
// app dir is relative to server home
org.apache.catalina.Context ctx =
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
Tomcat.addServlet(ctx, "webdav", new WebdavServlet());
ctx.addServletMapping("/*", "webdav");
-
+
tomcat.start();
-
+
final ByteChunk res = new ByteChunk();
-
+
int rc =getUrl("http://localhost:" + getPort() + contextPath +
"/WEB-INF/web.xml", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/WEB-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/WEB-INF/", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/META-INF/MANIFEST.MF", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/META-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
}
/**
@@ -83,63 +83,63 @@ public class TestWebdavServlet extends T
@Test
public void testGetWithSubpathmount() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
String contextPath = "/examples";
-
+
File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
// app dir is relative to server home
org.apache.catalina.Context ctx =
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
Tomcat.addServlet(ctx, "webdav", new WebdavServlet());
ctx.addServletMapping("/webdav/*", "webdav");
-
+
tomcat.start();
-
+
final ByteChunk res = new ByteChunk();
-
+
// Make sure WebdavServlet isn't exposing special directories
// by remounting the webapp under a sub-path
-
+
int rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/WEB-INF/web.xml", res, null);
-
+
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/WEB-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/WEB-INF/", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/META-INF/MANIFEST.MF", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/META-INF/doesntexistanywhere", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
- // Make sure WebdavServlet is serving resources
+
+ // Make sure WebdavServlet is serving resources
// relative to the map/mount point
final ByteChunk rootResource = new ByteChunk();
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/index.html", rootResource, null);
assertEquals(HttpServletResponse.SC_OK, rc);
-
+
final ByteChunk subpathResource = new ByteChunk();
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/index.html", subpathResource, null);
assertEquals(HttpServletResponse.SC_OK, rc);
-
+
assertEquals(rootResource.toString(), subpathResource.toString());
-
+
rc =getUrl("http://localhost:" + getPort() + contextPath +
"/webdav/static/index.html", res, null);
assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
-
+
}
public static int getUrl(String path, ByteChunk out,
Modified: tomcat/trunk/test/org/apache/catalina/session/Benchmarks.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/session/Benchmarks.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/session/Benchmarks.java (original)
+++ tomcat/trunk/test/org/apache/catalina/session/Benchmarks.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,7 +42,7 @@ public class Benchmarks {
* 2 threads - ~2,100ms
* 4 threads - ~3,100ms
* 16 threads - ~14,700ms
- *
+ *
* Results on markt's 2-core OSX dev box
* 1 thread - ~1,400ms
* 2 threads - ~1,700ms
@@ -65,8 +65,8 @@ public class Benchmarks {
doTestManagerBaseGenerateSessionId(100, 100000);
doTestManagerBaseGenerateSessionId(400, 10000);
}
-
-
+
+
private void doTestManagerBaseGenerateSessionId(int threadCount,
int iterCount) throws Exception {
@@ -87,16 +87,16 @@ public class Benchmarks {
mgr.sessionExpirationTiming.add(null);
}
-
+
Thread[] threads = new Thread[threadCount];
-
+
for (int i = 0; i < threadCount; i++) {
threads[i] = new Thread(
new TestThreadGenerateSessionId(mgr, iterCount));
}
-
+
long start = System.currentTimeMillis();
-
+
for (int i = 0; i < threadCount; i++) {
threads[i].start();
}
@@ -109,7 +109,7 @@ public class Benchmarks {
}
}
long end = System.currentTimeMillis();
-
+
StringBuilder result = new StringBuilder();
result.append("Threads: ");
result.append(threadCount);
@@ -117,13 +117,13 @@ public class Benchmarks {
result.append(end-start);
System.out.println(result.toString());
}
-
-
+
+
private static final class TestThreadGenerateSessionId implements Runnable {
private ManagerBase mgr;
private int count;
-
+
public TestThreadGenerateSessionId(ManagerBase mgr, int count) {
this.mgr = mgr;
this.count = count;
@@ -137,14 +137,14 @@ public class Benchmarks {
}
}
-
+
/*
* Results on markt's 4-core Windows dev box
* 1 thread - ~3,800ms
* 2 threads - ~6,700ms
* 4 threads - ~11,000ms
* 16 threads - ~43,500ms
- *
+ *
* Results on markt's 2-core OSX dev box
* 1 thread - ~4,100ms
* 2 threads - ~5,700ms
@@ -161,8 +161,8 @@ public class Benchmarks {
doTestManagerBaseCreateSession(100, 100000);
doTestManagerBaseCreateSession(400, 10000);
}
-
-
+
+
private void doTestManagerBaseCreateSession(int threadCount,
int iterCount) {
@@ -185,14 +185,14 @@ public class Benchmarks {
}
Thread[] threads = new Thread[threadCount];
-
+
for (int i = 0; i < threadCount; i++) {
threads[i] = new Thread(
new TestThreadCreateSession(mgr, iterCount));
}
-
+
long start = System.currentTimeMillis();
-
+
for (int i = 0; i < threadCount; i++) {
threads[i].start();
}
@@ -205,7 +205,7 @@ public class Benchmarks {
}
}
long end = System.currentTimeMillis();
-
+
StringBuilder result = new StringBuilder();
result.append("Threads: ");
result.append(threadCount);
@@ -213,12 +213,12 @@ public class Benchmarks {
result.append(end-start);
System.out.println(result.toString());
}
-
+
private static final class TestThreadCreateSession implements Runnable {
private ManagerBase mgr;
private int count;
-
+
public TestThreadCreateSession(ManagerBase mgr, int count) {
this.mgr = mgr;
this.count = count;
@@ -232,18 +232,18 @@ public class Benchmarks {
}
}
}
-
-
+
+
/*
* SecureRandom vs. reading /dev/urandom. Very different performance noted
* on some platforms.
- *
+ *
* Results on markt's 4-core Windows dev box
* SecureRandom /dev/urandom
* 1 thread - ~766ms N/A
* 2 threads - ~843ms N/A
* 4 threads - ~766ms N/A
- *
+ *
* Results on markt's 2-core OSX dev box
* SecureRandom /dev/urandom
* 1 thread - ~759ms ~3,500ms
@@ -267,7 +267,7 @@ public class Benchmarks {
int iterCount, boolean useSecureRandom) throws Exception {
Thread[] threads = new Thread[threadCount];
-
+
for (int i = 0; i < threadCount; i++) {
if (useSecureRandom) {
threads[i] = new Thread(new TestThreadSecureRandom(iterCount));
@@ -275,9 +275,9 @@ public class Benchmarks {
threads[i] = new Thread(new TestThreadDevUrandom(iterCount));
}
}
-
+
long start = System.currentTimeMillis();
-
+
for (int i = 0; i < threadCount; i++) {
threads[i].start();
}
@@ -290,7 +290,7 @@ public class Benchmarks {
}
}
long end = System.currentTimeMillis();
-
+
StringBuilder result = new StringBuilder();
if (useSecureRandom) {
result.append("SecureRandom ");
@@ -305,11 +305,11 @@ public class Benchmarks {
}
private static final class TestThreadSecureRandom implements Runnable {
-
+
private SecureRandom secureRandom;
private byte[] bytes = new byte[16];
private int count;
-
+
TestThreadSecureRandom(int iterCount) throws Exception {
this.count = iterCount;
this.secureRandom = SecureRandom.getInstance("SHA1PRNG");
@@ -321,15 +321,15 @@ public class Benchmarks {
secureRandom.nextBytes(bytes);
}
}
-
+
}
-
+
private static final class TestThreadDevUrandom implements Runnable {
-
+
private InputStream is;
private byte[] bytes = new byte[16];
private int count;
-
+
TestThreadDevUrandom(int iterCount) {
try {
is = new FileInputStream("/dev/urandom");
Modified: tomcat/trunk/test/org/apache/catalina/session/Threading.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/session/Threading.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/session/Threading.java (original)
+++ tomcat/trunk/test/org/apache/catalina/session/Threading.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.
@@ -29,7 +29,7 @@ import org.junit.Test;
* a number of classes. In some cases the Javadoc is unclear on the
* thread-safety of a class. These tests were written to test the thread-safety
* of key classes.
- *
+ *
* Named Threading so it is not automatically executed as part of the unit
* tests.
*/
@@ -38,12 +38,12 @@ public class Threading {
/**
* {@link FileInputStream#read(byte[])} and related methods are all native
* methods so it isn't immediately obvious if they are thread-safe or not.
- *
+ *
* <pre>
* Windows JDK 1.6.0_22_x64 - Thread safe
* OSX JDK 1.6.0_22_x64 - Not thread safe
* </pre>
- *
+ *
* Therefore, have to assume that {@link FileInputStream#read(byte[])} is
* not thread safe.
*/
@@ -56,24 +56,24 @@ public class Threading {
}
public void doTestFileInputStream(int threadCount) throws Exception {
-
+
// Assumes "ant release" has been run
// Will need to be updated as new releases are made
File file = new File(
"./output/release/v7.0.20-dev/bin/apache-tomcat-7.0.20-dev.zip");
-
+
FileInputStream fis = new FileInputStream(file);
-
+
Thread[] threads = new Thread[threadCount];
FisReaderThread[] runnables = new FisReaderThread[threadCount];
-
+
for (int i = 0; i < threadCount; i++) {
runnables[i] = new FisReaderThread(fis);
threads[i] = new Thread(runnables[i]);
}
-
+
long start = System.currentTimeMillis();
-
+
for (int i = 0; i < threadCount; i++) {
threads[i].start();
}
@@ -89,7 +89,7 @@ public class Threading {
}
}
long end = System.currentTimeMillis();
-
+
long byteCount = 0;
for (int i = 0; i < threadCount; i++) {
byteCount += runnables[i].getByteCount();
@@ -135,11 +135,11 @@ public class Threading {
}
}
}
-
+
public long getByteCount() {
return byteCount;
}
-
+
public boolean isfailed() {
return fail;
}
Modified: tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.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.
@@ -28,16 +28,16 @@ import javax.servlet.annotation.WebFilte
/**
* Test Mock with wrong Annotation!
- *
+ *
* @author Peter Rossbach
* @version $Id$
- *
+ *
*/
-@WebFilter(value = "/param", filterName="paramDFilter",
+@WebFilter(value = "/param", filterName="paramDFilter",
urlPatterns = { "/param1" , "/param2" })
public class DuplicateMappingParamFilter implements Filter {
-
+
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// NO-OP
Modified: tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.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.
@@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletRes
/**
* Test Mock with wrong Annotation!
- *
+ *
* @author Peter Rossbach
* @version $Revision$
*/
Modified: tomcat/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.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/org/apache/catalina/startup/NoMappingParamServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.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.
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
/**
- *
+ *
* @author Peter Rossbach
* @version $Id$
*/
Modified: tomcat/trunk/test/org/apache/catalina/startup/ParamFilter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/ParamFilter.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/ParamFilter.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/ParamFilter.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/org/apache/catalina/startup/ParamServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/ParamServlet.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/ParamServlet.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/ParamServlet.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.
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
/**
- *
+ *
* @author Peter Rossbach
* @version $Id$
*/
Modified: tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java Sat Oct 22 21:23:07 2011
@@ -40,7 +40,7 @@ import java.util.List;
public abstract class SimpleHttpClient {
public static final String TEMP_DIR =
System.getProperty("java.io.tmpdir");
-
+
public static final String CRLF = "\r\n";
public static final String INFO_100 = "HTTP/1.1 100";
@@ -51,19 +51,19 @@ public abstract class SimpleHttpClient {
public static final String FAIL_50X = "HTTP/1.1 50";
public static final String FAIL_500 = "HTTP/1.1 500";
public static final String FAIL_501 = "HTTP/1.1 501";
-
+
private static final String SESSION_COOKIE_HEADER_PREFIX =
"Set-Cookie: JSESSIONID=";
-
+
private Socket socket;
private Writer writer;
private BufferedReader reader;
private int port = 8080;
-
+
private String[] request;
private boolean useContinue = false;
private int requestPause = 1000;
-
+
private String responseLine;
private List<String> responseHeaders = new ArrayList<String>();
private String responseBody;
@@ -76,7 +76,7 @@ public abstract class SimpleHttpClient {
public void setRequest(String[] theRequest) {
request = theRequest;
}
-
+
public void setUseContinue(boolean theUseContinueFlag) {
useContinue = theUseContinueFlag;
}
@@ -131,7 +131,7 @@ public abstract class SimpleHttpClient {
public void connect() throws UnknownHostException, IOException {
connect(0,0);
}
-
+
public void processRequest() throws IOException, InterruptedException {
processRequest(true);
}
@@ -169,7 +169,7 @@ public abstract class SimpleHttpClient {
// Is a 100 continue response expected?
if (useContinue) {
if (isResponse100()) {
- // Skip the blank after the 100 Continue response
+ // Skip the blank after the 100 Continue response
readLine();
// Now get the final response
responseLine = readLine();
@@ -177,7 +177,7 @@ public abstract class SimpleHttpClient {
throw new IOException("No 100 Continue response");
}
}
-
+
// Put the headers into the map
String line = readLine();
int cl = -1;
@@ -188,7 +188,7 @@ public abstract class SimpleHttpClient {
cl = Integer.parseInt(line.substring(16));
}
}
-
+
// Read the body, if any
StringBuilder builder = new StringBuilder();
if (readBody) {
@@ -210,32 +210,32 @@ public abstract class SimpleHttpClient {
public String readLine() throws IOException {
return reader.readLine();
}
-
+
public void disconnect() throws IOException {
writer.close();
reader.close();
socket.close();
}
-
+
public void reset() {
socket = null;
writer = null;
reader = null;
-
+
request = null;
requestPause = 1000;
-
+
useContinue = false;
responseLine = null;
responseHeaders = new ArrayList<String>();
responseBody = null;
}
-
+
public boolean isResponse100() {
return getResponseLine().startsWith(INFO_100);
}
-
+
public boolean isResponse200() {
return getResponseLine().startsWith(OK_200);
}
@@ -255,15 +255,15 @@ public abstract class SimpleHttpClient {
public boolean isResponse50x() {
return getResponseLine().startsWith(FAIL_50X);
}
-
+
public boolean isResponse500() {
return getResponseLine().startsWith(FAIL_500);
}
-
+
public boolean isResponse501() {
return getResponseLine().startsWith(FAIL_501);
}
-
+
public Socket getSocket() {
return socket;
}
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestContextConfig.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestContextConfig.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestContextConfig.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.
@@ -59,19 +59,19 @@ public class TestContextConfig extends T
"/test", appDir.getAbsolutePath());
ctxt.setDefaultWebXml(new File("conf/web.xml").getAbsolutePath());
ctxt.addLifecycleListener(new ContextConfig());
-
+
ctxt.addServletContainerInitializer(
new CustomDefaultServletSCI(servletName), null);
tomcat.start();
ByteChunk res = new ByteChunk();
-
+
int rc =getUrl("http://localhost:" + getPort() + "/test", res, null);
// Check return code
assertEquals(HttpServletResponse.SC_OK, rc);
-
+
// Check context
assertEquals("OK - Custom default Servlet", res.toString());
}
@@ -83,13 +83,13 @@ public class TestContextConfig extends T
File appDir = new File("test/webapp-3.0-fragments");
// app dir is relative to server home
tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
-
+
tomcat.start();
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() +
"/test/bug51396.jsp", bc, null);
-
+
assertEquals(HttpServletResponse.SC_OK, rc);
assertTrue(bc.toString().contains("<p>OK</p>"));
}
@@ -98,7 +98,7 @@ public class TestContextConfig extends T
implements ServletContainerInitializer {
private String servletName;
-
+
public CustomDefaultServletSCI(String servletName) {
this.servletName = servletName;
}
@@ -110,7 +110,7 @@ public class TestContextConfig extends T
ServletRegistration.Dynamic r = ctx.addServlet(servletName, s);
r.addMapping("/");
}
-
+
}
private static class CustomDefaultServlet extends HttpServlet {
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.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.
@@ -47,7 +47,7 @@ import org.apache.catalina.deploy.WebXml
/**
* Check Servlet 3.0 Spec 8.2.3.3: Override annotation parameter from web.xml or
* fragment.
- *
+ *
* @author Peter Rossbach
* @version $Revision$
*/
@@ -191,7 +191,7 @@ public class TestContextConfigAnnotation
assertNotNull(fdef);
assertEquals("Servlet says: ",fdef.getParameterMap().get("message"));
}
-
+
@Test
public void testOverwriteFilterMapping() throws Exception {
WebXml webxml = new WebXml();
@@ -204,14 +204,14 @@ public class TestContextConfigAnnotation
filterDef.setLargeIcon("LargeIcon");
filterDef.setSmallIcon("SmallIcon");
filterDef.setAsyncSupported("true");
-
+
webxml.addFilter(filterDef);
FilterMap filterMap = new FilterMap();
filterMap.addURLPattern("/param1");
filterMap.setFilterName("paramFilter");
webxml.addFilterMapping(filterMap);
-
+
ContextConfig config = new ContextConfig();
File sFile = paramClassResource(
"org/apache/catalina/startup/ParamServlet");
@@ -239,12 +239,12 @@ public class TestContextConfigAnnotation
assertEquals("SmallIcon", fdef.getSmallIcon());
// FIXME: Strange why servletDef is Boolean and FilterDef is String?
assertEquals("true", fdef.getAsyncSupported());
-
+
String[] dis = filterMap.getDispatcherNames();
assertEquals(2, dis.length);
assertEquals(DispatcherType.ERROR.toString(),dis[0]);
assertEquals(DispatcherType.ASYNC.toString(),dis[1]);
-
+
}
@Test
@@ -267,7 +267,7 @@ public class TestContextConfigAnnotation
@Test
public void testCheckHandleTypes() throws Exception {
ContextConfig config = new ContextConfig();
-
+
// Need a Context, Loader and ClassLoader for checkHandleTypes
StandardContext context = new StandardContext();
context.setLoader(new TesterLoader());
@@ -276,14 +276,14 @@ public class TestContextConfigAnnotation
// Add an SCI that has no interest in any type
SCI sciNone = new SCI();
config.initializerClassMap.put(sciNone, new HashSet<Class<?>>());
-
+
// Add an SCI with an interest in Servlets
SCI sciServlet = new SCI();
config.initializerClassMap.put(sciServlet, new HashSet<Class<?>>());
config.typeInitializerMap.put(Servlet.class,
new HashSet<ServletContainerInitializer>());
config.typeInitializerMap.get(Servlet.class).add(sciServlet);
-
+
// Add an SCI with an interest in Objects - i.e. everything
SCI sciObject = new SCI();
config.initializerClassMap.put(sciObject, new HashSet<Class<?>>());
@@ -302,7 +302,7 @@ public class TestContextConfigAnnotation
config.processAnnotationsFile(file, ignore);
file = paramClassResource("org/apache/catalina/startup/TestListener");
config.processAnnotationsFile(file, ignore);
-
+
// Check right number of classes were noted to be handled
assertEquals(0, config.initializerClassMap.get(sciNone).size());
assertEquals(2, config.initializerClassMap.get(sciServlet).size());
@@ -316,7 +316,7 @@ public class TestContextConfigAnnotation
// NO-OP. Just need a class that implements SCI.
}
}
-
+
private static final class TesterLoader implements Loader {
@Override
@@ -352,7 +352,7 @@ public class TestContextConfigAnnotation
/**
* Find compiled test class
- *
+ *
* @param className
* @return File Resource
*/
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestListener.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestListener.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestListener.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.
@@ -94,7 +94,7 @@ public class TestListener extends Tomcat
// NOOP
}
}
-
+
public static class SCL2 implements ServletContextListener {
@Override
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.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.
@@ -59,7 +59,7 @@ public class TestTomcat extends TomcatBa
private static final long serialVersionUID = 1L;
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse res)
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
res.getWriter().write("Hello world");
}
@@ -73,7 +73,7 @@ public class TestTomcat extends TomcatBa
private static final long serialVersionUID = 1L;
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse res)
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
HttpSession s = req.getSession(true);
s.getId();
@@ -82,20 +82,20 @@ public class TestTomcat extends TomcatBa
}
/**
- * Simple servlet to test JNDI
+ * Simple servlet to test JNDI
*/
public static class HelloWorldJndi extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String JNDI_ENV_NAME = "test";
-
+
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse res)
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
-
+
String name = null;
-
+
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
@@ -103,7 +103,7 @@ public class TestTomcat extends TomcatBa
} catch (NamingException e) {
throw new IOException(e);
}
-
+
res.getWriter().write("Hello, " + name);
}
}
@@ -112,14 +112,14 @@ public class TestTomcat extends TomcatBa
* Servlet that tries to obtain a URL for WEB-INF/web.xml
*/
public static class GetResource extends HttpServlet {
-
+
private static final long serialVersionUID = 1L;
-
+
@Override
- public void doGet(HttpServletRequest req, HttpServletResponse res)
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
URL url = req.getServletContext().getResource("/WEB-INF/web.xml");
-
+
res.getWriter().write("The URL obtained for /WEB-INF/web.xml was ");
if (url == null) {
res.getWriter().write("null");
@@ -129,7 +129,7 @@ public class TestTomcat extends TomcatBa
// Read some content from the resource
URLConnection conn = url.openConnection();
-
+
InputStream is = null;
Reader reader = null;
char cbuf[] = new char[20];
@@ -150,14 +150,14 @@ public class TestTomcat extends TomcatBa
try { is.close(); } catch(IOException ioe) {/*Ignore*/}
}
}
-
-
+
+
}
-
-
+
+
}
}
-
+
/**
* Simple Realm that uses a configurable {@link Map} to link user names and
* passwords.
@@ -166,7 +166,7 @@ public class TestTomcat extends TomcatBa
private Map<String,String> users = new HashMap<String,String>();
private Map<String,List<String>> roles =
new HashMap<String,List<String>>();
-
+
public void addUser(String username, String password) {
users.put(username, password);
}
@@ -195,31 +195,31 @@ public class TestTomcat extends TomcatBa
return new GenericPrincipal(username, getPassword(username),
roles.get(username));
}
-
+
}
- /**
- * Start tomcat with a single context and one
- * servlet - all programmatic, no server.xml or
+ /**
+ * Start tomcat with a single context and one
+ * servlet - all programmatic, no server.xml or
* web.xml used.
- *
- * @throws Exception
+ *
+ * @throws Exception
*/
@Test
public void testProgrammatic() 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"));
- // You can customize the context by calling
+ // You can customize the context by calling
// its API
-
+
Tomcat.addServlet(ctx, "myServlet", new HelloWorld());
ctx.addServletMapping("/", "myServlet");
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello world", res.toString());
}
@@ -231,7 +231,7 @@ public class TestTomcat extends TomcatBa
File appDir = new File(getBuildDirectory(), "webapps/examples");
// app dir is relative to server home
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() +
@@ -246,7 +246,7 @@ public class TestTomcat extends TomcatBa
File appDir = new File(getBuildDirectory(), "webapps/examples");
// app dir is relative to server home
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
tomcat.start();
ByteChunk res = getUrl("http://localhost:" + getPort() +
@@ -257,18 +257,18 @@ public class TestTomcat extends TomcatBa
@Test
public void testSession() 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"));
- // You can customize the context by calling
+ // You can customize the context by calling
// its API
-
+
Tomcat.addServlet(ctx, "myServlet", new HelloWorldSession());
ctx.addServletMapping("/", "myServlet");
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello world", res.toString());
}
@@ -279,24 +279,24 @@ public class TestTomcat extends TomcatBa
long t0 = System.currentTimeMillis();
tomcat.addContext(null, "/", ".");
tomcat.start();
- System.err.println("Test time: " +
+ System.err.println("Test time: " +
(System.currentTimeMillis() - t0));
}
-
- /**
+
+ /**
* Test for enabling JNDI.
*/
@Test
public void testEnableNaming() 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"));
-
+
// You can customise the context by calling its API
-
+
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
@@ -305,29 +305,29 @@ public class TestTomcat extends TomcatBa
environment.setName(HelloWorldJndi.JNDI_ENV_NAME);
environment.setValue("Tomcat User");
ctx.getNamingResources().addEnvironment(environment);
-
+
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
- /**
+ /**
* Test for enabling JNDI and using global resources.
*/
@Test
public void testEnableNamingGlobal() 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"));
-
+
// You can customise the context by calling its API
-
+
// Enable JNDI - it is disabled by default
tomcat.enableNaming();
@@ -336,17 +336,17 @@ public class TestTomcat extends TomcatBa
environment.setName("globalTest");
environment.setValue("Tomcat User");
tomcat.getServer().getGlobalNamingResources().addEnvironment(environment);
-
+
ContextResourceLink link = new ContextResourceLink();
link.setGlobal("globalTest");
link.setName(HelloWorldJndi.JNDI_ENV_NAME);
ctx.getNamingResources().addResourceLink(link);
-
+
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("Hello, Tomcat User", res.toString());
}
@@ -358,21 +358,21 @@ public class TestTomcat extends TomcatBa
@Test
public void testGetResource() throws Exception {
Tomcat tomcat = getTomcatInstance();
-
+
String contextPath = "/examples";
-
+
File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
// app dir is relative to server home
org.apache.catalina.Context ctx =
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
-
+
Tomcat.addServlet(ctx, "testGetResource", new GetResource());
ctx.addServletMapping("/testGetResource", "testGetResource");
-
+
tomcat.start();
-
+
ByteChunk res = new ByteChunk();
-
+
int rc =getUrl("http://localhost:" + getPort() + contextPath +
"/testGetResource", res, null);
assertEquals(HttpServletResponse.SC_OK, rc);
@@ -383,7 +383,7 @@ public class TestTomcat extends TomcatBa
public void testBug50826() throws Exception {
Tomcat tomcat = getTomcatInstance();
String contextPath = "/examples";
-
+
File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
// app dir is relative to server home
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.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.
@@ -43,40 +43,40 @@ public class TestTomcatClassLoader exten
// Must have a real docBase - just use temp
Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
Tomcat.addServlet(ctx, "ClassLoaderReport", new ClassLoaderReport(null));
ctx.addServletMapping("/", "ClassLoaderReport");
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("WEBAPP,SYSTEM,OTHER,", res.toString());
}
@Test
public void testNonDefaultClassLoader() throws Exception {
-
+
ClassLoader cl = new URLClassLoader(new URL[0],
Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(cl);
-
+
Tomcat tomcat = getTomcatInstance();
tomcat.getServer().setParentClassLoader(cl);
// Must have a real docBase - just use temp
Context ctx =
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-
+
Tomcat.addServlet(ctx, "ClassLoaderReport", new ClassLoaderReport(cl));
ctx.addServletMapping("/", "ClassLoaderReport");
-
+
tomcat.start();
-
+
ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
assertEquals("WEBAPP,CUSTOM,SYSTEM,OTHER,", res.toString());
}
-
+
private static final class ClassLoaderReport extends HttpServlet {
private static final long serialVersionUID = 1L;
@@ -93,7 +93,7 @@ public class TestTomcatClassLoader exten
PrintWriter out = resp.getWriter();
ClassLoader system = ClassLoader.getSystemClassLoader();
-
+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (cl != null) {
if (system == cl) {
Modified: tomcat/trunk/test/org/apache/catalina/startup/TesterServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TesterServlet.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TesterServlet.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TesterServlet.java Sat Oct 22 21:23:07 2011
@@ -31,7 +31,7 @@ public class TesterServlet extends HttpS
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
-
+
resp.setContentType("text/plain");
PrintWriter out = resp.getWriter();
out.print("OK");
Modified: tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.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.
@@ -77,7 +77,7 @@ public abstract class TomcatBaseTest {
public int getPort() {
return port;
}
-
+
/**
* Sub-classes may want to add connectors on a new port
*/
@@ -89,7 +89,7 @@ public abstract class TomcatBaseTest {
/**
* Helper method that returns the path of the temporary directory used by
* the test runs. The directory is configured during {@link #setUp()}.
- *
+ *
* <p>
* It is used as <code>${catalina.base}</code> for the instance of Tomcat
* that is being started, but can be used to store other temporary files as
@@ -122,7 +122,7 @@ public abstract class TomcatBaseTest {
/**
* Schedule the given file or directory to be deleted during after-test
* cleanup.
- *
+ *
* @param file
* File or directory
*/
@@ -142,16 +142,16 @@ public abstract class TomcatBaseTest {
if (!tempDir.mkdirs() && !tempDir.isDirectory()) {
fail("Unable to create temporary directory for test");
}
-
+
System.setProperty("catalina.base", tempDir.getAbsolutePath());
// Trigger loading of catalina.properties
CatalinaProperties.getProperty("foo");
-
+
File appBase = new File(tempDir, "webapps");
if (!appBase.exists() && !appBase.mkdir()) {
fail("Unable to create appBase for test");
}
-
+
tomcat = new TomcatWithFastSessionIDs();
String protocol = getProtocol();
@@ -172,7 +172,7 @@ public abstract class TomcatBaseTest {
server.addLifecycleListener(listener);
connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
}
-
+
tomcat.setBaseDir(tempDir.getAbsolutePath());
tomcat.getHost().setAppBase(appBase.getAbsolutePath());
@@ -185,11 +185,11 @@ public abstract class TomcatBaseTest {
tomcat.getHost().getPipeline().addValve(alv);
}
}
-
+
protected String getProtocol() {
// Has a protocol been specified
String protocol = System.getProperty("tomcat.test.protocol");
-
+
// Use BIO by default
if (protocol == null) {
protocol = "org.apache.coyote.http11.Http11Protocol";
@@ -220,7 +220,7 @@ public abstract class TomcatBaseTest {
}
deleteOnTearDown.clear();
}
-
+
/**
* Simple Hello World servlet for use by test cases
*/
@@ -238,7 +238,7 @@ public abstract class TomcatBaseTest {
out.print(RESPONSE_TEXT);
}
}
-
+
/**
* Wrapper for getting the response.
@@ -259,13 +259,13 @@ public abstract class TomcatBaseTest {
Map<String, List<String>> resHead) throws IOException {
return getUrl(path, out, 1000000, reqHead, resHead);
}
-
+
public static int getUrl(String path, ByteChunk out, int readTimeout,
Map<String, List<String>> reqHead,
Map<String, List<String>> resHead) throws IOException {
URL url = new URL(path);
- HttpURLConnection connection =
+ HttpURLConnection connection =
(HttpURLConnection) url.openConnection();
connection.setUseCaches(false);
connection.setReadTimeout(readTimeout);
@@ -310,7 +310,7 @@ public abstract class TomcatBaseTest {
}
return rc;
}
-
+
public static ByteChunk postUrl(byte[] body, String path)
throws IOException {
ByteChunk out = new ByteChunk();
@@ -322,13 +322,13 @@ public abstract class TomcatBaseTest {
Map<String, List<String>> resHead) throws IOException {
return postUrl(body, path, out, null, resHead);
}
-
+
public static int postUrl(byte[] body, String path, ByteChunk out,
Map<String, List<String>> reqHead,
Map<String, List<String>> resHead) throws IOException {
URL url = new URL(path);
- HttpURLConnection connection =
+ HttpURLConnection connection =
(HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setReadTimeout(1000000);
@@ -346,7 +346,7 @@ public abstract class TomcatBaseTest {
}
}
connection.connect();
-
+
// Write the request body
OutputStream os = null;
try {
Modified: tomcat/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java?rev=1187806&r1=1187805&r2=1187806&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tribes/demos/ChannelCreator.java Sat Oct 22 21:23:07 2011
@@ -51,16 +51,16 @@ import org.apache.catalina.tribes.transp
* @version 1.0
*/
public class ChannelCreator {
-
-
+
+
public static StringBuilder usage() {
StringBuilder buf = new StringBuilder();
buf.append("\n\t\t[-bind tcpbindaddress]")
- .append("\n\t\t[-tcpselto tcpselectortimeout]")
- .append("\n\t\t[-tcpthreads tcpthreadcount]")
+ .append("\n\t\t[-tcpselto tcpselectortimeout]")
+ .append("\n\t\t[-tcpthreads tcpthreadcount]")
.append("\n\t\t[-port tcplistenport]")
.append("\n\t\t[-autobind tcpbindtryrange]")
- .append("\n\t\t[-ackto acktimeout]")
+ .append("\n\t\t[-ackto acktimeout]")
.append("\n\t\t[-receiver org.apache.catalina.tribes.transport.nio.NioReceiver|org.apache.catalina.tribes.transport.bio.BioReceiver|]")
.append("\n\t\t[-transport org.apache.catalina.tribes.transport.nio.PooledParallelSender|org.apache.catalina.tribes.transport.bio.PooledMultiSender]")
.append("\n\t\t[-transport.xxx transport specific property]")
@@ -108,7 +108,7 @@ public class ChannelCreator {
int asyncsize = 1024*1024*50; //50MB
boolean throughput = false;
boolean failuredetect = false;
-
+
for (int i = 0; i < args.length; i++) {
if ("-bind".equals(args[i])) {
bind = args[++i];
@@ -169,7 +169,7 @@ public class ChannelCreator {
mbind = args[++i];
}
}
-
+
System.out.println("Creating receiver class="+receiver);
Class<?> cl = Class.forName(receiver, true,
ChannelCreator.class.getClassLoader());
@@ -184,7 +184,7 @@ public class ChannelCreator {
rx.setTxBufSize(25188);
rx.setAutoBind(autoBind);
-
+
ReplicationTransmitter ps = new ReplicationTransmitter();
System.out.println("Creating transport class="+transport);
MultiPointSender sender = (MultiPointSender)Class.forName(transport,true,ChannelCreator.class.getClassLoader()).newInstance();
@@ -211,7 +211,7 @@ public class ChannelCreator {
channel.setChannelReceiver(rx);
channel.setChannelSender(ps);
channel.setMembershipService(service);
-
+
if ( throughput ) channel.addInterceptor(new ThroughputInterceptor());
if (gzip) channel.addInterceptor(new GzipInterceptor());
if ( frag ) {
@@ -224,14 +224,14 @@ public class ChannelCreator {
oi.setMaxQueue(ordersize);
channel.addInterceptor(oi);
}
-
+
if ( async ) {
MessageDispatchInterceptor mi = new MessageDispatch15Interceptor();
mi.setMaxQueueSize(asyncsize);
channel.addInterceptor(mi);
System.out.println("Added MessageDispatchInterceptor");
}
-
+
if ( failuredetect ) {
TcpFailureDetector tcpfi = new TcpFailureDetector();
channel.addInterceptor(tcpfi);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org