lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r886210 [4/4] - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/bg/ contrib/analyzers/common/src/java/org/apache/l...
Date Wed, 02 Dec 2009 17:27:08 GMT
Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/function/CustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/function/CustomScoreQuery.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/function/CustomScoreQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/function/CustomScoreQuery.java Wed Dec  2 17:26:34 2009
@@ -349,7 +349,7 @@
     @Override
     public Explanation explain(IndexReader reader, int doc) throws IOException {
       Explanation explain = doExplain(reader, doc);
-      return explain == null ? new Explanation(0.0f, "no matching docs") : doExplain(reader, doc);
+      return explain == null ? new Explanation(0.0f, "no matching docs") : explain;
     }
     
     private Explanation doExplain(IndexReader reader, int doc) throws IOException {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanScorer.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanScorer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanScorer.java Wed Dec  2 17:26:34 2009
@@ -95,7 +95,7 @@
   @Override
   public float score() throws IOException {
     float raw = getSimilarity().tf(freq) * value; // raw score
-    return norms == null? raw : raw * Similarity.decodeNorm(norms[doc]); // normalize
+    return norms == null? raw : raw * getSimilarity().decodeNormValue(norms[doc]); // normalize
   }
 
   /** This method is no longer an official member of {@link Scorer},

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanWeight.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanWeight.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanWeight.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanWeight.java Wed Dec  2 17:26:34 2009
@@ -118,7 +118,7 @@
     Explanation fieldNormExpl = new Explanation();
     byte[] fieldNorms = reader.norms(field);
     float fieldNorm =
-      fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 1.0f;
+      fieldNorms!=null ? similarity.decodeNormValue(fieldNorms[doc]) : 1.0f;
     fieldNormExpl.setValue(fieldNorm);
     fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
     fieldExpl.addDetail(fieldNormExpl);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/FSDirectory.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/FSDirectory.java Wed Dec  2 17:26:34 2009
@@ -372,7 +372,13 @@
     isOpen = false;
   }
 
+  /** @deprecated Use {@link #getDirectory} instead. */
   public File getFile() {
+    return getDirectory();
+  }
+
+  /** @return the underlying filesystem directory */
+  public File getDirectory() {
     ensureOpen();
     return directory;
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleLRUCache.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleLRUCache.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleLRUCache.java Wed Dec  2 17:26:34 2009
@@ -24,7 +24,9 @@
  * Simple LRU cache implementation that uses a LinkedHashMap.
  * This cache is not synchronized, use {@link Cache#synchronizedCache(Cache)}
  * if needed.
- * 
+ *
+ * @deprecated Lucene's internal use of this class has now
+ * switched to {@link DoubleBarrelLRUCache}.
  */
 public class SimpleLRUCache<K,V> extends SimpleMapCache<K,V> {
   private final static float LOADFACTOR = 0.75f;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleMapCache.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleMapCache.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleMapCache.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/cache/SimpleMapCache.java Wed Dec  2 17:26:34 2009
@@ -25,6 +25,9 @@
  * Simple cache implementation that uses a HashMap to store (key, value) pairs.
  * This cache is not synchronized, use {@link Cache#synchronizedCache(Cache)}
  * if needed.
+ *
+ * @deprecated Lucene's internal use of this class has now
+ * switched to {@link DoubleBarrelLRUCache}.
  */
 public class SimpleMapCache<K,V> extends Cache<K,V> {
   protected Map<K,V> map;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java Wed Dec  2 17:26:34 2009
@@ -108,8 +108,8 @@
   }
 
   private void runTest(Directory dir) throws Exception {
-    // Run for ~7 seconds
-    final long stopTime = System.currentTimeMillis() + 7000;
+    // Run for ~1 seconds
+    final long stopTime = System.currentTimeMillis() + 1000;
 
     SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
     final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), dp, IndexWriter.MaxFieldLength.UNLIMITED);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestAnalyzers.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestAnalyzers.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestAnalyzers.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestAnalyzers.java Wed Dec  2 17:26:34 2009
@@ -139,6 +139,99 @@
     assertTrue(ts.incrementToken());
     assertFalse(ts.incrementToken());
   }
+  
+  private static class LowerCaseWhitespaceAnalyzer extends Analyzer {
+
+    @Override
+    public TokenStream tokenStream(String fieldName, Reader reader) {
+      return new LowerCaseFilter(Version.LUCENE_CURRENT,
+          new WhitespaceTokenizer(reader));
+    }
+    
+  }
+  
+  /**
+   * @deprecated remove this when lucene 3.0 "broken unicode 4" support
+   * is no longer needed.
+   */
+  private static class LowerCaseWhitespaceAnalyzerBWComp extends Analyzer {
+
+    @Override
+    public TokenStream tokenStream(String fieldName, Reader reader) {
+      return new LowerCaseFilter(new WhitespaceTokenizer(reader));
+    }
+    
+  }
+  
+  /**
+   * Test that LowercaseFilter handles entire unicode range correctly
+   */
+  public void testLowerCaseFilter() throws IOException {
+    Analyzer a = new LowerCaseWhitespaceAnalyzer();
+    // BMP
+    assertAnalyzesTo(a, "AbaCaDabA", new String[] { "abacadaba" });
+    // supplementary
+    assertAnalyzesTo(a, "\ud801\udc16\ud801\udc16\ud801\udc16\ud801\udc16",
+        new String[] {"\ud801\udc3e\ud801\udc3e\ud801\udc3e\ud801\udc3e"});
+    assertAnalyzesTo(a, "AbaCa\ud801\udc16DabA", 
+        new String[] { "abaca\ud801\udc3edaba" });
+    // unpaired lead surrogate
+    assertAnalyzesTo(a, "AbaC\uD801AdaBa", 
+        new String [] { "abac\uD801adaba" });
+    // unpaired trail surrogate
+    assertAnalyzesTo(a, "AbaC\uDC16AdaBa", 
+        new String [] { "abac\uDC16adaba" });
+  }
+  
+  /**
+   * Test that LowercaseFilter handles the lowercasing correctly if the term
+   * buffer has a trailing surrogate character leftover and the current term in
+   * the buffer ends with a corresponding leading surrogate.
+   */
+  public void testLowerCaseFilterLowSurrogateLeftover() throws IOException {
+    // test if the limit of the termbuffer is correctly used with supplementary
+    // chars
+    WhitespaceTokenizer tokenizer = new WhitespaceTokenizer(new StringReader(
+        "BogustermBogusterm\udc16"));
+    LowerCaseFilter filter = new LowerCaseFilter(Version.LUCENE_CURRENT,
+        tokenizer);
+    assertTokenStreamContents(filter, new String[] {"bogustermbogusterm\udc16"});
+    filter.reset();
+    String highSurEndingUpper = "BogustermBoguster\ud801";
+    String highSurEndingLower = "bogustermboguster\ud801";
+    tokenizer.reset(new StringReader(highSurEndingUpper));
+    assertTokenStreamContents(filter, new String[] {highSurEndingLower});
+    assertTrue(filter.hasAttribute(TermAttribute.class));
+    char[] termBuffer = filter.getAttribute(TermAttribute.class).termBuffer();
+    int length = highSurEndingLower.length();
+    assertEquals('\ud801', termBuffer[length - 1]);
+    assertEquals('\udc3e', termBuffer[length]);
+    
+  }
+  
+  /**
+   * Test that LowercaseFilter only works on BMP for back compat,
+   * depending upon version
+   * @deprecated remove this test when lucene 3.0 "broken unicode 4" support
+   * is no longer needed.
+   */
+  public void testLowerCaseFilterBWComp() throws IOException {
+    Analyzer a = new LowerCaseWhitespaceAnalyzerBWComp();
+    // BMP
+    assertAnalyzesTo(a, "AbaCaDabA", new String[] { "abacadaba" });
+    // supplementary, no-op
+    assertAnalyzesTo(a, "\ud801\udc16\ud801\udc16\ud801\udc16\ud801\udc16",
+        new String[] {"\ud801\udc16\ud801\udc16\ud801\udc16\ud801\udc16"});
+    assertAnalyzesTo(a, "AbaCa\ud801\udc16DabA",
+        new String[] { "abaca\ud801\udc16daba" });
+    // unpaired lead surrogate
+    assertAnalyzesTo(a, "AbaC\uD801AdaBa", 
+        new String [] { "abac\uD801adaba" });
+    // unpaired trail surrogate
+    assertAnalyzesTo(a, "AbaC\uDC16AdaBa", 
+        new String [] { "abac\uDC16adaba" });
+  }
+  
 }
 
 class PayloadSetter extends TokenFilter {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestCharArraySet.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestCharArraySet.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestCharArraySet.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestCharArraySet.java Wed Dec  2 17:26:34 2009
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Version;
 
 public class TestCharArraySet extends LuceneTestCase {
   
@@ -33,7 +34,7 @@
   
   
   public void testRehash() throws Exception {
-    CharArraySet cas = new CharArraySet(0, true);
+    CharArraySet cas = new CharArraySet(Version.LUCENE_CURRENT, 0, true);
     for(int i=0;i<TEST_STOP_WORDS.length;i++)
       cas.add(TEST_STOP_WORDS[i]);
     assertEquals(TEST_STOP_WORDS.length, cas.size());
@@ -44,7 +45,7 @@
   public void testNonZeroOffset() {
     String[] words={"Hello","World","this","is","a","test"};
     char[] findme="xthisy".toCharArray();   
-    CharArraySet set=new CharArraySet(10,true);
+    CharArraySet set=new CharArraySet(Version.LUCENE_CURRENT, 10,true);
     set.addAll(Arrays.asList(words));
     assertTrue(set.contains(findme, 1, 4));
     assertTrue(set.contains(new String(findme,1,4)));
@@ -56,7 +57,7 @@
   }
   
   public void testObjectContains() {
-    CharArraySet set = new CharArraySet(10, true);
+    CharArraySet set = new CharArraySet(Version.LUCENE_CURRENT, 10, true);
     Integer val = Integer.valueOf(1);
     set.add(val);
     assertTrue(set.contains(val));
@@ -68,7 +69,7 @@
   }
   
   public void testClear(){
-    CharArraySet set=new CharArraySet(10,true);
+    CharArraySet set=new CharArraySet(Version.LUCENE_CURRENT, 10,true);
     set.addAll(Arrays.asList(TEST_STOP_WORDS));
     assertEquals("Not all words added", TEST_STOP_WORDS.length, set.size());
     try{
@@ -81,7 +82,7 @@
   }
   
   public void testModifyOnUnmodifiable(){
-    CharArraySet set=new CharArraySet(10,true);
+    CharArraySet set=new CharArraySet(Version.LUCENE_CURRENT, 10,true);
     set.addAll(Arrays.asList(TEST_STOP_WORDS));
     final int size = set.size();
     set = CharArraySet.unmodifiableSet(set);
@@ -162,7 +163,7 @@
   }
   
   public void testUnmodifiableSet(){
-    CharArraySet set=new CharArraySet(10,true);
+    CharArraySet set = new CharArraySet(Version.LUCENE_CURRENT, 10,true);
     set.addAll(Arrays.asList(TEST_STOP_WORDS));
     final int size = set.size();
     set = CharArraySet.unmodifiableSet(set);
@@ -175,4 +176,129 @@
       // expected
     }
   }
+  
+  public void testSupplementaryChars() {
+    String missing = "Term %s is missing in the set";
+    String falsePos = "Term %s is in the set but shouldn't";
+    // for reference see
+    // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[[%3ACase_Sensitive%3DTrue%3A]%26[^[\u0000-\uFFFF]]]&esc=on
+    String[] upperArr = new String[] {"Abc\ud801\udc1c",
+        "\ud801\udc1c\ud801\udc1cCDE", "A\ud801\udc1cB"};
+    String[] lowerArr = new String[] {"abc\ud801\udc44",
+        "\ud801\udc44\ud801\udc44cde", "a\ud801\udc44b"};
+    CharArraySet set = new CharArraySet(Version.LUCENE_31, Arrays.asList(TEST_STOP_WORDS), true);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertTrue(String.format(missing, lowerArr[i]), set.contains(lowerArr[i]));
+    }
+    set = new CharArraySet(Version.LUCENE_31, Arrays.asList(TEST_STOP_WORDS), false);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertFalse(String.format(falsePos, lowerArr[i]), set.contains(lowerArr[i]));
+    }
+  }
+  
+  public void testSingleHighSurrogate() {
+    String missing = "Term %s is missing in the set";
+    String falsePos = "Term %s is in the set but shouldn't";
+    String[] upperArr = new String[] { "ABC\uD800", "ABC\uD800EfG",
+        "\uD800EfG", "\uD800\ud801\udc1cB" };
+
+    String[] lowerArr = new String[] { "abc\uD800", "abc\uD800efg",
+        "\uD800efg", "\uD800\ud801\udc44b" };
+    CharArraySet set = new CharArraySet(Version.LUCENE_31, Arrays
+        .asList(TEST_STOP_WORDS), true);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertTrue(String.format(missing, lowerArr[i]), set.contains(lowerArr[i]));
+    }
+    set = new CharArraySet(Version.LUCENE_31, Arrays.asList(TEST_STOP_WORDS),
+        false);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertFalse(String.format(falsePos, upperArr[i]), set
+          .contains(lowerArr[i]));
+    }
+  }
+  
+  /**
+   * @deprecated remove this test when lucene 3.0 "broken unicode 4" support is
+   *             no longer needed.
+   */
+  public void testSupplementaryCharsBWCompat() {
+    String missing = "Term %s is missing in the set";
+    String falsePos = "Term %s is in the set but shouldn't";
+    // for reference see
+    // http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[[%3ACase_Sensitive%3DTrue%3A]%26[^[\u0000-\uFFFF]]]&esc=on
+    String[] upperArr = new String[] {"Abc\ud801\udc1c",
+        "\ud801\udc1c\ud801\udc1cCDE", "A\ud801\udc1cB"};
+    String[] lowerArr = new String[] {"abc\ud801\udc44",
+        "\ud801\udc44\ud801\udc44cde", "a\ud801\udc44b"};
+    CharArraySet set = new CharArraySet(Version.LUCENE_30, Arrays.asList(TEST_STOP_WORDS), true);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertFalse(String.format(falsePos, lowerArr[i]), set.contains(lowerArr[i]));
+    }
+    set = new CharArraySet(Version.LUCENE_30, Arrays.asList(TEST_STOP_WORDS), false);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertFalse(String.format(falsePos, lowerArr[i]), set.contains(lowerArr[i]));
+    }
+  }
+
+  /**
+   * @deprecated remove this test when lucene 3.0 "broken unicode 4" support is
+   *             no longer needed.
+   */
+  public void testSingleHighSurrogateBWComapt() {
+    String missing = "Term %s is missing in the set";
+    String falsePos = "Term %s is in the set but shouldn't";
+    String[] upperArr = new String[] { "ABC\uD800", "ABC\uD800EfG",
+        "\uD800EfG", "\uD800\ud801\udc1cB" };
+
+    String[] lowerArr = new String[] { "abc\uD800", "abc\uD800efg",
+        "\uD800efg", "\uD800\ud801\udc44b" };
+    CharArraySet set = new CharArraySet(Version.LUCENE_30, Arrays
+        .asList(TEST_STOP_WORDS), true);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      if (i == lowerArr.length - 1)
+        assertFalse(String.format(falsePos, lowerArr[i]), set
+            .contains(lowerArr[i]));
+      else
+        assertTrue(String.format(missing, lowerArr[i]), set
+            .contains(lowerArr[i]));
+    }
+    set = new CharArraySet(Version.LUCENE_30, Arrays.asList(TEST_STOP_WORDS),
+        false);
+    for (String upper : upperArr) {
+      set.add(upper);
+    }
+    for (int i = 0; i < upperArr.length; i++) {
+      assertTrue(String.format(missing, upperArr[i]), set.contains(upperArr[i]));
+      assertFalse(String.format(falsePos, lowerArr[i]), set
+          .contains(lowerArr[i]));
+    }
+  }
 }

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 17:26:34 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:880793
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213-833960,880727-882265,883074
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:824912-825292,826213-833960,880727-886190

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestStopFilter.java Wed Dec  2 17:26:34 2009
@@ -19,6 +19,7 @@
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
 import org.apache.lucene.util.English;
+import org.apache.lucene.util.Version;
 
 import java.io.IOException;
 import java.io.StringReader;
@@ -37,7 +38,7 @@
   public void testExactCase() throws IOException {
     StringReader reader = new StringReader("Now is The Time");
     Set<String> stopWords = new HashSet(Arrays.asList("is", "the", "Time"));
-    TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords, false);
+    TokenStream stream = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopWords, false);
     final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("Now", termAtt.term());
@@ -49,7 +50,7 @@
   public void testIgnoreCase() throws IOException {
     StringReader reader = new StringReader("Now is The Time");
     Set<String> stopWords = new HashSet(Arrays.asList( "is", "the", "Time" ));
-    TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords, true);
+    TokenStream stream = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopWords, true);
     final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("Now", termAtt.term());
@@ -59,8 +60,8 @@
   public void testStopFilt() throws IOException {
     StringReader reader = new StringReader("Now is The Time");
     String[] stopWords = new String[] { "is", "the", "Time" };
-    Set stopSet = StopFilter.makeStopSet(stopWords);
-    TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopSet);
+    Set stopSet = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords);
+    TokenStream stream = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopSet);
     final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
     assertTrue(stream.incrementToken());
     assertEquals("Now", termAtt.term());
@@ -83,14 +84,14 @@
     log(sb.toString());
     String stopWords[] = (String[]) a.toArray(new String[0]);
     for (int i=0; i<a.size(); i++) log("Stop: "+stopWords[i]);
-    Set stopSet = StopFilter.makeStopSet(stopWords);
+    Set stopSet = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords);
     // with increments
     StringReader reader = new StringReader(sb.toString());
-    StopFilter stpf = new StopFilter(false, new WhitespaceTokenizer(reader), stopSet);
+    StopFilter stpf = new StopFilter(Version.LUCENE_24, new WhitespaceTokenizer(reader), stopSet);
     doTestStopPositons(stpf,true);
     // without increments
     reader = new StringReader(sb.toString());
-    stpf = new StopFilter(false, new WhitespaceTokenizer(reader), stopSet);
+    stpf = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopSet);
     doTestStopPositons(stpf,false);
     // with increments, concatenating two stop filters
     ArrayList a0 = new ArrayList();
@@ -106,12 +107,12 @@
     for (int i=0; i<a0.size(); i++) log("Stop0: "+stopWords0[i]);
     String stopWords1[] = (String[]) a1.toArray(new String[0]);
     for (int i=0; i<a1.size(); i++) log("Stop1: "+stopWords1[i]);
-    Set stopSet0 = StopFilter.makeStopSet(stopWords0);
-    Set stopSet1 = StopFilter.makeStopSet(stopWords1);
+    Set stopSet0 = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords0);
+    Set stopSet1 = StopFilter.makeStopSet(Version.LUCENE_CURRENT, stopWords1);
     reader = new StringReader(sb.toString());
-    StopFilter stpf0 = new StopFilter(false, new WhitespaceTokenizer(reader), stopSet0); // first part of the set
+    StopFilter stpf0 = new StopFilter(Version.LUCENE_CURRENT, new WhitespaceTokenizer(reader), stopSet0); // first part of the set
     stpf0.setEnablePositionIncrements(true);
-    StopFilter stpf01 = new StopFilter(false, stpf0, stopSet1); // two stop filters concatenated!
+    StopFilter stpf01 = new StopFilter(Version.LUCENE_CURRENT, stpf0, stopSet1); // two stop filters concatenated!
     doTestStopPositons(stpf01,true);
   }
   

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/analysis/TestTeeSinkTokenFilter.java Wed Dec  2 17:26:34 2009
@@ -146,7 +146,7 @@
     assertEquals("there must be 2 times 'Dog' in the stream", 2, i);
     
     source1.reset();
-    TokenStream lowerCasing = new LowerCaseFilter(source1);
+    TokenStream lowerCasing = new LowerCaseFilter(Version.LUCENE_CURRENT, source1);
     i = 0;
     termAtt = lowerCasing.getAttribute(TermAttribute.class);
     while (lowerCasing.incrementToken()) {

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 17:26:34 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java:880793
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213-833960,880727-882265,883074
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:824912-825292,826213-833960,880727-886190

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 17:26:34 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java:880793
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213-833960,880727-882265,883074
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:824912-825292,826213-833960,880727-886190

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestAtomicUpdate.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestAtomicUpdate.java Wed Dec  2 17:26:34 2009
@@ -53,7 +53,7 @@
   private static abstract class TimedThread extends Thread {
     boolean failed;
     int count;
-    private static int RUN_TIME_SEC = 3;
+    private static float RUN_TIME_SEC = 0.5f;
     private TimedThread[] allThreads;
 
     abstract public void doWork() throws Throwable;
@@ -64,7 +64,7 @@
 
     @Override
     public void run() {
-      final long stopTime = System.currentTimeMillis() + 1000*RUN_TIME_SEC;
+      final long stopTime = System.currentTimeMillis() + (long) (1000*RUN_TIME_SEC);
 
       count = 0;
 

Propchange: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 17:26:34 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:880793
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213-833960,880727-882265,883074
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:824912-825292,826213-833960,880727-886190

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReader.java Wed Dec  2 17:26:34 2009
@@ -513,7 +513,7 @@
     // is open against the index:
     public void testWritingNorms() throws IOException
     {
-        String tempDir = System.getProperty("tempDir");
+        String tempDir = "target/test";
         if (tempDir == null)
             throw new IOException("tempDir undefined, cannot run test");
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderClone.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderClone.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderClone.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderClone.java Wed Dec  2 17:26:34 2009
@@ -17,9 +17,6 @@
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-
 import org.apache.lucene.index.SegmentReader.Norm;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.analysis.SimpleAnalyzer;
@@ -28,9 +25,7 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.MockRAMDirectory;
-import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.AlreadyClosedException;
 
 /**
  * Tests cloning multiple types of readers, modifying the deletedDocs and norms
@@ -273,13 +268,13 @@
    * @throws Exception
    */
   private void performDefaultTests(IndexReader r1) throws Exception {
-    float norm1 = Similarity.decodeNorm(r1.norms("field1")[4]);
+    float norm1 = Similarity.getDefault().decodeNormValue(r1.norms("field1")[4]);
 
     IndexReader pr1Clone = (IndexReader) r1.clone();
     pr1Clone.deleteDocument(10);
     pr1Clone.setNorm(4, "field1", 0.5f);
-    assertTrue(Similarity.decodeNorm(r1.norms("field1")[4]) == norm1);
-    assertTrue(Similarity.decodeNorm(pr1Clone.norms("field1")[4]) != norm1);
+    assertTrue(Similarity.getDefault().decodeNormValue(r1.norms("field1")[4]) == norm1);
+    assertTrue(Similarity.getDefault().decodeNormValue(pr1Clone.norms("field1")[4]) != norm1);
 
     assertTrue(!r1.isDeleted(10));
     assertTrue(pr1Clone.isDeleted(10));
@@ -426,7 +421,7 @@
     TestIndexReaderReopen.createIndex(dir1, false);
     IndexReader orig = IndexReader.open(dir1, false);
     orig.setNorm(1, "field1", 17.0f);
-    final byte encoded = Similarity.encodeNorm(17.0f);
+    final byte encoded = Similarity.getDefault().encodeNormValue(17.0f);
     assertEquals(encoded, orig.norms("field1")[1]);
 
     // the cloned segmentreader should have 2 references, 1 to itself, and 1 to

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Wed Dec  2 17:26:34 2009
@@ -216,7 +216,8 @@
     }
     
     // norm values should be different 
-    assertTrue(Similarity.decodeNorm(segmentReader3C.norms("field1")[5]) != Similarity.decodeNorm(segmentReader4C.norms("field1")[5]));
+    assertTrue(Similarity.getDefault().decodeNormValue(segmentReader3C.norms("field1")[5]) 
+    		!= Similarity.getDefault().decodeNormValue(segmentReader4C.norms("field1")[5]));
     Norm reader4CCNorm = segmentReader4C.norms.get("field1");
     assertEquals(3, reader3CCNorm.bytesRef().refCount());
     assertEquals(1, reader4CCNorm.bytesRef().refCount());
@@ -283,7 +284,7 @@
       assertEquals("number of norms mismatches", numDocNorms, b.length);
       ArrayList storedNorms = (i == 1 ? modifiedNorms : norms);
       for (int j = 0; j < b.length; j++) {
-        float norm = Similarity.decodeNorm(b[j]);
+        float norm = Similarity.getDefault().decodeNormValue(b[j]);
         float norm1 = ((Float) storedNorms.get(j)).floatValue();
         assertEquals("stored norm value of " + field + " for doc " + j + " is "
             + norm + " - a mismatch!", norm, norm1, 0.000001);
@@ -321,7 +322,8 @@
   private float nextNorm() {
     float norm = lastNorm + normDelta;
     do {
-      float norm1 = Similarity.decodeNorm(Similarity.encodeNorm(norm));
+      float norm1 = Similarity.getDefault().decodeNormValue(
+    		  Similarity.getDefault().encodeNormValue(norm));
       if (norm1 > lastNorm) {
         // System.out.println(norm1+" > "+lastNorm);
         norm = norm1;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Wed Dec  2 17:26:34 2009
@@ -699,7 +699,7 @@
   
   public void testThreadSafety() throws Exception {
     final Directory dir = new MockRAMDirectory();
-    final int n = 150;
+    final int n = 30;
 
     IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
     for (int i = 0; i < n; i++) {
@@ -741,7 +741,7 @@
     final Set readersToClose = Collections.synchronizedSet(new HashSet());
     
     for (int i = 0; i < n; i++) {
-      if (i % 10 == 0) {
+      if (i % 2 == 0) {
         IndexReader refreshed = reader.reopen();
         if (refreshed != reader) {
           readersToClose.add(reader);
@@ -754,7 +754,7 @@
       
       ReaderThreadTask task;
       
-      if (i < 20 ||( i >=50 && i < 70) || i > 90) {
+      if (i < 4 ||( i >=10 && i < 14) || i > 18) {
         task = new ReaderThreadTask() {
           
           @Override
@@ -825,7 +825,7 @@
     }
     
     synchronized(this) {
-      wait(15000);
+      wait(1000);
     }
     
     for (int i = 0; i < n; i++) {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriter.java Wed Dec  2 17:26:34 2009
@@ -438,8 +438,8 @@
 
           dir.close();
 
-          // Try again with 2000 more bytes of free space:
-          diskFree += 2000;
+          // Try again with 5000 more bytes of free space:
+          diskFree += 5000;
         }
       }
 
@@ -2204,7 +2204,7 @@
 
       int idUpto = 0;
       int fullCount = 0;
-      final long stopTime = System.currentTimeMillis() + 500;
+      final long stopTime = System.currentTimeMillis() + 200;
 
       while(System.currentTimeMillis() < stopTime) {
         try {
@@ -2251,7 +2251,7 @@
   public void testCloseWithThreads() throws Exception {
     int NUM_THREADS = 3;
 
-    for(int iter=0;iter<20;iter++) {
+    for(int iter=0;iter<7;iter++) {
       MockRAMDirectory dir = new MockRAMDirectory();
       IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
       ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
@@ -2434,7 +2434,7 @@
 
     int NUM_THREADS = 3;
 
-    for(int iter=0;iter<5;iter++) {
+    for(int iter=0;iter<2;iter++) {
       MockRAMDirectory dir = new MockRAMDirectory();
       IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
       ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Wed Dec  2 17:26:34 2009
@@ -63,7 +63,7 @@
       final Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
       doc.add(idField);
 
-      final long stopTime = System.currentTimeMillis() + 3000;
+      final long stopTime = System.currentTimeMillis() + 500;
 
       while(System.currentTimeMillis() < stopTime) {
         doFail.set(this);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestIndexWriterReader.java Wed Dec  2 17:26:34 2009
@@ -242,7 +242,7 @@
   }
 
   public void testAddIndexesAndDoDeletesThreads() throws Throwable {
-    final int numIter = 5;
+    final int numIter = 2;
     int numDirs = 3;
     
     Directory mainDir = new MockRAMDirectory();
@@ -691,7 +691,7 @@
     IndexReader r = writer.getReader();
 
     final int NUM_THREAD = 5;
-    final float SECONDS = 3;
+    final float SECONDS = 0.5f;
 
     final long endTime = (long) (System.currentTimeMillis() + 1000.*SECONDS);
     final List excs = Collections.synchronizedList(new ArrayList());
@@ -755,7 +755,7 @@
     IndexReader r = writer.getReader();
 
     final int NUM_THREAD = 5;
-    final float SECONDS = 3;
+    final float SECONDS = 0.5f;
 
     final long endTime = (long) (System.currentTimeMillis() + 1000.*SECONDS);
     final List excs = Collections.synchronizedList(new ArrayList());

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java Wed Dec  2 17:26:34 2009
@@ -46,7 +46,7 @@
       indexThreads[x].start();
     }    
     long startTime = System.currentTimeMillis();
-    long duration = 5*1000;
+    long duration = 1000;
     while ((System.currentTimeMillis() - startTime) < duration) {
       Thread.sleep(100);
     }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNorms.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestNorms.java Wed Dec  2 17:26:34 2009
@@ -187,7 +187,7 @@
       assertEquals("number of norms mismatches",numDocNorms,b.length);
       ArrayList storedNorms = (i==1 ? modifiedNorms : norms);
       for (int j = 0; j < b.length; j++) {
-        float norm = Similarity.decodeNorm(b[j]);
+        float norm = similarityOne.decodeNormValue(b[j]);
         float norm1 = ((Float)storedNorms.get(j)).floatValue();
         assertEquals("stored norm value of "+field+" for doc "+j+" is "+norm+" - a mismatch!", norm, norm1, 0.000001);
       }
@@ -223,7 +223,7 @@
   private float nextNorm() {
     float norm = lastNorm + normDelta;
     do {
-      float norm1 = Similarity.decodeNorm(Similarity.encodeNorm(norm));
+      float norm1 = similarityOne.decodeNormValue(similarityOne.encodeNormValue(norm));
       if (norm1 > lastNorm) {
         //System.out.println(norm1+" > "+lastNorm);
         norm = norm1;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestSegmentReader.java Wed Dec  2 17:26:34 2009
@@ -26,7 +26,7 @@
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.search.DefaultSimilarity;
+import org.apache.lucene.search.Similarity;
 import org.apache.lucene.store.RAMDirectory;
 
 public class TestSegmentReader extends LuceneTestCase {
@@ -170,7 +170,7 @@
         if (!reader.hasNorms(f.name())) {
           // test for fake norms of 1.0 or null depending on the flag
           byte [] norms = reader.norms(f.name());
-          byte norm1 = DefaultSimilarity.encodeNorm(1.0f);
+          byte norm1 = Similarity.getDefault().encodeNormValue(1.0f);
           assertNull(norms);
           norms = new byte[reader.maxDoc()];
           reader.norms(f.name(),norms, 0);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing.java Wed Dec  2 17:26:34 2009
@@ -33,7 +33,7 @@
   private static abstract class TimedThread extends Thread {
     boolean failed;
     int count;
-    private static int RUN_TIME_SEC = 6;
+    private static int RUN_TIME_SEC = 1;
     private TimedThread[] allThreads;
 
     abstract public void doWork() throws Throwable;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestStressIndexing2.java Wed Dec  2 17:26:34 2009
@@ -58,7 +58,7 @@
     Directory dir = new MockRAMDirectory();
     
     // TODO: verify equals using IW.getReader
-    DocsAndWriter dw = indexRandomIWReader(10, 100, 100, dir);
+    DocsAndWriter dw = indexRandomIWReader(10, 10, 100, dir);
     IndexReader r = dw.writer.getReader();
     dw.writer.commit();
     verifyEquals(r, dir, "id");
@@ -74,7 +74,7 @@
     Directory dir2 = new MockRAMDirectory();
     // mergeFactor=2; maxBufferedDocs=2; Map docs = indexRandom(1, 3, 2, dir1);
 
-    Map docs = indexRandom(10, 100, 100, dir1);
+    Map docs = indexRandom(10, 10, 100, dir1);
     indexSerial(docs, dir2);
 
     // verifying verify
@@ -87,7 +87,7 @@
   public void testMultiConfig() throws Throwable {
     // test lots of smaller different params together
     r = newRandom();
-    for (int i=0; i<100; i++) {  // increase iterations for better testing
+    for (int i=0; i<20; i++) {  // increase iterations for better testing
       sameFieldOrder=r.nextBoolean();
       mergeFactor=r.nextInt(3)+2;
       maxBufferedDocs=r.nextInt(3)+2;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTransactions.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTransactions.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTransactions.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/TestTransactions.java Wed Dec  2 17:26:34 2009
@@ -39,7 +39,7 @@
 
   private static abstract class TimedThread extends Thread {
     boolean failed;
-    private static int RUN_TIME_SEC = 6;
+    private static float RUN_TIME_SEC = 0.5f;
     private TimedThread[] allThreads;
 
     abstract public void doWork() throws Throwable;
@@ -50,7 +50,7 @@
 
     @Override
     public void run() {
-      final long stopTime = System.currentTimeMillis() + 1000*RUN_TIME_SEC;
+      final long stopTime = System.currentTimeMillis() + (long) (1000*RUN_TIME_SEC);
 
       try {
         while(System.currentTimeMillis() < stopTime && !anyErrors())

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java Wed Dec  2 17:26:34 2009
@@ -138,7 +138,7 @@
     public TokenStream tokenStream(String fieldName, Reader reader) {
       TokenStream result = new StandardTokenizer(Version.LUCENE_CURRENT, reader);
       result = new TestFilter(result);
-      result = new LowerCaseFilter(result);
+      result = new LowerCaseFilter(Version.LUCENE_CURRENT, result);
       return result;
     }
   }
@@ -206,7 +206,7 @@
     public TokenStream tokenStream(String fieldName, Reader reader) {
       TokenStream result = new StandardTokenizer(Version.LUCENE_CURRENT, reader);
       result = new TestPosIncrementFilter(result);
-      result = new LowerCaseFilter(result);
+      result = new LowerCaseFilter(Version.LUCENE_CURRENT, result);
       return result;
     }
   }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/queryParser/TestQueryParser.java Wed Dec  2 17:26:34 2009
@@ -956,7 +956,7 @@
   }
 
   public void testStopwords() throws Exception {
-    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT, StopFilter.makeStopSet("the", "foo")));
+    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT, StopFilter.makeStopSet(Version.LUCENE_CURRENT, "the", "foo")));
     Query result = qp.parse("a:the OR a:foo");
     assertNotNull("result is null and it shouldn't be", result);
     assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
@@ -972,7 +972,7 @@
   }
 
   public void testPositionIncrement() throws Exception {
-    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT, StopFilter.makeStopSet("the", "in", "are", "this")));
+    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT, StopFilter.makeStopSet(Version.LUCENE_CURRENT, "the", "in", "are", "this")));
     qp.setEnablePositionIncrements(true);
     String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
     //               0         2                      5           7  8

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CheckHits.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CheckHits.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CheckHits.java Wed Dec  2 17:26:34 2009
@@ -158,9 +158,6 @@
         Searcher searcher,
         int[] results)
           throws IOException {
-    if (searcher instanceof IndexSearcher) {
-      QueryUtils.check(query,searcher);
-    }
 
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBoolean2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBoolean2.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBoolean2.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBoolean2.java Wed Dec  2 17:26:34 2009
@@ -209,7 +209,7 @@
     try {
 
       // increase number of iterations for more complete testing
-      for (int i=0; i<1000; i++) {
+      for (int i=0; i<50; i++) {
         int level = rnd.nextInt(3);
         q1 = randBoolQuery(new Random(rnd.nextLong()), rnd.nextBoolean(), level, field, vals, null);
         

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Wed Dec  2 17:26:34 2009
@@ -316,7 +316,7 @@
 
 
       // increase number of iterations for more complete testing      
-      for (int i=0; i<1000; i++) {
+      for (int i=0; i<50; i++) {
         int lev = rnd.nextInt(maxLev);
         final long seed = rnd.nextLong();
         BooleanQuery q1 = TestBoolean2.randBoolQuery(new Random(seed), true, lev, field, vals, null);
@@ -331,10 +331,10 @@
         // will not normalize scores.
         TopDocs top1 = s.search(q1,null,100);
         TopDocs top2 = s.search(q2,null,100);
-
-        QueryUtils.check(q1,s);
-        QueryUtils.check(q2,s);
-
+        if (i < 100) {
+          QueryUtils.check(q1,s);
+          QueryUtils.check(q2,s);
+        }
         // The constrained query
         // should be a superset to the unconstrained query.
         if (top2.totalHits > top1.totalHits) {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Wed Dec  2 17:26:34 2009
@@ -24,7 +24,9 @@
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericField;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.TermRef;
 import org.apache.lucene.index.IndexWriter.MaxFieldLength;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.NumericUtils;
@@ -228,7 +230,7 @@
     final Random rnd=newRandom();
     String field="field"+precisionStep;
     int termCountT=0,termCountC=0;
-    for (int i=0; i<50; i++) {
+    for (int i=0; i<10; i++) {
       int lower=(int)(rnd.nextDouble()*noDocs*distance)+startOffset;
       int upper=(int)(rnd.nextDouble()*noDocs*distance)+startOffset;
       if (lower>upper) {
@@ -271,8 +273,8 @@
       assertEquals("Total number of terms should be equal for unlimited precStep", termCountT, termCountC);
     } else {
       System.out.println("Average number of terms during random search on '" + field + "':");
-      System.out.println(" Trie query: " + (((double)termCountT)/(50*4)));
-      System.out.println(" Classical query: " + (((double)termCountC)/(50*4)));
+      System.out.println(" Trie query: " + (((double)termCountT)/(10*4)));
+      System.out.println(" Classical query: " + (((double)termCountC)/(10*4)));
     }
   }
   
@@ -295,8 +297,8 @@
   private void testRangeSplit(int precisionStep) throws Exception {
     final Random rnd=newRandom();
     String field="ascfield"+precisionStep;
-    // 50 random tests
-    for (int i=0; i<50; i++) {
+    // 10 random tests
+    for (int i=0; i<10; i++) {
       int lower=(int)(rnd.nextDouble()*noDocs - noDocs/2);
       int upper=(int)(rnd.nextDouble()*noDocs - noDocs/2);
       if (lower>upper) {
@@ -437,4 +439,41 @@
     assertFalse(q2.equals(q1));
   }
   
+  private void testEnum(int lower, int upper) throws Exception {
+    NumericRangeQuery<Integer> q = NumericRangeQuery.newIntRange("field4", 4,
+        lower, upper, true, true);
+    FilteredTermsEnum termEnum = q.getTermsEnum(searcher.getIndexReader());
+    //nocommit: double check this merge 'fix'
+    int count = 0;
+    if (termEnum.next() != null) {
+      do {
+        final TermRef t = termEnum.term();
+        if (t != null) {
+          final int val = NumericUtils.prefixCodedToInt(t.toString());
+          assertTrue("value not in bounds " + val + " >= " + lower + " && "
+              + val + " <= " + upper, val >= lower && val <= upper);
+          count++;
+        } else
+          break;
+      } while (termEnum.next() != null);
+    }
+    assertFalse(termEnum.next() != null);
+    System.out.println("TermEnum on 'field4' for range [" + lower + "," + upper
+        + "] contained " + count + " terms.");
+
+  }
+  
+  public void testEnum() throws Exception {
+    int count=3000;
+    int lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
+    // test enum with values
+    testEnum(lower, upper);
+    // test empty enum
+    testEnum(upper, lower);
+    // test empty enum outside of bounds
+    lower = distance*noDocs+startOffset;
+    upper = 2 * lower;
+    testEnum(lower, upper);
+  }
+  
 }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java Wed Dec  2 17:26:34 2009
@@ -244,7 +244,7 @@
     final Random rnd=newRandom();
     String field="field"+precisionStep;
     int termCountT=0,termCountC=0;
-    for (int i=0; i<50; i++) {
+    for (int i=0; i<10; i++) {
       long lower=(long)(rnd.nextDouble()*noDocs*distance)+startOffset;
       long upper=(long)(rnd.nextDouble()*noDocs*distance)+startOffset;
       if (lower>upper) {
@@ -287,8 +287,8 @@
       assertEquals("Total number of terms should be equal for unlimited precStep", termCountT, termCountC);
     } else {
       System.out.println("Average number of terms during random search on '" + field + "':");
-      System.out.println(" Trie query: " + (((double)termCountT)/(50*4)));
-      System.out.println(" Classical query: " + (((double)termCountC)/(50*4)));
+      System.out.println(" Trie query: " + (((double)termCountT)/(10*4)));
+      System.out.println(" Classical query: " + (((double)termCountC)/(10*4)));
     }
   }
   
@@ -315,8 +315,8 @@
   private void testRangeSplit(int precisionStep) throws Exception {
     final Random rnd=newRandom();
     String field="ascfield"+precisionStep;
-    // 50 random tests
-    for (int i=0; i<50; i++) {
+    // 10 random tests
+    for (int i=0; i<10; i++) {
       long lower=(long)(rnd.nextDouble()*noDocs - noDocs/2);
       long upper=(long)(rnd.nextDouble()*noDocs - noDocs/2);
       if (lower>upper) {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositionIncrement.java Wed Dec  2 17:26:34 2009
@@ -234,7 +234,8 @@
     @Override
     public TokenStream tokenStream(String fieldName, Reader reader) {
       TokenStream ts = a.tokenStream(fieldName,reader);
-      return new StopFilter(enablePositionIncrements, ts, new CharArraySet(Collections.singleton("stop"), true));
+      return new StopFilter(enablePositionIncrements?Version.LUCENE_CURRENT:Version.LUCENE_24, ts,
+          new CharArraySet(Version.LUCENE_CURRENT, Collections.singleton("stop"), true));
     }
   }
   
@@ -264,7 +265,7 @@
     assertFalse(tp.next());
 
     IndexSearcher is = new IndexSearcher(r);
-
+  
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
     SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
     SpanQuery[] sqs = { stq1, stq2 };
@@ -281,14 +282,14 @@
         System.out.println("doc " + pspans.doc() + ": span " + pspans.start()
             + " to " + pspans.end());
       }
-      Collection payloads = pspans.getPayload();
+      Collection<byte[]> payloads = pspans.getPayload();
       sawZero |= pspans.start() == 0;
-      for (Iterator it = payloads.iterator(); it.hasNext();) {
+      for (@SuppressWarnings("unused") byte[] bytes : payloads) {
         count++;
         if (!VERBOSE) {
-          it.next();
+          // do nothing
         } else {
-          System.out.println("  payload: " + new String((byte[]) it.next()));
+          System.out.println("  payload: " + new String((byte[]) bytes));
         }
       }
     }
@@ -312,11 +313,11 @@
 
     sawZero = false;
     PayloadSpanUtil psu = new PayloadSpanUtil(is.getIndexReader());
-    Collection pls = psu.getPayloadsForQuery(snq);
+    Collection<byte[]> pls = psu.getPayloadsForQuery(snq);
     count = pls.size();
-    for (Iterator it = pls.iterator(); it.hasNext();) {
-      String s = new String((byte[]) it.next());
-      // System.out.println(s);
+    for (byte[] bytes : pls) {
+      String s = new String(bytes);
+      //System.out.println(s);
       sawZero |= s.equals("pos: 0");
     }
     assertEquals(5, count);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Wed Dec  2 17:26:34 2009
@@ -40,7 +40,7 @@
  * and (3) a sanity test with multiple searching threads.
  */
 public class TestTimeLimitingCollector extends LuceneTestCase {
-  private static final int SLOW_DOWN = 47;
+  private static final int SLOW_DOWN = 3;
   private static final long TIME_ALLOWED = 17 * SLOW_DOWN; // so searches can find about 17 docs.
   
   // max time allowed is relaxed for multithreading tests. 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestWildcard.java Wed Dec  2 17:26:34 2009
@@ -104,7 +104,7 @@
     MultiTermQuery wq = new WildcardQuery(new Term("field", ""));
     wq.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
     assertMatches(searcher, wq, 0);
-    BooleanQuery expected = new BooleanQuery();
+    BooleanQuery expected = new BooleanQuery(true);
     assertEquals(searcher.rewrite(expected), searcher.rewrite(wq));
   }
   

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java Wed Dec  2 17:26:34 2009
@@ -206,7 +206,13 @@
     assertEquals("queries should have same #hits",h1.size(),h3CustomMul.size());
     assertEquals("queries should have same #hits",h1.size(),h4CustomAdd.size());
     assertEquals("queries should have same #hits",h1.size(),h5CustomMulAdd.size());
-    
+
+    QueryUtils.check(q1,s);
+    QueryUtils.check(q2,s);
+    QueryUtils.check(q3,s);
+    QueryUtils.check(q4,s);
+    QueryUtils.check(q5,s);
+
     // verify scores ratios
     for (Iterator it = h1.keySet().iterator(); it.hasNext();) {
       Integer x = (Integer) it.next();
@@ -240,7 +246,6 @@
   }
 
   private void logResult(String msg, IndexSearcher s, Query q, int doc, float score1) throws IOException {
-    QueryUtils.check(q,s);
     log(msg+" "+score1);
     log("Explain by: "+q);
     log(s.explain(q,doc));

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Wed Dec  2 17:26:34 2009
@@ -58,7 +58,7 @@
     }
   }
 
-  private static final long TEST_FILE_LENGTH = 1024*1024;
+  private static final long TEST_FILE_LENGTH = 100*1024;
  
   // Call readByte() repeatedly, past the buffer boundary, and see that it
   // is working as expected.
@@ -94,15 +94,10 @@
     // run test with chunk size of 10 bytes
     runReadBytesAndClose(new SimpleFSIndexInput(tmpInputFile,
                                                 inputBufferSize, 10), inputBufferSize, r);
-    // run test with chunk size of 100 MB - default
-    runReadBytesAndClose(new SimpleFSIndexInput(tmpInputFile,
-                                                inputBufferSize, FSDirectory.DEFAULT_READ_CHUNK_SIZE), inputBufferSize, r);
+
     // run test with chunk size of 10 bytes
     runReadBytesAndClose(new NIOFSIndexInput(tmpInputFile,
                                              inputBufferSize, 10), inputBufferSize, r);
-    // run test with chunk size of 100 MB - default
-    runReadBytesAndClose(new NIOFSIndexInput(tmpInputFile,
-                                             inputBufferSize, FSDirectory.DEFAULT_READ_CHUNK_SIZE), inputBufferSize, r);
   }
 
   private void runReadBytesAndClose(IndexInput input, int bufferSize, Random r)
@@ -129,7 +124,7 @@
       }
     }
     // wildly fluctuating size:
-    for (long i = 0; i < 1000; i++) {
+    for (long i = 0; i < 100; i++) {
       final int size = r.nextInt(10000);
       checkReadBytes(input, 1+size, pos);
       pos += 1+size;
@@ -172,10 +167,10 @@
     }
   }
    
-   // This tests that attempts to readBytes() past an EOF will fail, while
-   // reads up to the EOF will succeed. The EOF is determined by the
-   // BufferedIndexInput's arbitrary length() value.
-   public void testEOF() throws Exception {
+  // This tests that attempts to readBytes() past an EOF will fail, while
+  // reads up to the EOF will succeed. The EOF is determined by the
+  // BufferedIndexInput's arbitrary length() value.
+  public void testEOF() throws Exception {
      MyBufferedIndexInput input = new MyBufferedIndexInput(1024);
      // see that we can read all the bytes at one go:
      checkReadBytes(input, (int)input.length(), 0);  
@@ -223,25 +218,25 @@
         // an infinite file
         this(Long.MAX_VALUE);
       }
-    @Override
-    protected void readInternal(byte[] b, int offset, int length) throws IOException {
-      for(int i=offset; i<offset+length; i++)
-        b[i] = byten(pos++);
-    }
+      @Override
+      protected void readInternal(byte[] b, int offset, int length) throws IOException {
+        for(int i=offset; i<offset+length; i++)
+          b[i] = byten(pos++);
+      }
 
-    @Override
-    protected void seekInternal(long pos) throws IOException {
-      this.pos = pos;
-    }
+      @Override
+      protected void seekInternal(long pos) throws IOException {
+        this.pos = pos;
+      }
 
-    @Override
-    public void close() throws IOException {
-    }
+      @Override
+      public void close() throws IOException {
+      }
 
-    @Override
-    public long length() {
-      return len;
-    }
+      @Override
+      public long length() {
+        return len;
+      }
     }
 
     public void testSetBufferSize() throws IOException {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/LuceneTestCase.java Wed Dec  2 17:26:34 2009
@@ -24,7 +24,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.index.ConcurrentMergeScheduler;
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.search.FieldCache.CacheEntry;
@@ -203,6 +202,7 @@
   
   @Override
   public void runBare() throws Throwable {
+    //long t0 = System.currentTimeMillis();
     try {
       seed = null;
       super.runBare();
@@ -212,6 +212,8 @@
       }
       throw e;
     }
+    //long t = System.currentTimeMillis() - t0;
+    //System.out.println(t + " msec for " + getName());
   }
   
   // recorded seed

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestAttributeSource.java Wed Dec  2 17:26:34 2009
@@ -142,6 +142,7 @@
       src.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
   }
   
+  @SuppressWarnings("unchecked")
   public void testInvalidArguments() throws Exception {
     try {
       AttributeSource src = new AttributeSource();
@@ -154,5 +155,12 @@
       src.addAttribute(Token.class);
       fail("Should throw IllegalArgumentException");
     } catch (IllegalArgumentException iae) {}
+    
+    try {
+      AttributeSource src = new AttributeSource();
+      // break this by unsafe cast
+      src.addAttribute((Class) Iterator.class);
+      fail("Should throw IllegalArgumentException");
+    } catch (IllegalArgumentException iae) {}
   }
 }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/TestIndexableBinaryStringTools.java Wed Dec  2 17:26:34 2009
@@ -22,7 +22,7 @@
 import java.nio.ByteBuffer;
 
 public class TestIndexableBinaryStringTools extends LuceneTestCase {
-  private static final int NUM_RANDOM_TESTS = 20000;
+  private static final int NUM_RANDOM_TESTS = 2000;
   private static final int MAX_RANDOM_BINARY_LENGTH = 300;
   
   public void testSingleBinaryRoundTrip() {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/cache/TestSimpleLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/cache/TestSimpleLRUCache.java?rev=886210&r1=886209&r2=886210&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/cache/TestSimpleLRUCache.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/util/cache/TestSimpleLRUCache.java Wed Dec  2 17:26:34 2009
@@ -17,47 +17,10 @@
 * limitations under the License.
 */
 
-import org.apache.lucene.util.LuceneTestCase;
-
-public class TestSimpleLRUCache extends LuceneTestCase {
-
+/** @deprecated */
+public class TestSimpleLRUCache extends BaseTestLRU {
   public void testLRUCache() throws Exception {
     final int n = 100;
-    Object dummy = new Object();
-    
-    Cache cache = new SimpleLRUCache(n);
-    
-    for (int i = 0; i < n; i++) {
-      cache.put(Integer.valueOf(i), dummy);
-    }
-    
-    // access every 2nd item in cache
-    for (int i = 0; i < n; i+=2) {
-      assertNotNull(cache.get(Integer.valueOf(i)));
-    }
-    
-    // add n/2 elements to cache, the ones that weren't
-    // touched in the previous loop should now be thrown away
-    for (int i = n; i < n + (n / 2); i++) {
-      cache.put(Integer.valueOf(i), dummy);
-    }
-    
-    // access every 4th item in cache
-    for (int i = 0; i < n; i+=4) {
-      assertNotNull(cache.get(Integer.valueOf(i)));
-    }
-
-    // add 3/4n elements to cache, the ones that weren't
-    // touched in the previous loops should now be thrown away
-    for (int i = n; i < n + (n * 3 / 4); i++) {
-      cache.put(Integer.valueOf(i), dummy);
-    }
-    
-    // access every 4th item in cache
-    for (int i = 0; i < n; i+=4) {
-      assertNotNull(cache.get(Integer.valueOf(i)));
-    }
-    
+    testCache(new SimpleLRUCache(n), n);
   }
-  
 }



Mime
View raw message