Java Code Examples for org.jboss.staxmapper.XMLMapper#parseDocument()
The following examples show how to use
org.jboss.staxmapper.XMLMapper#parseDocument() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jbas9020TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testFSExploded() throws Exception { final String xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<server name=\"example\" xmlns=\"urn:jboss:domain:1.0\">" + " <deployments>" + " <deployment name=\"test.war\" runtime-name=\"test-run.war\">" + " <fs-exploded path=\"deployments/test.jar\" relative-to=\"jboss.server.base.dir\"/>" + " </deployment>" + " </deployments>" + "</server>"; final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); final StandaloneXml parser = new StandaloneXml(null, null, null, null); final List<ModelNode> operationList = new ArrayList<ModelNode>(); final XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(namespace, "server"), parser); mapper.parseDocument(operationList, reader); final ModelNode content = operationList.get(1).get("content"); assertEquals(false, content.get(0).get("archive").asBoolean()); assertEquals("deployments/test.jar", content.get(0).get("path").asString()); assertEquals("jboss.server.base.dir", content.get(0).get("relative-to").asString()); }
Example 2
Source File: Jbas9020TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testFSArchive() throws Exception { final String xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<server name=\"example\" xmlns=\"urn:jboss:domain:1.0\">" + " <deployments>" + " <deployment name=\"test.war\" runtime-name=\"test-run.war\">" + " <fs-archive path=\"${jboss.home}/content/welcome.jar\"/>" + " </deployment>" + " </deployments>" + "</server>"; final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); final StandaloneXml parser = new StandaloneXml(null, null, null, null); final List<ModelNode> operationList = new ArrayList<ModelNode>(); final XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(namespace, "server"), parser); mapper.parseDocument(operationList, reader); System.out.println(operationList.get(1)); final ModelNode content = operationList.get(1).get("content"); assertEquals(true, content.get(0).get("archive").asBoolean()); assertEquals("${jboss.home}/content/welcome.jar", content.get(0).get("path").asString()); }
Example 3
Source File: Jbas9020TestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testContent() throws Exception { final String xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<server name=\"example\" xmlns=\"urn:jboss:domain:1.0\">" + " <deployments>" + " <deployment name=\"test.war\" runtime-name=\"test-run.war\">" + " <content sha1=\"1234\"/>" + " </deployment>" + " </deployments>" + "</server>"; final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); final StandaloneXml parser = new StandaloneXml(null, null, null, null); final List<ModelNode> operationList = new ArrayList<ModelNode>(); final XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(namespace, "server"), parser); mapper.parseDocument(operationList, reader); final ModelNode content = operationList.get(1).get("content"); assertArrayEquals(new byte[] { 0x12, 0x34 }, content.get(0).get("hash").asBytes()); }
Example 4
Source File: JBossAllXMLParsingProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parse(final InputStream source, final File file,final XMLMapper mapper, final JBossAllXmlParseContext context) throws DeploymentUnitProcessingException { try { final XMLInputFactory inputFactory = INPUT_FACTORY; setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE); setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(source); try { mapper.parseDocument(context, streamReader); } finally { safeClose(streamReader); } } catch (XMLStreamException e) { throw ServerLogger.ROOT_LOGGER.errorLoadingJBossXmlFile(file.getPath(), e); } }
Example 5
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testChildlessResource() throws Exception { MyParser parser = new ChildlessParser(); String xml = "<subsystem xmlns=\"" + MyParser.NAMESPACE + "\">" + " <cluster attr1=\"alice\"/>" + "</subsystem>"; StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); ModelNode subsystem = opsToModel(operations); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance() .createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 6
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testComplexAttributesStuff() throws Exception { CoreParser parser = new CoreParser(); String xml = readResource("core-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName("urn:jboss:domain:core:1.0", "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(2, operations.size()); Assert.assertEquals(2, operations.get(1).get("listeners").asList().size()); ModelNode subsystem = opsToModel(operations); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 7
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testElementParsers() throws Exception { MyParser parser = new MyParser(); String xml = readResource("elements.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(5, operations.size()); ModelNode subsystem = opsToModel(operations); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 8
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testORBSubsystem() throws Exception { IIOPSubsystemParser parser = new IIOPSubsystemParser(); String xml = readResource("orb-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName("urn:jboss:domain:orb-test:1.0", "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(1, operations.size()); ModelNode subsystem = opsToModel(operations); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 9
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testServerWithComplexAttributeParser() throws Exception { ServerParser parser = new ServerParser(); String xml = readResource("server-complex-attribute.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(5, operations.size()); ModelNode subsystem = opsToModel(operations); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 10
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testMail() throws Exception { MyParser parser = new MailParser(); String xml = readResource("mail-parser.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(4, operations.size()); ModelNode subsystem = opsToModel(operations); ModelNode propsModel = subsystem.get("mail-session", "custom"); assertTrue("Model should be defined", propsModel.has(MyParser.WRAPPED_PROPERTIES.getName())); Map<String,String> props = MyParser.WRAPPED_PROPERTIES.unwrap(ExpressionResolver.TEST_RESOLVER, propsModel); Assert.assertEquals(0, props.size()); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 11
Source File: SystemPropertiesParsingTest.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSystemPropertyAlreadyExistIsCalled() throws Exception { // assign two properties in the system System.setProperty("org.jboss.as.server.parsing.test", "test-value"); System.setProperty("org.jboss.as.server.parsing.secret", "super-secret-value"); System.setProperty("org.jboss.as.server.parsing.secret-nested", "super-secret-value"); try { final String xml = "<?xml version='1.0' encoding='UTF-8'?>" + "<server name=\"example\" xmlns=\"urn:jboss:domain:8.0\">" + " <system-properties>\n" + " <property name=\"org.jboss.as.server.parsing.secret\" value=\"${VAULT::vb::password::1}\"/>\n" + " <property name=\"org.jboss.as.server.parsing.secret-nested\" value=\"${VAULT::vb::${not-found:password}::1}\"/>\n" + " <property name=\"org.jboss.as.server.parsing.test\" value=\"other-value\"/>\n" + " </system-properties>\n" + "</server>"; final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); final ExtensionRegistry extensionRegistry = new ExtensionRegistry(ProcessType.STANDALONE_SERVER, new RunningModeControl(RunningMode.NORMAL), null, null, null, RuntimeHostControllerInfoAccessor.SERVER); final StandaloneXml parser = new StandaloneXml(null, null, extensionRegistry); final List<ModelNode> operationList = new ArrayList<>(); final XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(namespace, "server"), parser); mapper.parseDocument(operationList, reader); // assert the method is called only once for test Mockito.verify(mockedLogger, Mockito.times(1)).systemPropertyAlreadyExist(Mockito.anyString()); Mockito.verify(mockedLogger, Mockito.times(1)).systemPropertyAlreadyExist(Mockito.eq("org.jboss.as.server.parsing.test")); } finally { System.clearProperty("org.jboss.as.server.parsing.test"); System.clearProperty("org.jboss.as.server.parsing.secret"); System.clearProperty("org.jboss.as.server.parsing.secret-nested"); } }
Example 12
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testServerParser() throws Exception { ServerParser parser = new ServerParser(); String xml = readResource("server-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(4, operations.size()); ModelNode subsystem = opsToModel(operations); ModelNode server = subsystem.get("server", "default"); ModelNode interceptors = MyParser.INTERCEPTORS.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, server); Assert.assertEquals("Model type should be list", ModelType.LIST, interceptors.getType()); Assert.assertEquals("List should have 0 elements", 0, interceptors.asList().size()); ModelNode complexList = MyParser.COMPLEX_LIST.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, server); //this one should be undefined Assert.assertTrue("Should be empty", !complexList.isDefined()); ModelNode complexListWithDefault = MyParser.COMPLEX_LIST_WITH_DEFAULT.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, server); //this one should be undefined Assert.assertEquals("Model type should be list", ModelType.LIST, complexListWithDefault.getType()); Assert.assertEquals("List should have 1 elements", 1, complexListWithDefault.asList().size()); /*List<ModelNode> unwrapped = MyParser.COMPLEX_LIST_WITH_DEFAULT.unwrap(ExpressionResolver.TEST_RESOLVER, server); //this one should be undefined Assert.assertEquals("it should contain one element", 1, unwrapped.size());*/ StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 13
Source File: AbstractMgmtTestBase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static List<ModelNode> xmlToModelOperations(String xml, String nameSpaceUriString, XMLElementReader<List<ModelNode>> parser) throws Exception { XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(nameSpaceUriString, "subsystem"), parser); StringReader strReader = new StringReader(xml); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> newList = new ArrayList<ModelNode>(); mapper.parseDocument(newList, reader); return newList; }
Example 14
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSimpleParser() throws Exception { MyParser parser = new MyParser(); String xml = readResource("simple-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); Assert.assertEquals(4, operations.size()); ModelNode subsystem = opsToModel(operations); ModelNode resource = subsystem.get("resource","foo"); ModelNode complexMap = MyParser.COMPLEX_MAP.resolveModelAttribute(ExpressionResolver.TEST_RESOLVER, resource); Assert.assertEquals("Model type should be map", ModelType.OBJECT, complexMap.getType()); Assert.assertEquals("Map should have 3 elements", 3, complexMap.asList().size()); Assert.assertEquals("some.class1", complexMap.get("key1", "name").asString()); Assert.assertEquals("some.class2", complexMap.get("key2", "name").asString()); Assert.assertEquals("some.module3", complexMap.get("key3", "module").asString()); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 15
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test(expected = XMLStreamException.class) public void testInvalidGroups() throws Exception { MyParser parser = new AttributeGroupParser(); String xml = "<subsystem xmlns=\"" + MyParser.NAMESPACE + "\">" + " <invalid/>" + "</subsystem>"; StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); }
Example 16
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test(expected = XMLStreamValidationException.class) public void testInvalidMultipleObjectTypes() throws Exception { MyParser parser = new AttributeGroupParser(); String xml = readResource("invalid-multiple-object-type-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); }
Example 17
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test(expected = XMLStreamValidationException.class) public void testInvalidMultipleGroups() throws Exception { MyParser parser = new AttributeGroupParser(); String xml = readResource("invalid-multiple-groups-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); }
Example 18
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testGroups() throws Exception { MyParser parser = new AttributeGroupParser(); String xml = readResource("groups-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); ModelNode subsystem = opsToModel(operations); assertEquals("bar", subsystem.get("resource", "foo", "cluster-attr1").asString()); assertEquals("baz", subsystem.get("resource", "foo", "cluster-attr2").asString()); assertEquals("alice", subsystem.get("resource", "foo", "security-my-attr1").asString()); assertEquals("bob", subsystem.get("resource", "foo", "security-my-attr2").asString()); assertEquals("val", subsystem.get("resource", "foo", "props", "prop").asString()); assertEquals("val", subsystem.get("resource", "foo", "wrapped-properties", "prop").asString()); assertEquals("bar2", subsystem.get("resource", "foo2", "cluster-attr1").asString()); assertEquals("baz2", subsystem.get("resource", "foo2", "cluster-attr2").asString()); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance() .createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }
Example 19
Source File: PersistentResourceXMLParserTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testWrappersAndGroups() throws Exception { MyParser parser = new MyParser(); String xml = readResource("groups-wrappers-subsystem.xml"); StringReader strReader = new StringReader(xml); XMLMapper mapper = XMLMapper.Factory.create(); mapper.registerRootElement(new QName(MyParser.NAMESPACE, "subsystem"), parser); XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader)); List<ModelNode> operations = new ArrayList<>(); mapper.parseDocument(operations, reader); ModelNode subsystem = opsToModel(operations); assertEquals("bar", subsystem.get("resource", "foo", "cluster-attr1").asString()); assertEquals("baz", subsystem.get("resource", "foo", "cluster-attr2").asString()); assertEquals("alice", subsystem.get("resource", "foo", "security-my-attr1").asString()); assertEquals("bob", subsystem.get("resource", "foo", "security-my-attr2").asString()); assertEquals("bar2", subsystem.get("resource", "foo2", "cluster-attr1").asString()); assertEquals("baz2", subsystem.get("resource", "foo2", "cluster-attr2").asString()); StringWriter stringWriter = new StringWriter(); XMLExtendedStreamWriter xmlStreamWriter = createXMLStreamWriter(XMLOutputFactory.newInstance() .createXMLStreamWriter(stringWriter)); SubsystemMarshallingContext context = new SubsystemMarshallingContext(subsystem, xmlStreamWriter); mapper.deparseDocument(parser, context, xmlStreamWriter); String out = stringWriter.toString(); Assert.assertEquals(normalizeXML(xml), normalizeXML(out)); }