Sal-rest-connector unit tests switch to new yang parser.
[netconf.git] / opendaylight / restconf / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / rest / impl / test / providers / TestJsonBodyReader.java
index ffd06f5d422cff7aab241c35a94bbed92f73df8c..9fa26d53767c0798e640582e8c16b4812aee9a9a 100644 (file)
@@ -11,13 +11,18 @@ package org.opendaylight.controller.sal.rest.impl.test.providers;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import com.google.common.base.Optional;
-import com.google.common.collect.Sets;
+
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.net.URI;
+import java.util.Collection;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -30,6 +35,11 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
 
 /**
  * sal-rest-connector
@@ -57,10 +67,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-        schemaContext = schemaContextLoader("/modules", schemaContext);
-        schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
+    public static void initialization() throws NoSuchFieldException, SecurityException, FileNotFoundException, SourceException, ReactorException {
+        Collection<File> testFiles = TestRestconfUtils.loadFiles("/instanceidentifier/yang");
+        testFiles.addAll(TestRestconfUtils.loadFiles("/modules"));
+        testFiles.addAll(TestRestconfUtils.loadFiles("/invoke-rpc"));
+        schemaContext = TestRestconfUtils.parseYangSources(testFiles);
         controllerContext.setSchemas(schemaContext);
     }