diff --git a/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThreadTest.java b/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThreadTest.java index 813dbf46446..4b784eece42 100644 --- a/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThreadTest.java +++ b/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThreadTest.java @@ -225,7 +225,7 @@ public void testBadMessagePropertyType() throws Exception { producer.setProperties(createJsonProperty("myType", "myKey", "myValue")); producer.applyProperties(mockMessage); - assertEquals("Unable to set property: myKey. Did not recognize type: myType. Supported types are: boolean, int, long, byte, short, float, double, string.\n", context.getStderr()); + assertEquals("Unable to set property: myKey. Did not recognize type: myType. Supported types are: boolean, int, long, byte, short, float, double, string.\n", context.getStderr().replace("\r\n", "\n")); } private static String createJsonProperty(String type, String key, String value) { diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java index f3508008ef2..0d84690864e 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/NetworkHealthTest.java @@ -327,12 +327,18 @@ public boolean purePing(InetAddress address) throws IOException, InterruptedExce @Test @Timeout(30) public void testPurePingTimeout() throws Exception { - NetworkHealthCheck check = new NetworkHealthCheck(null, 100, 2000); + int timeout = 2000; + + // Add a "tolerance" for Windows, since it reports less time spent in timeout than the networkTimeout parameter (around 200ms) + int tolerance = 500; + + NetworkHealthCheck check = new NetworkHealthCheck(null, 100, timeout); long time = System.currentTimeMillis(); //[RFC1166] reserves the address block 192.0.2.0/24 for test. assertFalse(check.purePing(InetAddress.getByName("192.0.2.0"))); - assertTrue(System.currentTimeMillis() - time >= 2000); + + assertTrue(System.currentTimeMillis() - time >= (timeout - tolerance)); } } diff --git a/artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java b/artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java index c2dac261303..aa5d800493c 100644 --- a/artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java +++ b/artemis-dto/src/test/java/org/apache/activemq/artemis/dto/XmlUtilTest.java @@ -30,13 +30,18 @@ public class XmlUtilTest extends ArtemisTestCase { @Test - public void testPropertySubstituion(@TempDir Path tempDir) throws Exception { + public void testPropertySubstitution(@TempDir Path tempDir) throws Exception { final String SYSTEM_PROP_NAME = getTestMethodName() + "SysPropName"; final String SYSTEM_PROP_VALUE = getTestMethodName() + "SysPropValue"; System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE); // since System.getenv() returns an immutable Map we rely here on an environment variable that is likely to exist - final String ENV_VAR_NAME = "HOME"; + String ENV_VAR_NAME = "HOME"; + + // override to USERPROFILE if OS is windows + if (System.getProperty("os.name").toLowerCase().contains("win")) { + ENV_VAR_NAME = "USERPROFILE"; + } BrokerDTO brokerDTO = getBrokerDTO(tempDir, SYSTEM_PROP_NAME, ENV_VAR_NAME); assertEquals(SYSTEM_PROP_VALUE, ((JaasSecurityDTO)brokerDTO.security).domain); @@ -44,7 +49,7 @@ public void testPropertySubstituion(@TempDir Path tempDir) throws Exception { } @Test - public void testPropertySubstituionPrecedence(@TempDir Path tempDir) throws Exception { + public void testPropertySubstitutionPrecedence(@TempDir Path tempDir) throws Exception { final String SYSTEM_PROP_NAME = "HOME"; final String SYSTEM_PROP_VALUE = getTestMethodName() + "SysPropValue"; System.setProperty(SYSTEM_PROP_NAME, SYSTEM_PROP_VALUE); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java index 6d43db8f4b7..b878681dba7 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java @@ -2969,12 +2969,15 @@ public void testRegxPropertiesFilesInDir() throws Exception { File tmpFile = File.createTempFile("a_stuff", ".properties", temporaryFolder); Properties properties = new Properties(); properties.put("name", "a"); - properties.store(new FileOutputStream(tmpFile), null); - + try (FileOutputStream out = new FileOutputStream(tmpFile)) { + properties.store(out, null); + } tmpFile = File.createTempFile("b_stuff", ".0-properties", temporaryFolder); properties = new Properties(); properties.put("name", "0"); - properties.store(new FileOutputStream(tmpFile), null); + try (FileOutputStream out = new FileOutputStream(tmpFile)) { + properties.store(out, null); + } ConfigurationImpl configuration = new ConfigurationImpl(); configuration.parseProperties(temporaryFolder + "/"); diff --git a/pom.xml b/pom.xml index c9850b5e4c7..9b59341939e 100644 --- a/pom.xml +++ b/pom.xml @@ -269,10 +269,9 @@ -Djava.library.path="${activemq.basedir}/target/bin/lib/linux-x86_64:${activemq.basedir}/target/bin/lib/linux-i686" -Djgroups.bind_addr=localhost -Djava.net.preferIPv4Stack=true - -Dbasedir=${basedir} -Djdk.attach.allowAttachSelf=true -Dartemis.distribution.output="${artemis.distribution.output}" - -Dlog4j2.configurationFile="file:${activemq.basedir}/tests/config/${logging.config}" + -Dlog4j2.configurationFile="${activemq.basedir}/tests/config/${logging.config}" ${project.basedir} false