Skip to content

Commit

Permalink
[WFCORE-6829] Add a new 'urn:jboss:domain:community:20.0' schema.
Browse files Browse the repository at this point in the history
Also update the SupportedNamespaceParsingTestCases to include stability
level tests.
  • Loading branch information
darranl committed Aug 29, 2024
1 parent e56de14 commit 1f3b1c4
Show file tree
Hide file tree
Showing 5 changed files with 3,962 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private enum Version implements Feature {
VERSION_18(18),
VERSION_19(19),
VERSION_20(20),
VERSION_20_COMMUNITY(20, Stability.COMMUNITY),
;

private final int majorVersion;
Expand All @@ -66,6 +67,10 @@ private enum Version implements Feature {
this(majorVersion, 0);
}

Version(final int majorVersion, final Stability stability) {
this(majorVersion, 0, stability);
}

Version(final int majorVersion, final int minorVersion) {
this(majorVersion, minorVersion, Stability.DEFAULT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.jboss.as.controller.parsing.ManagementXmlSchema;
Expand All @@ -23,13 +25,16 @@
import org.jboss.dmr.ModelNode;
import org.jboss.staxmapper.XMLMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.projectodd.vdx.core.XMLStreamValidationException;

/**
* Test case testing the handling on unsupported namespaces when parsing the configuration.
*
* @author <a href="mailto:[email protected]">Darran Lofthouse</a>
*/
@RunWith(Parameterized.class)
public class SupportedNamespaceParsingTestCase {

private static final String TEMPLATE = "<?xml version='1.0' encoding='UTF-8'?>" +
Expand All @@ -44,9 +49,20 @@ public class SupportedNamespaceParsingTestCase {
"urn:jboss:domain:1.5",
"urn:jboss:domain:1.6");

private final Stability testStability;

public SupportedNamespaceParsingTestCase(Stability testStability) {
this.testStability = testStability;
}

@Parameterized.Parameters
public static Iterable<Stability> stabilityLevels() {
return Arrays.asList(Stability.DEFAULT, Stability.COMMUNITY, Stability.PREVIEW, Stability.EXPERIMENTAL);
}

@Test
public void testNamespaceHandling() throws Exception {
DomainXmlSchemas xmlSchemas = new DomainXmlSchemas(Stability.DEFAULT, null, null, null);
DomainXmlSchemas xmlSchemas = new DomainXmlSchemas(testStability, null, null, null);
Set<ManagementXmlSchema> schemas = new HashSet<>();
schemas.add(xmlSchemas.getCurrent());
schemas.addAll(xmlSchemas.getAdditional());
Expand All @@ -68,9 +84,16 @@ public void testNamespaceHandling() throws Exception {
} catch (XMLStreamValidationException e) {
assertTrue("Expected error should be WFLYCTL0513" , e.getMessage().contains("WFLYCTL0513"));
}
} else {
// We expect no error if supported.
} else if (testStability.enables(current.getStability())) {
// We expect no error if supported
mapper.parseDocument(operationList, reader);
} else {
try {
mapper.parseDocument(operationList, reader);
fail(String.format("Parsing expected to fail due to unsupported stability level %s", currentNamespace));
} catch (XMLStreamException e) {
assertTrue("Expected error should be WFLYCTL0514" , e.getMessage().contains("WFLYCTL0514"));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@

import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.jboss.as.controller.parsing.ManagementXmlSchema;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.staxmapper.XMLMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.projectodd.vdx.core.XMLStreamValidationException;

/**
* Test case testing the handling on unsupported namespaces when parsing the configuration.
*
* @author <a href="mailto:[email protected]">Darran Lofthouse</a>
*/
@RunWith(Parameterized.class)
public class SupportedNamespaceParsingTestCase {

private static final String TEMPLATE = "<?xml version='1.0' encoding='UTF-8'?>" +
Expand All @@ -48,9 +53,20 @@ public class SupportedNamespaceParsingTestCase {
"urn:jboss:domain:1.5",
"urn:jboss:domain:1.6");

private final Stability testStability;

public SupportedNamespaceParsingTestCase(Stability testStability) {
this.testStability = testStability;
}

@Parameterized.Parameters
public static Iterable<Stability> stabilityLevels() {
return Arrays.asList(Stability.DEFAULT, Stability.COMMUNITY, Stability.PREVIEW, Stability.EXPERIMENTAL);
}

@Test
public void testNamespaceHandling() throws Exception {
HostXmlSchemas xmlSchemas = new HostXmlSchemas(Stability.DEFAULT, "primary", null, false, null, null, null);
HostXmlSchemas xmlSchemas = new HostXmlSchemas(testStability, "primary", null, false, null, null, null);
Set<ManagementXmlSchema> schemas = new HashSet<>();
schemas.add(xmlSchemas.getCurrent());
schemas.addAll(xmlSchemas.getAdditional());
Expand All @@ -72,9 +88,16 @@ public void testNamespaceHandling() throws Exception {
} catch (XMLStreamValidationException e) {
assertTrue("Expected error should be WFLYCTL0513" , e.getMessage().contains("WFLYCTL0513"));
}
} else {
// We expect no error if supported.
} else if (testStability.enables(current.getStability())) {
// We expect no error if supported
mapper.parseDocument(operationList, reader);
} else {
try {
mapper.parseDocument(operationList, reader);
fail(String.format("Parsing expected to fail due to unsupported stability level %s", currentNamespace));
} catch (XMLStreamException e) {
assertTrue("Expected error should be WFLYCTL0514" , e.getMessage().contains("WFLYCTL0514"));
}
}
}
}
Expand Down
Loading

0 comments on commit 1f3b1c4

Please sign in to comment.