Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / sal-netconf-connector / src / test / java / org / opendaylight / netconf / sal / connect / netconf / sal / NetconfDeviceTopologyAdapterTest.java
index 9397635d9ec3b31fbd34e81de441e1131a0981f5..bd416339a92ac97b7a0cba8e3a5278f024b92779 100644 (file)
@@ -17,12 +17,8 @@ import static org.mockito.Mockito.verify;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
 import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.EnumMap;
-import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import javassist.ClassPool;
@@ -72,7 +68,7 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class NetconfDeviceTopologyAdapterTest {
 
-    private RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
+    private final RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
 
     @Mock
     private DataBroker broker;
@@ -83,10 +79,10 @@ public class NetconfDeviceTopologyAdapterTest {
     @Mock
     private NetconfNode data;
 
-    private String txIdent = "test transaction";
+    private final String txIdent = "test transaction";
 
     private SchemaContext schemaContext = null;
-    private String sessionIdForReporting = "netconf-test-session1";
+    private final String sessionIdForReporting = "netconf-test-session1";
 
     private BindingTransactionChain transactionChain;
 
@@ -106,7 +102,10 @@ public class NetconfDeviceTopologyAdapterTest {
 
         doReturn(txIdent).when(writeTx).getIdentifier();
 
-        this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+        this.schemaContext = YangParserTestUtils.parseYangResources(NetconfDeviceTopologyAdapterTest.class,
+            "/schemas/network-topology@2013-10-21.yang", "/schemas/ietf-inet-types@2013-07-15.yang",
+            "/schemas/yang-ext.yang", "/schemas/netconf-node-topology.yang",
+            "/schemas/network-topology-augment-test@2016-08-08.yang");
         schemaContext.getModules();
         final SchemaService schemaService = createSchemaService();
 
@@ -118,7 +117,7 @@ public class NetconfDeviceTopologyAdapterTest {
         datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
 
         ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
-                16, 16, "CommitFutures");
+                16, 16, "CommitFutures", NetconfDeviceTopologyAdapterTest.class);
 
         concurrentDOMDataBroker = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
 
@@ -137,13 +136,13 @@ public class NetconfDeviceTopologyAdapterTest {
 
         transactionChain = dataBroker.createTransactionChain(new TransactionChainListener() {
             @Override
-            public void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction,
-                                                 Throwable cause) {
+            public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+                    final AsyncTransaction<?, ?> transaction, final Throwable cause) {
 
             }
 
             @Override
-            public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
+            public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
 
             }
         });
@@ -209,9 +208,9 @@ public class NetconfDeviceTopologyAdapterTest {
         NormalizedNode<?, ?> augmentNode = ImmutableLeafNodeBuilder.create().withValue(dataTestId)
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(netconfTestLeafQname)).build();
 
-        DOMDataWriteTransaction writeTx =  concurrentDOMDataBroker.newWriteOnlyTransaction();
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, pathToAugmentedLeaf, augmentNode);
-        writeTx.submit();
+        DOMDataWriteTransaction wtx =  concurrentDOMDataBroker.newWriteOnlyTransaction();
+        wtx.put(LogicalDatastoreType.OPERATIONAL, pathToAugmentedLeaf, augmentNode);
+        wtx.submit();
 
         adapter.updateDeviceData(true, new NetconfDeviceCapabilities());
         Optional<NormalizedNode<?, ?>> testNode = concurrentDOMDataBroker.newReadOnlyTransaction()
@@ -229,29 +228,15 @@ public class NetconfDeviceTopologyAdapterTest {
                 dataTestId, testNode.get().getValue());
     }
 
-    private List<InputStream> getYangSchemas() {
-        final List<String> schemaPaths = Arrays.asList("/schemas/network-topology@2013-10-21.yang",
-                "/schemas/ietf-inet-types@2013-07-15.yang", "/schemas/yang-ext.yang",
-                "/schemas/netconf-node-topology.yang", "/schemas/network-topology-augment-test@2016-08-08.yang");
-        final List<InputStream> schemas = new ArrayList<>();
-
-        for (String schemaPath : schemaPaths) {
-            InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
-            schemas.add(resourceAsStream);
-        }
-
-        return schemas;
-    }
-
     private SchemaService createSchemaService() {
         return new SchemaService() {
 
             @Override
-            public void addModule(Module module) {
+            public void addModule(final Module module) {
             }
 
             @Override
-            public void removeModule(Module module) {
+            public void removeModule(final Module module) {
 
             }