You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/09/23 12:43:58 UTC

[3/3] lucene-solr:master: SOLR-9551: Add JSONWriter constructor variant, JSONWriterTest.testConstantsUnchanged test. (Jonny Marks, Christine Poerschke)

SOLR-9551: Add JSONWriter constructor variant, JSONWriterTest.testConstantsUnchanged test. (Jonny Marks, Christine Poerschke)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/ef5da970
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/ef5da970
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/ef5da970

Branch: refs/heads/master
Commit: ef5da9705d99561f5dda7cdbed0b6f5b5ebf66d4
Parents: a9eb64e
Author: Christine Poerschke <cp...@apache.org>
Authored: Fri Sep 23 11:09:58 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Fri Sep 23 13:42:54 2016 +0100

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 +++
 .../solr/response/JSONResponseWriter.java       | 25 +++++++++++++-------
 .../apache/solr/response/JSONWriterTest.java    | 10 ++++++++
 3 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ef5da970/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 662f6dd..242052a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -180,6 +180,9 @@ Other Changes
 
 * SOLR-6090: Remove unreachable printLayout usage in cloud tests. (Cao Manh Dat via shalin)
 
+* SOLR-9551: Add JSONWriter constructor variant, JSONWriterTest.testConstantsUnchanged test.
+  (Jonny Marks, Christine Poerschke)
+
 ==================  6.2.1 ==================
 
 Bug Fixes

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ef5da970/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java b/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java
index cd8d07c..522030f 100644
--- a/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/JSONResponseWriter.java
@@ -66,19 +66,26 @@ public class JSONResponseWriter implements QueryResponseWriter {
 
 class JSONWriter extends TextResponseWriter {
   protected String wrapperFunction;
-  private String namedListStyle;
+  final private String namedListStyle;
 
-  private static final String JSON_NL_STYLE="json.nl";
-  private static final String JSON_NL_MAP="map";
-  private static final String JSON_NL_FLAT="flat";
-  private static final String JSON_NL_ARROFARR="arrarr";
-  private static final String JSON_NL_ARROFMAP="arrmap";
-  private static final String JSON_WRAPPER_FUNCTION="json.wrf";
+  static final String JSON_NL_STYLE="json.nl";
+  static final String JSON_NL_MAP="map";
+  static final String JSON_NL_FLAT="flat";
+  static final String JSON_NL_ARROFARR="arrarr";
+  static final String JSON_NL_ARROFMAP="arrmap";
+  static final String JSON_WRAPPER_FUNCTION="json.wrf";
 
   public JSONWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) {
+    this(writer, req, rsp,
+        req.getParams().get(JSON_WRAPPER_FUNCTION),
+        req.getParams().get(JSON_NL_STYLE, JSON_NL_FLAT).intern());
+  }
+
+  public JSONWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp,
+                    String wrapperFunction, String namedListStyle) {
     super(writer, req, rsp);
-    namedListStyle = req.getParams().get(JSON_NL_STYLE, JSON_NL_FLAT).intern();
-    wrapperFunction = req.getParams().get(JSON_WRAPPER_FUNCTION);
+    this.wrapperFunction = wrapperFunction;
+    this.namedListStyle = namedListStyle;
   }
 
   public void writeResponse() throws IOException {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ef5da970/solr/core/src/test/org/apache/solr/response/JSONWriterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/response/JSONWriterTest.java b/solr/core/src/test/org/apache/solr/response/JSONWriterTest.java
index 59de096..ad390cb 100644
--- a/solr/core/src/test/org/apache/solr/response/JSONWriterTest.java
+++ b/solr/core/src/test/org/apache/solr/response/JSONWriterTest.java
@@ -131,4 +131,14 @@ public class JSONWriterTest extends SolrTestCaseJ4 {
     req.close();
   }
   
+  @Test
+  public void testConstantsUnchanged() {
+    assertEquals("json.nl", JSONWriter.JSON_NL_STYLE);
+    assertEquals("map", JSONWriter.JSON_NL_MAP);
+    assertEquals("flat", JSONWriter.JSON_NL_FLAT);
+    assertEquals("arrarr", JSONWriter.JSON_NL_ARROFARR);
+    assertEquals("arrmap", JSONWriter.JSON_NL_ARROFMAP);
+    assertEquals("json.wrf", JSONWriter.JSON_WRAPPER_FUNCTION);
+  }
+
 }