Skip to content

Commit

Permalink
WFLY-7562 allow expressions for statistics-enabled of webservices sub…
Browse files Browse the repository at this point in the history
…system
  • Loading branch information
TomasHofman committed Nov 22, 2016
1 parent b476206 commit b8bf022
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -178,6 +179,7 @@ public void initialize(final ExtensionContext context) {

if (context.isRegisterTransformers()) {
registerTransformers1_2_0(subsystem);
registerTransformers2_0_0(subsystem);
}
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
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;
import java.util.List;

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;
Expand Down Expand Up @@ -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);
Expand All @@ -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());
}


Expand Down Expand Up @@ -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())
Expand All @@ -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<ModelNode> 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));
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2016, Red Hat Middleware LLC, and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
~
-->

<subsystem xmlns="urn:jboss:domain:webservices:2.0">
<modify-wsdl-address>true</modify-wsdl-address>
<wsdl-host>localhost</wsdl-host>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<subsystem xmlns="urn:jboss:domain:webservices:2.0">
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2016, Red Hat Middleware LLC, and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
~
-->

<subsystem xmlns="urn:jboss:domain:webservices:2.0" statistics-enabled="${ws.statistics-enabled:false}">
<modify-wsdl-address>${ws.modify-wsdl-address:true}</modify-wsdl-address>
<wsdl-host>${jboss.bind.address:localhost}</wsdl-host>
<wsdl-port>${ws.wsdl-port:9090}</wsdl-port>
Expand Down

0 comments on commit b8bf022

Please sign in to comment.