Fix default namespace emission 50/79550/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Jan 2019 18:19:08 +0000 (19:19 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Jan 2019 02:38:57 +0000 (03:38 +0100)
commitc946e61de9daece3bce9412187eaf7c91d406fb9
tree3dddaf10ecb27249672e83821ce63379db98d92e
parent51d445102dce25fe7ecd054f801a4b18ab9aab9f
Fix default namespace emission

When we are emitting opening a new element, we need to consult
XMLStreamWriter before we emit the element, otherwise its state
already reflects the newly-started element.

In non-repairing mode the JDK writer will accept our invocation
and update the namespace mapping, which will lead us to erroneously
assume we do not need to emit the declaration.

Since it is non-repairing, it will not emit the declaration itself,
leading to a blank document -- something for which we are actually
testing in one of our tests.

In order to improve the confidence in results, also update tests
which used only repairing factories to use both repairing and
non-repairing ones.

JIRA: YANGTOOLS-801
Change-Id: I6975cf21121f7a8f92056b5b49b31d53b685dc0f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 706aaed3e21eb3c5d080ee974f27b9348c3d2e92)
12 files changed:
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XMLStreamNormalizedNodeStreamWriter.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug5446Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8745Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8803Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/DOMSourceXMLStreamReaderTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodeXmlTranslationTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodesToXmlTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemaOrderedNormalizedNodeWriterTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemalessXMLStreamNormalizedNodeStreamWriterTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/TestFactories.java [new file with mode: 0644]
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLSerializationTest.java