@@ -44,7 +44,7 @@ public class TestRawResponseWriter extends SolrTestCaseJ4 {
4444 private static RawResponseWriter writerJsonBase ;
4545 private static RawResponseWriter writerBinBase ;
4646 private static RawResponseWriter writerCborBase ;
47- // private static RawResponseWriter writerNoBase;
47+ private static RawResponseWriter writerNoBase ;
4848
4949 private static RawResponseWriter [] allWriters ;
5050
@@ -56,22 +56,26 @@ public static void setupCoreAndWriters() throws Exception {
5656 // we spin up.
5757 initCore ("solrconfig.xml" , "schema.xml" );
5858
59- // writerNoBase = newRawResponseWriter(null); /* defaults to standard writer as base */
59+ writerNoBase =
60+ newRawResponseWriter (
61+ null ); /* null base uses core's default writer (XML for this core), or JSON if no core */
6062 writerXmlBase = newRawResponseWriter ("xml" );
6163 writerJsonBase = newRawResponseWriter ("json" );
6264 writerBinBase = newRawResponseWriter ("javabin" );
6365 writerCborBase = newRawResponseWriter ("cbor" );
6466
6567 allWriters =
66- new RawResponseWriter [] {writerXmlBase , writerJsonBase , writerBinBase , writerCborBase };
68+ new RawResponseWriter [] {
69+ writerXmlBase , writerJsonBase , writerBinBase , writerCborBase , writerNoBase
70+ };
6771 }
6872
6973 @ AfterClass
7074 public static void cleanupWriters () {
7175 writerXmlBase = null ;
7276 writerJsonBase = null ;
7377 writerBinBase = null ;
74- // writerNoBase = null;
78+ writerNoBase = null ;
7579 writerCborBase = null ;
7680 allWriters = null ;
7781 }
@@ -131,7 +135,7 @@ public void testStructuredDataViaBaseWriters() throws IOException {
131135 rsp .add ("foo" , "bar" );
132136
133137 // check Content-Type against each writer
134- // assertEquals("application/xml; charset=UTF-8", writerNoBase.getContentType(req(), rsp));
138+ assertEquals ("application/xml; charset=UTF-8" , writerNoBase .getContentType (req (), rsp ));
135139 assertEquals ("application/xml; charset=UTF-8" , writerXmlBase .getContentType (req (), rsp ));
136140 assertEquals ("application/json; charset=UTF-8" , writerJsonBase .getContentType (req (), rsp ));
137141 assertEquals ("application/octet-stream" , writerBinBase .getContentType (req (), rsp ));
@@ -153,11 +157,10 @@ public void testStructuredDataViaBaseWriters() throws IOException {
153157 writerXmlBase .write (xmlBout , req (), rsp );
154158 assertEquals (xml , xmlBout .toString (StandardCharsets .UTF_8 ));
155159
156- //
157- // assertEquals(xml, writerNoBase.writeToString(req(), rsp));
158- // ByteArrayOutputStream noneBout = new ByteArrayOutputStream();
159- // writerNoBase.write(noneBout, req(), rsp);
160- // assertEquals(xml, noneBout.toString(StandardCharsets.UTF_8.toString()));
160+ assertEquals (xml , writerNoBase .writeToString (req (), rsp ));
161+ ByteArrayOutputStream noneBout = new ByteArrayOutputStream ();
162+ writerNoBase .write (noneBout , req (), rsp );
163+ assertEquals (xml , noneBout .toString (StandardCharsets .UTF_8 ));
161164
162165 // json
163166 String json = "{\n " + " \" content\" :\" test\" ,\n " + " \" foo\" :\" bar\" }\n " ;
@@ -204,7 +207,7 @@ private byte[] convertJsonToCborFormat(byte[] inputJson) throws IOException {
204207 }
205208
206209 /**
207- * Generates a new {@link RawResponseWriter} wrapping the specified baseWriter name (which much
210+ * Generates a new {@link RawResponseWriter} wrapping the specified baseWriter name (which must
208211 * either be an implicitly defined response writer, or one explicitly configured in
209212 * solrconfig.xml)
210213 *
0 commit comments