BUG-576: fixed text file loading in test. 37/10237/1
authorMartin Vitez <mvitez@cisco.com>
Mon, 25 Aug 2014 09:12:02 +0000 (11:12 +0200)
committerMartin Vitez <mvitez@cisco.com>
Mon, 25 Aug 2014 09:12:02 +0000 (11:12 +0200)
Change-Id: Iff660142345ba292d9492b06a1199db1e11dd265
Signed-off-by: Martin Vitez <mvitez@cisco.com>
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/StreamToNormalizedNodeTest.java

index 1010989bc890300f56ea7ad540d80c384688351e..e38c63bbf5ce375a175d5eaa667fbcbc3d49d9dc 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import com.google.gson.stream.JsonReader;
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -16,9 +15,9 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -45,10 +44,10 @@ public class StreamToNormalizedNodeTest {
     private static String streamAsString;
 
     @BeforeClass
-    public static void initialization() throws IOException {
+    public static void initialization() throws IOException, URISyntaxException {
         schemaContext = loadModules("/complexjson/yang");
-        streamAsString = loadTextFile(StreamToNormalizedNodeTest.class.getResource("/complexjson/complex-json.json")
-                .getPath());
+        streamAsString = loadTextFile(new File(StreamToNormalizedNodeTest.class.getResource(
+                "/complexjson/complex-json.json").toURI()));
     }
 
     /**
@@ -138,8 +137,8 @@ public class StreamToNormalizedNodeTest {
         return parser.parseFiles(testFiles);
     }
 
-    private static String loadTextFile(final String filePath) throws IOException {
-        FileReader fileReader = new FileReader(filePath);
+    private static String loadTextFile(final File file) throws IOException {
+        FileReader fileReader = new FileReader(file);
         BufferedReader bufReader = new BufferedReader(fileReader);
 
         String line = null;