Fix notification namespace reference 49/105849/4
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 5 May 2023 23:04:19 +0000 (01:04 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 6 May 2023 09:37:29 +0000 (11:37 +0200)
The code is getting confused here -- it is using the capability URN
instead of namespace URN. Introduce constant to fix that up.

This also fixes the obviously wrong test cases introduced as part of
Ieae248057d890071c6ac5b05b22f1a05a0a98b0c.

JIRA: NETCONF-1018
Change-Id: I4976c24c2e16f11823a64a0ca152ca144d3557a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
plugins/netconf-server-mdsal/src/test/java/org/opendaylight/netconf/server/mdsal/notifications/NotificationsTransformUtilTest.java
protocol/netconf-api/src/main/java/org/opendaylight/netconf/api/messages/NotificationMessage.java
protocol/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlNetconfConstants.java
protocol/netconf-api/src/test/java/org/opendaylight/netconf/api/messages/NotificationMessageTest.java
protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/spi/SubtreeFilter.java
protocol/netconf-test-util/src/main/resources/subtree/notification/0/post-filter.xml
protocol/netconf-test-util/src/main/resources/subtree/notification/0/pre-filter.xml
protocol/netconf-test-util/src/main/resources/subtree/notification/1/pre-filter.xml
protocol/netconf-test-util/src/main/resources/subtree/notification/2/pre-filter.xml
protocol/netconf-test-util/src/main/resources/subtree/notification/3/pre-filter.xml
protocol/netconf-test-util/src/main/resources/subtree/notification/4/pre-filter.xml

index e7cad2869ece7c80238242401cc558c29ef4f5c7..6cf5268064654752a5237f5b2602d9ac44490c61 100644 (file)
@@ -43,7 +43,7 @@ public class NotificationsTransformUtilTest {
         """;
 
     private static final String EXPECTED_NOTIFICATION =
-        "<notification xmlns=\"urn:ietf:params:netconf:capability:notification:1.0\">\n"
+        "<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">\n"
         + INNER_NOTIFICATION
         + "    <eventTime>" + NotificationMessage.RFC3339_DATE_FORMATTER.apply(EVENT_TIME) + "</eventTime>\n"
         + "</notification>\n";
index 8a9b9b9e64599d85997c2eaa3f4b5c87a08f40a5..f7b31d8442c2634e7b4ed3492d90adf7632f31ac 100644 (file)
@@ -195,12 +195,12 @@ public final class NotificationMessage extends NetconfMessage {
 
         final Element baseNotification = notificationContent.getDocumentElement();
         final Element entireNotification = notificationContent.createElementNS(
-            XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_NOTIFICATION_1_0,
+            XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0,
             XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME);
         entireNotification.appendChild(baseNotification);
 
         final Element eventTimeElement = notificationContent.createElementNS(
-            XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_NOTIFICATION_1_0, XmlNetconfConstants.EVENT_TIME);
+            XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0, XmlNetconfConstants.EVENT_TIME);
         eventTimeElement.setTextContent(RFC3339_DATE_FORMATTER.apply(eventTime));
         entireNotification.appendChild(eventTimeElement);
 
index 803e7df055a0e7262c04157c3ed01e31b31feafa..602917ef71a811a1d513e23bfc6f3cfac99991ee 100644 (file)
@@ -38,6 +38,9 @@ public final class XmlNetconfConstants {
     public static final String URN_IETF_PARAMS_NETCONF_BASE_1_0 = "urn:ietf:params:netconf:base:1.0";
     public static final String URN_IETF_PARAMS_NETCONF_BASE_1_1 = "urn:ietf:params:netconf:base:1.1";
     public static final String URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0 = "urn:ietf:params:xml:ns:netconf:exi:1.0";
+    public static final String URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0 =
+        "urn:ietf:params:xml:ns:netconf:notification:1.0";
+
     public static final String URN_IETF_PARAMS_NETCONF_CAPABILITY_NOTIFICATION_1_0 =
             "urn:ietf:params:netconf:capability:notification:1.0";
     public static final String URN_IETF_PARAMS_NETCONF_CAPABILITY_ROLLBACK_ON_ERROR_1_0 =
index f8a9ee8f15d93b1618e724d4781b3031c80c8a81..95f0b0840709732efc76e13b0d9ad79e8e0f9ae5 100644 (file)
@@ -30,7 +30,7 @@ public class NotificationMessageTest {
         final NotificationMessage netconfNotification = new NotificationMessage(document, eventTime);
         final Document resultDoc = netconfNotification.getDocument();
         final NodeList nodeList = resultDoc.getElementsByTagNameNS(
-            "urn:ietf:params:netconf:capability:notification:1.0", "notification");
+            "urn:ietf:params:xml:ns:netconf:notification:1.0", "notification");
 
         assertNotNull(nodeList);
         // expected only the one NOTIFICATION tag
@@ -38,7 +38,7 @@ public class NotificationMessageTest {
 
         final Element entireNotification = (Element) nodeList.item(0);
         final NodeList childNodes = entireNotification.getElementsByTagNameNS(
-            "urn:ietf:params:netconf:capability:notification:1.0", "eventTime");
+            "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime");
 
         assertNotNull(childNodes);
         // expected only the one EVENT_TIME tag
index c4234953c15b10b98dff66248e2e35c15da4725f..3db13d873de8c1f910c6ee1712e6a45d3316d998 100644 (file)
@@ -76,8 +76,10 @@ public final class SubtreeFilter {
     }
 
     private static void removeEventTimeNode(final Document document) {
-        final Node eventTimeNode = document.getDocumentElement().getElementsByTagNameNS(XmlNetconfConstants
-                .URN_IETF_PARAMS_NETCONF_CAPABILITY_NOTIFICATION_1_0, XmlNetconfConstants.EVENT_TIME).item(0);
+        final Node eventTimeNode = document.getDocumentElement()
+            .getElementsByTagNameNS(
+                XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_NOTIFICATION_1_0, XmlNetconfConstants.EVENT_TIME)
+            .item(0);
         document.getDocumentElement().removeChild(eventTimeNode);
     }
 
index 9f1667a4c837465e0f59a0f1d217fca46f8ecf95..aa78832aff4155560940021ad15a63cfee6c34fb 100644 (file)
@@ -9,6 +9,3 @@
     <username>admin</username>
     <session-id>2</session-id>
 </netconf-session-end>
-
-
-
index af5368ea8074bf97fe4bd80abcad020b4de5d828..58c1eb0122d1ca15e3fd4d4ec87ea450eaaffee9 100644 (file)
@@ -5,7 +5,7 @@
   ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
   ~ and is available at http://www.eclipse.org/legal/epl-v10.html
   -->
-<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0">
+<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
     <netconf-session-end xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
         <username>admin</username>
         <session-id>2</session-id>
index af5368ea8074bf97fe4bd80abcad020b4de5d828..58c1eb0122d1ca15e3fd4d4ec87ea450eaaffee9 100644 (file)
@@ -5,7 +5,7 @@
   ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
   ~ and is available at http://www.eclipse.org/legal/epl-v10.html
   -->
-<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0">
+<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
     <netconf-session-end xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
         <username>admin</username>
         <session-id>2</session-id>
index 66e7b561f3104609c9e5de45b94177891a230365..8dcdb462725498b2042a9d0f3b72cc78d04f4a4b 100644 (file)
@@ -5,7 +5,7 @@
   ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
   ~ and is available at http://www.eclipse.org/legal/epl-v10.html
   -->
-<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0">
+<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
     <netconf-session-start xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
         <username>admin</username>
         <session-id>2</session-id>
index 66e7b561f3104609c9e5de45b94177891a230365..8dcdb462725498b2042a9d0f3b72cc78d04f4a4b 100644 (file)
@@ -5,7 +5,7 @@
   ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
   ~ and is available at http://www.eclipse.org/legal/epl-v10.html
   -->
-<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0">
+<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
     <netconf-session-start xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
         <username>admin</username>
         <session-id>2</session-id>
index 10f229dfb0c91788f5ff34bb249a5a8676f9107d..8f31ada32effa8b009eebf36af2a6c659ac122cf 100644 (file)
@@ -5,7 +5,7 @@
   ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
   ~ and is available at http://www.eclipse.org/legal/epl-v10.html
   -->
-<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0">
+<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
     <netconf-session-end xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
         <username>admin</username>
         <session-id>2</session-id>