Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / mdsal-netconf-connector / src / test / java / org / opendaylight / netconf / mdsal / connector / ops / NetconfMDSalMappingTest.java
index c23155a2b3e87f7dc568e52c84e8ec386907f7cc..ad35b0dfa55d5498815cfdf59b074a565308769d 100644 (file)
@@ -17,12 +17,8 @@ import static org.mockito.Mockito.doAnswer;
 
 import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
 import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.EnumMap;
-import java.util.List;
 import java.util.concurrent.ExecutorService;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
@@ -133,7 +129,8 @@ public class NetconfMDSalMappingTest {
         XMLUnit.setIgnoreWhitespace(true);
         XMLUnit.setIgnoreAttributeOrder(true);
 
-        this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+        this.schemaContext = YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
+            "/META-INF/yang/config@2013-04-05.yang", "/yang/mdsal-netconf-mapping-test.yang");
         schemaContext.getModules();
         final SchemaService schemaService = createSchemaService();
 
@@ -145,7 +142,7 @@ public class NetconfMDSalMappingTest {
         datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
 
         final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                16, 16, "CommitFutures");
+                16, 16, "CommitFutures", NetconfMDSalMappingTest.class);
 
         final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
         this.transactionProvider = new TransactionProvider(cdb, SESSION_ID_FOR_REPORTING);
@@ -154,7 +151,7 @@ public class NetconfMDSalMappingTest {
             final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
             final YangTextSchemaSource yangTextSchemaSource =
                     YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
-            return Futures.immediateCheckedFuture(yangTextSchemaSource);
+            return Futures.immediateFuture(yangTextSchemaSource);
 
         }).when(sourceProvider).getSource(any(SourceIdentifier.class));
 
@@ -556,7 +553,7 @@ public class NetconfMDSalMappingTest {
                         + "  </edit-config>\n"
                         + "</rpc>";
         XmlElement xe = getXmlElement(stringWithoutPrefix);
-        NodeList nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+        NodeList nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
         Assert.assertEquals(1, nodeList.getLength());
 
         String stringWithPrefix =
@@ -569,7 +566,7 @@ public class NetconfMDSalMappingTest {
                         + "</nc:rpc>";
 
         xe = getXmlElement(stringWithPrefix);
-        nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+        nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
         Assert.assertEquals(1, nodeList.getLength());
 
         String stringWithoutTarget =
@@ -582,7 +579,7 @@ public class NetconfMDSalMappingTest {
         xe = getXmlElement(stringWithoutTarget);
 
         try {
-            nodeList = editConfig.getElementsByTagName(xe, TARGET_KEY);
+            nodeList = EditConfig.getElementsByTagName(xe, TARGET_KEY);
             XmlElement.fromDomElement((Element) nodeList.item(0)).getOnlyChildElement();
             Assert.fail("Not specified target, we should fail");
         } catch (DocumentedException documentedException) {
@@ -591,7 +588,7 @@ public class NetconfMDSalMappingTest {
 
     }
 
-    private XmlElement getXmlElement(final String elementAsString) throws Exception {
+    private static XmlElement getXmlElement(final String elementAsString) throws Exception {
         Document document = XmlUtil.readXmlToDocument(elementAsString);
         Element element = document.getDocumentElement();
         return XmlElement.fromDomElement(element);
@@ -824,19 +821,6 @@ public class NetconfMDSalMappingTest {
         return response;
     }
 
-    private List<InputStream> getYangSchemas() {
-        final List<String> schemaPaths = Arrays.asList("/META-INF/yang/config@2013-04-05.yang",
-                "/yang/mdsal-netconf-mapping-test.yang");
-        final List<InputStream> schemas = new ArrayList<>();
-
-        for (final String schemaPath : schemaPaths) {
-            final InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
-            schemas.add(resourceAsStream);
-        }
-
-        return schemas;
-    }
-
     private SchemaService createSchemaService() {
         return new SchemaService() {