Skip to content

Commit

Permalink
[WFLY-2218] Renable the xts transformers test, and some fixes to the …
Browse files Browse the repository at this point in the history
…transformers
  • Loading branch information
kabir committed Oct 25, 2013
1 parent d5619f7 commit f325111
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"model-description" => {
"description" => "The configuration of the XST subsystem.",
"attributes" => {
"url" => {
"type" => STRING,
"description" => "If set configures a remote coordinator service to be used when an XTS client start a transaction.",
"expressions-allowed" => true,
"nillable" => true,
"min-length" => 1L,
"max-length" => 2147483647L
},
"xts-environment" => {
"type" => OBJECT,
"description" => "The XTS environment configuration.",
"expressions-allowed" => false,
"nillable" => true,
"deprecated" => {
"since" => "1.1.0",
"reason" => "Deprecated since it was complex attribute and now has replacement in attribute 'url'"
},
"value-type" => {"url" => {
"type" => STRING,
"description" => "If set configures a remote coordinator service to be used when an XTS client start a transaction.",
"expressions-allowed" => true,
"nillable" => true,
"min-length" => 1L,
"max-length" => 2147483647L
}}
}
},
"operations" => undefined,
"children" => {}
},
"address" => [("subsystem" => "xts")]
}
3 changes: 2 additions & 1 deletion xts/src/main/java/org/jboss/as/xts/XTSExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ protected boolean isValueDiscardable(PathAddress address, String attributeName,
return attributeValue.isDefined() && attributeValue.equals(XTSSubsystemDefinition.HOST_NAME.getDefaultValue());
}
}, XTSSubsystemDefinition.HOST_NAME)
.addRejectCheck(RejectAttributeChecker.DEFINED, XTSSubsystemDefinition.HOST_NAME)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION)
.addRejectCheck(RejectAttributeChecker.DEFINED, XTSSubsystemDefinition.HOST_NAME, XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION)
.end();

TransformationDescription.Tools.register(builder.build(), subsystem, ModelVersion.create(1, 1, 0));
Expand Down
107 changes: 57 additions & 50 deletions xts/src/test/java/org/jboss/as/xts/XTSSubsystemTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@

import java.io.IOException;

import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.model.test.ModelTestControllerVersion;
import org.jboss.as.model.test.OperationFixer;
import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
import org.jboss.as.subsystem.test.AdditionalInitialization;
import org.jboss.as.subsystem.test.KernelServices;
import org.jboss.as.subsystem.test.KernelServicesBuilder;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;
import org.junit.Test;

/**
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
Expand All @@ -38,54 +49,50 @@ public XTSSubsystemTestCase() {
protected String getSubsystemXml() throws IOException {
return readResource("subsystem.xml");
}
//TODO These cannot work due to problems in the legacydescription
//This can only work if we use the legacy classloader to load up everything
//There is a problem with how the descriptions for ObjectTypeDefinition play with the current ones which are used for testing
//The old resource bundle misses a key which was never used in the old version, while the tests use the new ObjectTypeDefinition
//which try to look for that key
// @Test
// public void testBoot712() throws Exception {
// //Override the core model version to make sure that our custom transformer for model version 1.0.0 running on 7.1.2 kicks in
// testBootOldVersion("7.1.2.Final");
// }
//
// @Test
// public void testBoot713() throws Exception {
// //The model version has not changed, make sure we can boot 7.1.3 with the current config
// testBootOldVersion("7.1.3.Final");
// }
//
// private void testBootOldVersion(String asVersion) throws Exception {
//
// String subsystemXml = readResource("subsystem.xml");
// ModelVersion modelVersion = ModelVersion.create(1, 1, 0);
// //Use the non-runtime version of the extension which will happen on the HC
// KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
// .setSubsystemXml(subsystemXml);
//
// // Add legacy subsystems
// builder.createLegacyKernelServicesBuilder(new AdditionalInitialization() {
// @Override
// protected RunningMode getRunningMode() {
// return RunningMode.ADMIN_ONLY;
// }
//
// @Override
// protected boolean isValidateOperations() {
// //There is a problem with how the descriptions for ObjectTypeDefinition play with the current ones which are used for testing
// //The old resource bundle misses a key which was never used in the old version, while the tests use the new ObjectTypeDefinition
// //which try to look for that key
// return false;
// }
//
// }, modelVersion)
// .addMavenResourceURL("org.jboss.as:jboss-as-xts:" + asVersion);
//
// KernelServices mainServices = builder.build();
// KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
// Assert.assertTrue(mainServices.isSuccessfulBoot());
// Assert.assertTrue(legacyServices.isSuccessfulBoot());
//
// checkSubsystemModelTransformation(mainServices, modelVersion);
// }
@Test
public void testBoot712() throws Exception {
testBoot1_1_0(ModelTestControllerVersion.V7_1_2_FINAL);
}

@Test
public void testBoot713() throws Exception {
testBoot1_1_0(ModelTestControllerVersion.V7_1_2_FINAL);
}

@Test
public void testBoot720() throws Exception {
testBoot1_1_0(ModelTestControllerVersion.V7_2_0_FINAL);
}

private void testBoot1_1_0(ModelTestControllerVersion controllerVersion) throws Exception {

String subsystemXml = readResource("subsystem.xml");
ModelVersion modelVersion = ModelVersion.create(1, 1, 0);
//Use the non-runtime version of the extension which will happen on the HC
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
.setSubsystemXml(subsystemXml);


builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion)
.configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, null, new OperationFixer() {
@Override
public ModelNode fixOperation(ModelNode operation) {
String name = operation.get(ModelDescriptionConstants.OP).asString();
PathAddress addr = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
if (name.equals(ModelDescriptionConstants.ADD) && addr.size() == 1 && addr.getElement(0).equals(XTSExtension.SUBSYSTEM_PATH)) {
operation.get(ModelDescriptionConstants.HOST).set("default-host");
operation.get(XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION.getName()).set(false);
}
return operation;
}
})
.addMavenResourceURL("org.jboss.as:jboss-as-xts:" + controllerVersion.getMavenGavVersion());

KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertTrue(mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());

checkSubsystemModelTransformation(mainServices, modelVersion);
}
}
4 changes: 2 additions & 2 deletions xts/src/test/resources/org/jboss/as/xts/subsystem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@

<subsystem xmlns="urn:jboss:domain:xts:2.0">
<host name="default-host"/>
<xts-environment url="${test.expr:http://localhost:8080/ws-c11/ActivationService}"/>
<default-context-propagation enabled="true" />
<xts-environment url="http://${jboss.bind.address:127.0.0.1}:8080/ws-c11/ActivationService"/>
<default-context-propagation enabled="false"/>
</subsystem>

0 comments on commit f325111

Please sign in to comment.