Skip to content

Commit

Permalink
Merge pull request #6205 from yersan/WFCORE-7012-WFCORE-7013
Browse files Browse the repository at this point in the history
[WFCORE-7012][WFCORE-7013] Fix ServerEnvironmentTestCase and ignore when server is running in default stability level
  • Loading branch information
yersan authored Sep 27, 2024
2 parents 3353eff + 375c463 commit 63d052d
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,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;

Expand Down Expand Up @@ -104,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"));
Expand All @@ -115,14 +121,23 @@ 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);
assertEquals(Stability.DEFAULT, productConfig.getDefaultStability());

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) {
Expand Down

0 comments on commit 63d052d

Please sign in to comment.