You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2015/03/12 13:47:30 UTC
svn commit: r1666167 -
/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
Author: yonik
Date: Thu Mar 12 12:47:30 2015
New Revision: 1666167
URL: http://svn.apache.org/r1666167
Log:
tests: let json parser handle single quoted strings
Modified:
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1666167&r1=1666166&r2=1666167&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Thu Mar 12 12:47:30 2015
@@ -750,7 +750,7 @@ public abstract class SolrTestCaseJ4 ext
try {
String m = (null == message) ? "" : message + " ";
String response = h.query(req);
-
+
if (req.getParams().getBool("facet", false)) {
// add a test to ensure that faceting did not throw an exception
// internally, where it would be added to facet_counts/exception
@@ -814,9 +814,9 @@ public abstract class SolrTestCaseJ4 ext
}
/**
* Validates a query matches some JSON test expressions and closes the
- * query. The text expression is of the form path:JSON. To facilitate
- * easy embedding in Java strings, the JSON tests can have double quotes
- * replaced with single quotes.
+ * query. The text expression is of the form path:JSON. The Noggit JSON
+ * parser used accepts single quoted strings and bare strings to allow
+ * easy embedding in Java Strings.
* <p>
* Please use this with care: this makes it easy to match complete
* structures, but doing so can result in fragile tests if you are
@@ -1129,22 +1129,15 @@ public abstract class SolrTestCaseJ4 ext
return Arrays.asList(docs);
}
- /** Converts "test JSON" and returns standard JSON.
- * Currently this only consists of changing unescaped single quotes to double quotes,
- * and escaped single quotes to single quotes.
- *
- * The primary purpose is to be able to easily embed JSON strings in a JAVA string
- * with the best readability.
+ /** Converts "test JSON" strings into JSON parseable by our JSON parser.
+ * For example, this method changed single quoted strings into double quoted strings before
+ * the parser could natively handle them.
*
* This transformation is automatically applied to JSON test srings (like assertJQ).
*/
public static String json(String testJSON) {
- testJSON = nonEscapedSingleQuotePattern.matcher(testJSON).replaceAll("\"");
- testJSON = escapedSingleQuotePattern.matcher(testJSON).replaceAll("'");
return testJSON;
}
- private static Pattern nonEscapedSingleQuotePattern = Pattern.compile("(?<!\\\\)\'");
- private static Pattern escapedSingleQuotePattern = Pattern.compile("\\\\\'");
/** Creates JSON from a SolrInputDocument. Doesn't currently handle boosts.