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 2010/05/08 17:54:44 UTC
svn commit: r942407 -
/tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
Author: markt
Date: Sat May 8 15:54:44 2010
New Revision: 942407
URL: http://svn.apache.org/viewvc?rev=942407&view=rev
Log:
Fix JULI configuration so JULI is actually used.
Fix FindBugs warnings
Modified:
tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java
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=942407&r1=942406&r2=942407&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TomcatBaseTest.java Sat May 8 15:54:44 2010
@@ -25,15 +25,12 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.LogManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleState;
import org.apache.tomcat.util.buf.ByteChunk;
@@ -82,17 +79,19 @@ public abstract class TomcatBaseTest ext
@Override
public void setUp() throws Exception {
- // Need to use JULI and to configure a ConsoleHandler so log messages
- // from the tests are visible
- System.setProperty("java.util.logging.config.class",
+ // Need to use JULI so log messages from the tests are visible
+ System.setProperty("java.util.logging.manager",
"org.apache.juli.ClassLoaderLogManager");
- LogManager.getLogManager().getLogger("").addHandler(
- new ConsoleHandler());
tempDir = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
- tempDir.mkdir();
+ if (!tempDir.mkdir()) {
+ fail("Unable to create temporary directory for test");
+ }
+
File appBase = new File(tempDir, "webapps");
- appBase.mkdir();
+ if (!appBase.mkdir()) {
+ fail("Unable to create appBase for test");
+ }
tomcat = new Tomcat();
tomcat.setBaseDir(tempDir.getAbsolutePath());
@@ -139,9 +138,9 @@ public abstract class TomcatBaseTest ext
return out;
}
- public static int getUrl(String path,
- ByteChunk out,
- Map<String, List<String>> resHead) throws IOException {
+ public static int getUrl(String path, ByteChunk out,
+ Map<String, List<String>> resHead) throws IOException {
+
URL url = new URL(path);
HttpURLConnection connection =
(HttpURLConnection) url.openConnection();
@@ -153,11 +152,22 @@ public abstract class TomcatBaseTest ext
resHead.putAll(head);
}
InputStream is = connection.getInputStream();
- BufferedInputStream bis = new BufferedInputStream(is);
- byte[] buf = new byte[2048];
- int rd = 0;
- while((rd = bis.read(buf)) > 0) {
- out.append(buf, 0, rd);
+ BufferedInputStream bis = null;
+ try {
+ bis = new BufferedInputStream(is);
+ byte[] buf = new byte[2048];
+ int rd = 0;
+ while((rd = bis.read(buf)) > 0) {
+ out.append(buf, 0, rd);
+ }
+ } finally {
+ if (bis != null) {
+ try {
+ bis.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
}
return rc;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org