From b8bf02299ac4255abe2eb573bf5e8e74d6ac6c1f Mon Sep 17 00:00:00 2001 From: Tomas Hofman Date: Mon, 21 Nov 2016 12:01:31 +0100 Subject: [PATCH] WFLY-7562 allow expressions for statistics-enabled of webservices subsystem --- .../jboss/as/webservices/dmr/Attributes.java | 2 +- .../jboss/as/webservices/dmr/WSExtension.java | 11 +++- .../WebservicesSubsystemParserTestCase.java | 52 ++++++++++++++++++- .../as/webservices/dmr/ws-subsystem20-rt.xml | 23 ++++++++ .../as/webservices/dmr/ws-subsystem20.xml | 25 ++++++++- 5 files changed, 109 insertions(+), 4 deletions(-) diff --git a/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/Attributes.java b/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/Attributes.java index 280ab8f7a2f9..b33c01be1ad0 100644 --- a/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/Attributes.java +++ b/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/Attributes.java @@ -79,7 +79,7 @@ enum WsdlUriSchema {http, https} SimpleAttributeDefinition STATISTICS_ENABLED = new SimpleAttributeDefinitionBuilder(Constants.STATISTICS_ENABLED, ModelType.BOOLEAN) .setAllowNull(true) .setDefaultValue(new ModelNode(false)) - .setAllowExpression(false) + .setAllowExpression(true) .build(); SimpleAttributeDefinition[] SUBSYSTEM_ATTRIBUTES = {MODIFY_WSDL_ADDRESS, WSDL_HOST, WSDL_PORT, WSDL_SECURE_PORT, WSDL_URI_SCHEME, WSDL_PATH_REWRITE_RULE}; diff --git a/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSExtension.java b/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSExtension.java index b93e641ed770..a7745d23ca36 100644 --- a/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSExtension.java +++ b/webservices/server-integration/src/main/java/org/jboss/as/webservices/dmr/WSExtension.java @@ -46,6 +46,7 @@ import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; +import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.TransformationDescription; import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; @@ -73,7 +74,7 @@ public final class WSExtension implements Extension { static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); private static final String RESOURCE_NAME = WSExtension.class.getPackage().getName() + ".LocalDescriptions"; - private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(2, 0, 0); + private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(3, 0, 0); // attributes on the endpoint element static final AttributeDefinition ENDPOINT_WSDL = new SimpleAttributeDefinitionBuilder( @@ -178,6 +179,7 @@ public void initialize(final ExtensionContext context) { if (context.isRegisterTransformers()) { registerTransformers1_2_0(subsystem); + registerTransformers2_0_0(subsystem); } } @@ -198,4 +200,11 @@ private void registerTransformers1_2_0(SubsystemRegistration registration) { builder.getAttributeBuilder().setDiscard(DiscardAttributeChecker.ALWAYS, Attributes.WSDL_PATH_REWRITE_RULE); TransformationDescription.Tools.register(builder.build(), registration, version); } + + private void registerTransformers2_0_0(SubsystemRegistration registration) { + ModelVersion version = ModelVersion.create(2, 0, 0); + ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance(); + builder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, Attributes.STATISTICS_ENABLED); + TransformationDescription.Tools.register(builder.build(), registration, version); + } } diff --git a/webservices/server-integration/src/test/java/org/jboss/as/webservices/dmr/WebservicesSubsystemParserTestCase.java b/webservices/server-integration/src/test/java/org/jboss/as/webservices/dmr/WebservicesSubsystemParserTestCase.java index e1d20ef820f8..37b1116766ef 100644 --- a/webservices/server-integration/src/test/java/org/jboss/as/webservices/dmr/WebservicesSubsystemParserTestCase.java +++ b/webservices/server-integration/src/test/java/org/jboss/as/webservices/dmr/WebservicesSubsystemParserTestCase.java @@ -22,6 +22,7 @@ package org.jboss.as.webservices.dmr; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -29,8 +30,11 @@ import org.jboss.as.controller.ExpressionResolver; import org.jboss.as.controller.ModelVersion; +import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.RunningMode; +import org.jboss.as.model.test.FailedOperationTransformationConfig; import org.jboss.as.model.test.ModelTestControllerVersion; +import org.jboss.as.model.test.ModelTestUtils; import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest; import org.jboss.as.subsystem.test.AdditionalInitialization; import org.jboss.as.subsystem.test.KernelServices; @@ -106,11 +110,23 @@ public void testParseV11() throws Exception { @Test public void testParseV12() throws Exception { - //no need to do extra standardSubsystemTest("ws-subsystem12.xml") as that is default! KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT) .setSubsystemXmlResource("ws-subsystem12.xml") .build(); ModelNode model = services.readWholeModel().get("subsystem", getMainSubsystemName()); + standardSubsystemTest("ws-subsystem12.xml", false); + checkSubsystemBasics(model); + checkEndpointConfigs(model); + checkClientConfigs(model); + } + + @Test + public void testParseV20() throws Exception { + // no need to do extra standardSubsystemTest("ws-subsystem20.xml") as that is default! + KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT) + .setSubsystemXmlResource("ws-subsystem20.xml") + .build(); + ModelNode model = services.readWholeModel().get("subsystem", getMainSubsystemName()); checkSubsystemBasics(model); checkEndpointConfigs(model); checkClientConfigs(model); @@ -121,6 +137,7 @@ private void checkSubsystemBasics(ModelNode model) throws Exception { assertEquals(9443, Attributes.WSDL_SECURE_PORT.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asInt()); assertEquals("localhost", Attributes.WSDL_HOST.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asString()); assertTrue(Attributes.MODIFY_WSDL_ADDRESS.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asBoolean()); + assertFalse(Attributes.STATISTICS_ENABLED.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, model).asBoolean()); } @@ -162,6 +179,11 @@ public void testTransformersEAP640() throws Exception { testTransformers_1_2_0(ModelTestControllerVersion.EAP_6_4_0); } + @Test + public void testTransformersEAP700() throws Exception { + testRejections_2_0_0(ModelTestControllerVersion.EAP_7_0_0); + } + private void testTransformers_1_2_0(ModelTestControllerVersion controllerVersion) throws Exception { // create builder for current subsystem version KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) @@ -183,4 +205,32 @@ private void testTransformers_1_2_0(ModelTestControllerVersion controllerVersion checkSubsystemModelTransformation(mainServices, version_1_2_0); } + private void testRejections_2_0_0(ModelTestControllerVersion controllerVersion) throws Exception { + // create builder for current subsystem version + KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()); + + // create builder for legacy subsystem version + ModelVersion version_2_0_0 = ModelVersion.create(2, 0, 0); + builder.createLegacyKernelServicesBuilder(null, controllerVersion, version_2_0_0) + .addMavenResourceURL("org.jboss.eap:wildfly-webservices-server-integration:" + controllerVersion.getMavenGavVersion()) + .configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, null) + .dontPersistXml(); + + KernelServices mainServices = builder.build(); + KernelServices legacyServices = mainServices.getLegacyServices(version_2_0_0); + + Assert.assertNotNull(legacyServices); + Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot()); + Assert.assertTrue(legacyServices.isSuccessfulBoot()); + + List xmlOps = builder.parseXmlResource("ws-subsystem20.xml"); + ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_2_0_0, xmlOps, getFailedTransformationConfig()); + } + + private FailedOperationTransformationConfig getFailedTransformationConfig() { + PathAddress subsystemAddress = PathAddress.pathAddress(WSExtension.SUBSYSTEM_PATH); + return new FailedOperationTransformationConfig() + .addFailedAttribute(subsystemAddress, new FailedOperationTransformationConfig.RejectExpressionsConfig(Attributes.STATISTICS_ENABLED)); + } + } diff --git a/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20-rt.xml b/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20-rt.xml index 4be80e6378d0..22d0a9d1dc62 100644 --- a/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20-rt.xml +++ b/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20-rt.xml @@ -1,3 +1,26 @@ + + true localhost diff --git a/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20.xml b/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20.xml index e4d45cbd0ab1..220a1d5d9955 100644 --- a/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20.xml +++ b/webservices/server-integration/src/test/resources/org/jboss/as/webservices/dmr/ws-subsystem20.xml @@ -1,4 +1,27 @@ - + + + ${ws.modify-wsdl-address:true} ${jboss.bind.address:localhost} ${ws.wsdl-port:9090}