use of org.jboss.staxmapper.XMLExtendedStreamWriter in project wildfly-core by wildfly.
the class PersistentResourceXMLParserTestCase method testORBSubsystem.
@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));
}
use of org.jboss.staxmapper.XMLExtendedStreamWriter in project wildfly-core by wildfly.
the class ModuleConfigImpl method main.
// test
public static void main(String[] args) throws Exception {
ModuleConfigImpl module = new ModuleConfigImpl("o.r.g");
module.setProperty("jboss.api", "private");
module.setProperty("prop", VALUE);
module.setMainClass("o.r.g.MainClass");
module.addResource(new ResourceRoot("a.jar"));
module.addResource(new ResourceRoot("another.jar"));
module.addDependency(new ModuleDependency("a.module"));
module.addDependency(new ModuleDependency("another.module"));
StringWriter strWriter = new StringWriter();
XMLExtendedStreamWriter writer = create(XMLOutputFactory.newInstance().createXMLStreamWriter(strWriter));
module.writeContent(writer, module);
writer.flush();
System.out.println(strWriter.toString());
}
use of org.jboss.staxmapper.XMLExtendedStreamWriter in project wildfly-core by wildfly.
the class PersistentResourceXMLParserTestCase method testServerWithComplexAttributeParser.
@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));
}
use of org.jboss.staxmapper.XMLExtendedStreamWriter in project wildfly-core by wildfly.
the class PersistentResourceXMLParserTestCase method testElementParsers.
@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));
}
use of org.jboss.staxmapper.XMLExtendedStreamWriter in project wildfly-core by wildfly.
the class PersistentResourceXMLParserTestCase method testWrappersAndGroups.
@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));
}
Aggregations