From c7ab9f6da96bc28cb6d52659b9a681cf8e530158 Mon Sep 17 00:00:00 2001 From: Yeray Borges Date: Fri, 27 Sep 2024 12:11:02 +0100 Subject: [PATCH 1/2] [WFCORE-7012] Fix to assert expected message in ServerEnvironmentTestCase#testAliasNotWorkingInDefaultStability Jira issue: https://issues.redhat.com/browse/WFCORE-7012 --- .../as/server/ServerEnvironmentTestCase.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java b/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java index bba0dcee36b..f6ad5a8e3e8 100644 --- a/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java +++ b/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java @@ -9,6 +9,9 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.jboss.as.server.ServerEnvironment.HOME_DIR; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; @@ -115,14 +118,21 @@ public void testAliasFunctionality() throws IOException { assertThat(serverEnvironment.getServerConfigurationFile().getBootFile().getName(), is("custom.xml")); } - @Test(expected = IllegalStateException.class) - public void testAliasNotWorkingInDefaultStability() { + @Test + public void testAliasNotWorkingInDefaultStability() throws IOException { Properties props = new Properties(); + Path standaloneDir = homeDir.resolve("standalone"); + Files.createDirectories(standaloneDir.resolve("configuration")); + Files.createFile(standaloneDir.resolve("configuration").resolve("standalone-load-balancer.xml")); props.put(HOME_DIR, homeDir.toAbsolutePath().toString()); // default stability = DEFAULT ProductConfig productConfig = new ProductConfig(null, null, null); - createServerEnvironment(props, "lb", productConfig); + Exception exception = assertThrows(IllegalStateException.class, () -> { + createServerEnvironment(props, "lb", productConfig); + }); + String expectedMessage = "WFLYCTL0215:"; + assertTrue(String.format("We expect message with ID " + expectedMessage + ", however message %s was thrown.", exception.getMessage()), exception.getMessage().startsWith(expectedMessage)); } private ServerEnvironment createServerEnvironment(Properties props, String serverConfig, ProductConfig productConfig) { From 375c4636f58187f1f267d656d4002c612da40d1f Mon Sep 17 00:00:00 2001 From: Yeray Borges Date: Fri, 27 Sep 2024 12:14:52 +0100 Subject: [PATCH 2/2] [WFCORE-7013] Ignore ServerEnvironmentTestCase#testAliasFunctionality when server stability is default Jira issue: https://issues.redhat.com/browse/WFCORE-7013 --- .../java/org/jboss/as/server/ServerEnvironmentTestCase.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java b/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java index f6ad5a8e3e8..7c76c2732f2 100644 --- a/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java +++ b/server/src/test/java/org/jboss/as/server/ServerEnvironmentTestCase.java @@ -25,6 +25,8 @@ import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.persistence.ConfigurationFile; import org.jboss.as.version.ProductConfig; +import org.jboss.as.version.Stability; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -107,6 +109,7 @@ public void testAliasFunctionality() throws IOException { // default stability = COMMUNITY ProductConfig productConfig = ProductConfig.fromFilesystemSlot(null, "", props); + Assume.assumeTrue(Stability.COMMUNITY.equals(productConfig.getDefaultStability())); ServerEnvironment serverEnvironment = createServerEnvironment(props, null, productConfig); assertThat(serverEnvironment.getServerConfigurationFile().getBootFile().getName(), is("standalone.xml")); @@ -128,6 +131,8 @@ public void testAliasNotWorkingInDefaultStability() throws IOException { // default stability = DEFAULT ProductConfig productConfig = new ProductConfig(null, null, null); + assertEquals(Stability.DEFAULT, productConfig.getDefaultStability()); + Exception exception = assertThrows(IllegalStateException.class, () -> { createServerEnvironment(props, "lb", productConfig); });