mirror of https://github.com/apache/lucene.git
SOLR-6048 the assert was not really failing the test
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1602138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb3113bc83
commit
51412938e5
|
@ -26,7 +26,6 @@ import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
import org.apache.solr.common.SolrDocumentList;
|
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
@ -407,16 +406,16 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
|
||||||
SolrDocument doc2 = new SolrDocument();
|
SolrDocument doc2 = new SolrDocument();
|
||||||
doc2.addField("foo", randomString);
|
doc2.addField("foo", randomString);
|
||||||
|
|
||||||
assertTrue(assertSolrDocumentEquals(doc1, doc2));
|
assertTrue(compareSolrDocument(doc1, doc2));
|
||||||
|
|
||||||
doc1.addField("foo", "bar");
|
doc1.addField("foo", "bar");
|
||||||
|
|
||||||
assertFalse(assertSolrDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrDocument(doc1, doc2));
|
||||||
|
|
||||||
doc1 = new SolrDocument();
|
doc1 = new SolrDocument();
|
||||||
doc1.addField("bar", randomString);
|
doc1.addField("bar", randomString);
|
||||||
|
|
||||||
assertFalse(assertSolrDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrDocument(doc1, doc2));
|
||||||
|
|
||||||
int randomInt = random().nextInt();
|
int randomInt = random().nextInt();
|
||||||
doc1 = new SolrDocument();
|
doc1 = new SolrDocument();
|
||||||
|
@ -424,12 +423,12 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
|
||||||
doc2 = new SolrDocument();
|
doc2 = new SolrDocument();
|
||||||
doc2.addField("foo", randomInt);
|
doc2.addField("foo", randomInt);
|
||||||
|
|
||||||
assertTrue(assertSolrDocumentEquals(doc1, doc2));
|
assertTrue(compareSolrDocument(doc1, doc2));
|
||||||
|
|
||||||
doc2 = new SolrDocument();
|
doc2 = new SolrDocument();
|
||||||
doc2.addField("bar", randomInt);
|
doc2.addField("bar", randomInt);
|
||||||
|
|
||||||
assertFalse(assertSolrDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrDocument(doc1, doc2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,16 +441,16 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
|
||||||
SolrInputDocument doc2 = new SolrInputDocument();
|
SolrInputDocument doc2 = new SolrInputDocument();
|
||||||
doc2.addField("foo", randomString);
|
doc2.addField("foo", randomString);
|
||||||
|
|
||||||
assertTrue(assertSolrInputDocumentEquals(doc1, doc2));
|
assertTrue(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
doc1.setDocumentBoost(1.1f);
|
doc1.setDocumentBoost(1.1f);
|
||||||
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
doc2.setDocumentBoost(1.1f);
|
doc2.setDocumentBoost(1.1f);
|
||||||
assertTrue(assertSolrInputDocumentEquals(doc1, doc2));
|
assertTrue(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
doc2.setDocumentBoost(20f);
|
doc2.setDocumentBoost(20f);
|
||||||
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
|
|
||||||
doc1 = new SolrInputDocument();
|
doc1 = new SolrInputDocument();
|
||||||
|
@ -463,15 +462,15 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
|
||||||
childDoc.addField("foo", "bar");
|
childDoc.addField("foo", "bar");
|
||||||
|
|
||||||
doc1.addChildDocument(childDoc);
|
doc1.addChildDocument(childDoc);
|
||||||
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
doc2.addChildDocument(childDoc);
|
doc2.addChildDocument(childDoc);
|
||||||
assertTrue(assertSolrInputDocumentEquals(doc1, doc2));
|
assertTrue(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
SolrInputDocument childDoc1 = new SolrInputDocument();
|
SolrInputDocument childDoc1 = new SolrInputDocument();
|
||||||
childDoc.addField(TestUtil.randomSimpleString(random()), TestUtil.randomSimpleString(random()));
|
childDoc.addField(TestUtil.randomSimpleString(random()), TestUtil.randomSimpleString(random()));
|
||||||
doc2.addChildDocument(childDoc1);
|
doc2.addChildDocument(childDoc1);
|
||||||
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
|
assertFalse(compareSolrInputDocument(doc1, doc2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.apache.solr.common.EnumFieldValue;
|
import org.apache.solr.common.EnumFieldValue;
|
||||||
|
@ -183,13 +182,13 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
||||||
byte[] b2 = (byte[]) matchObj.get(i);
|
byte[] b2 = (byte[]) matchObj.get(i);
|
||||||
assertTrue(Arrays.equals(b1, b2));
|
assertTrue(Arrays.equals(b1, b2));
|
||||||
} else if(unmarshaledObj.get(i) instanceof SolrDocument && matchObj.get(i) instanceof SolrDocument ) {
|
} else if(unmarshaledObj.get(i) instanceof SolrDocument && matchObj.get(i) instanceof SolrDocument ) {
|
||||||
assertSolrDocumentEquals(unmarshaledObj.get(i), matchObj.get(i));
|
assertTrue(compareSolrDocument(unmarshaledObj.get(i), matchObj.get(i)));
|
||||||
} else if(unmarshaledObj.get(i) instanceof SolrDocumentList && matchObj.get(i) instanceof SolrDocumentList ) {
|
} else if(unmarshaledObj.get(i) instanceof SolrDocumentList && matchObj.get(i) instanceof SolrDocumentList ) {
|
||||||
assertSolrDocumentEquals(unmarshaledObj.get(i), matchObj.get(i));
|
assertTrue(compareSolrDocumentList(unmarshaledObj.get(i), matchObj.get(i)));
|
||||||
} else if(unmarshaledObj.get(i) instanceof SolrInputDocument && matchObj.get(i) instanceof SolrInputDocument) {
|
} else if(unmarshaledObj.get(i) instanceof SolrInputDocument && matchObj.get(i) instanceof SolrInputDocument) {
|
||||||
assertSolrInputDocumentEquals(unmarshaledObj.get(i), matchObj.get(i));
|
assertTrue(compareSolrInputDocument(unmarshaledObj.get(i), matchObj.get(i)));
|
||||||
} else if(unmarshaledObj.get(i) instanceof SolrInputField && matchObj.get(i) instanceof SolrInputField) {
|
} else if(unmarshaledObj.get(i) instanceof SolrInputField && matchObj.get(i) instanceof SolrInputField) {
|
||||||
assertSolrInputFieldEquals(unmarshaledObj.get(i), matchObj.get(i));
|
assertTrue(assertSolrInputFieldEquals(unmarshaledObj.get(i), matchObj.get(i)));
|
||||||
} else {
|
} else {
|
||||||
assertEquals(unmarshaledObj.get(i), matchObj.get(i));
|
assertEquals(unmarshaledObj.get(i), matchObj.get(i));
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
||||||
InputStream is = getClass().getResourceAsStream(SOLRJ_JAVABIN_BACKCOMPAT_BIN_CHILD_DOCS);
|
InputStream is = getClass().getResourceAsStream(SOLRJ_JAVABIN_BACKCOMPAT_BIN_CHILD_DOCS);
|
||||||
SolrDocument sdoc = (SolrDocument) javabin.unmarshal(is);
|
SolrDocument sdoc = (SolrDocument) javabin.unmarshal(is);
|
||||||
SolrDocument matchSolrDoc = generateSolrDocumentWithChildDocs();
|
SolrDocument matchSolrDoc = generateSolrDocumentWithChildDocs();
|
||||||
assertTrue(assertSolrDocumentEquals(sdoc, matchSolrDoc));
|
assertTrue(compareSolrDocument(sdoc, matchSolrDoc));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1873,7 +1873,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean assertSolrDocumentEquals(Object expected, Object actual) {
|
public boolean compareSolrDocument(Object expected, Object actual) {
|
||||||
|
|
||||||
if (!(expected instanceof SolrDocument) || !(actual instanceof SolrDocument)) {
|
if (!(expected instanceof SolrDocument) || !(actual instanceof SolrDocument)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1916,7 +1916,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
Iterator<SolrDocument> childDocsIter1 = solrDocument1.getChildDocuments().iterator();
|
Iterator<SolrDocument> childDocsIter1 = solrDocument1.getChildDocuments().iterator();
|
||||||
Iterator<SolrDocument> childDocsIter2 = solrDocument2.getChildDocuments().iterator();
|
Iterator<SolrDocument> childDocsIter2 = solrDocument2.getChildDocuments().iterator();
|
||||||
while(childDocsIter1.hasNext()) {
|
while(childDocsIter1.hasNext()) {
|
||||||
if(!assertSolrDocumentEquals(childDocsIter1.next(), childDocsIter2.next())) {
|
if(!compareSolrDocument(childDocsIter1.next(), childDocsIter2.next())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1924,7 +1924,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean assertSolrDocumentList(Object expected, Object actual) {
|
public boolean compareSolrDocumentList(Object expected, Object actual) {
|
||||||
if (!(expected instanceof SolrDocumentList) || !(actual instanceof SolrDocumentList)) {
|
if (!(expected instanceof SolrDocumentList) || !(actual instanceof SolrDocumentList)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1941,14 +1941,14 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(int i=0; i<list1.getNumFound(); i++) {
|
for(int i=0; i<list1.getNumFound(); i++) {
|
||||||
if(!assertSolrDocumentEquals(list1.get(i), list2.get(i))) {
|
if(!compareSolrDocument(list1.get(i), list2.get(i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean assertSolrInputDocumentEquals(Object expected, Object actual) {
|
public boolean compareSolrInputDocument(Object expected, Object actual) {
|
||||||
|
|
||||||
if (!(expected instanceof SolrInputDocument) || !(actual instanceof SolrInputDocument)) {
|
if (!(expected instanceof SolrInputDocument) || !(actual instanceof SolrInputDocument)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1993,7 +1993,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
||||||
Iterator<SolrInputDocument> childDocsIter1 = sdoc1.getChildDocuments().iterator();
|
Iterator<SolrInputDocument> childDocsIter1 = sdoc1.getChildDocuments().iterator();
|
||||||
Iterator<SolrInputDocument> childDocsIter2 = sdoc2.getChildDocuments().iterator();
|
Iterator<SolrInputDocument> childDocsIter2 = sdoc2.getChildDocuments().iterator();
|
||||||
while(childDocsIter1.hasNext()) {
|
while(childDocsIter1.hasNext()) {
|
||||||
if(!assertSolrInputDocumentEquals(childDocsIter1.next(), childDocsIter2.next())) {
|
if(!compareSolrInputDocument(childDocsIter1.next(), childDocsIter2.next())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue