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

This commit is contained in:
Christine Poerschke 2016-09-23 11:09:58 +01:00
parent a9eb64e427
commit ef5da9705d
3 changed files with 29 additions and 9 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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);
}
}