Skip to content

Commit ba7004d

Browse files
committed
Update subsystem stability test to utilise SubsystemResourceXMLSchema.
1 parent ed89bc9 commit ba7004d

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

subsystem-test/tests/src/test/java/org/jboss/as/subsystem/test/stability/FooSubsystemExtension.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import org.jboss.as.controller.Extension;
1010
import org.jboss.as.controller.ExtensionContext;
11-
import org.jboss.as.controller.PersistentResourceXMLDescriptionWriter;
1211
import org.jboss.as.controller.SubsystemRegistration;
1312
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
1413
import org.jboss.as.controller.parsing.ExtensionParsingContext;
14+
import org.jboss.as.controller.persistence.xml.SubsystemResourceXMLElementWriter;
1515
import org.jboss.as.controller.registry.ManagementResourceRegistration;
1616

1717
/**
@@ -21,15 +21,15 @@ public class FooSubsystemExtension implements Extension {
2121

2222
@Override
2323
public void initialize(ExtensionContext context) {
24-
SubsystemRegistration subsystem = context.registerSubsystem(FooSubsystemResourceDefinition.SUBSYSTEM_NAME, FooSubsystemModel.CURRENT.getVersion());
24+
SubsystemRegistration subsystem = context.registerSubsystem(FooSubsystemResourceDefinition.REGISTRATION.getName(), FooSubsystemModel.CURRENT.getVersion());
2525
ManagementResourceRegistration registration = subsystem.registerSubsystemModel(new FooSubsystemResourceDefinition());
2626
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
2727

28-
subsystem.registerXMLElementWriter(new PersistentResourceXMLDescriptionWriter(FooSubsystemSchema.CURRENT.get(context.getStability())));
28+
subsystem.registerXMLElementWriter(new SubsystemResourceXMLElementWriter(FooSubsystemSchema.CURRENT.get(context.getStability()).getSubsystemXMLElement()));
2929
}
3030

3131
@Override
3232
public void initializeParsers(ExtensionParsingContext context) {
33-
context.setSubsystemXmlMappings(FooSubsystemResourceDefinition.SUBSYSTEM_NAME, EnumSet.allOf(FooSubsystemSchema.class));
33+
context.setSubsystemXmlMappings(FooSubsystemResourceDefinition.REGISTRATION.getName(), EnumSet.allOf(FooSubsystemSchema.class));
3434
}
3535
}

subsystem-test/tests/src/test/java/org/jboss/as/subsystem/test/stability/FooSubsystemResourceDefinition.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
import java.util.List;
99

1010
import org.jboss.as.controller.AttributeDefinition;
11-
import org.jboss.as.controller.PathElement;
1211
import org.jboss.as.controller.ReloadRequiredAddStepHandler;
1312
import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
1413
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
1514
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
1615
import org.jboss.as.controller.SimpleResourceDefinition;
17-
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
16+
import org.jboss.as.controller.SubsystemResourceRegistration;
1817
import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver;
1918
import org.jboss.as.controller.registry.ManagementResourceRegistration;
2019
import org.jboss.as.version.Stability;
@@ -25,8 +24,7 @@
2524
* @author Paul Ferraro
2625
*/
2726
public class FooSubsystemResourceDefinition extends SimpleResourceDefinition {
28-
static final String SUBSYSTEM_NAME = "foo";
29-
static final PathElement PATH = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME);
27+
static final SubsystemResourceRegistration REGISTRATION = SubsystemResourceRegistration.of("foo");
3028

3129
static final AttributeDefinition EXPERIMENTAL = new SimpleAttributeDefinitionBuilder("experimental", ModelType.STRING)
3230
.setRequired(false)
@@ -36,7 +34,7 @@ public class FooSubsystemResourceDefinition extends SimpleResourceDefinition {
3634
static final Collection<AttributeDefinition> ATTRIBUTES = List.of(EXPERIMENTAL);
3735

3836
FooSubsystemResourceDefinition() {
39-
super(new Parameters(PATH, NonResolvingResourceDescriptionResolver.INSTANCE)
37+
super(new Parameters(REGISTRATION.getPathElement(), NonResolvingResourceDescriptionResolver.INSTANCE)
4038
.setAddHandler(ReloadRequiredAddStepHandler.INSTANCE)
4139
.setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE));
4240
}

subsystem-test/tests/src/test/java/org/jboss/as/subsystem/test/stability/FooSubsystemSchema.java

+16-11
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,34 @@
88
import java.util.Map;
99

1010
import org.jboss.as.controller.Feature;
11-
import org.jboss.as.controller.PersistentResourceXMLDescription;
12-
import org.jboss.as.controller.PersistentSubsystemSchema;
1311
import org.jboss.as.controller.SubsystemSchema;
12+
import org.jboss.as.controller.persistence.xml.ResourceRegistrationXMLElement;
13+
import org.jboss.as.controller.persistence.xml.ResourceXMLParticleFactory;
14+
import org.jboss.as.controller.persistence.xml.SubsystemResourceRegistrationXMLElement;
15+
import org.jboss.as.controller.persistence.xml.SubsystemResourceXMLSchema;
1416
import org.jboss.as.controller.xml.VersionedNamespace;
1517
import org.jboss.as.version.Stability;
1618
import org.jboss.staxmapper.IntVersion;
1719

1820
/**
1921
* @author Paul Ferraro
2022
*/
21-
public enum FooSubsystemSchema implements PersistentSubsystemSchema<FooSubsystemSchema> {
23+
public enum FooSubsystemSchema implements SubsystemResourceXMLSchema<FooSubsystemSchema> {
2224
VERSION_1_0(1),
2325
VERSION_1_0_PREVIEW(1, Stability.PREVIEW),
2426
VERSION_1_0_EXPERIMENTAL(1, Stability.EXPERIMENTAL),
2527
;
2628
static final Map<Stability, FooSubsystemSchema> CURRENT = Feature.map(EnumSet.of(VERSION_1_0, VERSION_1_0_PREVIEW, VERSION_1_0_EXPERIMENTAL));
2729

2830
private final VersionedNamespace<IntVersion, FooSubsystemSchema> namespace;
31+
private final ResourceXMLParticleFactory factory = ResourceXMLParticleFactory.newInstance(this);
2932

3033
FooSubsystemSchema(int major) {
31-
this.namespace = SubsystemSchema.createSubsystemURN(FooSubsystemResourceDefinition.SUBSYSTEM_NAME, new IntVersion(major));
34+
this(major, Stability.DEFAULT);
3235
}
3336

3437
FooSubsystemSchema(int major, Stability stability) {
35-
this.namespace = SubsystemSchema.createSubsystemURN(FooSubsystemResourceDefinition.SUBSYSTEM_NAME, stability, new IntVersion(major));
38+
this.namespace = SubsystemSchema.createSubsystemURN(FooSubsystemResourceDefinition.REGISTRATION.getName(), stability, new IntVersion(major));
3639
}
3740

3841
@Override
@@ -41,11 +44,13 @@ public VersionedNamespace<IntVersion, FooSubsystemSchema> getNamespace() {
4144
}
4245

4346
@Override
44-
public PersistentResourceXMLDescription getXMLDescription() {
45-
PersistentResourceXMLDescription.Factory factory = PersistentResourceXMLDescription.factory(this);
46-
PersistentResourceXMLDescription.Builder builder = factory.builder(FooSubsystemResourceDefinition.PATH);
47-
builder.addAttributes(FooSubsystemResourceDefinition.ATTRIBUTES.stream());
48-
builder.addChild(factory.builder(BarResourceDefinition.REGISTRATION).addAttribute(BarResourceDefinition.TYPE).build());
49-
return builder.build();
47+
public SubsystemResourceRegistrationXMLElement getSubsystemXMLElement() {
48+
ResourceRegistrationXMLElement barElement = this.factory.namedElement(BarResourceDefinition.REGISTRATION)
49+
.addAttribute(BarResourceDefinition.TYPE)
50+
.build();
51+
return this.factory.subsystemElement(FooSubsystemResourceDefinition.REGISTRATION)
52+
.addAttributes(FooSubsystemResourceDefinition.ATTRIBUTES)
53+
.withContent(this.factory.sequence().addElement(barElement).build())
54+
.build();
5055
}
5156
}

subsystem-test/tests/src/test/java/org/jboss/as/subsystem/test/stability/MixedStabilitySubsystemTestCase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public static Iterable<FooSubsystemSchema> getParameters() {
2222
}
2323

2424
public MixedStabilitySubsystemTestCase(FooSubsystemSchema schema) {
25-
super(FooSubsystemResourceDefinition.SUBSYSTEM_NAME, new FooSubsystemExtension(), schema, FooSubsystemSchema.CURRENT.get(schema.getStability()));
25+
super(FooSubsystemResourceDefinition.REGISTRATION.getName(), new FooSubsystemExtension(), schema, FooSubsystemSchema.CURRENT.get(schema.getStability()));
2626
}
2727
}

0 commit comments

Comments
 (0)