Remove unused XMLStreamWriterUtils.writeAttribute() method 84/79584/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Jan 2019 18:38:52 +0000 (19:38 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Jan 2019 19:53:03 +0000 (20:53 +0100)
This method is completely unused, remove it.

Change-Id: I74c5eb42a1d20464270a41329bb849dd0e5b0b0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XMLStreamWriterUtils.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlStreamUtilsTest.java

index 502531261bfc93a840d80a90d18b115e73ea77e6..61d79b17301b1f556e2d9e232475c859936c80df 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.codec.xml;
 import static com.google.common.base.Preconditions.checkArgument;
 
 import com.google.common.annotations.VisibleForTesting;
-import java.util.Map.Entry;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import org.eclipse.jdt.annotation.NonNull;
@@ -34,15 +33,6 @@ import org.slf4j.LoggerFactory;
 abstract class XMLStreamWriterUtils {
     private static final Logger LOG = LoggerFactory.getLogger(XMLStreamWriterUtils.class);
 
-    @VisibleForTesting
-    static void writeAttribute(final XMLStreamWriter writer, final Entry<QName, String> attribute,
-                               final RandomPrefix randomPrefix) throws XMLStreamException {
-        final QName key = attribute.getKey();
-        final String prefix = randomPrefix.encodePrefix(key.getNamespace());
-        writer.writeAttribute("xmlns:" + prefix, key.getNamespace().toString());
-        writer.writeAttribute(prefix, key.getNamespace().toString(), key.getLocalName(), attribute.getValue());
-    }
-
     /**
      * Write a value into a XML stream writer. This method assumes the start and end of element is
      * emitted by the caller.
index 881e566a22f8a98852c597a0750db37a1ab4c960..0114f548c7f14423d881f97e4145281bd3ea9d01 100644 (file)
@@ -16,7 +16,6 @@ import static org.junit.Assert.assertTrue;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.URI;
-import java.util.AbstractMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
@@ -24,8 +23,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -44,7 +41,6 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-import org.w3c.dom.Document;
 
 public class XmlStreamUtilsTest {
     @FunctionalInterface
@@ -70,44 +66,6 @@ public class XmlStreamUtilsTest {
         schemaContext = null;
     }
 
-    @Test
-    public void testWriteAttribute() throws Exception {
-        final ByteArrayOutputStream out = new ByteArrayOutputStream();
-        final XMLStreamWriter writer = TestFactories.DEFAULT_OUTPUT_FACTORY.createXMLStreamWriter(out);
-        writer.writeStartElement("element");
-
-        QName name = getAttrQName("namespace", "2012-12-12", "attr", Optional.of("prefix"));
-        final Map.Entry<QName, String> attributeEntry = new AbstractMap.SimpleEntry<>(name, "value");
-
-        name = getAttrQName("namespace2", "2012-12-12", "attr", Optional.empty());
-        final Map.Entry<QName, String> attributeEntryNoPrefix = new AbstractMap.SimpleEntry<>(name, "value");
-
-        final RandomPrefix randomPrefix = new RandomPrefix(null);
-        XMLStreamWriterUtils.writeAttribute(writer, attributeEntry, randomPrefix);
-        XMLStreamWriterUtils.writeAttribute(writer, attributeEntryNoPrefix, randomPrefix);
-
-        writer.writeEndElement();
-        writer.close();
-        out.close();
-
-        final String xmlAsString = new String(out.toByteArray());
-
-        final Map<String, String> mappedPrefixes = mapPrefixed(randomPrefix.getPrefixes());
-        assertEquals(2, mappedPrefixes.size());
-        final String randomPrefixValue = mappedPrefixes.get("namespace2");
-
-        final String expectedXmlAsString = "<element xmlns:a=\"namespace\" a:attr=\"value\" xmlns:" + randomPrefixValue
-                + "=\"namespace2\" " + randomPrefixValue + ":attr=\"value\"></element>";
-
-        XMLUnit.setIgnoreAttributeOrder(true);
-        final Document control = XMLUnit.buildControlDocument(expectedXmlAsString);
-        final Document test = XMLUnit.buildTestDocument(xmlAsString);
-        final Diff diff = XMLUnit.compareXML(control, test);
-
-        final boolean identical = diff.identical();
-        assertTrue("Xml differs: " + diff.toString(), identical);
-    }
-
     @Test
     public void testWriteIdentityRef() throws Exception {
         final QNameModule parent = QNameModule.create(URI.create("parent:uri"), Revision.of("2000-01-01"));
@@ -132,7 +90,7 @@ public class XmlStreamUtilsTest {
         assertTrue("Xml: " + xmlAsString + " should match: " + prefixedIdentityPattern, matcher.matches());
     }
 
-    private static String createXml(XMLStreamWriterConsumer consumer) throws XMLStreamException, IOException {
+    private static String createXml(final XMLStreamWriterConsumer consumer) throws XMLStreamException, IOException {
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
         final XMLStreamWriter writer = TestFactories.DEFAULT_OUTPUT_FACTORY.createXMLStreamWriter(out);