Use DOMMountPointServiceHandler non-statically 70/71170/1
authorTom Pantelis <tompantelis@gmail.com>
Fri, 20 Apr 2018 13:30:32 +0000 (09:30 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Fri, 20 Apr 2018 13:32:32 +0000 (09:32 -0400)
Removed the static field in RestConnectorProvider and made the
DOMMountPointServiceHandler instance static temporarily for the
RestconfApplication but converts the rest of the code to reference
it non-statically. The static DOMMountPointServiceHandler will be
removed in a subsequent patch.

Change-Id: I92e98c4f8c15a8e77bc2e0b970e74e3fe56d58a5
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
25 files changed:
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestconfApplication.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/handlers/DOMMountPointServiceHandler.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/JsonNormalizedNodeBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/AbstractToPatchBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractIdentifierAwareJaxRsProvider.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/spi/AbstractNormalizedNodeBodyReader.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040Impl.java
restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/JsonBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/XmlBodyReaderTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceTest.java
restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java

index e13a2f691ed2a04769715eacf8144168cf451431..6b21b7c9adfe081922d705fd77a38252f6ccddd2 100644 (file)
@@ -9,9 +9,7 @@
 package org.opendaylight.restconf.nb.rfc8040;
 
 import com.google.common.base.Preconditions;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
@@ -33,35 +31,31 @@ public class RestConnectorProvider<T extends ServiceWrapper> implements Restconf
 
     private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class);
 
-    @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
-    private static volatile DOMMountPointServiceHandler mountPointServiceHandler;
-
     private final DOMRpcService rpcService;
     private final DOMNotificationService notificationService;
-    private final DOMMountPointService mountPointService;
     private final DOMSchemaService domSchemaService;
     private final TransactionChainHandler transactionChainHandler;
     private final DOMDataBroker dataBroker;
     private final SchemaContextHandler schemaCtxHandler;
+    private final DOMMountPointServiceHandler mountPointServiceHandler;
     private final T wrapperServices;
 
     public RestConnectorProvider(final DOMDataBroker domDataBroker, final DOMSchemaService domSchemaService,
             final DOMRpcService rpcService, final DOMNotificationService notificationService,
-            final DOMMountPointService mountPointService, final TransactionChainHandler transactionChainHandler,
-            final SchemaContextHandler schemaCtxHandler, final T wrapperServices) {
+            final TransactionChainHandler transactionChainHandler,
+            final SchemaContextHandler schemaCtxHandler, final DOMMountPointServiceHandler mountPointServiceHandler,
+            final T wrapperServices) {
         this.wrapperServices = wrapperServices;
         this.domSchemaService = Preconditions.checkNotNull(domSchemaService);
         this.rpcService = Preconditions.checkNotNull(rpcService);
         this.notificationService = Preconditions.checkNotNull(notificationService);
-        this.mountPointService = Preconditions.checkNotNull(mountPointService);
         this.transactionChainHandler = Preconditions.checkNotNull(transactionChainHandler);
         this.dataBroker = Preconditions.checkNotNull(domDataBroker);
         this.schemaCtxHandler = Preconditions.checkNotNull(schemaCtxHandler);
+        this.mountPointServiceHandler = Preconditions.checkNotNull(mountPointServiceHandler);
     }
 
     public synchronized void start() {
-        mountPointServiceHandler = new DOMMountPointServiceHandler(mountPointService);
-
         final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(dataBroker);
 
         final RpcServiceHandler rpcServiceHandler = new RpcServiceHandler(rpcService);
@@ -70,26 +64,13 @@ public class RestConnectorProvider<T extends ServiceWrapper> implements Restconf
                 new NotificationServiceHandler(notificationService);
 
         if (wrapperServices != null) {
-            wrapperServices.setHandlers(this.schemaCtxHandler, RestConnectorProvider.mountPointServiceHandler,
+            wrapperServices.setHandlers(this.schemaCtxHandler, mountPointServiceHandler,
                     transactionChainHandler, brokerHandler, rpcServiceHandler,
                     notificationServiceHandler, domSchemaService);
         }
     }
 
-    public DOMMountPointServiceHandler getMountPointServiceHandler() {
-        return mountPointServiceHandler;
-    }
-
-    /**
-     * Get current {@link DOMMountPointService} from {@link DOMMountPointServiceHandler}.
-     * @return {@link DOMMountPointService}
-     */
-    public static DOMMountPointService getMountPointService() {
-        return mountPointServiceHandler.get();
-    }
-
     @Override
     public void close() {
-        mountPointServiceHandler = null;
     }
 }
index 3c386490a4d3681974d93093f32e2bfa14354791..c8c328b0d2a7bf665070b3cf4628bbcc3e216e4f 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableSet;
 import java.util.HashSet;
 import java.util.Set;
 import javax.ws.rs.core.Application;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeJsonBodyWriter;
@@ -26,6 +27,7 @@ import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl
 
 public class RestconfApplication extends Application {
     private final SchemaContextHandler schemaContextHandler = SchemaContextHandler.instance();
+    private final DOMMountPointServiceHandler mountPointServiceHandler = DOMMountPointServiceHandler.instance();
 
     @Override
     public Set<Class<?>> getClasses() {
@@ -40,10 +42,10 @@ public class RestconfApplication extends Application {
     public Set<Object> getSingletons() {
         final Set<Object> singletons = new HashSet<>();
         singletons.add(ServicesWrapperImpl.getInstance());
-        singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler));
-        singletons.add(new JsonToPatchBodyReader(schemaContextHandler));
-        singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler));
-        singletons.add(new XmlToPatchBodyReader(schemaContextHandler));
+        singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
+        singletons.add(new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
+        singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
+        singletons.add(new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
         return singletons;
     }
 }
index c95ee3f64cf7aa54383336a4996e453647432862..e299fe071587c1690620b44669926efdd7444602 100644 (file)
@@ -14,8 +14,10 @@ import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
  * Implementation of {@link DOMMountPointServiceHandler}.
  *
  */
-public class DOMMountPointServiceHandler implements Handler<DOMMountPointService> {
-    private final DOMMountPointService domMountPointService;
+public final class DOMMountPointServiceHandler implements Handler<DOMMountPointService> {
+    private static final DOMMountPointServiceHandler INSTANCE = new DOMMountPointServiceHandler();
+
+    private DOMMountPointService domMountPointService;
 
     /**
      * Prepare mount point service for Restconf services.
@@ -23,10 +25,24 @@ public class DOMMountPointServiceHandler implements Handler<DOMMountPointService
      * @param domMountPointService
      *             mount point service
      */
-    public DOMMountPointServiceHandler(final DOMMountPointService domMountPointService) {
+    private DOMMountPointServiceHandler(final DOMMountPointService domMountPointService) {
         this.domMountPointService = Objects.requireNonNull(domMountPointService);
     }
 
+    @Deprecated
+    private DOMMountPointServiceHandler() {
+    }
+
+    @Deprecated
+    public static DOMMountPointServiceHandler instance() {
+        return INSTANCE;
+    }
+
+    public static DOMMountPointServiceHandler newInstance(DOMMountPointService domMountPointService) {
+        INSTANCE.domMountPointService = domMountPointService;
+        return INSTANCE;
+    }
+
     @Override
     public DOMMountPointService get() {
         return this.domMountPointService;
index e03f60c805cf7abcf0b60bc12fb4861451550601..37a39b62d9c3874d5e0be9ae8eb498152dc0521b 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractNormalizedNodeBodyReader;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
@@ -53,8 +54,9 @@ import org.slf4j.LoggerFactory;
 public class JsonNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReader {
     private static final Logger LOG = LoggerFactory.getLogger(JsonNormalizedNodeBodyReader.class);
 
-    public JsonNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) {
-        super(schemaContextHandler);
+    public JsonNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
+        super(schemaContextHandler, mountPointServiceHandler);
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
index a2e873a067927d82b880261e10f2dc303828ca03..62fd33a51f1f7deba2bec1373fb3d92b83898b38 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractNormalizedNodeBodyReader;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
@@ -64,8 +65,9 @@ import org.xml.sax.SAXException;
 public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReader {
     private static final Logger LOG = LoggerFactory.getLogger(XmlNormalizedNodeBodyReader.class);
 
-    public XmlNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) {
-        super(schemaContextHandler);
+    public XmlNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
+        super(schemaContextHandler, mountPointServiceHandler);
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
index 963194001e7c8fad1164b3ca0fc653b7b0c79712..5ceaf04544efe91f0086d3c2a243b47c19b1f0e4 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.patch.PatchContext;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
 
@@ -18,8 +19,9 @@ import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentif
  * @author Robert Varga
  */
 abstract class AbstractToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider<PatchContext> {
-    protected AbstractToPatchBodyReader(SchemaContextHandler schemaContextHandler) {
-        super(schemaContextHandler);
+    protected AbstractToPatchBodyReader(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
+        super(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
index 489f8e0e3277bb1c635a5207d3a6a592c9076d82..232a9a7c03ff4b5eeac6a67f2c3c8189395bab23 100644 (file)
@@ -33,9 +33,9 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchEditOperation;
 import org.opendaylight.restconf.common.patch.PatchEntity;
-import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
 import org.opendaylight.restconf.nb.rfc8040.codecs.StringModuleInstanceIdentifierCodec;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
@@ -58,8 +58,9 @@ import org.slf4j.LoggerFactory;
 public class JsonToPatchBodyReader extends AbstractToPatchBodyReader {
     private static final Logger LOG = LoggerFactory.getLogger(JsonToPatchBodyReader.class);
 
-    public JsonToPatchBodyReader(SchemaContextHandler schemaContextHandler) {
-        super(schemaContextHandler);
+    public JsonToPatchBodyReader(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
+        super(schemaContextHandler, mountPointServiceHandler);
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
@@ -89,7 +90,7 @@ public class JsonToPatchBodyReader extends AbstractToPatchBodyReader {
         try {
             return readFrom(
                     ParserIdentifier.toInstanceIdentifier(uriPath, getSchemaContext(),
-                            Optional.of(RestConnectorProvider.getMountPointService())), entityStream);
+                            Optional.fromNullable(getMountPointService())), entityStream);
         } catch (final Exception e) {
             propagateExceptionAs(e);
             return null; // no-op
index 338c605867e34178127e0376982b2fcd26387332..8364572de4874a2e2b8ca807e07375e9805eab32 100644 (file)
@@ -34,6 +34,7 @@ import org.opendaylight.restconf.common.patch.PatchEditOperation;
 import org.opendaylight.restconf.common.patch.PatchEntity;
 import org.opendaylight.restconf.nb.rfc8040.Rfc8040;
 import org.opendaylight.restconf.nb.rfc8040.codecs.StringModuleInstanceIdentifierCodec;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
@@ -67,8 +68,9 @@ public class XmlToPatchBodyReader extends AbstractToPatchBodyReader {
     private static final Logger LOG = LoggerFactory.getLogger(XmlToPatchBodyReader.class);
     private static final Splitter SLASH_SPLITTER = Splitter.on('/');
 
-    public XmlToPatchBodyReader(SchemaContextHandler schemaContextHandler) {
-        super(schemaContextHandler);
+    public XmlToPatchBodyReader(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
+        super(schemaContextHandler, mountPointServiceHandler);
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
index a3398aa7b2af47f56f815a62eaf69b752e02436b..f516e5f1d45f2882e0f599a6d6f0bfe3bc453d0a 100644 (file)
@@ -22,8 +22,9 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.MessageBodyReader;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
-import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
@@ -38,9 +39,12 @@ public abstract class AbstractIdentifierAwareJaxRsProvider<T> implements Message
     private Request request;
 
     private final SchemaContextHandler schemaContextHandler;
+    private final DOMMountPointServiceHandler mountPointServiceHandler;
 
-    protected AbstractIdentifierAwareJaxRsProvider(SchemaContextHandler schemaContextHandler) {
+    protected AbstractIdentifierAwareJaxRsProvider(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
         this.schemaContextHandler = schemaContextHandler;
+        this.mountPointServiceHandler = mountPointServiceHandler;
     }
 
     @Override
@@ -86,7 +90,7 @@ public abstract class AbstractIdentifierAwareJaxRsProvider<T> implements Message
 
     private InstanceIdentifierContext<?> getInstanceIdentifierContext() {
         return ParserIdentifier.toInstanceIdentifier(getIdentifier(), getSchemaContext(),
-                Optional.of(RestConnectorProvider.getMountPointService()));
+                Optional.fromNullable(getMountPointService()));
     }
 
     protected UriInfo getUriInfo() {
@@ -97,6 +101,10 @@ public abstract class AbstractIdentifierAwareJaxRsProvider<T> implements Message
         return schemaContextHandler.get();
     }
 
+    protected DOMMountPointService getMountPointService() {
+        return mountPointServiceHandler.get();
+    }
+
     protected boolean isPost() {
         return HttpMethod.POST.equals(this.request.getMethod());
     }
index 3e2862ee7107816d123a585909daf5daa3f1d8c0..90703bfee42eb347a5640ac4c94d6f644b470395 100644 (file)
@@ -12,6 +12,7 @@ import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 
 /**
@@ -22,8 +23,9 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 @Beta
 public abstract class AbstractNormalizedNodeBodyReader
         extends AbstractIdentifierAwareJaxRsProvider<NormalizedNodeContext> {
-    protected AbstractNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler) {
-        super(schemaContextHandler);
+    protected AbstractNormalizedNodeBodyReader(SchemaContextHandler schemaContextHandler,
+            DOMMountPointServiceHandler mountPointServiceHandler) {
+        super(schemaContextHandler, mountPointServiceHandler);
     }
 
     public final void injectParams(final UriInfo uriInfo, final Request request) {
index 52664062ec135d7091da5424a0a155b413aa7812..5efca62de73e4feba25732a261c68a3751e57ae6 100644 (file)
@@ -195,7 +195,8 @@ public class JSONRestconfServiceRfc8040Impl implements JSONRestconfService, Auto
 
         final InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
 
-        JsonToPatchBodyReader jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler);
+        JsonToPatchBodyReader jsonToPatchBodyReader =
+                new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler);
         final PatchContext context = jsonToPatchBodyReader.readFrom(uriPath, entityStream);
 
         LOG.debug("Parsed YangInstanceIdentifier: {}", context.getInstanceIdentifierContext().getInstanceIdentifier());
index 943639892e9fcc8c2f474de6f77c704bb85162a0..b8d27c5693699974b74af957a442306eb6242e0e 100644 (file)
     <argument ref="domSchemaService"/>
   </bean>
 
+  <bean id="mountPointServiceHandler" class="org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler"
+      factory-method="newInstance">
+    <argument ref="domMountPointService"/>
+  </bean>
+
   <bean id="restconfProvider" class="org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider"
           init-method="start" destroy-method="close">
     <argument ref="domDataBroker"/>
     <argument ref="domSchemaService"/>
     <argument ref="domRpcService"/>
     <argument ref="domNotificationService"/>
-    <argument ref="domMountPointService"/>
     <argument ref="transactionChainHandler"/>
     <argument ref="schemaContextHandler"/>
+    <argument ref="mountPointServiceHandler"/>
     <argument ref="wrapper"/>
   </bean>
 
@@ -70,9 +75,7 @@
       class="org.opendaylight.restconf.nb.rfc8040.rests.services.impl.JSONRestconfServiceRfc8040Impl"
       destroy-method="close">
     <argument ref="wrapper"/>
-    <argument>
-      <bean factory-ref="restconfProvider" factory-method="getMountPointServiceHandler" />
-    </argument>
+    <argument ref="mountPointServiceHandler"/>
     <argument ref="schemaContextHandler"/>
   </bean>
 
index 767f94e468f4b221babb0fd797a17e9ce6517188..c02c2d26a9be5cdd905e1286815f8aa2eb6fced3 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl;
@@ -59,8 +60,9 @@ public class RestConnectorProviderTest {
 
         final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(mockDataBroker);
         this.connectorProvider = new RestConnectorProvider<>(mockDataBroker, domSchemaService, mockRpcService,
-                mockNotificationService, mockMountPointService, transactionChainHandler,
+                mockNotificationService, transactionChainHandler,
                 SchemaContextHandler.newInstance(transactionChainHandler, domSchemaService),
+                DOMMountPointServiceHandler.newInstance(mockMountPointService),
                 ServicesWrapperImpl.getInstance());
     }
 
index aa33375b5701febaf6d7f8be19ae6852bb0188a4..578bcd7e8c23bdf10e7fa6841e5580430deb907b 100644 (file)
@@ -11,11 +11,7 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
@@ -25,7 +21,6 @@ import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
@@ -54,7 +49,7 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
 
     public XmlBodyReaderMountPointTest() throws Exception {
         super(schemaContext);
-        this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler);
+        this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -67,13 +62,6 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
         schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
-
-        final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
-        final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
-
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService);
-        when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint));
-        when(mountPoint.getSchemaContext()).thenReturn(schemaContext);
     }
 
     @Test
index 1453027ed571b2692d0c3ec2815d186dbbc53ec1..4730d31c83ba68c5d254312e0699f7d3af2ca276 100644 (file)
@@ -11,22 +11,15 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import java.io.InputStream;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
@@ -37,7 +30,7 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
 
     public JsonPatchBodyReaderMountPointTest() throws Exception {
         super(schemaContext);
-        jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler);
+        jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -48,13 +41,6 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
     @BeforeClass
     public static void initialization() {
         schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-
-        final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
-        final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
-
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService);
-        when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint));
-        when(mountPoint.getSchemaContext()).thenReturn(schemaContext);
     }
 
     @Test
index 770746ce81f8df7ba6d6307ff3ed18356c85f312..f84917da6f40ddc76ef01ed7b96910fe38a707f9 100644 (file)
@@ -11,14 +11,11 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.io.InputStream;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
@@ -32,7 +29,7 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest {
 
     public JsonPatchBodyReaderTest() throws Exception {
         super(schemaContext);
-        jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler);
+        jsonToPatchBodyReader = new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -43,7 +40,6 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest {
     @BeforeClass
     public static void initialization() {
         schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
     }
 
     @Test
index c6383310979ff181c28fe8219632e033c267cf68..cfe49159387518906164f31510efc9570999bb3b 100644 (file)
@@ -10,22 +10,15 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import com.google.common.base.Optional;
 import java.io.InputStream;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
@@ -36,7 +29,7 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
 
     public XmlPatchBodyReaderMountPointTest() throws Exception {
         super(schemaContext);
-        xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler);
+        xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -47,13 +40,6 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
     @BeforeClass
     public static void initialization() {
         schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-
-        final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
-        final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
-
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mountPointService);
-        when(mountPointService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountPoint));
-        when(mountPoint.getSchemaContext()).thenReturn(schemaContext);
     }
 
     @Test
index f98f576a9581daa1ccc91b652f650b6b7e36bcfd..2733f9001ab61eae860aeacf1318e62ecf703d2f 100644 (file)
@@ -10,14 +10,11 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.io.InputStream;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
@@ -31,7 +28,7 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest {
 
     public XmlPatchBodyReaderTest() throws Exception {
         super(schemaContext);
-        xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler);
+        xmlToPatchBodyReader = new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -42,7 +39,6 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest {
     @BeforeClass
     public static void initialization() {
         schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
     }
 
     @Test
index a112fd00152a87710f7c079736daf0af30679995..5f876d67068545104b2b57462cdb5acc4502f06a 100644 (file)
@@ -9,44 +9,48 @@
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test;
 
 import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.lang.reflect.Field;
+import com.google.common.base.Optional;
 import java.util.Collections;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriInfo;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.TestUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
 import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public abstract class AbstractBodyReaderTest {
 
-    protected static final DOMMountPointServiceHandler MOUNT_POINT_SERVICE_HANDLER =
-            mock(DOMMountPointServiceHandler.class);
-
     protected final MediaType mediaType;
     protected final SchemaContextHandler schemaContextHandler;
+    protected final DOMMountPointServiceHandler mountPointServiceHandler;
 
     protected AbstractBodyReaderTest(SchemaContext schemaContext) throws NoSuchFieldException, IllegalAccessException {
         mediaType = getMediaType();
 
-        final Field mountPointServiceHandlerField =
-                RestConnectorProvider.class.getDeclaredField("mountPointServiceHandler");
-        mountPointServiceHandlerField.setAccessible(true);
-        mountPointServiceHandlerField.set(RestConnectorProvider.class, MOUNT_POINT_SERVICE_HANDLER);
-
         schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
+
+        final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
+        final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
+        doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
+        doReturn(schemaContext).when(mountPoint).getSchemaContext();
+
+        mountPointServiceHandler = DOMMountPointServiceHandler.newInstance(mountPointService);
     }
 
     protected abstract MediaType getMediaType();
index b372915132bfa326a1a7d5c42a69f66ad1f2e9e5..1c3050e33e09cd113030ab0cde2210570c9de643 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Sets;
 import java.io.File;
@@ -22,7 +20,6 @@ import java.util.Collection;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
@@ -49,7 +46,7 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
 
     public JsonBodyReaderTest() throws Exception {
         super(schemaContext);
-        this.jsonBodyReader = new JsonNormalizedNodeBodyReader(schemaContextHandler);
+        this.jsonBodyReader = new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -63,7 +60,6 @@ public class JsonBodyReaderTest extends AbstractBodyReaderTest {
         final Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
     }
 
     @Test
index ead68d4848ae4dcfb15072067760149f848648ad..7f8d621cf921926c77cb5bf735022440cf353448 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Sets;
 import java.io.File;
@@ -24,7 +22,6 @@ import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
@@ -53,7 +50,7 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
 
     public XmlBodyReaderTest() throws Exception {
         super(schemaContext);
-        this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler);
+        this.xmlBodyReader = new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler);
     }
 
     @Override
@@ -67,7 +64,6 @@ public class XmlBodyReaderTest extends AbstractBodyReaderTest {
         testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
         testFiles.addAll(TestRestconfUtils.loadFiles("/foo-xml-test/yang"));
         schemaContext = YangParserTestUtils.parseYangFiles(testFiles);
-        when(MOUNT_POINT_SERVICE_HANDLER.get()).thenReturn(mock(DOMMountPointService.class));
     }
 
     @Test
index 681dd4db76ab9856ac32df822e6d541f299957bf..b6a81801f3f0c61a29bf65ff749aa7c415c8da29 100644 (file)
@@ -51,7 +51,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider;
 import org.opendaylight.restconf.nb.rfc8040.TestUtils;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
@@ -178,7 +177,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
         final TransactionChainHandler txChainHandler = new TransactionChainHandler(mockDOMDataBroker);
 
         final DOMMountPointServiceHandler mountPointServiceHandler =
-                new DOMMountPointServiceHandler(mockMountPointService);
+                DOMMountPointServiceHandler.newInstance(mockMountPointService);
 
         final DOMNotificationService mockNotificationService = mock(DOMNotificationService.class);
         ServicesWrapperImpl.getInstance().setHandlers(schemaContextHandler, mountPointServiceHandler,
@@ -188,9 +187,6 @@ public class JSONRestconfServiceRfc8040ImplTest {
 
         service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler,
                 schemaContextHandler);
-
-        new RestConnectorProvider<>(mockDOMDataBroker, domSchemaService, mockRpcService, mockNotificationService,
-                mockMountPointService, txChainHandler, schemaContextHandler, null).start();
     }
 
     private static String loadData(final String path) throws IOException {
index 37e62b0bbc7f31e2af9eba94bfec3911e64bc090..e6046caee54baa30c97ab52634a6e3ca06b1ed53 100644 (file)
@@ -101,8 +101,6 @@ public class RestconfDataServiceImplTest {
     @Mock
     private DOMDataWriteTransaction write;
     @Mock
-    private DOMMountPointServiceHandler mountPointServiceHandler;
-    @Mock
     private DOMMountPointService mountPointService;
     @Mock
     private DOMMountPoint mountPoint;
@@ -190,8 +188,7 @@ public class RestconfDataServiceImplTest {
 
         schemaContextHandler.onGlobalContextUpdated(this.contextRef.get());
         this.dataService = new RestconfDataServiceImpl(schemaContextHandler, this.transactionChainHandler,
-                this.mountPointServiceHandler, this.delegRestconfSubscrService);
-        doReturn(this.mountPointService).when(this.mountPointServiceHandler).get();
+                DOMMountPointServiceHandler.newInstance(mountPointService), this.delegRestconfSubscrService);
         doReturn(Optional.of(this.mountPoint)).when(this.mountPointService)
                 .getMountPoint(any(YangInstanceIdentifier.class));
         doReturn(this.contextRef.get()).when(this.mountPoint).getSchemaContext();
index 078f27534b25a44ad7c3d9ee2a761b9fda3f532b..70ac7888449677e76e4f9b28618b4402d0cb17f1 100644 (file)
@@ -53,7 +53,7 @@ public class RestconfOperationsServiceTest {
         this.schemaContext = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles("/modules"));
         this.schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
 
-        this.domMountPointServiceHandler = new DOMMountPointServiceHandler(this.domMountPointService);
+        this.domMountPointServiceHandler = DOMMountPointServiceHandler.newInstance(this.domMountPointService);
 
         final QNameModule module1 = QNameModule.create(URI.create("module:1"));
         final QNameModule module2 = QNameModule.create(URI.create("module:2"));
index 80b9231159cd8515c135a22db3cb2e0546b28511..d9b280212ec512e6565d4b4588e93c94a3db28ec 100644 (file)
@@ -63,8 +63,6 @@ public class RestconfSchemaServiceTest {
     @Mock
     private SchemaContextHandler mockContextHandler;
     @Mock
-    private DOMMountPointServiceHandler mockMountPointHandler;
-    @Mock
     private DOMYangTextSourceProvider sourceProvider;
 
     // schema context with modules
@@ -107,10 +105,9 @@ public class RestconfSchemaServiceTest {
         this.mountPointService = new DOMMountPointServiceImpl();
         ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPoint);
         ((DOMMountPointServiceImpl) this.mountPointService).registerMountPoint(this.mountPointWithNullSchemaContext);
-        when(this.mockMountPointHandler.get()).thenReturn(this.mountPointService);
 
-        this.schemaService = new RestconfSchemaServiceImpl(this.mockContextHandler, this.mockMountPointHandler,
-                sourceProvider);
+        this.schemaService = new RestconfSchemaServiceImpl(this.mockContextHandler,
+                DOMMountPointServiceHandler.newInstance(mountPointService), sourceProvider);
     }
 
     /**