Fix default namespace emission 46/79546/3
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 01:19:01 +0000 (02:19 +0100)
commit706aaed3e21eb3c5d080ee974f27b9348c3d2e92
treeec0b2d428dd0834bb4a57369e052c6780e1134f7
parentfea3a6991aa892b676ab550393e944c3e6215ef3
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>
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