dsmiley commented on code in PR #3902:
URL: https://github.com/apache/solr/pull/3902#discussion_r2575533176


##########
solr/core/src/test/org/apache/solr/response/TestRawResponseWriter.java:
##########
@@ -162,6 +176,33 @@ public void testStructuredDataViaBaseWriters() throws 
IOException {
     assertEquals("test", out.getVal(0));
     assertEquals("foo", out.getName(1));
     assertEquals("bar", out.getVal(1));
+
+    // cbor
+
+    byte[] cborBytes = serializeToCbor(json.getBytes());
+    assertEquals(25, cborBytes.length);
+    LongAdder numberOfObjectsInResponse = new LongAdder();
+    new CborLoader(null, (document) -> numberOfObjectsInResponse.increment())
+        .stream(new ByteArrayInputStream(cborBytes));
+    assertEquals(1, numberOfObjectsInResponse.intValue());
+  }
+
+  private byte[] serializeToCbor(byte[] is) throws IOException {
+    ByteArrayOutputStream baos;

Review Comment:
   It's better to define vars just-in-time (later) and closer to the logical 
flow of usage, not all up front like this is C code.



##########
solr/core/src/test/org/apache/solr/response/TestRawResponseWriter.java:
##########
@@ -162,6 +176,33 @@ public void testStructuredDataViaBaseWriters() throws 
IOException {
     assertEquals("test", out.getVal(0));
     assertEquals("foo", out.getName(1));
     assertEquals("bar", out.getVal(1));
+
+    // cbor
+
+    byte[] cborBytes = serializeToCbor(json.getBytes());
+    assertEquals(25, cborBytes.length);
+    LongAdder numberOfObjectsInResponse = new LongAdder();
+    new CborLoader(null, (document) -> numberOfObjectsInResponse.increment())
+        .stream(new ByteArrayInputStream(cborBytes));
+    assertEquals(1, numberOfObjectsInResponse.intValue());
+  }
+
+  private byte[] serializeToCbor(byte[] is) throws IOException {

Review Comment:
   please rename the param to `inputJson` or something similar.  It's current 
name is very ambiguous and suggestive of a type it doesn't have.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to