From 1e524542e1b4413ec30879a224ffb6d94cb13da7 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 20 May 2014 18:17:30 +0000 Subject: [PATCH] make this assert more robust git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596346 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/solr/request/TestFaceting.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/request/TestFaceting.java b/solr/core/src/test/org/apache/solr/request/TestFaceting.java index 410d4da1e98..3e7e57db1b8 100644 --- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java +++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java @@ -23,6 +23,7 @@ import java.util.Locale; import java.util.Random; import org.apache.lucene.index.DocValues; +import org.apache.lucene.index.MultiDocValues; import org.apache.lucene.index.SortedDocValues; import org.apache.lucene.index.SortedSetDocValues; import org.apache.lucene.index.Term; @@ -955,9 +956,27 @@ public class TestFaceting extends SolrTestCaseJ4 { SortedDocValues singleton1 = DocValues.unwrapSingleton(dv1); SortedDocValues singleton2 = DocValues.unwrapSingleton(dv2); if (singleton1 == null || singleton2 == null) { - assertSame(dv1, dv2); + // actually a multi-valued field + if (dv1 instanceof MultiDocValues.MultiSortedSetDocValues) { + // if we produced more than one segment, ensure the core ordinal map is the same object + assertTrue(dv2 instanceof MultiDocValues.MultiSortedSetDocValues); + assertSame(((MultiDocValues.MultiSortedSetDocValues) dv1).mapping, + ((MultiDocValues.MultiSortedSetDocValues) dv2).mapping); + } else { + // otherwise, same atomic instance + assertSame(dv1, dv2); + } } else { - assertSame(singleton1, singleton2); + // just wrapping a field that is actually single-valued + if (singleton1 instanceof MultiDocValues.MultiSortedDocValues) { + // if we produced more than one segment, ensure the core ordinal map is the same object + assertTrue(singleton2 instanceof MultiDocValues.MultiSortedDocValues); + assertSame(((MultiDocValues.MultiSortedDocValues) singleton1).mapping, + ((MultiDocValues.MultiSortedDocValues) singleton2).mapping); + } else { + // otherwise, same atomic instance + assertSame(singleton1, singleton2); + } } } }