From 0c28880fd3df1ba253161b6b75f63f2d7a6e7c02 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 20 Nov 2017 14:13:31 +0100 Subject: [PATCH] YANGTOOLS-813: add parent schemapath to error report It is not immediately clear in what context the search is being made -- make sure we report parent path, too. Change-Id: I86a15b409c6241d93f24ee75cc68ff78fc067ebc Signed-off-by: Robert Varga --- .../yangtools/yang/data/codec/xml/XmlParserStream.java | 4 ++-- .../yang/data/codec/xml/StrictParsingModeTest.java | 6 +++--- .../yang/data/codec/xml/XmlToNormalizedNodesTest.java | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java b/yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java index 3da0ccafcd..bac8d12840 100644 --- a/yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java +++ b/yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java @@ -356,8 +356,8 @@ public final class XmlParserStream implements Closeable, Flushable { new URI(xmlElementNamespace)); if (childDataSchemaNodes.isEmpty()) { - checkState(!strictParsing, "Schema for node with name %s and namespace %s doesn't exist.", - xmlElementName, xmlElementNamespace); + checkState(!strictParsing, "Schema for node with name %s and namespace %s doesn't exist at %s", + xmlElementName, xmlElementNamespace, parentSchema.getPath()); skipUnknownNode(in); continue; } diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java index fd15f68ba5..070b892464 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java @@ -8,8 +8,8 @@ package org.opendaylight.yangtools.yang.data.codec.xml; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.InputStream; @@ -78,8 +78,8 @@ public class StrictParsingModeTest { xmlParser.parse(reader); fail("IllegalStateException should have been thrown because of an unknown child node."); } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Schema for node with name unknown-container-a and namespace " - + "foo doesn't exist.")); + assertEquals("Schema for node with name unknown-container-a and namespace foo doesn't exist at " + + "AbsoluteSchemaPath{path=[(foo)top-level-container]}", ex.getMessage()); } } } diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java index 9833be92bb..7414efb14e 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java @@ -304,8 +304,9 @@ public class XmlToNormalizedNodesTest { xmlParser.parse(reader); fail("IllegalStateException should have been thrown because of an unknown child node."); } catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Schema for node with name my-container-1 and namespace baz-namespace" - + " doesn't exist.")); + assertEquals("Schema for node with name my-container-1 and namespace baz-namespace doesn't exist at " + + "AbsoluteSchemaPath{path=[(baz-namespace)outer-container, (baz-namespace)my-container-1]}", + ex.getMessage()); } } -- 2.36.6