Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves#236 Update the namespace detection for the root namespace to support stability level qualifiers. #237

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@
import java.util.regex.Pattern;

final class OfflineServerVersion {
private static final Pattern ROOT_XMLNS = Pattern.compile("[\"']urn:jboss:domain:(\\d+)\\.(\\d+)[\"']");

/*
* The namespaces in WildFly may also contain an optional Stability qualifier e.g.
*
* urn:jboss:domain:community:21.0
*
* Within the regular expression "(?:community:|preview:|experimental:)?":
* - This is a non capturing group to avoid changing the index of the versions.
* - The group is optional so can appear 0 or 1 times.
* - As the stability qualifier appears in the same space as some subsystem names
* the allowed qualifiers are specified.
*/

private static final Pattern ROOT_XMLNS = Pattern.compile("[\"']urn:jboss:domain:(?:community:|preview:|experimental:)?(\\d+)\\.(\\d+)[\"']");

private OfflineServerVersion() {
// avoid instantiation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public class OfflineServerVersionTest {
private static final String WFLY27_ROOT = "20.0";
private static final String WFLY28_ROOT = "21.0";

private static final String COMMUNITY = "community";
private static final String PREVIEW = "preview";
private static final String EXPERIMENTAL = "experimental";

@Rule
public final TemporaryFolder tmp = new TemporaryFolder();

Expand Down Expand Up @@ -196,6 +200,23 @@ public void discoverStandaloneXml_wfly28() throws IOException {
test(ServerVersion.VERSION_21_0_0, STANDALONE_XML, WFLY28_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverStandaloneXml_wfly34_community() throws IOException {
test(ServerVersion.VERSION_20_0_0, STANDALONE_XML, COMMUNITY, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverStandaloneXml_wfly34_experimental() throws IOException {
// Doesn't currently exist but verify it can be parsed correctly.
test(ServerVersion.VERSION_20_0_0, STANDALONE_XML, EXPERIMENTAL, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverStandaloneXml_wfly34_preview() throws IOException {
// Doesn't currently exist but verify it can be parsed correctly.
test(ServerVersion.VERSION_20_0_0, STANDALONE_XML, PREVIEW, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverHostXml_eap6() throws IOException {
test(ServerVersion.VERSION_1_7_0, HOST_XML, EAP6_ROOT, EAP6_LOGGING, EAP6_EE);
Expand Down Expand Up @@ -296,6 +317,23 @@ public void discoverHostXml_wfly28() throws IOException {
test(ServerVersion.VERSION_21_0_0, HOST_XML, WFLY28_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverHostXml_wfly34_community() throws IOException {
test(ServerVersion.VERSION_20_0_0, HOST_XML, COMMUNITY, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
Copy link
Collaborator

@jbliznak jbliznak Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just note: the version of root element does not correspond to the test target but we will be updating supported WF versions in next PR so we might fix it there later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 there is no guarantee that the schema version will even be updated on a major WildFly version so many WildFly versions will share the same schema version even if they have distinct model versions.

}

@Test
public void discoverHostXml_wfly34_preview() throws IOException {
// Doesn't currently exist but verify it can be parsed correctly.
test(ServerVersion.VERSION_20_0_0, HOST_XML, PREVIEW, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverHostXml_wfly34_experimental() throws IOException {
// Doesn't currently exist but verify it can be parsed correctly.
test(ServerVersion.VERSION_20_0_0, HOST_XML, EXPERIMENTAL, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverDomainXml_eap6() throws IOException {
test(ServerVersion.VERSION_1_7_0, DOMAIN_XML, EAP6_ROOT, EAP6_LOGGING, EAP6_EE);
Expand Down Expand Up @@ -396,10 +434,33 @@ public void discoverDomainXml_wfly28() throws IOException {
test(ServerVersion.VERSION_21_0_0, DOMAIN_XML, WFLY28_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverDomainXml_wfly34_community() throws IOException {
test(ServerVersion.VERSION_20_0_0, DOMAIN_XML, COMMUNITY, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverDomainXml_wfly34_preview() throws IOException {
// Doesn't currently exist but verify it can be parsed correctly.
test(ServerVersion.VERSION_20_0_0, DOMAIN_XML, PREVIEW, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

@Test
public void discoverDomainXml_wfly34_experimental() throws IOException {
// Doesn't currently exist but verify it can be parsed correctly.
test(ServerVersion.VERSION_20_0_0, DOMAIN_XML, EXPERIMENTAL, WFLY27_ROOT, EAP7_LOGGING, EAP8_EE);
}

private void test(ServerVersion expected, String xmlPattern,
String rootVersion, String loggingVersion, String eeVersion) throws IOException {
test(expected, xmlPattern, null, rootVersion, loggingVersion, eeVersion);
}

private void test(ServerVersion expected, String xmlPattern, String stability,
String rootVersion, String loggingVersion, String eeVersion) throws IOException {
String version = stability == null ? rootVersion : stability + ":" + rootVersion;
String xml = xmlPattern
.replace("%ROOT_VERSION%", rootVersion)
.replace("%ROOT_VERSION%", version)
.replace("%LOGGING_VERSION%", loggingVersion)
.replace("%EE_VERSION%", eeVersion);

Expand Down
Loading