Update MRI projects for Aluminium
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / rest / impl / test / providers / AbstractBodyReaderTest.java
index 0912ce245a4db4af442bf41eb8fa21e5dc742102..57c6ef2943170d3927c56a555f7f31ed33de81f5 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertNotNull;
@@ -21,34 +20,44 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.netconf.sal.rest.api.RestconfConstants;
 import org.opendaylight.netconf.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public abstract class AbstractBodyReaderTest {
-
-    protected static final ControllerContext CONTROLLER_CONTEXT = ControllerContext.getInstance();
-    protected final MediaType mediaType;
     private static Field uriField;
     private static Field requestField;
 
-    public AbstractBodyReaderTest() throws NoSuchFieldException {
-        uriField = AbstractIdentifierAwareJaxRsProvider.class
-                .getDeclaredField("uriInfo");
-        uriField.setAccessible(true);
-        requestField = AbstractIdentifierAwareJaxRsProvider.class
-                .getDeclaredField("request");
-        requestField.setAccessible(true);
+    static {
+        try {
+            uriField = AbstractIdentifierAwareJaxRsProvider.class
+                    .getDeclaredField("uriInfo");
+            uriField.setAccessible(true);
+            requestField = AbstractIdentifierAwareJaxRsProvider.class
+                    .getDeclaredField("request");
+            requestField.setAccessible(true);
+        } catch (NoSuchFieldException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected final ControllerContext controllerContext;
+    protected final MediaType mediaType;
+
+    protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext, final DOMMountPoint mountInstance) {
         this.mediaType = getMediaType();
+
+        controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance);
     }
 
     protected abstract MediaType getMediaType();
 
-    protected static SchemaContext schemaContextLoader(final String yangPath,
-            final SchemaContext schemaContext) {
+    protected static EffectiveModelContext schemaContextLoader(final String yangPath,
+            final EffectiveModelContext schemaContext) {
         return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
     }