This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 5f6ac4e03e Refactor tests to avoid use of @Ignore
5f6ac4e03e is described below

commit 5f6ac4e03ef7024d80ed7a4b68bfda7b2e60fa45
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Dec 15 13:43:58 2023 +0000

    Refactor tests to avoid use of @Ignore
    
    Ignored tests get reported as skipped and I'd like to keep the skipped
    tests to those that have been skipped because a feature (Tomcat Native,
    OpenSSL vi FFM etc) is not available. This helps ensure that all tesst
    are run during release testing.
    
    This work is not yet complete.
---
 .../org/apache/catalina/connector/TestRequest.java | 22 -------
 .../catalina/connector/TestRequestPerformance.java | 43 +++++++++++++
 .../catalina/core/TestDefaultInstanceManager.java  | 73 ----------------------
 ... => TestDefaultInstanceManagerPerformance.java} | 69 +-------------------
 ...terWebappClassLoaderThreadLocalMemoryLeak.java} |  4 +-
 5 files changed, 45 insertions(+), 166 deletions(-)

diff --git a/test/org/apache/catalina/connector/TestRequest.java 
b/test/org/apache/catalina/connector/TestRequest.java
index 413d35f7e9..b2289a8bb3 100644
--- a/test/org/apache/catalina/connector/TestRequest.java
+++ b/test/org/apache/catalina/connector/TestRequest.java
@@ -43,7 +43,6 @@ import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
@@ -862,27 +861,6 @@ public class TestRequest extends TomcatBaseTest {
     }
 
 
-    @Test
-    @Ignore("Used to check performance of different parsing approaches")
-    public void localeParsePerformance() throws Exception {
-        TesterRequest req = new TesterRequest();
-        req.addHeader("accept-encoding", "en-gb,en");
-
-        long start = System.nanoTime();
-
-        // Takes about 0.3s on a quad core 2.7Ghz 2013 MacBook
-        for (int i = 0; i < 10000000; i++) {
-            req.parseLocales();
-            req.localesParsed = false;
-            req.locales.clear();
-        }
-
-        long time = System.nanoTime() - start;
-
-        System.out.println(time);
-    }
-
-
     @Test
     public void testGetReaderValidEncoding() throws Exception {
         doTestGetReader("ISO-8859-1", true);
diff --git a/test/org/apache/catalina/connector/TestRequestPerformance.java 
b/test/org/apache/catalina/connector/TestRequestPerformance.java
new file mode 100644
index 0000000000..81a00829ce
--- /dev/null
+++ b/test/org/apache/catalina/connector/TestRequestPerformance.java
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  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.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.catalina.connector;
+
+import org.junit.Test;
+
+import org.apache.tomcat.unittest.TesterRequest;
+
+public class TestRequestPerformance {
+
+    @Test
+    public void localeParsePerformance() throws Exception {
+        TesterRequest req = new TesterRequest();
+        req.addHeader("accept-encoding", "en-gb,en");
+
+        long start = System.nanoTime();
+
+        // Takes about 0.3s on a quad core 2.7Ghz 2013 MacBook
+        for (int i = 0; i < 10000000; i++) {
+            req.parseLocales();
+            req.localesParsed = false;
+            req.locales.clear();
+        }
+
+        long time = System.nanoTime() - start;
+
+        System.out.println(time);
+    }
+}
diff --git a/test/org/apache/catalina/core/TestDefaultInstanceManager.java 
b/test/org/apache/catalina/core/TestDefaultInstanceManager.java
index f2b1ec5830..46bec32d65 100644
--- a/test/org/apache/catalina/core/TestDefaultInstanceManager.java
+++ b/test/org/apache/catalina/core/TestDefaultInstanceManager.java
@@ -17,21 +17,14 @@
 package org.apache.catalina.core;
 
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.naming.NamingException;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.servlets.DefaultServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.jasper.servlet.JasperInitializer;
-import org.apache.tomcat.InstanceManager;
 
 
 public class TestDefaultInstanceManager extends TomcatBaseTest {
@@ -94,70 +87,4 @@ public class TestDefaultInstanceManager extends 
TomcatBaseTest {
 
         return (DefaultInstanceManager) ctxt.getInstanceManager();
     }
-
-
-    /*
-     * Performance test. Comment out @Ignore to run the test.
-     */
-    @Ignore
-    @Test
-    public void testConcurrency() throws Exception {
-        // Create a populated InstanceManager
-        Tomcat tomcat = getTomcatInstance();
-        Context ctx = tomcat.addContext(null, "", null);
-
-        tomcat.start();
-
-        InstanceManager im = ctx.getInstanceManager();
-
-        for (int i = 1; i < 9; i++) {
-            doTestConcurrency(im, i);
-        }
-    }
-
-
-    private void doTestConcurrency(InstanceManager im, int threadCount) throws 
Exception {
-        long start = System.nanoTime();
-
-        Thread[] threads = new Thread[threadCount];
-
-        for (int i = 0; i < threadCount; i++) {
-            threads[i] = new Thread(new InstanceManagerRunnable(im));
-        }
-
-        for (int i = 0; i < threadCount; i++) {
-            threads[i].start();
-        }
-
-        for (int i = 0; i < threadCount; i++) {
-            threads[i].join();
-        }
-
-        long duration = System.nanoTime() - start;
-
-        System.out.println(threadCount + " threads completed in " + duration + 
"ns");
-    }
-
-
-    private static class InstanceManagerRunnable implements Runnable {
-
-        private final InstanceManager im;
-
-        private InstanceManagerRunnable(InstanceManager im) {
-            this.im = im;
-        }
-
-        @Override
-        public void run() {
-            try {
-                Object test = new DefaultServlet();
-                for (int i = 0; i < 200000; i++) {
-                    im.newInstance(test);
-                    im.destroyInstance(test);
-                }
-            } catch (NamingException | IllegalAccessException | 
InvocationTargetException ne) {
-                ne.printStackTrace();
-            }
-        }
-    }
 }
diff --git a/test/org/apache/catalina/core/TestDefaultInstanceManager.java 
b/test/org/apache/catalina/core/TestDefaultInstanceManagerPerformance.java
similarity index 53%
copy from test/org/apache/catalina/core/TestDefaultInstanceManager.java
copy to test/org/apache/catalina/core/TestDefaultInstanceManagerPerformance.java
index f2b1ec5830..c496efeb08 100644
--- a/test/org/apache/catalina/core/TestDefaultInstanceManager.java
+++ b/test/org/apache/catalina/core/TestDefaultInstanceManagerPerformance.java
@@ -16,90 +16,23 @@
  */
 package org.apache.catalina.core;
 
-import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 
 import javax.naming.NamingException;
 
-import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
-import org.apache.catalina.Wrapper;
 import org.apache.catalina.servlets.DefaultServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
-import org.apache.jasper.servlet.JasperInitializer;
 import org.apache.tomcat.InstanceManager;
 
-
-public class TestDefaultInstanceManager extends TomcatBaseTest {
-
-    @Test
-    public void testClassUnloading() throws Exception {
-
-        DefaultInstanceManager instanceManager = doClassUnloadingPrep();
-
-        // Request a JSP page (that doesn't load any tag libraries etc.)
-        // This page does use @PostConstruct to ensure that the cache does not
-        // retain strong references
-        getUrl("http://localhost:"; + getPort() + "/test/annotations.jsp");
-        // Request a second JSP (again, no tag libraries etc.)
-        getUrl("http://localhost:"; + getPort() + "/test/bug36923.jsp");
-
-        // Check the number of classes in the cache
-        int count = instanceManager.getAnnotationCacheSize();
-
-        // Request a third JSP (again, no tag libraries etc.)
-        getUrl("http://localhost:"; + getPort() + 
"/test/bug5nnnn/bug51544.jsp");
-
-        // Force a GC to clear out unloaded class (first JSP)
-        System.gc();
-
-        // Spin a while until GC happens or we wait too long
-        int loop = 0;
-        while (loop < 10) {
-            instanceManager.backgroundProcess();
-            if (instanceManager.getAnnotationCacheSize() == count) {
-                break;
-            }
-            Thread.sleep(100);
-            loop++;
-        }
-
-        // First JSP should be unloaded and replaced by third (second left
-        // alone) so no change in overall count
-        Assert.assertEquals(count, instanceManager.getAnnotationCacheSize());
-    }
-
-    private DefaultInstanceManager doClassUnloadingPrep() throws Exception {
-        Tomcat tomcat = getTomcatInstance();
-
-        // Create the context (don't use addWebapp as we want to modify the
-        // JSP Servlet settings).
-        File appDir = new File("test/webapp");
-        StandardContext ctxt = (StandardContext) tomcat.addContext(
-                null, "/test", appDir.getAbsolutePath());
-
-        ctxt.addServletContainerInitializer(new JasperInitializer(), null);
-
-        // Configure the defaults and then tweak the JSP servlet settings
-        // Note: Min value for maxLoadedJsps is 2
-        Tomcat.initWebappDefaults(ctxt);
-        Wrapper w = (Wrapper) ctxt.findChild("jsp");
-        w.addInitParameter("maxLoadedJsps", "2");
-
-        tomcat.start();
-
-        return (DefaultInstanceManager) ctxt.getInstanceManager();
-    }
-
+public class TestDefaultInstanceManagerPerformance extends TomcatBaseTest {
 
     /*
      * Performance test. Comment out @Ignore to run the test.
      */
-    @Ignore
     @Test
     public void testConcurrency() throws Exception {
         // Create a populated InstanceManager
diff --git 
a/test/org/apache/catalina/loader/TestWebappClassLoaderThreadLocalMemoryLeak.java
 
b/test/org/apache/catalina/loader/TesterWebappClassLoaderThreadLocalMemoryLeak.java
similarity index 98%
rename from 
test/org/apache/catalina/loader/TestWebappClassLoaderThreadLocalMemoryLeak.java
rename to 
test/org/apache/catalina/loader/TesterWebappClassLoaderThreadLocalMemoryLeak.java
index e28e25f08e..c833e1252f 100644
--- 
a/test/org/apache/catalina/loader/TestWebappClassLoaderThreadLocalMemoryLeak.java
+++ 
b/test/org/apache/catalina/loader/TesterWebappClassLoaderThreadLocalMemoryLeak.java
@@ -22,7 +22,6 @@ import java.util.concurrent.Executor;
 import jakarta.servlet.http.HttpServletResponse;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import org.apache.catalina.Context;
@@ -49,8 +48,7 @@ import org.apache.tomcat.util.threads.ThreadPoolExecutor;
  * most systems (just not all and particularly some of the ASF's CI systems) 
and
  * still may be useful if a bug is reported in this area in the future.
  */
-@Ignore
-public class TestWebappClassLoaderThreadLocalMemoryLeak extends TomcatBaseTest 
{
+public class TesterWebappClassLoaderThreadLocalMemoryLeak extends 
TomcatBaseTest {
 
     @Test
     public void testThreadLocalLeak1() throws Exception {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to