You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2012/07/30 17:40:11 UTC

svn commit: r1367125 - in /lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component: DummyCustomParamSpellChecker.java SpellCheckComponentTest.java

Author: yonik
Date: Mon Jul 30 15:40:11 2012
New Revision: 1367125

URL: http://svn.apache.org/viewvc?rev=1367125&view=rev
Log:
SOLR-3688: fix spellcheck test relying on map order

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java?rev=1367125&r1=1367124&r2=1367125&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DummyCustomParamSpellChecker.java Mon Jul 30 15:40:11 2012
@@ -8,8 +8,10 @@ import org.apache.solr.spelling.Spelling
 import org.apache.solr.spelling.SpellingResult;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -49,12 +51,20 @@ public class DummyCustomParamSpellChecke
 
     SpellingResult result = new SpellingResult();
     //just spit back out the results
+
+    // sort the keys to make ordering predictable
     Iterator<String> iterator = options.customParams.getParameterNamesIterator();
+    List<String> lst = new ArrayList<String>();
+    while (iterator.hasNext()) {
+      lst.add(iterator.next());
+    }
+    Collections.sort(lst);
+
     int i = 0;
-    while (iterator.hasNext()){
-      String name = iterator.next();
+    for (String name : lst) {
       String value = options.customParams.get(name);
-      result.add(new Token(name, i++, i++),  Collections.singletonList(value));
+      result.add(new Token(name, i, i+1),  Collections.singletonList(value));
+      i += 2;
     }    
     return result;
   }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java?rev=1367125&r1=1367124&r2=1367125&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java Mon Jul 30 15:40:11 2012
@@ -100,7 +100,6 @@ public class SpellCheckComponentTest ext
 
   @Test
   public void testPerDictionary() throws Exception {
-    assumeFalse("This test fails in most cases with Java 8+, looks like it depends on order of some HashSet/HashMap whatever", Constants.JRE_IS_MINIMUM_JAVA8);
     assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, "true", "q","documemt"
         , SpellingParams.SPELLCHECK_DICT, "perDict", SpellingParams.SPELLCHECK_PREFIX + ".perDict.foo", "bar", SpellingParams.SPELLCHECK_PREFIX + ".perDict.bar", "foo")
        ,"/spellcheck/suggestions/bar=={'numFound':1, 'startOffset':0, 'endOffset':1, 'suggestion':['foo']}"