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:
Noble Paul 2014-06-12 12:18:21 +00:00
parent cb3113bc83
commit 51412938e5
3 changed files with 23 additions and 25 deletions

View File

@ -26,7 +26,6 @@ import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
@ -407,16 +406,16 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
SolrDocument doc2 = new SolrDocument();
doc2.addField("foo", randomString);
assertTrue(assertSolrDocumentEquals(doc1, doc2));
assertTrue(compareSolrDocument(doc1, doc2));
doc1.addField("foo", "bar");
assertFalse(assertSolrDocumentEquals(doc1, doc2));
assertFalse(compareSolrDocument(doc1, doc2));
doc1 = new SolrDocument();
doc1.addField("bar", randomString);
assertFalse(assertSolrDocumentEquals(doc1, doc2));
assertFalse(compareSolrDocument(doc1, doc2));
int randomInt = random().nextInt();
doc1 = new SolrDocument();
@ -424,12 +423,12 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
doc2 = new SolrDocument();
doc2.addField("foo", randomInt);
assertTrue(assertSolrDocumentEquals(doc1, doc2));
assertTrue(compareSolrDocument(doc1, doc2));
doc2 = new SolrDocument();
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();
doc2.addField("foo", randomString);
assertTrue(assertSolrInputDocumentEquals(doc1, doc2));
assertTrue(compareSolrInputDocument(doc1, doc2));
doc1.setDocumentBoost(1.1f);
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
assertFalse(compareSolrInputDocument(doc1, doc2));
doc2.setDocumentBoost(1.1f);
assertTrue(assertSolrInputDocumentEquals(doc1, doc2));
assertTrue(compareSolrInputDocument(doc1, doc2));
doc2.setDocumentBoost(20f);
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
assertFalse(compareSolrInputDocument(doc1, doc2));
doc1 = new SolrInputDocument();
@ -463,15 +462,15 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
childDoc.addField("foo", "bar");
doc1.addChildDocument(childDoc);
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
assertFalse(compareSolrInputDocument(doc1, doc2));
doc2.addChildDocument(childDoc);
assertTrue(assertSolrInputDocumentEquals(doc1, doc2));
assertTrue(compareSolrInputDocument(doc1, doc2));
SolrInputDocument childDoc1 = new SolrInputDocument();
childDoc.addField(TestUtil.randomSimpleString(random()), TestUtil.randomSimpleString(random()));
doc2.addChildDocument(childDoc1);
assertFalse(assertSolrInputDocumentEquals(doc1, doc2));
assertFalse(compareSolrInputDocument(doc1, doc2));
}

View File

@ -32,7 +32,6 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.EnumFieldValue;
@ -183,13 +182,13 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
byte[] b2 = (byte[]) matchObj.get(i);
assertTrue(Arrays.equals(b1, b2));
} 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 ) {
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) {
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) {
assertSolrInputFieldEquals(unmarshaledObj.get(i), matchObj.get(i));
assertTrue(assertSolrInputFieldEquals(unmarshaledObj.get(i), matchObj.get(i)));
} else {
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);
SolrDocument sdoc = (SolrDocument) javabin.unmarshal(is);
SolrDocument matchSolrDoc = generateSolrDocumentWithChildDocs();
assertTrue(assertSolrDocumentEquals(sdoc, matchSolrDoc));
assertTrue(compareSolrDocument(sdoc, matchSolrDoc));
} catch (IOException e) {
throw e;
}

View File

@ -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)) {
return false;
@ -1916,7 +1916,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
Iterator<SolrDocument> childDocsIter1 = solrDocument1.getChildDocuments().iterator();
Iterator<SolrDocument> childDocsIter2 = solrDocument2.getChildDocuments().iterator();
while(childDocsIter1.hasNext()) {
if(!assertSolrDocumentEquals(childDocsIter1.next(), childDocsIter2.next())) {
if(!compareSolrDocument(childDocsIter1.next(), childDocsIter2.next())) {
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)) {
return false;
}
@ -1941,14 +1941,14 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
return false;
}
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 true;
}
public boolean assertSolrInputDocumentEquals(Object expected, Object actual) {
public boolean compareSolrInputDocument(Object expected, Object actual) {
if (!(expected instanceof SolrInputDocument) || !(actual instanceof SolrInputDocument)) {
return false;
@ -1993,7 +1993,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
Iterator<SolrInputDocument> childDocsIter1 = sdoc1.getChildDocuments().iterator();
Iterator<SolrInputDocument> childDocsIter2 = sdoc2.getChildDocuments().iterator();
while(childDocsIter1.hasNext()) {
if(!assertSolrInputDocumentEquals(childDocsIter1.next(), childDocsIter2.next())) {
if(!compareSolrInputDocument(childDocsIter1.next(), childDocsIter2.next())) {
return false;
}
}