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

remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1867d8e7fe0e0bc9c6401fe1b626676e49df9e41
Author: remm <r...@apache.org>
AuthorDate: Tue Sep 24 16:32:14 2024 +0200

    Workaround Windows locking issue
    
    Manager deploy locking seems a bit difficult to avoid.
---
 test/org/apache/catalina/manager/TestManagerWebapp.java | 14 ++++++++++----
 test/org/apache/catalina/startup/LoggingBaseTest.java   |  4 +++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/test/org/apache/catalina/manager/TestManagerWebapp.java 
b/test/org/apache/catalina/manager/TestManagerWebapp.java
index 0efb515f01..dbe8c45b8f 100644
--- a/test/org/apache/catalina/manager/TestManagerWebapp.java
+++ b/test/org/apache/catalina/manager/TestManagerWebapp.java
@@ -66,8 +66,10 @@ public class TestManagerWebapp extends TomcatBaseTest {
         tomcat.addRole("admin", "manager-jmx");
         tomcat.addRole("admin", "manager-status");
 
+        File webappDir = new File(getBuildDirectory(), "webapps");
+
         // Add manager webapp
-        File appDir = new File(getBuildDirectory(), "webapps/manager");
+        File appDir = new File(webappDir, "manager");
         tomcat.addWebapp(null, "/manager", appDir.getAbsolutePath());
 
         tomcat.start();
@@ -194,11 +196,13 @@ public class TestManagerWebapp extends TomcatBaseTest {
 
     @Test
     public void testDeploy() throws Exception {
+        // Avoid possible locking failure due to deployment with the manager
+        ignoreTearDown = true;
         Tomcat tomcat = getTomcatInstance();
         tomcat.setAddDefaultWebXmlToWebapp(false);
         tomcat.getServer().addLifecycleListener(new 
StoreConfigLifecycleListener());
 
-        File configFile = new File(getTemporaryDirectory(), 
"tomcat-users-manager-delpoy.xml");
+        File configFile = new File(getTemporaryDirectory(), 
"tomcat-users-manager-deploy.xml");
         try (PrintWriter writer = new PrintWriter(configFile)) {
             writer.write(CONFIG);
         }
@@ -209,8 +213,10 @@ public class TestManagerWebapp extends TomcatBaseTest {
         memoryRealm.setPathname(configFile.getAbsolutePath());
         tomcat.getEngine().setRealm(memoryRealm);
 
+        File webappDir = new File(getBuildDirectory(), "webapps");
+
         // Add manager webapp
-        File appDir = new File(getBuildDirectory(), "webapps/manager");
+        File appDir = new File(webappDir, "manager");
         Context ctx = tomcat.addWebapp(null, "/manager", 
appDir.getAbsolutePath());
 
         // Add host config otherwise there's no JMX deployer bean
@@ -228,7 +234,7 @@ public class TestManagerWebapp extends TomcatBaseTest {
         client.setPort(getPort());
         String basicHeader = (new BasicAuthHeader("Basic", "admin", 
"sekr3t")).getHeader().toString();
 
-        appDir = new File(System.getProperty("tomcat.test.basedir"), 
"webapps/examples");
+        appDir = new File(webappDir, "examples");
 
         client.setRequest(new String[] {
                 "GET /manager/text/deploy?war=" + 
URLEncoder.QUERY.encode(appDir.getAbsolutePath(), StandardCharsets.UTF_8) + " 
HTTP/1.1" + CRLF +
diff --git a/test/org/apache/catalina/startup/LoggingBaseTest.java 
b/test/org/apache/catalina/startup/LoggingBaseTest.java
index 893148b7bf..200978c92f 100644
--- a/test/org/apache/catalina/startup/LoggingBaseTest.java
+++ b/test/org/apache/catalina/startup/LoggingBaseTest.java
@@ -59,6 +59,8 @@ public abstract class LoggingBaseTest {
 
     private List<File> deleteOnTearDown = new ArrayList<>();
 
+    protected boolean ignoreTearDown = false;
+
     /**
      * Provides name of the currently executing test method.
      */
@@ -143,7 +145,7 @@ public abstract class LoggingBaseTest {
         }
         deleteOnTearDown.clear();
 
-        Assert.assertTrue("Failed to delete at least one file", deleted);
+        Assert.assertTrue("Failed to delete at least one file", ignoreTearDown 
|| deleted);
     }
 
     @AfterClass


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

Reply via email to