@Test public void testIncludesWithOverriddenSubsystems() throws Exception { try { // Here we test changing the includes attribute value // Testing what happens when adding subsystems at runtime becomes a bit too hard to mock up // so we test that in ServerManagementTestCase PathAddress addr = getProfileAddress("profile-four"); ModelNode list = new ModelNode().add("profile-three"); ModelNode op = Util.getWriteAttributeOperation(addr, INCLUDES, list); MockOperationContext operationContext = getOperationContextForSubsystemIncludes( addr, new RootResourceInitializer() { @Override public void addAdditionalResources(Resource root) { Resource subsystemA = Resource.Factory.create(); root.getChild(PathElement.pathElement(PROFILE, "profile-three")) .registerChild(PathElement.pathElement(SUBSYSTEM, "a"), subsystemA); Resource subsystemB = Resource.Factory.create(); Resource profile4 = root.getChild(PathElement.pathElement(PROFILE, "profile-four")); profile4.registerChild(PathElement.pathElement(SUBSYSTEM, "a"), subsystemB); } }); ProfileResourceDefinition.createIncludesValidationHandler().execute(operationContext, op); operationContext.executeNextStep(); Assert.fail("Expected error"); } catch (OperationFailedException expected) { Assert.assertTrue(expected.getMessage().contains("164")); Assert.assertTrue(expected.getMessage().contains("'profile-four'")); Assert.assertTrue(expected.getMessage().contains("'a'")); Assert.assertTrue(expected.getMessage().contains("'profile-three'")); } }
/** Resolve expressions in the given model (if there are any) */ private ModelNode resolveExpressions(final ModelNode unresolved) { if (unresolved == null) { return null; } try { return expressionResolver.resolveExpressions(unresolved.clone()); } catch (OperationFailedException e) { // Fail throw new IllegalStateException(e.getMessage(), e); } }
public static ModelNode parseField(String name, String value, XMLStreamReader reader) throws XMLStreamException { final String trimmed = value == null ? null : value.trim(); ModelNode node; if (trimmed != null) { node = new ModelNode().set(trimmed); } else { node = new ModelNode(); } try { fieldValidator.validateParameter(name, node); } catch (OperationFailedException e) { throw new XMLStreamException(e.getFailureDescription().toString(), reader.getLocation()); } return node; }
public OperationFailedRuntimeException(OperationFailedException e) { super(e.getMessage()); }