You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@artemis.apache.org by cl...@apache.org on 2026/06/30 21:31:17 UTC

(artemis) branch main updated: ARTEMIS-6126 Fixing basedir resolution on testsuite

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 26f934addb ARTEMIS-6126 Fixing basedir resolution on testsuite
26f934addb is described below

commit 26f934addbe13f2fce960a026006d3f1450438e2
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue Jun 30 13:46:20 2026 -0400

    ARTEMIS-6126 Fixing basedir resolution on testsuite
    
    This is particularly important if running tests through the IDE
---
 .../activemq/artemis/utils/BasedirSupport.java     | 37 ++++++++++++++++++++++
 .../activemq/artemis/utils/RealServerTestBase.java |  2 +-
 .../artemis/tests/e2e/common/E2ETestBase.java      |  3 +-
 .../smoke/upgradeTest/CompareUpgradeTest.java      |  4 +--
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/BasedirSupport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/BasedirSupport.java
new file mode 100644
index 0000000000..f86236f534
--- /dev/null
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/BasedirSupport.java
@@ -0,0 +1,37 @@
+/*
+ * 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.activemq.artemis.utils;
+
+import java.io.File;
+import java.io.IOException;
+
+public class BasedirSupport {
+
+   public static String getBasedir() {
+      String basedir = System.getProperty("basedir");
+      if (basedir == null) {
+         try {
+            basedir = new File(".").getCanonicalPath();
+         } catch (IOException e) {
+            throw new RuntimeException("Failed to resolve canonical path for current directory", e);
+         }
+      }
+      return basedir;
+   }
+
+}
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/RealServerTestBase.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/RealServerTestBase.java
index 43b41cba77..4f11d7c7d3 100644
--- a/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/RealServerTestBase.java
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/utils/RealServerTestBase.java
@@ -62,7 +62,7 @@ public class RealServerTestBase extends ActiveMQTestBase {
    private static final String JMX_SERVER_HOSTNAME = "localhost";
    private static final int JMX_SERVER_PORT = 10099;
 
-   public static final String basedir = System.getProperty("basedir");
+   public static final String basedir = BasedirSupport.getBasedir();
 
    public static final String ARTEMIS_HOME_PROPERTY = "artemis.distribution.output";
 
diff --git a/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/E2ETestBase.java b/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/E2ETestBase.java
index 1a59b17c1d..28b9813dd3 100644
--- a/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/E2ETestBase.java
+++ b/tests/e2e-tests/src/test/java/org/apache/activemq/artemis/tests/e2e/common/E2ETestBase.java
@@ -19,10 +19,11 @@ package org.apache.activemq.artemis.tests.e2e.common;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.utils.BasedirSupport;
 
 public class E2ETestBase extends ActiveMQTestBase {
 
-   public static final String basedir = System.getProperty("basedir");
+   public static final String basedir = BasedirSupport.getBasedir();
 
    protected static final void recreateBrokerDirectory(final String homeInstance) {
       recreateDirectory(homeInstance + "/data");
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/upgradeTest/CompareUpgradeTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/upgradeTest/CompareUpgradeTest.java
index b6f6bc797b..98bbd246ca 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/upgradeTest/CompareUpgradeTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/upgradeTest/CompareUpgradeTest.java
@@ -43,6 +43,7 @@ import java.util.stream.Stream;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
 import org.apache.activemq.artemis.cli.commands.Create;
 import org.apache.activemq.artemis.cli.commands.Upgrade;
+import org.apache.activemq.artemis.utils.BasedirSupport;
 import org.apache.activemq.artemis.utils.FileUtil;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
@@ -55,8 +56,7 @@ public class CompareUpgradeTest {
 
    private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-   public static final String basedir = System.getProperty("basedir");
-
+   public static final String basedir = BasedirSupport.getBasedir();
 
    @Test
    public void testCompareWindowsFreshInstance() throws Exception {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@artemis.apache.org
For additional commands, e-mail: commits-help@artemis.apache.org