From: kkolinko Date: Fri, 30 Apr 2010 04:00:01 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49218 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f52ae69ef5b0764a0e03f6f448e14479458b6793;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49218 The test runs successfully if JreMemoryLeakPreventionListener is present. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@939553 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/org/apache/catalina/core/TestStandardContextResources.java b/test/org/apache/catalina/core/TestStandardContextResources.java index 5f6d72d96..556d305f9 100644 --- a/test/org/apache/catalina/core/TestStandardContextResources.java +++ b/test/org/apache/catalina/core/TestStandardContextResources.java @@ -35,6 +35,20 @@ import org.apache.tomcat.util.buf.ByteChunk; public class TestStandardContextResources extends TomcatBaseTest { + @Override + public void setUp() throws Exception { + super.setUp(); + + Tomcat tomcat = getTomcatInstance(); + + // BZ 49218: The test fails if JreMemoryLeakPreventionListener is not + // present. The listener affects the JVM, and thus not only the current, + // but also the subsequent tests that are run in the same JVM. So it is + // fair to add it in every test. + tomcat.getServer().addLifecycleListener( + new JreMemoryLeakPreventionListener()); + } + public void testResources() throws Exception { Tomcat tomcat = getTomcatInstance(); @@ -44,9 +58,6 @@ public class TestStandardContextResources extends TomcatBaseTest { tomcat.start(); - if (false) { - // FIXME: These tests are currently failing. See comment in testResources2() below. - assertPageContains("/test/resourceA.jsp", "

resourceA.jsp in the web application

"); assertPageContains("/test/resourceB.jsp", @@ -57,7 +68,6 @@ public class TestStandardContextResources extends TomcatBaseTest { "

resourceD.jsp in resources.jar

"); assertPageContains("/test/folder/resourceE.jsp", "

resourceE.jsp in the web application

"); - } } public void testResources2() throws Exception { @@ -73,26 +83,6 @@ public class TestStandardContextResources extends TomcatBaseTest { tomcat.start(); - // FIXME: These tests are currently failing. - // - // I do not have a fix yet, but I know the following: - // when trying to get "/resourceB.jsp" in ApplicationContext#getResource() - // an Exception is caught and silently swallowed. That exception is - // - // java.lang.IllegalStateException: zip file closed - // at java.util.jar.JarFile.getMetaInfEntryNames(Native Method) - // at java.util.jar.JarFile.maybeInstantiateVerifier(JarFile.java:277) - // at java.util.jar.JarFile.getInputStream(JarFile.java:381) - // at org.apache.naming.resources.WARDirContext$WARResource.streamContent(WARDirContext.java:951) - // at org.apache.naming.resources.ProxyDirContext.cacheLoad(ProxyDirContext.java:1578) - // at org.apache.naming.resources.ProxyDirContext.cacheLookup(ProxyDirContext.java:1458) - // at org.apache.naming.resources.ProxyDirContext.lookup(ProxyDirContext.java:292) - // at org.apache.catalina.core.ApplicationContext.getResource(ApplicationContext.java:506) - // at org.apache.catalina.core.ApplicationContextFacade.getResource(ApplicationContextFacade.java:196) - // at org.apache.catalina.core.TestStandardContextResources$GetResourceServlet.doGet(TestStandardContextResources.java:126) - // - if (false) { - assertPageContains("/test/getresource?path=/resourceA.jsp", "

resourceA.jsp in the web application

"); assertPageContains("/test/getresource?path=/resourceB.jsp", @@ -103,7 +93,6 @@ public class TestStandardContextResources extends TomcatBaseTest { "

resourceD.jsp in resources.jar

"); assertPageContains("/test/getresource?path=/folder/resourceE.jsp", "

resourceE.jsp in the web application

"); - } } /**