Added URL decoding for json file paths.
Change-Id: I8361696a090f106662beaf14af61f1b073fdfad5
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillString.java b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
index 602709b..d3da39d 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillString.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
@@ -1,7 +1,9 @@
package de.ids_mannheim.korap.util;
import java.io.*;
+import java.net.URLDecoder;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -26,7 +28,10 @@
*/
public static String StringfromFile (String path, Charset encoding)
throws IOException {
- byte[] encoded = Files.readAllBytes(Paths.get(path));
+ path = URLDecoder.decode(path,"UTF-8");
+ path = path.replaceFirst("^/(.:/)", "$1");
+ Path p = Paths.get(path);
+ byte[] encoded = Files.readAllBytes(p);
return new String(encoded, encoding);
};
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index 17179aa..6451ae4 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -2,6 +2,7 @@
import java.util.*;
import java.io.*;
+import java.net.URLDecoder;
import static org.junit.Assert.*;
@@ -95,7 +96,7 @@
SpanQueryWrapper sqwi;
try {
- String json = getString(jsonFile);
+ String json = getJsonString(jsonFile);
sqwi = new KrillQuery("tokens").fromKoral(json);
}
catch (QueryException e) {
@@ -107,9 +108,11 @@
// Get string
- public static String getString (String path) {
+ public static String getJsonString (String path) {
+
StringBuilder contentBuilder = new StringBuilder();
try {
+ path = URLDecoder.decode(path, "UTF-8");
BufferedReader in = new BufferedReader(new FileReader(path));
String str;
while ((str = in.readLine()) != null) {
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
index 9232711..8b08bda 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
@@ -186,7 +186,7 @@
// Legacy collections reflect old tests, that were adopted to the new scheme
@Test
public void metaQuery1Legacy () {
- String metaQuery = getString(getClass().getResource(
+ String metaQuery = getJsonString(getClass().getResource(
"/queries/metaquery.jsonld").getFile());
KrillCollection kc = new KrillCollection(metaQuery);
@@ -211,7 +211,7 @@
@Test
public void metaQuery2Legacy () {
- String metaQuery = getString(getClass().getResource(
+ String metaQuery = getJsonString(getClass().getResource(
"/queries/metaquery2.jsonld").getFile());
KrillCollection kc = new KrillCollection(metaQuery);
/*
@@ -227,7 +227,7 @@
@Test
public void metaQuery3Legacy () {
- String metaQuery = getString(getClass().getResource(
+ String metaQuery = getJsonString(getClass().getResource(
"/queries/metaquery4.jsonld").getFile());
KrillCollection kc = new KrillCollection(metaQuery);
/*
@@ -245,7 +245,7 @@
@Test
public void metaQuery7Legacy () {
- String metaQuery = getString(getClass().getResource(
+ String metaQuery = getJsonString(getClass().getResource(
"/queries/metaquery7.jsonld").getFile());
KrillCollection kc = new KrillCollection(metaQuery);
/*
@@ -266,7 +266,7 @@
@Test
public void metaQuery9 () {
- String metaQuery = getString(getClass().getResource(
+ String metaQuery = getJsonString(getClass().getResource(
"/queries/metaquery9.jsonld").getFile());
KrillCollection kc = new KrillCollection(metaQuery);
/*
@@ -279,6 +279,6 @@
private String _getJSONString (String file) {
- return getString(getClass().getResource(path + file).getFile());
+ return getJsonString(getClass().getResource(path + file).getFile());
};
};
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
index 0b1eb95..2371d3d 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
@@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.net.URLDecoder;
import org.apache.lucene.search.spans.SpanQuery;
import org.junit.Test;
@@ -29,8 +30,8 @@
@Test
public void queryJSONpoly1 () throws QueryException, IOException {
- String jsonPath = getClass().getResource("/queries/poly1.json")
- .getFile();
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly1.json")
+ .getFile(),"UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
@@ -64,8 +65,8 @@
@Test
public void queryJSONpoly4 () throws QueryException, IOException {
- String jsonPath = getClass().getResource("/queries/poly4.json")
- .getFile();
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly4.json")
+ .getFile(),"UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
SpanQuery sq = sqwi.toQuery();
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
index 45ae9e3..43c15eb 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -277,7 +277,7 @@
ki.commit();
// 15
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/greater_highlights_15.jsonld").getFile());
Krill ks = new Krill(json);
@@ -292,7 +292,7 @@
kr.getMatch(0).getSnippetHTML(),
"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><mark><mark class=\"class-15 level-0\">Alphabet</mark></mark></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/greater_highlights_16.jsonld").getFile());
// 16
@@ -309,7 +309,7 @@
"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><mark><mark class=\"class-16 level-0\">Alphabet</mark></mark></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
// 127
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/greater_highlights_127.jsonld").getFile());
ks = new Krill(json);
@@ -325,7 +325,7 @@
"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><mark><mark class=\"class-127 level-0\">Alphabet</mark></mark></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
// 255
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/greater_highlights_255.jsonld").getFile());
ks = new Krill(json);
@@ -341,7 +341,7 @@
"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><mark>Alphabet</mark></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
// 300
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/greater_highlights_300.jsonld").getFile());
ks = new Krill(json);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
index 026a86a..7716322 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -5,6 +5,7 @@
import java.util.*;
import java.io.*;
+import java.net.URLDecoder;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.spans.SpanQuery;
@@ -205,8 +206,9 @@
ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
ki.commit();
- SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
- "/queries/cosmas1.json").getFile());
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/cosmas1.json")
+ .getFile(),"UTF-8");
+ SpanQueryWrapper sqwi = jsonQuery(jsonPath);
kr = ki.search(sqwi.toQuery(), (short) 10);
assertEquals((long) 3, kr.getTotalResults());
@@ -233,8 +235,9 @@
assertEquals(kr.getTotalResults(), 1);
assertEquals("[[ecebdc]]", kr.getMatch(0).getSnippetBrackets());
- sqwi = jsonQuery(getClass().getResource(
- "/queries/distances/in-same-t.jsonld").getFile());
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/distances/in-same-t.jsonld")
+ .getFile(),"UTF-8");
+ sqwi = jsonQuery(jsonPath);
assertEquals(
"spanElementDistance(tokens:s:c, tokens:s:e, [(base/s:t[0:0], ordered, notExcluded)])",
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
index 0962e64..a570e93 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.net.URLDecoder;
import org.apache.lucene.search.spans.SpanQuery;
import org.junit.Test;
@@ -198,9 +199,11 @@
};
ki.commit();
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/bsp18.jsonld")
+ .getFile(),"UTF-8");
+
// {1:der} \w0:5 nicht
- SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
- "/queries/bsp18.jsonld").getFile());
+ SpanQueryWrapper sqwi = jsonQuery(jsonPath);
Result kr = ki.search(sqwi.toQuery(), 0, (short) 5, true, (short) 2,
false, (short) 5);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
index 08f56a8..7af71f0 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
@@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.net.URLDecoder;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.RegexpQuery;
@@ -295,9 +296,8 @@
ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
ki.addDoc(getClass().getResourceAsStream("/wiki/00002.json.gz"), true);
ki.commit();
-
- String jsonPath = getClass().getResource("/queries/poly3.json")
- .getFile();
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly3.json")
+ .getFile(),"UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
@@ -405,9 +405,9 @@
ki.addDoc(createFieldDoc3());
ki.addDoc(createFieldDoc4());
ki.commit();
-
- String json = readFile(getClass().getResource(
- "/queries/bugs/expansion_bug_3.jsonld").getFile());
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/bugs/expansion_bug_3.jsonld")
+ .getFile(),"UTF-8");
+ String json = readFile(jsonPath);
KrillQuery kq = new KrillQuery("base");
SpanQuery sq = kq.fromKoral(json).toQuery();
assertEquals(
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
index f77f42a..7960560 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.net.URLDecoder;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.spans.SpanQuery;
@@ -1107,8 +1108,8 @@
// contains(<s>, (es wird | wird es))
@Test
public void queryJSONpoly2 () throws QueryException, IOException {
- String jsonPath = getClass().getResource("/queries/poly2.json")
- .getFile();
+ String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly2.json")
+ .getFile(),"UTF-8");
String jsonPQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonPQuery);
@@ -1144,8 +1145,8 @@
at de.ids_mannheim.korap.Krill.apply(Krill.java:304)
*/
- String jsonPath = getClass().getResource(
- "/queries/bugs/span_or_bug.jsonld").getFile();
+ String jsonPath = URLDecoder.decode(getClass().getResource(
+ "/queries/bugs/span_or_bug.jsonld").getFile(),"UTF-8");
String jsonPQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonPQuery);
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
index 27f00f3..d66be4f 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
@@ -2,6 +2,7 @@
import java.util.*;
import java.io.*;
+import java.net.URLDecoder;
import org.apache.lucene.search.spans.SpanQuery;
import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
@@ -617,7 +618,7 @@
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
- BufferedReader in = new BufferedReader(new FileReader(path));
+ BufferedReader in = new BufferedReader(new FileReader(URLDecoder.decode(path,"UTF-8")));
String str;
while ((str = in.readLine()) != null) {
contentBuilder.append(str);
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
index 72ae83e..d651318 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
@@ -48,7 +48,7 @@
FieldDocument fd = ki.addDoc(json);
ki.commit();
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/cosmas_classrefcheck.jsonld").getFile());
Krill ks = new Krill(json);
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
index 7ecf1c2..ab52dd0 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -1,6 +1,6 @@
package de.ids_mannheim.korap.search;
-import static de.ids_mannheim.korap.TestSimple.getString;
+import static de.ids_mannheim.korap.TestSimple.getJsonString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
@@ -129,7 +129,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/metaquery3.jsonld").getFile());
Krill ks = new Krill(json);
@@ -161,7 +161,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/metaquery4.jsonld").getFile());
Krill ks = new Krill(json);
@@ -176,14 +176,14 @@
assertEquals(kr.getTotalResults(), 5);
- json = getString(getClass().getResource("/queries/metaquery5.jsonld")
+ json = getJsonString(getClass().getResource("/queries/metaquery5.jsonld")
.getFile());
ks = new Krill(json);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 1);
- json = getString(getClass().getResource("/queries/metaquery6.jsonld")
+ json = getJsonString(getClass().getResource("/queries/metaquery6.jsonld")
.getFile());
ks = new Krill(json);
kr = ks.apply(ki);
@@ -231,7 +231,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-fail1.jsonld").getFile());
Result kr = new Krill(json).apply(ki);
@@ -254,7 +254,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-fail2.jsonld").getFile());
Result kr = new Krill(json).apply(ki);
@@ -271,7 +271,7 @@
public void queryJSONmirrorTestBug () throws IOException {
// Construct index
KrillIndex ki = new KrillIndex();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/failing_mirror.jsonld").getFile());
Krill ks = new Krill(json);
Result kr = ks.apply(ki);
@@ -281,7 +281,7 @@
assertEquals("Unable to parse JSON", res.at("/errors/0/1").asText());
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/failing_mirror_2.jsonld").getFile());
ks = new Krill(json);
kr = ks.apply(ki);
@@ -311,7 +311,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-context.jsonld").getFile());
Krill ks = new Krill(json);
@@ -330,7 +330,7 @@
assertEquals(5, kr.getStartIndex());
assertEquals(5, kr.getItemsPerPage());
- json = getString(getClass()
+ json = getJsonString(getClass()
.getResource("/queries/bsp-context-2.jsonld").getFile());
kr = new Krill(json).apply(ki);
@@ -363,7 +363,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-paging.jsonld").getFile());
Krill ks = new Krill(json);
@@ -372,7 +372,7 @@
assertEquals(5, kr.getStartIndex());
assertEquals(5, kr.getItemsPerPage());
- json = getString(getClass().getResource("/queries/bsp-cutoff.jsonld")
+ json = getJsonString(getClass().getResource("/queries/bsp-cutoff.jsonld")
.getFile());
ks = ks = new Krill(json);
kr = ks.apply(ki);
@@ -380,7 +380,7 @@
assertEquals(2, kr.getStartIndex());
assertEquals(2, kr.getItemsPerPage());
- json = getString(getClass().getResource("/queries/metaquery9.jsonld")
+ json = getJsonString(getClass().getResource("/queries/metaquery9.jsonld")
.getFile());
KrillCollection kc = new KrillCollection(json);
kc.setIndex(ki);
@@ -400,7 +400,7 @@
true);
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-itemsPerResource.jsonld").getFile());
Krill ks = new Krill(json);
@@ -480,7 +480,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-uid-example.jsonld").getFile());
Krill ks = new Krill(json);
@@ -665,7 +665,7 @@
getClass().getResourceAsStream("/bzk/D59-00089.json.gz"), true);
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/cosmas_boundary.jsonld").getFile());
QueryBuilder kq = new QueryBuilder("tokens");
@@ -723,7 +723,7 @@
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/multiple_classes.jsonld").getFile());
Krill ks = new Krill(json);
@@ -753,7 +753,7 @@
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/multiple_classes.jsonld").getFile());
Krill ks = new Krill(json);
@@ -795,7 +795,7 @@
assertEquals("BZK", fd.getCorpusSigle());
// [tt/p="A.*"]{0,3}[tt/p="N.*"]
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/multiterm_rewrite.jsonld").getFile());
Krill ks = new Krill(json);
@@ -858,7 +858,7 @@
ki.commit();
// ({1:Sonne []* Erde} | {2: Erde []* Sonne})
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/tokendistancespan_bug.jsonld").getFile());
Krill ks = new Krill(json);
@@ -881,7 +881,7 @@
true);
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/metaquery8-nocollection.jsonld").getFile());
Krill ks = new Krill(json);
@@ -890,7 +890,7 @@
assertEquals(0, kr.getStartIndex());
assertEquals(10, kr.getItemsPerPage());
- json = getString(getClass().getResource("/queries/metaquery8.jsonld")
+ json = getJsonString(getClass().getResource("/queries/metaquery8.jsonld")
.getFile());
ks = new Krill(json);
@@ -901,7 +901,7 @@
assertEquals(0, kr.getStartIndex());
assertEquals(10, kr.getItemsPerPage());
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/metaquery8-filtered.jsonld").getFile());
ks = new Krill(json);
@@ -912,7 +912,7 @@
assertEquals(0, kr.getStartIndex());
assertEquals(10, kr.getItemsPerPage());
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/metaquery8-filtered-further.jsonld").getFile());
ks = new Krill(json);
@@ -923,7 +923,7 @@
assertEquals(10, kr.getItemsPerPage());
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/metaquery8-filtered-nested.jsonld").getFile());
ks = new Krill(json);
@@ -958,7 +958,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-context-2.jsonld").getFile());
Krill ks = new Krill(json);
@@ -978,7 +978,7 @@
assertFalse(kr.getContext().toJsonNode().toString()
.equals("\"base/s:s\""));
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bsp-context-sentence.jsonld").getFile());
kr = new Krill(json).apply(ki);
@@ -1010,7 +1010,7 @@
};
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bsp-bug.jsonld").getFile());
Result kr = new Krill(json).apply(ki);
@@ -1034,7 +1034,7 @@
ki.commit();
// "der" []{2,3} [opennlp/p="NN"]
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/distances_with_regex_bug.jsonld").getFile());
Result kr = new Krill(json).apply(ki);
@@ -1059,7 +1059,7 @@
// Expansion bug
// der alte Digraph Aa durch Å
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/expansion_bug_2.jsonld").getFile());
Result kr = new Krill(json).apply(ki);
@@ -1079,7 +1079,7 @@
// der alte Digraph Aa durch []
// Works with one document
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/expansion_bug.jsonld").getFile());
kr = new Krill(json).apply(ki);
@@ -1104,7 +1104,7 @@
// Expansion bug
// der alte Digraph Aa durch Å
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/expansion_bug_2.jsonld").getFile());
kr = new Krill(json).apply(ki);
@@ -1117,7 +1117,7 @@
assertEquals(kr.getTotalResults(), 1);
// der alte Digraph Aa durch []
- json = getString(getClass().getResource(
+ json = getJsonString(getClass().getResource(
"/queries/bugs/expansion_bug.jsonld").getFile());
kr = new Krill(json).apply(ki);
@@ -1137,7 +1137,7 @@
ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
ki.commit();
- String json = getString(getClass().getResource(
+ String json = getJsonString(getClass().getResource(
"/queries/bugs/zero_repetition_bug.jsonld").getFile());
Result kr = new Krill(json).apply(ki);
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
index 5e15394..b297672 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
@@ -47,7 +47,7 @@
};
ki.commit();
- String jsonString = getString(getClass().getResource(
+ String jsonString = getJsonString(getClass().getResource(
"/queries/metas/fields.jsonld").getFile());
Krill ks = new Krill(jsonString);
@@ -87,7 +87,7 @@
assertTrue(res.at("/matches/0/layerInfos").isMissingNode());
assertTrue(res.at("/matches/0/tokenization").isMissingNode());
- jsonString = getString(getClass().getResource(
+ jsonString = getJsonString(getClass().getResource(
"/queries/metas/fields_2.jsonld").getFile());
ks = new Krill(jsonString);
kr = ks.apply(ki);
@@ -125,7 +125,7 @@
ki.addDoc(getClass().getResourceAsStream("/goe/AGX-00002.json"), false);
ki.commit();
- String jsonString = getString(getClass().getResource(
+ String jsonString = getJsonString(getClass().getResource(
"/queries/metas/fields_no.jsonld").getFile());
Krill ks = new Krill(jsonString);
@@ -153,7 +153,7 @@
// All fields
- jsonString = getString(getClass().getResource(
+ jsonString = getJsonString(getClass().getResource(
"/queries/metas/fields_all.jsonld").getFile());
ks = new Krill(jsonString);
@@ -184,7 +184,7 @@
// @All fields
- jsonString = getString(getClass().getResource(
+ jsonString = getJsonString(getClass().getResource(
"/queries/metas/fields_at_all.jsonld").getFile());
ks = new Krill(jsonString);
@@ -245,7 +245,7 @@
ki.commit();
// textClass = reisen & wissenschaft
- String jsonString = getString(getClass().getResource(
+ String jsonString = getJsonString(getClass().getResource(
"/queries/collections/collection_textClass.jsonld").getFile());
Krill ks = new Krill(jsonString);
KrillCollection kc = ks.getCollection();
@@ -253,7 +253,7 @@
assertEquals(1, kc.numberOf("documents"));
// textClass = reisen
- jsonString = getString(getClass().getResource(
+ jsonString = getJsonString(getClass().getResource(
"/queries/collections/collection_textClass_2.jsonld").getFile());
ks = new Krill(jsonString);
kc = ks.getCollection();
@@ -276,7 +276,7 @@
*/
// author = wolfgang
- jsonString = getString(getClass().getResource(
+ jsonString = getJsonString(getClass().getResource(
"/queries/collections/collection_goethe.jsonld").getFile());
ks = new Krill(jsonString);
kc = ks.getCollection();
@@ -284,7 +284,7 @@
assertEquals(1, kc.numberOf("documents"));
// author = Wolfgang
- jsonString = getString(getClass().getResource(
+ jsonString = getJsonString(getClass().getResource(
"/queries/collections/collection_goethe_2.jsonld").getFile());
ks = new Krill(jsonString);
kc = ks.getCollection();
@@ -303,7 +303,7 @@
public void searchMetaContext () throws IOException {
// All fields
- String jsonString = getString(getClass().getResource(
+ String jsonString = getJsonString(getClass().getResource(
"/queries/metas/context_paragraph.jsonld").getFile());
Krill ks = new Krill(jsonString);
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestResult.java b/src/test/java/de/ids_mannheim/korap/search/TestResult.java
index a106fae..12e5b3d 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestResult.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestResult.java
@@ -2,6 +2,7 @@
import java.util.*;
import java.io.*;
+import java.net.URLDecoder;
import org.apache.lucene.search.spans.SpanQuery;
@@ -263,7 +264,7 @@
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
- BufferedReader in = new BufferedReader(new FileReader(path));
+ BufferedReader in = new BufferedReader(new FileReader(URLDecoder.decode(path,"UTF-8")));
String str;
while ((str = in.readLine()) != null) {
contentBuilder.append(str);
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestResource.java b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
index 633a277..908f3e9 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestResource.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
@@ -17,6 +17,7 @@
import org.junit.Test;
import java.io.FileInputStream;
+import java.net.URLDecoder;
import de.ids_mannheim.korap.server.Node;
import de.ids_mannheim.korap.response.Result;
@@ -267,7 +268,7 @@
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
- BufferedReader in = new BufferedReader(new FileReader(path));
+ BufferedReader in = new BufferedReader(new FileReader(URLDecoder.decode(path,"UTF-8")));
String str;
while ((str = in.readLine()) != null) {
contentBuilder.append(str);