Bug 7159: Add yang-test-util artifact
[yangtools.git] / yang / yang-data-codec-gson / src / test / java / org / opendaylight / yangtools / yang / data / codec / gson / TestUtils.java
index d83e15957c246d6ef431037d2f1f3cafae8975d5..b98566e140562b5242734fe64691669286189a3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -16,39 +16,15 @@ import com.google.gson.JsonParser;
 import com.google.gson.JsonPrimitive;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
-import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class TestUtils {
 
     private TestUtils() {
     }
 
-    static SchemaContext loadModules(final String resourceDirectory) throws IOException, URISyntaxException {
-        YangContextParser parser = new YangParserImpl();
-        URI path = StreamToNormalizedNodeTest.class.getResource(resourceDirectory).toURI();
-        final File testDir = new File(path);
-        final String[] fileList = testDir.list();
-        final List<File> testFiles = new ArrayList<File>();
-        if (fileList == null) {
-            throw new FileNotFoundException(resourceDirectory);
-        }
-        for (String fileName : fileList) {
-            if (new File(testDir, fileName).isDirectory() == false) {
-                testFiles.add(new File(testDir, fileName));
-            }
-        }
-        return parser.parseFiles(testFiles);
-    }
-
     static String loadTextFile(final File file) throws IOException {
         FileReader fileReader = new FileReader(file);
         BufferedReader bufReader = new BufferedReader(fileReader);
@@ -66,7 +42,7 @@ public class TestUtils {
         return loadTextFile(new File(TestUtils.class.getResource(relativePath).toURI()));
     }
 
-    static JsonObject childObject(final JsonObject jsonObject,final String ... names) {
+    static JsonObject childObject(final JsonObject jsonObject, final String... names) {
         for (String name : names) {
             JsonObject childJsonObject = jsonObject.getAsJsonObject(name);
             if (childJsonObject != null) {
@@ -76,7 +52,7 @@ public class TestUtils {
         return null;
     }
 
-    static JsonPrimitive childPrimitive(final JsonObject jsonObject,final String ... names) {
+    static JsonPrimitive childPrimitive(final JsonObject jsonObject, final String... names) {
         for (String name : names) {
             JsonPrimitive childJsonPrimitive = jsonObject.getAsJsonPrimitive(name);
             if (childJsonPrimitive != null) {
@@ -86,7 +62,7 @@ public class TestUtils {
         return null;
     }
 
-    static JsonArray childArray(final JsonObject jsonObject,final String ... names) {
+    static JsonArray childArray(final JsonObject jsonObject, final String... names) {
         for (String name : names) {
             JsonArray childJsonArray = jsonObject.getAsJsonArray(name);
             if (childJsonArray != null) {
@@ -105,5 +81,4 @@ public class TestUtils {
         return cont1;
     }
 
-
 }