public class ModelTestUtils extends Object
| Constructor and Description |
|---|
ModelTestUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.jboss.dmr.ModelNode |
checkFailed(org.jboss.dmr.ModelNode result)
Checks that the operation failes
|
static void |
checkFailedTransformedBootOperations(ModelTestKernelServices<?> mainServices,
org.jboss.as.controller.ModelVersion modelVersion,
List<org.jboss.dmr.ModelNode> operations,
FailedOperationTransformationConfig config)
A standard test for transformers where things should be rejected.
|
static void |
checkModelAgainstDefinition(org.jboss.dmr.ModelNode model,
org.jboss.as.controller.registry.ManagementResourceRegistration rr) |
static org.jboss.dmr.ModelNode |
checkOutcome(org.jboss.dmr.ModelNode result)
Checks that the result was successful
|
static org.jboss.dmr.ModelNode |
checkResultAndGetContents(org.jboss.dmr.ModelNode result)
Checks that the result was successful and gets the real result contents
|
static void |
compare(org.jboss.dmr.ModelNode node1,
org.jboss.dmr.ModelNode node2)
Compares two models to make sure that they are the same
|
static void |
compare(org.jboss.dmr.ModelNode node1,
org.jboss.dmr.ModelNode node2,
boolean ignoreUndefined)
Compares two models to make sure that they are the same
|
static void |
compareXml(String original,
String marshalled)
Validate the marshalled xml without adjusting the namespaces for the original and marshalled xml.
|
static void |
compareXml(String original,
String marshalled,
boolean ignoreNamespace)
Validate the marshalled xml without adjusting the namespaces for the original and marshalled xml.
|
static org.jboss.dmr.ModelNode |
getSubModel(org.jboss.dmr.ModelNode model,
org.jboss.as.controller.PathAddress pathAddress) |
static org.jboss.dmr.ModelNode |
getSubModel(org.jboss.dmr.ModelNode model,
org.jboss.as.controller.PathElement pathElement) |
static List<org.jboss.as.controller.PathElement> |
moveWildcardChildrenToEnd(Set<org.jboss.as.controller.PathElement> children) |
static String |
normalizeXML(String xml)
Normalize and pretty-print XML so that it can be compared using string
compare.
|
static String |
readResource(Class<?> clazz,
String name)
Read the classpath resource with the given name and return its contents as a string.
|
static void |
resolveAndCompareModels(org.jboss.dmr.ModelNode node1,
org.jboss.dmr.ModelNode node2)
Resolve two models and compare them to make sure that they have same
content after expression resolution
|
static void |
scanForExpressionFormattedStrings(org.jboss.dmr.ModelNode model)
Scans for entries of type STRING containing expression formatted strings.
|
static void |
validateModelDescriptions(org.jboss.as.controller.PathAddress address,
org.jboss.as.controller.registry.ImmutableManagementResourceRegistration reg) |
public static String readResource(Class<?> clazz, String name) throws IOException
Class.getResource(String)name - the name of the resourceIOExceptionpublic static org.jboss.dmr.ModelNode checkResultAndGetContents(org.jboss.dmr.ModelNode result)
result - the result to checkpublic static org.jboss.dmr.ModelNode checkOutcome(org.jboss.dmr.ModelNode result)
result - the result to checkpublic static org.jboss.dmr.ModelNode checkFailed(org.jboss.dmr.ModelNode result)
result - the result to checkpublic static void validateModelDescriptions(org.jboss.as.controller.PathAddress address,
org.jboss.as.controller.registry.ImmutableManagementResourceRegistration reg)
public static void compare(org.jboss.dmr.ModelNode node1,
org.jboss.dmr.ModelNode node2)
node1 - the first modelnode2 - the second modelpublic static void resolveAndCompareModels(org.jboss.dmr.ModelNode node1,
org.jboss.dmr.ModelNode node2)
node1 - the first modelnode2 - the second modelpublic static void compare(org.jboss.dmr.ModelNode node1,
org.jboss.dmr.ModelNode node2,
boolean ignoreUndefined)
node1 - the first modelnode2 - the second modelignoreUndefined - true if keys containing undefined nodes should be ignoredpublic static String normalizeXML(String xml) throws Exception
xml - The XML to be normalizedExceptionpublic static void compareXml(String original, String marshalled) throws Exception
original - the original subsystem xmlmarshalled - the marshalled subsystem xmlExceptionpublic static void compareXml(String original, String marshalled, boolean ignoreNamespace) throws Exception
original - the original subsystem xmlmarshalled - the marshalled subsystem xmlignoreNamespace - if true the subsystem's namespace is ignored, otherwise it is taken into account when comparing the normalized xml.Exceptionpublic static org.jboss.dmr.ModelNode getSubModel(org.jboss.dmr.ModelNode model,
org.jboss.as.controller.PathElement pathElement)
public static org.jboss.dmr.ModelNode getSubModel(org.jboss.dmr.ModelNode model,
org.jboss.as.controller.PathAddress pathAddress)
public static void scanForExpressionFormattedStrings(org.jboss.dmr.ModelNode model)
model - the model to checkpublic static void checkModelAgainstDefinition(org.jboss.dmr.ModelNode model,
org.jboss.as.controller.registry.ManagementResourceRegistration rr)
public static void checkFailedTransformedBootOperations(ModelTestKernelServices<?> mainServices, org.jboss.as.controller.ModelVersion modelVersion, List<org.jboss.dmr.ModelNode> operations, FailedOperationTransformationConfig config) throws org.jboss.as.controller.OperationFailedException
A standard test for transformers where things should be rejected. Takes the operations and installs them in the main controller.
It then attempts to transform the same operations for the legacy controller, validating that expected failures take place. It then attempts to fix the operations so they can be executed in the legacy controller, since if an 'add' fails, there could be adds for children later in the list.
Internally the operations (both for the main and legacy controllers) are added to a composite so that we have
everything we need if any versions of the subsystem use capabilities and requirements. Normally this composite
will contain the original operations that have been fixed by the config. This composite is then transformed
before executing it in the legacy controller. However, in some extreme cases the one-shot transformation of the
composite intended for the legacy controller may not be possible. For these cases you can call
FailedOperationTransformationConfig.setDontTransformComposite() and the individually transformed operations
get added to the composite, which is then used as-is (without any transformation).
To configure a callback that gets executed before the composite is transformed for the legacy controller,
and executed there, you can call
FailedOperationTransformationConfig.setCallback(FailedOperationTransformationConfig.BeforeExecuteCompositeCallback).
mainServices - The main controller servicesmodelVersion - The version of the legacy controlleroperations - the operationsconfig - the configorg.jboss.as.controller.OperationFailedExceptionCopyright © 2022 JBoss by Red Hat. All rights reserved.