Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/385#discussion_r191401350
  
    --- Diff: solr/core/src/test/org/apache/solr/update/AddBlockUpdateTest.java 
---
    @@ -398,7 +523,43 @@ public void testXML() throws IOException, 
XMLStreamException {
         assertSingleParentOf(searcher, one("bc"), "A");
            
       }
    -  
    +
    +  @Test
    +  public void testJavaBinCodecNestedRelation() throws IOException {
    +    SolrInputDocument topDocument = new SolrInputDocument();
    +    topDocument.addField("parent_f1", "v1");
    +    topDocument.addField("parent_f2", "v2");
    +
    +    int childsNum = atLeast(10);
    +    Map<String, SolrInputDocument> children = new HashMap<>(childsNum);
    +    for(int i = 0; i < childsNum; ++i) {
    +      SolrInputDocument child = new SolrInputDocument();
    +      child.addField("key", (i + 5) * atLeast(4));
    +      String childKey = String.format(Locale.ROOT, "child%d", i);
    +      topDocument.addField(childKey, child);
    +      children.put(childKey, child);
    +    }
    +
    +    ByteArrayOutputStream os = new ByteArrayOutputStream();
    +    try (JavaBinCodec jbc = new JavaBinCodec()) {
    +      jbc.marshal(topDocument, os);
    +    }
    +    byte[] buffer = os.toByteArray();
    +    //now read the Object back
    +    SolrInputDocument result;
    +    try (JavaBinCodec jbc = new JavaBinCodec(); InputStream is = new 
ByteArrayInputStream(buffer)) {
    +      result = (SolrInputDocument) jbc.unmarshal(is);
    +    }
    +    assertEquals(2 + childsNum, result.size());
    --- End diff --
    
    This is a round-trip test.  Can we do assertEquals(topDocument, result)?


---

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

Reply via email to