X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2FNetconfMappingTest.java;h=beb3365f1c068487ddfb5cbb70883cb81ff14776;hp=e41b174b664740c685faa041d64c208630bf21c2;hb=8eb2fc510df912207d98589b82a22d84bf8ada66;hpb=0bdf3307bc17f562c84cceeacd29f42409bfff34 diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java index e41b174b66..beb3365f1c 100644 --- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java +++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java @@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -43,22 +42,20 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; - import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.ObjectName; import javax.xml.parsers.ParserConfigurationException; - import org.custommonkey.xmlunit.AbstractNodeTester; import org.custommonkey.xmlunit.NodeTest; import org.custommonkey.xmlunit.NodeTestException; import org.custommonkey.xmlunit.NodeTester; import org.custommonkey.xmlunit.XMLAssert; import org.custommonkey.xmlunit.XMLUnit; +import org.hamcrest.CoreMatchers; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.junit.matchers.JUnitMatchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.config.api.ConflictingVersionException; @@ -121,7 +118,7 @@ import org.xml.sax.SAXException; public class NetconfMappingTest extends AbstractConfigTest { - private static final Logger logger = LoggerFactory.getLogger(NetconfMappingTest.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfMappingTest.class); private static final String INSTANCE_NAME = "instance-from-code"; private static final String NETCONF_SESSION_ID = "foo"; @@ -498,7 +495,7 @@ public class NetconfMappingTest extends AbstractConfigTest { for (int i = 0; i < TESTS_COUNT; i++) { String file = String.format(format, i + 1); - logger.info("Reading {}", file); + LOG.info("Reading {}", file); try { edit(file); } catch (NetconfDocumentedException e) { @@ -569,7 +566,7 @@ public class NetconfMappingTest extends AbstractConfigTest { } private void assertContainsString(String string, String substring) { - assertThat(string, JUnitMatchers.containsString(substring)); + assertThat(string, CoreMatchers.containsString(substring)); } private void checkEnum(final Document response) throws Exception { @@ -662,7 +659,7 @@ public class NetconfMappingTest extends AbstractConfigTest { assertEquals(8 * 4, getElementsSize(response, "inner-inner-running-data")); assertEquals(8 * 4, getElementsSize(response, "deep3")); assertEquals(8 * 4 * 2, getElementsSize(response, "list-of-strings")); - assertEquals(8, getElementsSize(response, "inner-running-data-additional")); + assertEquals(8, getElementsSize(response, "inner-running-data-additional", "urn:opendaylight:params:xml:ns:yang:controller:test:impl")); assertEquals(8, getElementsSize(response, "deep4")); // TODO assert keys @@ -693,25 +690,29 @@ public class NetconfMappingTest extends AbstractConfigTest { return response.getElementsByTagName(elementName).getLength(); } + private int getElementsSize(Document response, String elementName, String namespace) { + return response.getElementsByTagNameNS(namespace, elementName).getLength(); + } + private Document executeOp(final NetconfOperation op, final String filename) throws ParserConfigurationException, SAXException, IOException, NetconfDocumentedException { final Document request = XmlFileLoader.xmlFileToDocument(filename); - logger.debug("Executing netconf operation\n{}", XmlUtil.toString(request)); + LOG.debug("Executing netconf operation\n{}", XmlUtil.toString(request)); HandlingPriority priority = op.canHandle(request); Preconditions.checkState(priority != HandlingPriority.CANNOT_HANDLE); final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT); - logger.debug("Got response\n{}", XmlUtil.toString(response)); + LOG.debug("Got response\n{}", XmlUtil.toString(response)); return response; } private List getYangs() throws FileNotFoundException { List paths = Arrays.asList("/META-INF/yang/config.yang", "/META-INF/yang/rpc-context.yang", "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang", "/META-INF/yang/test-types.yang", - "/META-INF/yang/ietf-inet-types.yang"); + "/META-INF/yang/test-groups.yang", "/META-INF/yang/ietf-inet-types.yang"); final Collection yangDependencies = new ArrayList<>(); for (String path : paths) { final InputStream is = Preconditions