Merge "Fix race condition in get/get-config netconf rpcs for config subsystem"
authorTony Tkacik <ttkacik@cisco.com>
Tue, 24 Feb 2015 08:50:15 +0000 (08:50 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 24 Feb 2015 08:50:15 +0000 (08:50 +0000)
1  2 
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java

index b1222997fb8d944eeb6f4e4b489262e082698ecc,136af5b3c6ea553cdd0cdd00bcb4aa83a821542c..356223515ab61951b6d5f1886465c329a092a300
@@@ -95,8 -95,8 +95,8 @@@ import org.opendaylight.controller.netc
  import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreService;
  import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider;
  import org.opendaylight.controller.netconf.impl.mapping.operations.DefaultCloseSession;
 +import org.opendaylight.controller.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
  import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
 -import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl;
  import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
  import org.opendaylight.controller.netconf.mapping.api.NetconfOperation;
  import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
@@@ -141,9 -141,7 +141,9 @@@ public class NetconfMappingTest extend
      @Mock
      NetconfOperationRouter netconfOperationRouter;
      @Mock
 -    NetconfOperationServiceSnapshotImpl netconfOperationServiceSnapshot;
 +    AggregatedNetconfOperationServiceFactory netconfOperationServiceSnapshot;
 +    @Mock
 +    private AutoCloseable sessionCloseable;
  
      private TransactionProvider transactionProvider;
  
  
          doReturn(getMbes()).when(this.yangStoreSnapshot).getModuleMXBeanEntryMap();
          doReturn(getModules()).when(this.yangStoreSnapshot).getModules();
 -        doNothing().when(netconfOperationServiceSnapshot).close();
  
          this.factory = new NetconfTestImplModuleFactory();
          this.factory2 = new DepTestImplModuleFactory();
          this.factory3 = new IdentityTestModuleFactory();
          factory4 = new TestImplModuleFactory();
 -
 +        doNothing().when(sessionCloseable).close();
  
          super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, this.factory, this.factory2,
                  this.factory3, factory4));
  
          edit("netconfMessages/editConfig_none.xml");
          closeSession();
 -        verify(netconfOperationServiceSnapshot).close();
 +        verify(sessionCloseable).close();
          verifyNoMoreInteractions(netconfOperationRouter);
          verifyNoMoreInteractions(netconfOperationServiceSnapshot);
      }
  
      private void closeSession() throws NetconfDocumentedException, ParserConfigurationException, SAXException,
              IOException {
 -        DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID, netconfOperationServiceSnapshot);
 +        DefaultCloseSession closeOp = new DefaultCloseSession(NETCONF_SESSION_ID, sessionCloseable);
          executeOp(closeOp, "netconfMessages/closeSession.xml");
      }
  
      }
  
      private Document get() throws NetconfDocumentedException, ParserConfigurationException, SAXException, IOException {
-         Get getOp = new Get(yangStoreSnapshot, configRegistryClient, NETCONF_SESSION_ID);
+         Get getOp = new Get(transactionProvider, yangStoreSnapshot, configRegistryClient, NETCONF_SESSION_ID);
          return executeOp(getOp, "netconfMessages/get.xml");
      }