Author: kkolinko Date: Sun Nov 6 21:12:12 2011 New Revision: 1198558 URL: http://svn.apache.org/viewvc?rev=1198558&view=rev Log: Porting r1187806 - whitespace cleanup in /test
Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamFilter.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamServlet.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcat.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServlet.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamFilter.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/DuplicateMappingParamServlet.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/FastNonSecureRandom.java Sun Nov 6 21:12:12 2011 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/NoMappingParamServlet.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamFilter.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamFilter.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamFilter.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamFilter.java Sun Nov 6 21:12:12 2011 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamServlet.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamServlet.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/ParamServlet.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfig.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestContextConfigAnnotation.java Sun Nov 6 21:12:12 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 @@ -354,7 +354,7 @@ public class TestContextConfigAnnotation /** * Find compiled test class - * + * * @param className * @return File Resource */ Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestListener.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcat.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcat.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcat.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcat.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestTomcatClassLoader.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServlet.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServlet.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TesterServlet.java Sun Nov 6 21:12:12 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/tc7.0.x/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java?rev=1198558&r1=1198557&r2=1198558&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java Sun Nov 6 21:12:12 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"; @@ -224,7 +224,7 @@ public abstract class TomcatBaseTest { } deleteOnTearDown.clear(); } - + /** * Simple Hello World servlet for use by test cases */ @@ -242,7 +242,7 @@ public abstract class TomcatBaseTest { out.print(RESPONSE_TEXT); } } - + /** * Wrapper for getting the response. @@ -263,13 +263,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); @@ -314,7 +314,7 @@ public abstract class TomcatBaseTest { } return rc; } - + public static ByteChunk postUrl(byte[] body, String path) throws IOException { ByteChunk out = new ByteChunk(); @@ -326,13 +326,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); @@ -350,7 +350,7 @@ public abstract class TomcatBaseTest { } } connection.connect(); - + // Write the request body OutputStream os = null; try { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org