package org.opendaylight.yangtools.yang.data.codec.xml;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+@RunWith(Parameterized.class)
public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
+ @Parameterized.Parameters(name = "{0}")
+ public static Collection<Object[]> data() {
+ return TestFactories.junitParameters();
+ }
+
+ private final XMLOutputFactory factory;
private QNameModule foobarModule;
private DOMSource anyxmlDomSource;
+ public SchemalessXMLStreamNormalizedNodeStreamWriterTest(final String factoryMode, final XMLOutputFactory factory) {
+ this.factory = factory;
+ }
+
@Before
- public void setup() throws URISyntaxException, ParseException {
- foobarModule = QNameModule.create(new URI("foobar-namespace"), SimpleDateFormatUtil.getRevisionFormat().parse(
- "2016-09-19"));
+ public void setup() {
+ foobarModule = QNameModule.create(URI.create("foobar-namespace"), Revision.of("2016-09-19"));
outerContainer = QName.create(foobarModule, "outer-container");
final DOMResult domResult = new DOMResult(UntrustedXML.newDocumentBuilder().newDocument());
- final XMLOutputFactory factory = XMLOutputFactory.newInstance();
- factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
-
final XMLStreamWriter xmlStreamWriter = factory.createXMLStreamWriter(domResult);
final NormalizedNodeStreamWriter schemalessXmlNormalizedNodeStreamWriter =
.build();
AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier(
- new AugmentationIdentifier(Sets.newHashSet(myDoublyKeyedList)))
+ new AugmentationIdentifier(Collections.singleton(myDoublyKeyedList)))
.withChild(myDoublyKeyedListNode).build();
ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier(
.withChild(myDoublyKeyedListAugNode).build();
AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier(
- new AugmentationIdentifier(Sets.newHashSet(myContainer3)))
+ new AugmentationIdentifier(Collections.singleton(myContainer3)))
.withChild(myContainer3Node).build();
ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier(
private static Document loadDocument(final String xmlPath) throws IOException, SAXException {
final InputStream resourceAsStream = SchemalessXMLStreamNormalizedNodeStreamWriterTest.class
.getResourceAsStream(xmlPath);
- final Document currentConfigElement = readXmlToDocument(resourceAsStream);
- Preconditions.checkNotNull(currentConfigElement);
- return currentConfigElement;
+ return requireNonNull(readXmlToDocument(resourceAsStream));
}
private static Document readXmlToDocument(final InputStream xmlContent) throws IOException, SAXException {