<artifactId>netconf-server-mdsal</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-test-util</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mdsal-netconf-monitoring</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- </dependency>
<!-- Applications -->
<dependency>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>netconf-test-util</artifactId>
</dependency>
</dependencies>
</project>
import org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator;
import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.w3c.dom.Document;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
assertTrue("ChunkedFramingMechanismEncoder was not installed in the Netconf pipeline",
channel.pipeline().get(NETCONF_MESSAGE_FRAME_ENCODER) instanceof ChunkedFramingMechanismEncoder);
}
-}
\ No newline at end of file
+}
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>netconf-test-util</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
import org.opendaylight.netconf.server.api.operations.NetconfOperation;
import org.opendaylight.netconf.server.api.operations.NetconfOperationChainedExecution;
-import org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.NetconfXmlUnitRecursiveQualifier;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.junit.rules.TemporaryFolder;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.opendaylight.yangtools.yang.common.ErrorSeverity;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.opendaylight.yangtools.yang.common.ErrorSeverity;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
import org.opendaylight.netconf.server.api.operations.HandlingPriority;
import org.opendaylight.netconf.server.api.operations.NetconfOperationChainedExecution;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.NoOpListenerRegistration;
import org.opendaylight.yangtools.yang.common.ErrorSeverity;
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>netconf-test-util</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>netconf-test-util</artifactId>
</dependency>
</dependencies>
import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.w3c.dom.Document;
public class NetconfClientSessionNegotiatorTest {
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.netconf.api.NetconfMessage;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
public class NetconfMessageUtilTest {
@Test
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>netconf-test-util</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactory;
import org.opendaylight.netconf.server.impl.DefaultSessionIdProvider;
import org.opendaylight.netconf.server.osgi.AggregatedNetconfOperationServiceFactory;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.CapabilitiesBuilder;
import org.opendaylight.yangtools.concepts.Registration;
import org.slf4j.Logger;
import org.junit.Test;
import org.opendaylight.netconf.api.NetconfMessage;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
public class ExiEncodeDecodeTest {
@Test
import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
public class MessageParserTest {
private NetconfMessage msg;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.netconf.test.util.XmlFileLoader;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>netconf-test-util</artifactId>
+ <name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
+package org.opendaylight.netconf.test.util;
-package org.opendaylight.netconf.util.test;
+import static java.util.Objects.requireNonNull;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.custommonkey.xmlunit.ElementNameAndTextQualifier;
import org.custommonkey.xmlunit.ElementQualifier;
import org.w3c.dom.Element;
* defaults to comparing element name and text content.
*/
public class NetconfXmlUnitRecursiveQualifier implements ElementQualifier {
-
private final ElementQualifier qualifier;
public NetconfXmlUnitRecursiveQualifier() {
- this.qualifier = new ElementNameAndTextQualifier();
+ this(new ElementNameAndTextQualifier());
}
public NetconfXmlUnitRecursiveQualifier(final ElementQualifier qualifier) {
- this.qualifier = qualifier;
+ this.qualifier = requireNonNull(qualifier);
}
@Override
- public boolean qualifyForComparison(Element currentControl,
- Element currentTest) {
+ public boolean qualifyForComparison(final Element currentControl,
+ final Element currentTest) {
return compareNodes(currentControl, currentTest);
}
@SuppressWarnings("checkstyle:IllegalCatch")
- private boolean compareNodes(Node currentControl, Node currentTest) {
+ @SuppressFBWarnings(value = "REC_CATCH_EXCEPTION")
+ private boolean compareNodes(final Node currentControl, final Node currentTest) {
try {
-
- if (!qualifier.qualifyForComparison((Element) currentControl,
- (Element) currentTest)) {
+ if (!qualifier.qualifyForComparison((Element) currentControl, (Element) currentTest)) {
return false;
}
controlNodes = currentControl.getChildNodes();
testNodes = currentTest.getChildNodes();
} else {
- return !(currentControl.hasChildNodes() || currentTest.hasChildNodes());
+ return !currentControl.hasChildNodes() && !currentTest.hasChildNodes();
}
- return (countNodesWithoutConsecutiveTextNodes(controlNodes)
- == countNodesWithoutConsecutiveTextNodes(testNodes)) && checkChildren(controlNodes, testNodes);
+ return countNodesWithoutConsecutiveTextNodes(controlNodes)
+ == countNodesWithoutConsecutiveTextNodes(testNodes) && checkChildren(controlNodes, testNodes);
} catch (Exception e) {
return false;
}
}
- private boolean checkChildren(NodeList controlNodes, NodeList testNodes) {
+ private boolean checkChildren(final NodeList controlNodes, final NodeList testNodes) {
for (int i = 0; i < controlNodes.getLength(); i++) {
boolean matchFound = false;
for (int j = 0; j < testNodes.getLength(); j++) {
return true;
}
- private static String concatenateText(Node textNode) {
+ private static String concatenateText(final Node textNode) {
StringBuilder builder = new StringBuilder();
Node next = textNode;
return builder.toString();
}
- private static int countNodesWithoutConsecutiveTextNodes(NodeList nodeList) {
+ private static int countNodesWithoutConsecutiveTextNodes(final NodeList nodeList) {
int count = 0;
boolean lastNodeWasText = false;
- final int length = nodeList.getLength();
- for (int i = 0; i < length; i++) {
+ for (int i = 0, length = nodeList.getLength(); i < length; i++) {
Node node = nodeList.item(i);
if (!lastNodeWasText || node.getNodeType() != Node.TEXT_NODE) {
count++;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.util.test;
+package org.opendaylight.netconf.test.util;
import static java.util.Objects.requireNonNull;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
-package org.opendaylight.netconf.util.test;
+package org.opendaylight.netconf.test.util;
import static org.custommonkey.xmlunit.XMLAssert.assertNodeTestPasses;
import static org.junit.Assert.assertEquals;
public final class XmlUnitUtil {
private XmlUnitUtil() {
-
+ // Hidden on purpose
}
- public static void assertContainsElementWithText(final Document doc,
- final String textToFind) throws NodeTestException {
+ public static void assertContainsElementWithText(final Document doc, final String textToFind)
+ throws NodeTestException {
NodeTest nt = new NodeTest(doc);
NodeTester tester = new AbstractNodeTester() {
<artifactId>netconf-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-generator</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-runtime-spi</artifactId>
<artifactId>xmlunit-legacy</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
</project>
<module>netconf-api</module>
<module>netconf-client</module>
<module>netconf-server</module>
+ <module>netconf-test-util</module>
<module>netconf-util</module>
<module>restconf-api</module>
</modules>