From f3bb0de0240648e0c4ddf73a304a5ef65bd1df29 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 5 Nov 2014 16:46:01 +0100 Subject: [PATCH] BUG-2304 Fix leafref/instanceIdentifier processing in restconf -> netconf pipeline Resolve the leafref type based on type being referenced by the xpath. Fix tests testing wrong instance identifier behavior Fix subtree filtering in netconf northbound when identityrefs are involved Change-Id: I561e0c92550dd6639a9f9fbd1909695041c378e4 Signed-off-by: Maros Marsalek --- .../mapping/NetconfMessageTransformer.java | 8 +-- .../sal/restconf/impl/RestCodec.java | 7 +-- .../sal/restconf/impl/RestconfImpl.java | 27 +++++++--- .../to/json/test/CnSnToJsonLeafrefType.java | 2 +- .../to/cnsn/test/JsonLeafrefToCnSnTest.java | 4 +- .../test/XmlAndJsonToCnSnLeafRefTest.java | 52 +++++++++++-------- .../impl/xml/to/cnsn/test/XmlToCnSnTest.java | 3 +- .../leafref/cont-augment-module.yang | 28 +++++----- .../leafref/xml/data_ref_to_not_leaf.xml | 2 +- .../test/resources/leafref/json/jsondata.json | 4 +- .../test/resources/leafref/xml/xmldata.xml | 10 ++-- .../xml-to-cnsn/leafref/leafref-module | 50 ++++++++++++++++-- .../xml-to-cnsn/leafref/xml/data.xml | 4 ++ .../netconf/impl/SubtreeFilter.java | 6 +-- .../netconf/impl/SubtreeFilterTest.java | 2 +- .../test/resources/subtree/10/post-filter.xml | 47 +++++++++++++++++ .../test/resources/subtree/10/pre-filter.xml | 52 +++++++++++++++++++ .../src/test/resources/subtree/10/request.xml | 15 ++++++ 18 files changed, 248 insertions(+), 75 deletions(-) create mode 100644 opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/post-filter.xml create mode 100644 opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/pre-filter.xml create mode 100644 opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/request.xml diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java index 02819c15c7..2971865a70 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java @@ -67,18 +67,18 @@ public class NetconfMessageTransformer implements MessageTransformer schemaForRpc = NetconfMessageTransformUtil.findSchemaForRpc(rpc, schemaContext.get()); if(schemaForRpc.isPresent()) { final DataNodeContainer schemaForGetConfig = NetconfMessageTransformUtil.createSchemaForRpc(schemaForRpc.get()); - w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaForGetConfig, codecProvider); + w3cPayload = XmlDocumentUtils.toDocument(rpcPayload, schemaContext.get(), schemaForGetConfig, codecProvider); } else { w3cPayload = toRpcRequestWithoutSchema(rpcPayload, codecProvider); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java index 665fafacc8..ceac03e3d9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java @@ -88,11 +88,6 @@ public class RestCodec { "Value is not instance of IdentityrefTypeDefinition but is {}. Therefore NULL is used as translation of - {}", input == null ? "null" : input.getClass(), String.valueOf(input)); return null; - } else if (type instanceof LeafrefTypeDefinition) { - if (input instanceof IdentityValuesDTO) { - return LEAFREF_DEFAULT_CODEC.deserialize(((IdentityValuesDTO) input).getOriginValue()); - } - return LEAFREF_DEFAULT_CODEC.deserialize(input); } else if (type instanceof InstanceIdentifierTypeDefinition) { if (input instanceof IdentityValuesDTO) { return instanceIdentifier.deserialize(input); @@ -232,7 +227,7 @@ public class RestCodec { IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0); Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint); if (module == null) { - logger.info("Module by namespace '{}' of first node in instance-identiefier was not found.", + logger.info("Module by namespace '{}' of first node in instance-identifier was not found.", valueWithNamespace.getNamespace()); logger.info("Instance-identifier will be translated as NULL for data - {}", String.valueOf(valueWithNamespace.getValue())); diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index cd860efab7..ded398a33d 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -84,7 +84,9 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition; import org.opendaylight.yangtools.yang.model.util.EmptyType; +import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder; import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder; import org.slf4j.Logger; @@ -1241,7 +1243,9 @@ public class RestconfImpl implements RestconfService { try { this.normalizeNode(nodeWrap, schema, null, mountPoint); } catch (IllegalArgumentException e) { - throw new RestconfDocumentedException(e.getMessage(), ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); + RestconfDocumentedException restconfDocumentedException = new RestconfDocumentedException(e.getMessage(), ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE); + restconfDocumentedException.addSuppressed(e); + throw restconfDocumentedException; } if (nodeWrap instanceof CompositeNodeWrapper) { return ((CompositeNodeWrapper) nodeWrap).unwrap(); @@ -1319,11 +1323,14 @@ public class RestconfImpl implements RestconfService { final Object value = simpleNode.getValue(); Object inputValue = value; TypeDefinition typeDefinition = this.typeDefinition(schema); - if ((typeDefinition instanceof IdentityrefTypeDefinition)) { - if ((value instanceof String)) { - inputValue = new IdentityValuesDTO(simpleNode.getNamespace().toString(), (String) value, null, - (String) value); - } // else value is already instance of IdentityValuesDTO + + // For leafrefs, extract the type it is pointing to + if(typeDefinition instanceof LeafrefTypeDefinition) { + typeDefinition = SchemaContextUtil.getBaseTypeForLeafRef(((LeafrefTypeDefinition) typeDefinition), mountPoint == null ? this.controllerContext.getGlobalSchema() : mountPoint.getSchemaContext(), schema); + } + + if (typeDefinition instanceof IdentityrefTypeDefinition) { + inputValue = parseToIdentityValuesDTO(simpleNode, value, inputValue); } Object outputValue = inputValue; @@ -1336,6 +1343,14 @@ public class RestconfImpl implements RestconfService { simpleNode.setValue(outputValue); } + private Object parseToIdentityValuesDTO(final SimpleNodeWrapper simpleNode, final Object value, Object inputValue) { + if ((value instanceof String)) { + inputValue = new IdentityValuesDTO(simpleNode.getNamespace().toString(), (String) value, null, + (String) value); + } // else value is already instance of IdentityValuesDTO + return inputValue; + } + private void normalizeCompositeNode(final CompositeNodeWrapper compositeNodeBuilder, final DataNodeContainer schema, final DOMMountPoint mountPoint, final QName currentAugment) { final List> children = compositeNodeBuilder.getValues(); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java index b5d3528e95..fa79fb7677 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonLeafrefType.java @@ -63,7 +63,7 @@ public class CnSnToJsonLeafrefType extends YangAndXmlAndDataSchemaLoader { @Test public void leafrefToNotLeafTest() { String json = toJson("/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml"); - validateJson(".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lf6\":\\p{Blank}*\"44.33\".*", json); + validateJson(".*\"cont-augment-module\\p{Blank}*:\\p{Blank}*lf6\":\\p{Blank}*\"44\".*", json); } /** diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java index 59696bc534..bdd74e8f96 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java @@ -51,9 +51,7 @@ public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader { } assertNotNull(lf2); - assertTrue(lf2.getValue() instanceof String); - assertEquals("121", lf2.getValue()); - + assertEquals(121, lf2.getValue()); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java index 1c8e53e69f..7b216ef1ba 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/XmlAndJsonToCnSnLeafRefTest.java @@ -12,17 +12,27 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.net.URISyntaxException; + import javax.ws.rs.WebApplicationException; + import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider; import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class XmlAndJsonToCnSnLeafRefTest extends YangAndXmlAndDataSchemaLoader { + final QName refContQName = QName.create("referenced:module", "2014-04-17", "cont"); + final QName refLf1QName = QName.create(refContQName, "lf1"); + final QName contQName = QName.create("leafref:module", "2014-04-17", "cont"); + final QName lf1QName = QName.create(contQName, "lf1"); + final QName lf2QName = QName.create(contQName, "lf2"); + final QName lf3QName = QName.create(contQName, "lf3"); + @BeforeClass public static void initialize() { dataLoad("/leafref/yang", 2, "leafref-module", "cont"); @@ -36,7 +46,11 @@ public class XmlAndJsonToCnSnLeafRefTest extends YangAndXmlAndDataSchemaLoader { CompositeNode cnSn = (CompositeNode)node; TestUtils.normalizeCompositeNode(cnSn, modules, schemaNodePath); - verifyContPredicate(cnSn, "/ns:cont/ns:lf1", "/cont/lf1", "/ns:cont/ns:lf1", "../lf1"); + + verifyContPredicate(cnSn, "lf4", YangInstanceIdentifier.builder().node(refContQName).node(refLf1QName).build()); + verifyContPredicate(cnSn, "lf2", YangInstanceIdentifier.builder().node(contQName).node(lf1QName).build()); + verifyContPredicate(cnSn, "lf3", YangInstanceIdentifier.builder().node(contQName).node(lf2QName).build()); + verifyContPredicate(cnSn, "lf5", YangInstanceIdentifier.builder().node(contQName).node(lf3QName).build()); } @Test @@ -47,31 +61,23 @@ public class XmlAndJsonToCnSnLeafRefTest extends YangAndXmlAndDataSchemaLoader { CompositeNode cnSn = (CompositeNode)node; TestUtils.normalizeCompositeNode(cnSn, modules, schemaNodePath); - verifyContPredicate(cnSn, "/leafref-module:cont/leafref-module:lf1", "/leafref-module:cont/leafref-module:lf1", - "/referenced-module:cont/referenced-module:lf1", "/leafref-module:cont/leafref-module:lf1"); + + verifyContPredicate(cnSn, "lf4", YangInstanceIdentifier.builder().node(refContQName).node(refLf1QName).build()); + verifyContPredicate(cnSn, "lf2", YangInstanceIdentifier.builder().node(contQName).node(lf1QName).build()); + verifyContPredicate(cnSn, "lf3", YangInstanceIdentifier.builder().node(contQName).node(lf2QName).build()); + verifyContPredicate(cnSn, "lf5", YangInstanceIdentifier.builder().node(contQName).node(lf3QName).build()); } - private void verifyContPredicate(CompositeNode cnSn, String... values) throws URISyntaxException { - Object lf2Value = null; - Object lf3Value = null; - Object lf4Value = null; - Object lf5Value = null; - - for (Node node : cnSn.getValue()) { - if (node.getNodeType().getLocalName().equals("lf2")) { - lf2Value = ((SimpleNode) node).getValue(); - } else if (node.getNodeType().getLocalName().equals("lf3")) { - lf3Value = ((SimpleNode) node).getValue(); - } else if (node.getNodeType().getLocalName().equals("lf4")) { - lf4Value = ((SimpleNode) node).getValue(); - } else if (node.getNodeType().getLocalName().equals("lf5")) { - lf5Value = ((SimpleNode) node).getValue(); + private void verifyContPredicate(CompositeNode cnSn, String leafName, Object value) throws URISyntaxException { + Object parsed = null; + + for (final Node node : cnSn.getValue()) { + if (node.getNodeType().getLocalName().equals(leafName)) { + parsed = node.getValue(); } } - assertEquals(values[0], lf2Value); - assertEquals(values[1], lf3Value); - assertEquals(values[2], lf4Value); - assertEquals(values[3], lf5Value); + + assertEquals(value, parsed); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java index d0af29e913..64568da769 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java @@ -54,8 +54,7 @@ public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { } assertNotNull(lf2); - assertTrue(lf2.getValue() instanceof String); - assertEquals("121", lf2.getValue()); + assertEquals(121, lf2.getValue()); } @Test diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/cont-augment-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/cont-augment-module.yang index afc23b7946..27b2dae243 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/cont-augment-module.yang +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/cont-augment-module.yang @@ -1,42 +1,42 @@ module cont-augment-module { - namespace "cont:augment:module"; + namespace "cont:augment:module"; prefix "cntaugmod"; - + import main-module {prefix mamo; revision-date 2013-12-2;} - + revision 2013-12-2 { - + } - + augment "/mamo:cont" { leaf-list lflst1 { type leafref { - path "../lf1"; + path "../mamo:lf1"; } - } - + } + leaf lf4 { type leafref { - path "../lf1"; + path "../mamo:lf1"; } } - + /* reference to not leaf element */ leaf lf6 { type leafref { path "../lflst1"; } } - + leaf lf7 { type leafref { path "../lf4"; } } } - - - + + + } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml index 10632a44af..b72d438c28 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/leafref/xml/data_ref_to_not_leaf.xml @@ -1,3 +1,3 @@ - 44.33 + 44 \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json index cbe455b33b..f4a435e3bf 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/json/jsondata.json @@ -2,7 +2,7 @@ "leafref-module:cont" : { "lf4" : "/referenced-module:cont/referenced-module:lf1", "lf2" : "/leafref-module:cont/leafref-module:lf1", - "lf3" : "/leafref-module:cont/leafref-module:lf1", - "lf5" : "/leafref-module:cont/leafref-module:lf1" + "lf3" : "/leafref-module:cont/leafref-module:lf2", + "lf5" : "/leafref-module:cont/leafref-module:lf3" } } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml index 01bf092d27..1b5ce835fc 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/leafref/xml/xmldata.xml @@ -1,6 +1,6 @@ - - /ns:cont/ns:lf1 - /ns:cont/ns:lf1 - /cont/lf1 - ../lf1 + + /nsa:cont/nsa:lf1 + /nsa:cont/nsa:lf1 + /ns:cont/ns:lf2 + /nsa:cont/nsa:lf3 diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module index 8ca9f09096..6fe770b40b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/leafref-module @@ -1,19 +1,61 @@ module leafref-module { - namespace "leafref:module"; + namespace "leafref:module"; prefix "lfrfmo"; - revision 2013-11-18 { + revision 2013-11-18 { } + identity base {} + container cont { leaf lf1 { type int32; } leaf lf2 { type leafref { - path "/cont/lf1"; + path "/cont/lf1"; + } + } + + leaf lf-ident { + type identityref { + base "lfrfmo:base"; } } + + leaf lf-ident-ref { + type leafref { + path "/cont/lf-ident"; + } + } + + leaf lf-ident-ref-relative { + type leafref { + path "../lf-ident"; + } + } + + leaf lf-ident-ref-relative-cnd { + type leafref { + path "/lfrfmo:cont/lfrfmo:lis[lfrfmo:id='abc']/lf-ident-ref"; + } + } + + + list lis { + key "id"; + + leaf id { + type string; + } + + leaf lf-ident-ref { + type leafref { + path "/cont/lf-ident"; + } + } + } + } - + } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml index 06200a69b5..c3071e5610 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/xml-to-cnsn/leafref/xml/data.xml @@ -1,4 +1,8 @@ 121 121 + a:base + a:base + a:base + a:base \ No newline at end of file diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java index 42a8bae448..8b2ca86010 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java @@ -178,10 +178,10 @@ public class SubtreeFilter { return false; } - final String unprefixedFilterContent = filter.getTextContent().substring(prefix.length()); - final String unprefixedSrcCOntnet = src.getTextContent().substring(prefix.length()); + final String unprefixedFilterContent = filter.getTextContent().substring(prefixToNamespaceOfFilter.getKey().length() + 1); + final String unprefixedSrcContnet = src.getTextContent().substring(prefixToNamespaceOfSrc.getKey().length() + 1); // Finally compare unprefixed content - return unprefixedFilterContent.equals(unprefixedSrcCOntnet); + return unprefixedFilterContent.equals(unprefixedSrcContnet); } enum MatchingResult { diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java index 5d9470750e..51dfa4b1a8 100644 --- a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java +++ b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java @@ -36,7 +36,7 @@ public class SubtreeFilterTest { @Parameters public static Collection data() { List result = new ArrayList<>(); - for (int i = 0; i <= 9; i++) { + for (int i = 0; i <= 10; i++) { result.add(new Object[]{i}); } return result; diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/post-filter.xml new file mode 100644 index 0000000000..3331cb8610 --- /dev/null +++ b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/post-filter.xml @@ -0,0 +1,47 @@ + + + + + + + prefix:sal-netconf-connector + controller-config + 1830 + 20000 + 2000 + 1.5 + admin + + prefix:dom-broker-osgi-registry + dom-broker + + + prefix:netconf-client-dispatcher + global-netconf-dispatcher + + admin +
127.0.0.1
+ + prefix:threadpool + global-netconf-processing-executor + + false + + prefix:binding-broker-osgi-registry + binding-osgi-broker + + 0 + + prefix:netty-event-executor + global-event-executor + +
+
+
+
\ No newline at end of file diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/pre-filter.xml new file mode 100644 index 0000000000..f2620bbb4d --- /dev/null +++ b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/pre-filter.xml @@ -0,0 +1,52 @@ + + + + + + + prefix:sal-netconf-connector + controller-config + 1830 + 20000 + 2000 + 1.5 + admin + + prefix:dom-broker-osgi-registry + dom-broker + + + prefix:netconf-client-dispatcher + global-netconf-dispatcher + + admin +
127.0.0.1
+ + prefix:threadpool + global-netconf-processing-executor + + false + + prefix:binding-broker-osgi-registry + binding-osgi-broker + + 0 + + prefix:netty-event-executor + global-event-executor + +
+ + prefix:shutdown + shutdown + + +
+
+
\ No newline at end of file diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/request.xml new file mode 100644 index 0000000000..259b123bdf --- /dev/null +++ b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/10/request.xml @@ -0,0 +1,15 @@ + + + + + + + + + x:sal-netconf-connector + controller-config + + + + + -- 2.36.6