lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r889683 [5/6] - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/cjk/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/cn/ contrib/analyzers/common/src/java/org/apache/...
Date Fri, 11 Dec 2009 16:22:46 GMT
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=889683&r1=889682&r2=889683&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 Fri Dec 11 16:22:30 2009
@@ -72,7 +72,7 @@
 public class TestQueryParser extends LocalizedTestCase {
 
   public TestQueryParser(String name) {
-    super(name, new HashSet(Arrays.asList(
+    super(name, new HashSet<String>(Arrays.asList(
       "testLegacyDateRange", "testDateRange",
       "testCJK", "testNumber", "testFarsiRangeCollating",
       "testLocalDateFormat"
@@ -798,7 +798,7 @@
 
   public void testBoost()
     throws Exception {
-    Set stopWords = new HashSet(1);
+    Set<Object> stopWords = new HashSet<Object>(1);
     stopWords.add("on");
     StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, stopWords);
     QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", oneStopAnalyzer);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/CachingWrapperFilterHelper.java Fri Dec 11 16:22:30 2009
@@ -18,7 +18,6 @@
  */
 
 import java.io.IOException;
-import java.util.BitSet;
 import java.util.WeakHashMap;
 
 import junit.framework.TestCase;
@@ -46,11 +45,11 @@
   @Override
   public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
     if (cache == null) {
-      cache = new WeakHashMap();
+      cache = new WeakHashMap<IndexReader,DocIdSet>();
     }
     
     synchronized (cache) {  // check cache
-      DocIdSet cached = (DocIdSet) cache.get(reader);
+      DocIdSet cached = cache.get(reader);
       if (shouldHaveCache) {
         TestCase.assertNotNull("Cache should have data ", cached);
       } else {

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=889683&r1=889682&r2=889683&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 Fri Dec 11 16:22:30 2009
@@ -45,7 +45,7 @@
     throws IOException {
 
     String d = q.toString(defaultFieldName);
-    Set ignore = new TreeSet();
+    Set<Integer> ignore = new TreeSet<Integer>();
     for (int i = 0; i < results.length; i++) {
       ignore.add(Integer.valueOf(results[i]));
     }
@@ -85,11 +85,11 @@
 
     QueryUtils.check(query,searcher);
     
-    Set correct = new TreeSet();
+    Set<Integer> correct = new TreeSet<Integer>();
     for (int i = 0; i < results.length; i++) {
       correct.add(Integer.valueOf(results[i]));
     }
-    final Set actual = new TreeSet();
+    final Set<Integer> actual = new TreeSet<Integer>();
     final Collector c = new SetCollector(actual);
 
     searcher.search(query, c);
@@ -117,8 +117,8 @@
   }
 
   public static class SetCollector extends Collector {
-    final Set bag;
-    public SetCollector(Set bag) {
+    final Set<Integer> bag;
+    public SetCollector(Set<Integer> bag) {
       this.bag = bag;
     }
     private int base = 0;
@@ -161,12 +161,12 @@
 
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
 
-    Set correct = new TreeSet();
+    Set<Integer> correct = new TreeSet<Integer>();
     for (int i = 0; i < results.length; i++) {
       correct.add(Integer.valueOf(results[i]));
     }
 
-    Set actual = new TreeSet();
+    Set<Integer> actual = new TreeSet<Integer>();
     for (int i = 0; i < hits.length; i++) {
       actual.add(Integer.valueOf(hits[i].doc));
     }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/JustCompileSearch.java Fri Dec 11 16:22:30 2009
@@ -420,9 +420,9 @@
     }    
   }
 
-  static final class JustCompileTopDocsCollector extends TopDocsCollector {
+  static final class JustCompileTopDocsCollector extends TopDocsCollector<ScoreDoc> {
 
-    protected JustCompileTopDocsCollector(PriorityQueue pq) {
+    protected JustCompileTopDocsCollector(PriorityQueue<ScoreDoc> pq) {
       super(pq);
     }
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/QueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/QueryUtils.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/QueryUtils.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/QueryUtils.java Fri Dec 11 16:22:30 2009
@@ -352,7 +352,7 @@
 
         List<IndexReader> readerList = new ArrayList<IndexReader>();
         ReaderUtil.gatherSubReaders(readerList, s.getIndexReader());
-        IndexReader[] readers = (IndexReader[]) readerList.toArray(new IndexReader[0]);
+        IndexReader[] readers =  readerList.toArray(new IndexReader[0]);
         for(int i = 0; i < readers.length; i++) {
           IndexReader reader = readers[i];
           Weight w = q.weight(s);
@@ -412,7 +412,7 @@
     
     List<IndexReader> readerList = new ArrayList<IndexReader>();
     ReaderUtil.gatherSubReaders(readerList, s.getIndexReader());
-    IndexReader[] readers = (IndexReader[]) readerList.toArray(new IndexReader[0]);
+    IndexReader[] readers = readerList.toArray(new IndexReader[0]);
     for(int i = 0; i < readers.length; i++) {
       IndexReader reader = readers[i];
       Weight w = q.weight(s);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestComplexExplanationsOfNonMatches.java Fri Dec 11 16:22:30 2009
@@ -18,24 +18,6 @@
  */
 
 
-import org.apache.lucene.store.RAMDirectory;
-
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.util.Random;
-import java.util.BitSet;
 
 /**
  * subclass of TestSimpleExplanations that verifies non matches.

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Fri Dec 11 16:22:30 2009
@@ -153,7 +153,7 @@
       // make a query without sorting first
     ScoreDoc[] hitsByRank = searcher.search(query, null, 1000).scoreDocs;
     checkHits(hitsByRank, "Sort by rank: "); // check for duplicates
-        Map resultMap = new TreeMap();
+        Map<Integer,Integer> resultMap = new TreeMap<Integer,Integer>();
         // store hits in TreeMap - TreeMap does not allow duplicates; existing entries are silently overwritten
         for(int hitid=0;hitid<hitsByRank.length; ++hitid) {
             resultMap.put(
@@ -190,7 +190,7 @@
    */
     private void checkHits(ScoreDoc[] hits, String prefix) {
         if(hits!=null) {
-            Map idMap = new TreeMap();
+            Map<Integer,Integer> idMap = new TreeMap<Integer,Integer>();
             for(int docnum=0;docnum<hits.length;++docnum) {
                 Integer luceneId = null;
 
@@ -200,7 +200,7 @@
                     message.append("Duplicate key for hit index = ");
                     message.append(docnum);
                     message.append(", previous index = ");
-                    message.append(((Integer)idMap.get(luceneId)).toString());
+                    message.append((idMap.get(luceneId)).toString());
                     message.append(", Lucene ID = ");
                     message.append(luceneId);
                     log(message.toString());

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestDocIdSet.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestDocIdSet.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestDocIdSet.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestDocIdSet.java Fri Dec 11 16:22:30 2009
@@ -77,7 +77,7 @@
       };
 	  
     DocIdSetIterator iter = filteredSet.iterator();
-    ArrayList/*<Integer>*/ list = new ArrayList/*<Integer>*/();
+    ArrayList<Integer> list = new ArrayList<Integer>();
     int doc = iter.advance(3);
     if (doc != DocIdSetIterator.NO_MORE_DOCS) {
       list.add(Integer.valueOf(doc));
@@ -88,9 +88,9 @@
 	  
     int[] docs = new int[list.size()];
     int c=0;
-    Iterator/*<Integer>*/ intIter = list.iterator();
+    Iterator<Integer> intIter = list.iterator();
     while(intIter.hasNext()) {
-      docs[c++] = ((Integer) intIter.next()).intValue();
+      docs[c++] = intIter.next().intValue();
     }
     int[] answer = new int[]{4,6,8};
     boolean same = Arrays.equals(answer, docs);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestElevationComparator.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestElevationComparator.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestElevationComparator.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestElevationComparator.java Fri Dec 11 16:22:30 2009
@@ -30,7 +30,7 @@
 
 public class TestElevationComparator extends LuceneTestCase {
 
-  private final Map/*<String, Integer>*/ priority = new HashMap/*<String, Integer>*/();
+  private final Map<String,Integer> priority = new HashMap<String,Integer>();
 
   //@Test
   public void testSorting() throws Throwable {
@@ -126,9 +126,9 @@
 }
 
 class ElevationComparatorSource extends FieldComparatorSource {
-  private final Map/*<String, Integer>*/ priority;
+  private final Map<String,Integer> priority;
 
-  public ElevationComparatorSource(final Map/*<String, Integer>*/ boosts) {
+  public ElevationComparatorSource(final Map<String,Integer> boosts) {
    this.priority = boosts;
   }
 
@@ -152,7 +152,7 @@
 
      private int docVal(int doc) throws IOException {
        String id = idIndex.lookup[idIndex.order[doc]];
-       Integer prio = (Integer) priority.get(id);
+       Integer prio = priority.get(id);
        return prio == null ? 0 : prio.intValue();
      }
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java Fri Dec 11 16:22:30 2009
@@ -18,8 +18,7 @@
  */
 
 import java.io.IOException;
-import java.text.Collator;
-import java.util.Locale;
+
 
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -66,7 +65,7 @@
     Query q = new TermQuery(new Term("body","body"));
 
     // test id, bounded on both ends
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter<String> fcrf;
     result = search.search(q,fcrf = FieldCacheRangeFilter.newStringRange("id",minIP,maxIP,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -213,7 +212,7 @@
     Query q = new TermQuery(new Term("body","body"));
 
     // test id, bounded on both ends
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter<Short> fcrf;
     result = search.search(q,fcrf=FieldCacheRangeFilter.newShortRange("id",minIdO,maxIdO,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -305,7 +304,7 @@
 
     // test id, bounded on both ends
         
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter<Integer> fcrf;
     result = search.search(q,fcrf=FieldCacheRangeFilter.newIntRange("id",minIdO,maxIdO,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -397,7 +396,7 @@
 
     // test id, bounded on both ends
         
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter<Long> fcrf;
     result = search.search(q,fcrf=FieldCacheRangeFilter.newLongRange("id",minIdO,maxIdO,T,T), numDocs).scoreDocs;
     assertTrue(fcrf.getDocIdSet(reader.getSequentialSubReaders()[0]).isCacheable());
     assertEquals("find all", numDocs, result.length);
@@ -550,7 +549,7 @@
     assertTrue(reader.hasDeletions());
 
     ScoreDoc[] result;
-    FieldCacheRangeFilter fcrf;
+    FieldCacheRangeFilter<Byte> fcrf;
     Query q = new TermQuery(new Term("body","body"));
 
     result = search.search(q,fcrf=FieldCacheRangeFilter.newByteRange("id",Byte.valueOf((byte) -20),Byte.valueOf((byte) 20),T,T), 100).scoreDocs;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFieldCacheTermsFilter.java Fri Dec 11 16:22:30 2009
@@ -54,20 +54,20 @@
     ScoreDoc[] results;
     MatchAllDocsQuery q = new MatchAllDocsQuery();
 
-    List terms = new ArrayList();
+    List<String> terms = new ArrayList<String>();
     terms.add("5");
-    results = searcher.search(q, new FieldCacheTermsFilter(fieldName, (String[]) terms.toArray(new String[0])), numDocs).scoreDocs;
+    results = searcher.search(q, new FieldCacheTermsFilter(fieldName,  terms.toArray(new String[0])), numDocs).scoreDocs;
     assertEquals("Must match nothing", 0, results.length);
 
-    terms = new ArrayList();
+    terms = new ArrayList<String>();
     terms.add("10");
-    results = searcher.search(q, new FieldCacheTermsFilter(fieldName, (String[]) terms.toArray(new String[0])), numDocs).scoreDocs;
+    results = searcher.search(q, new FieldCacheTermsFilter(fieldName,  terms.toArray(new String[0])), numDocs).scoreDocs;
     assertEquals("Must match 1", 1, results.length);
 
-    terms = new ArrayList();
+    terms = new ArrayList<String>();
     terms.add("10");
     terms.add("20");
-    results = searcher.search(q, new FieldCacheTermsFilter(fieldName, (String[]) terms.toArray(new String[0])), numDocs).scoreDocs;
+    results = searcher.search(q, new FieldCacheTermsFilter(fieldName,  terms.toArray(new String[0])), numDocs).scoreDocs;
     assertEquals("Must match 2", 2, results.length);
 
     reader.close();

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFilteredSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFilteredSearch.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFilteredSearch.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestFilteredSearch.java Fri Dec 11 16:22:30 2009
@@ -24,9 +24,12 @@
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.OpenBitSet;
 
@@ -42,19 +45,32 @@
 
   private static final String FIELD = "category";
   
-  public void testFilteredSearch() {
+  public void testFilteredSearch() throws CorruptIndexException, LockObtainFailedException, IOException {
+    boolean enforceSingleSegment = true;
     RAMDirectory directory = new RAMDirectory();
     int[] filterBits = {1, 36};
-    Filter filter = new SimpleDocIdSetFilter(filterBits);
-    
+    SimpleDocIdSetFilter filter = new SimpleDocIdSetFilter(filterBits);
+    IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+    searchFiltered(writer, directory, filter, enforceSingleSegment);
+    // run the test on more than one segment
+    enforceSingleSegment = false;
+    // reset - it is stateful
+    filter.reset();
+    writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+    // we index 60 docs - this will create 6 segments
+    writer.setMaxBufferedDocs(10);
+    searchFiltered(writer, directory, filter, enforceSingleSegment);
+  }
 
+  public void searchFiltered(IndexWriter writer, Directory directory, Filter filter, boolean optimize) {
     try {
-      IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
       for (int i = 0; i < 60; i++) {//Simple docs
         Document doc = new Document();
         doc.add(new Field(FIELD, Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
         writer.addDocument(doc);
       }
+      if(optimize)
+        writer.optimize();
       writer.close();
 
       BooleanQuery booleanQuery = new BooleanQuery();
@@ -69,24 +85,33 @@
     catch (IOException e) {
       fail(e.getMessage());
     }
-
+    
   }
-  
-
+ 
   public static final class SimpleDocIdSetFilter extends Filter {
-    private OpenBitSet bits;
-
+    private int docBase;
+    private final int[] docs;
+    private int index;
     public SimpleDocIdSetFilter(int[] docs) {
-      bits = new OpenBitSet();
-      for(int i = 0; i < docs.length; i++){
-    	  bits.set(docs[i]);
-      }
-      
+      this.docs = docs;
     }
-
     @Override
     public DocIdSet getDocIdSet(IndexReader reader) {
-      return bits;
+      final OpenBitSet set = new OpenBitSet();
+      final int limit = docBase+reader.maxDoc();
+      for (;index < docs.length; index++) {
+        final int docId = docs[index];
+        if(docId > limit)
+          break;
+        set.set(docId-docBase);
+      }
+      docBase = limit;
+      return set.isEmpty()?null:set;
+    }
+    
+    public void reset(){
+      index = 0;
+      docBase = 0;
     }
   }
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java Fri Dec 11 16:22:30 2009
@@ -17,7 +17,6 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.index.IndexReader;
@@ -69,7 +68,7 @@
         query1.add(new Term("body", "blueberry"));
         query2.add(new Term("body", "strawberry"));
 
-        LinkedList termsWithPrefix = new LinkedList();
+        LinkedList<Term> termsWithPrefix = new LinkedList<Term>();
         IndexReader ir = IndexReader.open(indexStore, true);
 
         // this TermEnum gives "piccadilly", "pie" and "pizza".
@@ -82,9 +81,9 @@
             }
         } while (te.next());
 
-        query1.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query1.add(termsWithPrefix.toArray(new Term[0]));
         assertEquals("body:\"blueberry (piccadilly pie pizza)\"", query1.toString());
-        query2.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query2.add(termsWithPrefix.toArray(new Term[0]));
         assertEquals("body:\"strawberry (piccadilly pie pizza)\"", query2.toString());
 
         ScoreDoc[] result;
@@ -105,8 +104,7 @@
             }
         } while (te.next());
         ir.close();
-
-        query3.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query3.add(termsWithPrefix.toArray(new Term[0]));
         query3.add(new Term("body", "pizza"));
 
         result = searcher.search(query3, null, 1000).scoreDocs;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcher.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcher.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestMultiSearcher.java Fri Dec 11 16:22:30 2009
@@ -35,6 +35,7 @@
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -253,9 +254,9 @@
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 2, document.getFields().size() == 2);
     //Should be one document from each directory
     //they both have two fields, contents and other
-    Set ftl = new HashSet();
+    Set<String> ftl = new HashSet<String>();
     ftl.add("other");
-    SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
+    SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, Collections. <String> emptySet());
     document = searcher.doc(hits[0].doc, fs);
     assertTrue("document is null and it shouldn't be", document != null);
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 1, document.getFields().size() == 1);
@@ -265,7 +266,7 @@
     assertTrue("value is null and it shouldn't be", value != null);
     ftl.clear();
     ftl.add("contents");
-    fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
+    fs = new SetBasedFieldSelector(ftl, Collections. <String> emptySet());
     document = searcher.doc(hits[1].doc, fs);
     value = document.get("contents");
     assertTrue("value is null and it shouldn't be", value != null);    
@@ -398,4 +399,25 @@
         // if the same similarity is used.
         assertEquals("MultiSearcher score must be equal to single esrcher score!", score1, scoreN, 1e-6);
     }
+    
+    public void testCreateDocFrequencyMap() throws IOException{
+      RAMDirectory dir1 = new RAMDirectory();
+      RAMDirectory dir2 = new RAMDirectory();
+      Term template = new Term("contents") ;
+      String[] contents  = {"a", "b", "c"};
+      HashSet<Term> termsSet = new HashSet<Term>();
+      for (int i = 0; i < contents.length; i++) {
+        initIndex(dir1, i+10, i==0, contents[i]); 
+        initIndex(dir2, i+5, i==0, contents[i]);
+        termsSet.add(template.createTerm(contents[i]));
+      }
+      IndexSearcher searcher1 = new IndexSearcher(dir1, true);
+      IndexSearcher searcher2 = new IndexSearcher(dir2, true);
+      MultiSearcher multiSearcher = getMultiSearcherInstance(new Searcher[]{searcher1, searcher2});
+      Map<Term,Integer> docFrequencyMap = multiSearcher.createDocFrequencyMap(termsSet);
+      assertEquals(3, docFrequencyMap.size());
+      for (int i = 0; i < contents.length; i++) {
+        assertEquals(Integer.valueOf((i*2) +15), docFrequencyMap.get(template.createTerm(contents[i])));
+      }
+    }
 }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Fri Dec 11 16:22:30 2009
@@ -76,7 +76,7 @@
         query1.add(new Term("body", "blueberry"));
         query2.add(new Term("body", "strawberry"));
 
-        LinkedList termsWithPrefix = new LinkedList();
+        LinkedList<Term> termsWithPrefix = new LinkedList<Term>();
         IndexReader ir = IndexReader.open(indexStore, true);
 
         // this TermEnum gives "piccadilly", "pie" and "pizza".
@@ -89,8 +89,8 @@
             }
         } while (te.next());
 
-        query1.add((Term[])termsWithPrefix.toArray(new Term[0]));
-        query2.add((Term[])termsWithPrefix.toArray(new Term[0]));
+        query1.add(termsWithPrefix.toArray(new Term[0]));
+        query2.add(termsWithPrefix.toArray(new Term[0]));
 
         ScoreDoc[] result;
         result = searcher.search(query1, null, 1000).scoreDocs;

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java Fri Dec 11 16:22:30 2009
@@ -66,7 +66,7 @@
     }
     
     Scorer s = new SimpleScorer();
-    TopDocsCollector tdc = TopScoreDocCollector.create(scores.length, true);
+    TopDocsCollector<ScoreDoc> tdc = TopScoreDocCollector.create(scores.length, true);
     Collector c = new PositiveScoresOnlyCollector(tdc);
     c.setScorer(s);
     while (s.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSimpleExplanationsOfNonMatches.java Fri Dec 11 16:22:30 2009
@@ -18,24 +18,7 @@
  */
 
 
-import org.apache.lucene.store.RAMDirectory;
 
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-
-import junit.framework.TestCase;
-
-import java.util.Random;
-import java.util.BitSet;
 
 /**
  * subclass of TestSimpleExplanations that verifies non matches.

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSort.java Fri Dec 11 16:22:30 2009
@@ -635,9 +635,9 @@
   public void testNormalizedScores() throws Exception {
 
     // capture relevancy scores
-    HashMap scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
-    HashMap scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
-    HashMap scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
+    HashMap<String,Float> scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
+    HashMap<String,Float> scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
+    HashMap<String,Float> scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
 
     // we'll test searching locally, remote and multi
     
@@ -978,9 +978,9 @@
     assertEquals (expectedResult, buff.toString());
   }
 
-  private HashMap getScores (ScoreDoc[] hits, Searcher searcher)
+  private HashMap<String,Float> getScores (ScoreDoc[] hits, Searcher searcher)
   throws IOException {
-    HashMap scoreMap = new HashMap();
+    HashMap<String,Float> scoreMap = new HashMap<String,Float>();
     int n = hits.length;
     for (int i=0; i<n; ++i) {
       Document doc = searcher.doc(hits[i].doc);
@@ -992,15 +992,15 @@
   }
 
   // make sure all the values in the maps match
-  private void assertSameValues (HashMap m1, HashMap m2) {
+  private <K, V> void assertSameValues (HashMap<K,V> m1, HashMap<K,V> m2) {
     int n = m1.size();
     int m = m2.size();
     assertEquals (n, m);
-    Iterator iter = m1.keySet().iterator();
+    Iterator<K> iter = m1.keySet().iterator();
     while (iter.hasNext()) {
-      Object key = iter.next();
-      Object o1 = m1.get(key);
-      Object o2 = m2.get(key);
+      K key = iter.next();
+      V o1 = m1.get(key);
+      V o2 = m2.get(key);
       if (o1 instanceof Float) {
         assertEquals(((Float)o1).floatValue(), ((Float)o2).floatValue(), 1e-6);
       } else {

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSpanQueryFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSpanQueryFilter.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSpanQueryFilter.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestSpanQueryFilter.java Fri Dec 11 16:22:30 2009
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.lucene.analysis.SimpleAnalyzer;
@@ -58,12 +57,11 @@
     DocIdSet docIdSet = result.getDocIdSet();
     assertTrue("docIdSet is null and it shouldn't be", docIdSet != null);
     assertContainsDocId("docIdSet doesn't contain docId 10", docIdSet, 10);
-    List spans = result.getPositions();
+    List<SpanFilterResult.PositionInfo> spans = result.getPositions();
     assertTrue("spans is null and it shouldn't be", spans != null);
     int size = getDocIdSetSize(docIdSet);
     assertTrue("spans Size: " + spans.size() + " is not: " + size, spans.size() == size);
-    for (Iterator iterator = spans.iterator(); iterator.hasNext();) {
-       SpanFilterResult.PositionInfo info = (SpanFilterResult.PositionInfo) iterator.next();
+    for (final SpanFilterResult.PositionInfo info: spans) {
       assertTrue("info is null and it shouldn't be", info != null);
       //The doc should indicate the bit is on
       assertContainsDocId("docIdSet doesn't contain docId " + info.getDoc(), docIdSet, info.getDoc());

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermScorer.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermScorer.java Fri Dec 11 16:22:30 2009
@@ -75,7 +75,7 @@
         Scorer ts = weight.scorer(indexSearcher.getIndexReader(),
                                   true, true);
         //we have 2 documents with the term all in them, one document for all the other values
-        final List docs = new ArrayList();
+        final List<TestHit> docs = new ArrayList<TestHit>();
         //must call next first
 
 
@@ -106,8 +106,8 @@
             }
         });
         assertTrue("docs Size: " + docs.size() + " is not: " + 2, docs.size() == 2);
-        TestHit doc0 = (TestHit) docs.get(0);
-        TestHit doc5 = (TestHit) docs.get(1);
+        TestHit doc0 =  docs.get(0);
+        TestHit doc5 =  docs.get(1);
         //The scores should be the same
         assertTrue(doc0.score + " does not equal: " + doc5.score, doc0.score == doc5.score);
         /*

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermVectors.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTermVectors.java Fri Dec 11 16:22:30 2009
@@ -28,7 +28,6 @@
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.SortedSet;
 
@@ -167,7 +166,6 @@
         }
         else{
           try{
-            TermPositionVector posVec = (TermPositionVector)vector[0];
             assertTrue(false);
           }
           catch(ClassCastException ignore){
@@ -208,7 +206,7 @@
     String test2 = "computer in a computer lab"; //5 terms
     String test3 = "a chocolate lab grows old"; //5 terms
     String test4 = "eating chocolate with a chocolate lab in an old chocolate colored computer lab"; //13 terms
-    Map test4Map = new HashMap();
+    Map<String,Integer> test4Map = new HashMap<String,Integer>();
     test4Map.put("chocolate", Integer.valueOf(3));
     test4Map.put("lab", Integer.valueOf(2));
     test4Map.put("eating", Integer.valueOf(1));
@@ -246,7 +244,7 @@
       TermDocs termDocs = knownSearcher.reader.termDocs();
       //System.out.println("Terms: " + termEnum.size() + " Orig Len: " + termArray.length);
       
-      Similarity sim = knownSearcher.getSimilarity();
+      //Similarity sim = knownSearcher.getSimilarity();
       while (termEnum.next() == true)
       {
         Term term = termEnum.term();
@@ -258,11 +256,11 @@
           int freq = termDocs.freq();
           //System.out.println("Doc Id: " + docId + " freq " + freq);
           TermFreqVector vector = knownSearcher.reader.getTermFreqVector(docId, "field");
-          float tf = sim.tf(freq);
-          float idf = sim.idf(knownSearcher.docFreq(term), knownSearcher.maxDoc());
+          //float tf = sim.tf(freq);
+          //float idf = sim.idf(knownSearcher.docFreq(term), knownSearcher.maxDoc());
           //float qNorm = sim.queryNorm()
           //This is fine since we don't have stop words
-          float lNorm = sim.lengthNorm("field", vector.getTerms().length);
+          //float lNorm = sim.lengthNorm("field", vector.getTerms().length);
           //float coord = sim.coord()
           //System.out.println("TF: " + tf + " IDF: " + idf + " LenNorm: " + lNorm);
           assertTrue(vector != null);
@@ -283,7 +281,6 @@
       ScoreDoc[] hits = knownSearcher.search(query, null, 1000).scoreDocs;
       //doc 3 should be the first hit b/c it is the shortest match
       assertTrue(hits.length == 3);
-      float score = hits[0].score;
       /*System.out.println("Hit 0: " + hits.id(0) + " Score: " + hits.score(0) + " String: " + hits.doc(0).toString());
       System.out.println("Explain: " + knownSearcher.explain(query, hits.id(0)));
       System.out.println("Hit 1: " + hits.id(1) + " Score: " + hits.score(1) + " String: " + hits.doc(1).toString());
@@ -304,21 +301,20 @@
         //System.out.println("Term: " + term);
         int freq = freqs[i];
         assertTrue(test4.indexOf(term) != -1);
-        Integer freqInt = (Integer)test4Map.get(term);
+        Integer freqInt = test4Map.get(term);
         assertTrue(freqInt != null);
         assertTrue(freqInt.intValue() == freq);        
       }
       SortedTermVectorMapper mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
       knownSearcher.reader.getTermFreqVector(hits[1].doc, mapper);
-      SortedSet vectorEntrySet = mapper.getTermVectorEntrySet();
+      SortedSet<TermVectorEntry> vectorEntrySet = mapper.getTermVectorEntrySet();
       assertTrue("mapper.getTermVectorEntrySet() Size: " + vectorEntrySet.size() + " is not: " + 10, vectorEntrySet.size() == 10);
       TermVectorEntry last = null;
-      for (Iterator iterator = vectorEntrySet.iterator(); iterator.hasNext();) {
-         TermVectorEntry tve = (TermVectorEntry) iterator.next();
+      for (final TermVectorEntry tve : vectorEntrySet) {
         if (tve != null && last != null)
         {
           assertTrue("terms are not properly sorted", last.getFrequency() >= tve.getFrequency());
-          Integer expectedFreq = (Integer) test4Map.get(tve.getTerm());
+          Integer expectedFreq =  test4Map.get(tve.getTerm());
           //we expect double the expectedFreq, since there are two fields with the exact same text and we are collapsing all fields
           assertTrue("Frequency is not correct:", tve.getFrequency() == 2*expectedFreq.intValue());
         }
@@ -328,9 +324,9 @@
 
       FieldSortedTermVectorMapper fieldMapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
       knownSearcher.reader.getTermFreqVector(hits[1].doc, fieldMapper);
-      Map map = fieldMapper.getFieldToTerms();
+      Map<String,SortedSet<TermVectorEntry>> map = fieldMapper.getFieldToTerms();
       assertTrue("map Size: " + map.size() + " is not: " + 2, map.size() == 2);
-      vectorEntrySet = (SortedSet) map.get("field");
+      vectorEntrySet = map.get("field");
       assertTrue("vectorEntrySet is null and it shouldn't be", vectorEntrySet != null);
       assertTrue("vectorEntrySet Size: " + vectorEntrySet.size() + " is not: " + 10, vectorEntrySet.size() == 10);
       knownSearcher.close();

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestThreadSafe.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestThreadSafe.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestThreadSafe.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestThreadSafe.java Fri Dec 11 16:22:30 2009
@@ -85,9 +85,8 @@
                 }
               );
 
-      List fields = doc.getFields();
-      for (int i=0; i<fields.size(); i++) {
-        Fieldable f = (Fieldable)fields.get(i);
+      List<Fieldable> fields = doc.getFields();
+      for (final Fieldable f : fields ) {
         validateField(f);
       }
 

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopDocsCollector.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopDocsCollector.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopDocsCollector.java Fri Dec 11 16:22:30 2009
@@ -30,7 +30,7 @@
 
 public class TestTopDocsCollector extends LuceneTestCase {
 
-  private static final class MyTopsDocCollector extends TopDocsCollector {
+  private static final class MyTopsDocCollector extends TopDocsCollector<ScoreDoc> {
 
     private int idx = 0;
     private int base = 0;
@@ -50,7 +50,7 @@
         maxScore = results[0].score;
       } else {
         for (int i = pq.size(); i > 1; i--) { pq.pop(); }
-        maxScore = ((ScoreDoc) pq.pop()).score;
+        maxScore = pq.pop().score;
       }
       
       return new TopDocs(totalHits, results, maxScore);
@@ -94,10 +94,10 @@
   
   private Directory dir = new RAMDirectory();
 
-  private TopDocsCollector doSearch(int numResults) throws IOException {
+  private TopDocsCollector<ScoreDoc> doSearch(int numResults) throws IOException {
     Query q = new MatchAllDocsQuery();
     IndexSearcher searcher = new IndexSearcher(dir, true);
-    TopDocsCollector tdc = new MyTopsDocCollector(numResults);
+    TopDocsCollector<ScoreDoc> tdc = new MyTopsDocCollector(numResults);
     searcher.search(q, tdc);
     searcher.close();
     return tdc;
@@ -125,7 +125,7 @@
   
   public void testInvalidArguments() throws Exception {
     int numResults = 5;
-    TopDocsCollector tdc = doSearch(numResults);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(numResults);
     
     // start < 0
     assertEquals(0, tdc.topDocs(-1).scoreDocs.length);
@@ -145,17 +145,17 @@
   }
   
   public void testZeroResults() throws Exception {
-    TopDocsCollector tdc = new MyTopsDocCollector(5);
+    TopDocsCollector<ScoreDoc> tdc = new MyTopsDocCollector(5);
     assertEquals(0, tdc.topDocs(0, 1).scoreDocs.length);
   }
   
   public void testFirstResultsPage() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(15);
     assertEquals(10, tdc.topDocs(0, 10).scoreDocs.length);
   }
   
   public void testSecondResultsPages() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(15);
     // ask for more results than are available
     assertEquals(5, tdc.topDocs(10, 10).scoreDocs.length);
     
@@ -169,12 +169,12 @@
   }
   
   public void testGetAllResults() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(15);
     assertEquals(15, tdc.topDocs().scoreDocs.length);
   }
   
   public void testGetResultsFromStart() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(15);
     // should bring all results
     assertEquals(15, tdc.topDocs(0).scoreDocs.length);
     
@@ -185,7 +185,7 @@
   
   public void testMaxScore() throws Exception {
     // ask for all results
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(15);
     TopDocs td = tdc.topDocs();
     assertEquals(MAX_SCORE, td.getMaxScore(), 0f);
     
@@ -198,7 +198,7 @@
   // This does not test the PQ's correctness, but whether topDocs()
   // implementations return the results in decreasing score order.
   public void testResultsOrder() throws Exception {
-    TopDocsCollector tdc = doSearch(15);
+    TopDocsCollector<ScoreDoc> tdc = doSearch(15);
     ScoreDoc[] sd = tdc.topDocs().scoreDocs;
     
     assertEquals(MAX_SCORE, sd[0].score, 0f);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java Fri Dec 11 16:22:30 2009
@@ -59,7 +59,7 @@
     bq.setMinimumNumberShouldMatch(1);
     IndexSearcher searcher = new IndexSearcher(dir, true);
     for (int i = 0; i < inOrder.length; i++) {
-      TopDocsCollector tdc = TopScoreDocCollector.create(3, inOrder[i]);
+      TopDocsCollector<ScoreDoc> tdc = TopScoreDocCollector.create(3, inOrder[i]);
       assertEquals("org.apache.lucene.search.TopScoreDocCollector$" + actualTSDCClass[i], tdc.getClass().getName());
       
       searcher.search(new MatchAllDocsQuery(), tdc);

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=889683&r1=889682&r2=889683&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 Fri Dec 11 16:22:30 2009
@@ -105,8 +105,9 @@
     MultiTermQuery wq = new WildcardQuery(new Term("field", ""));
     wq.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
     assertMatches(searcher, wq, 0);
-    BooleanQuery expected = new BooleanQuery(true);
-    assertEquals(searcher.rewrite(expected), searcher.rewrite(wq));
+    Query q = searcher.rewrite(wq);
+    assertTrue(q instanceof BooleanQuery);
+    assertEquals(0, ((BooleanQuery) q).clauses().size());
   }
   
   /**

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/FunctionTestSetup.java Fri Dec 11 16:22:30 2009
@@ -25,20 +25,23 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
-
-import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCaseJ4;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
 
 /**
  * Setup for function tests
  */
-public abstract class FunctionTestSetup extends LuceneTestCase {
+@Ignore
+public class FunctionTestSetup extends LuceneTestCaseJ4 {
 
   /**
    * Actual score computation order is slightly different than assumptios
    * this allows for a small amount of variation
    */
-  public static float TEST_SCORE_TOLERANCE_DELTA = 0.001f;
-  
+  protected static float TEST_SCORE_TOLERANCE_DELTA = 0.001f;
+
   protected static final boolean DBG = false; // change to true for logging to print
 
   protected static final int N_DOCS = 17; // select a primary number > 2
@@ -47,62 +50,57 @@
   protected static final String TEXT_FIELD = "text";
   protected static final String INT_FIELD = "iii";
   protected static final String FLOAT_FIELD = "fff";
-  
+
   private static final String DOC_TEXT_LINES[] = {
-    "Well, this is just some plain text we use for creating the ",
-    "test documents. It used to be a text from an online collection ",
-    "devoted to first aid, but if there was there an (online) lawyers ",
-    "first aid collection with legal advices, \"it\" might have quite ",
-    "probably advised one not to include \"it\"'s text or the text of ",
-    "any other online collection in one's code, unless one has money ",
-    "that one don't need and one is happy to donate for lawyers ",
-    "charity. Anyhow at some point, rechecking the usage of this text, ",
-    "it became uncertain that this text is free to use, because ",
-    "the web site in the disclaimer of he eBook containing that text ",
-    "was not responding anymore, and at the same time, in projGut, ",
-    "searching for first aid no longer found that eBook as well. ",
-    "So here we are, with a perhaps much less interesting ",
-    "text for the test, but oh much much safer. ",
+          "Well, this is just some plain text we use for creating the ",
+          "test documents. It used to be a text from an online collection ",
+          "devoted to first aid, but if there was there an (online) lawyers ",
+          "first aid collection with legal advices, \"it\" might have quite ",
+          "probably advised one not to include \"it\"'s text or the text of ",
+          "any other online collection in one's code, unless one has money ",
+          "that one don't need and one is happy to donate for lawyers ",
+          "charity. Anyhow at some point, rechecking the usage of this text, ",
+          "it became uncertain that this text is free to use, because ",
+          "the web site in the disclaimer of he eBook containing that text ",
+          "was not responding anymore, and at the same time, in projGut, ",
+          "searching for first aid no longer found that eBook as well. ",
+          "So here we are, with a perhaps much less interesting ",
+          "text for the test, but oh much much safer. ",
   };
-  
-  protected Directory dir;
-  protected Analyzer anlzr;
-  
-  /* @override constructor */
-  public FunctionTestSetup(String name) {
-    super(name);
-  }
 
-  /* @override */
+  protected Directory dir = null;
+  protected Analyzer anlzr = null;
+
   @Override
-  protected void tearDown() throws Exception {
+  @After
+  public void tearDown() throws Exception {
     super.tearDown();
     dir = null;
     anlzr = null;
   }
 
-  /* @override */
   @Override
-  protected void setUp() throws Exception {
+  @Before
+  public void setUp() throws Exception {
     super.setUp();
     // prepare a small index with just a few documents.  
     super.setUp();
     dir = new RAMDirectory();
     anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
     IndexWriter iw = new IndexWriter(dir, anlzr,
-                                     IndexWriter.MaxFieldLength.LIMITED);
+            IndexWriter.MaxFieldLength.LIMITED);
     // add docs not exactly in natural ID order, to verify we do check the order of docs by scores
     int remaining = N_DOCS;
     boolean done[] = new boolean[N_DOCS];
     int i = 0;
-    while (remaining>0) {
+    while (remaining > 0) {
       if (done[i]) {
-        throw new Exception("to set this test correctly N_DOCS="+N_DOCS+" must be primary and greater than 2!");
+        throw new Exception("to set this test correctly N_DOCS=" + N_DOCS + " must be primary and greater than 2!");
       }
-      addDoc(iw,i);
+      addDoc(iw, i);
       done[i] = true;
-      i = (i+4)%N_DOCS;
-      remaining --;
+      i = (i + 4) % N_DOCS;
+      remaining--;
     }
     iw.close();
   }
@@ -110,36 +108,36 @@
   private void addDoc(IndexWriter iw, int i) throws Exception {
     Document d = new Document();
     Fieldable f;
-    int scoreAndID = i+1;
-    
-    f = new Field(ID_FIELD,id2String(scoreAndID),Field.Store.YES,Field.Index.NOT_ANALYZED); // for debug purposes
+    int scoreAndID = i + 1;
+
+    f = new Field(ID_FIELD, id2String(scoreAndID), Field.Store.YES, Field.Index.NOT_ANALYZED); // for debug purposes
     f.setOmitNorms(true);
     d.add(f);
-    
-    f = new Field(TEXT_FIELD,"text of doc"+scoreAndID+textLine(i),Field.Store.NO,Field.Index.ANALYZED); // for regular search
+
+    f = new Field(TEXT_FIELD, "text of doc" + scoreAndID + textLine(i), Field.Store.NO, Field.Index.ANALYZED); // for regular search
     f.setOmitNorms(true);
     d.add(f);
-    
-    f = new Field(INT_FIELD,""+scoreAndID,Field.Store.NO,Field.Index.NOT_ANALYZED); // for function scoring
+
+    f = new Field(INT_FIELD, "" + scoreAndID, Field.Store.NO, Field.Index.NOT_ANALYZED); // for function scoring
     f.setOmitNorms(true);
     d.add(f);
-    
-    f = new Field(FLOAT_FIELD,scoreAndID+".000",Field.Store.NO,Field.Index.NOT_ANALYZED); // for function scoring
+
+    f = new Field(FLOAT_FIELD, scoreAndID + ".000", Field.Store.NO, Field.Index.NOT_ANALYZED); // for function scoring
     f.setOmitNorms(true);
     d.add(f);
 
     iw.addDocument(d);
-    log("added: "+d);
+    log("added: " + d);
   }
 
   // 17 --> ID00017
   protected String id2String(int scoreAndID) {
-    String s = "000000000"+scoreAndID;
-    int n = (""+N_DOCS).length() + 3;
-    int k = s.length() - n; 
-    return "ID"+s.substring(k);
+    String s = "000000000" + scoreAndID;
+    int n = ("" + N_DOCS).length() + 3;
+    int k = s.length() - n;
+    return "ID" + s.substring(k);
   }
-  
+
   // some text line for regular search
   private String textLine(int docNum) {
     return DOC_TEXT_LINES[docNum % DOC_TEXT_LINES.length];
@@ -147,11 +145,11 @@
 
   // extract expected doc score from its ID Field: "ID7" --> 7.0
   protected float expectedFieldScore(String docIDFieldVal) {
-    return Float.parseFloat(docIDFieldVal.substring(2)); 
+    return Float.parseFloat(docIDFieldVal.substring(2));
   }
-  
+
   // debug messages (change DBG to true for anything to print) 
-  protected void log (Object o) {
+  protected void log(Object o) {
     if (DBG) {
       System.out.println(o.toString());
     }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/JustCompileSearchSpans.java Fri Dec 11 16:22:30 2009
@@ -17,11 +17,11 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.FieldCache;
 
+import java.io.IOException;
+
 /**
  * Holds all implementations of classes in the o.a.l.s.function package as a
  * back-compatibility test. It does not run any tests per-se, however if
@@ -34,7 +34,6 @@
   private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
 
   static final class JustCompileDocValues extends DocValues {
-
     @Override
     public float floatVal(int doc) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
@@ -44,7 +43,7 @@
     public String toString(int doc) {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
-    
+
   }
 
   static final class JustCompileFieldCacheSource extends FieldCacheSource {
@@ -65,14 +64,13 @@
 
     @Override
     public DocValues getCachedFieldValues(FieldCache cache, String field,
-        IndexReader reader) throws IOException {
+                                          IndexReader reader) throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
-    
+
   }
 
   static final class JustCompileValueSource extends ValueSource {
-
     @Override
     public String description() {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
@@ -92,7 +90,7 @@
     public int hashCode() {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
-    
+
   }
-  
+
 }

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=889683&r1=889682&r2=889683&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 Fri Dec 11 16:22:30 2009
@@ -17,99 +17,114 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryUtils;
-import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.search.*;
 import org.apache.lucene.util.Version;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Test CustomScoreQuery search.
  */
+@SuppressWarnings({"MagicNumber"})
 public class TestCustomScoreQuery extends FunctionTestSetup {
 
-  /* @override constructor */
-  public TestCustomScoreQuery(String name) {
-    super(name);
-  }
 
-  /** Test that CustomScoreQuery of Type.BYTE returns the expected scores. */
-  public void testCustomScoreByte () throws CorruptIndexException, Exception {
+  /**
+   * Test that CustomScoreQuery of Type.BYTE returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreByte() throws Exception, ParseException {
     // INT field values are small enough to be parsed as byte
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.BYTE,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.BYTE,2.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.BYTE, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.BYTE, 2.0);
   }
 
-  /** Test that CustomScoreQuery of Type.SHORT returns the expected scores. */
-  public void testCustomScoreShort () throws CorruptIndexException, Exception {
+  /**
+   * Test that CustomScoreQuery of Type.SHORT returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreShort() throws Exception, ParseException {
     // INT field values are small enough to be parsed as short
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.SHORT,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.SHORT,3.0);
-  }
-
-  /** Test that CustomScoreQuery of Type.INT returns the expected scores. */
-  public void testCustomScoreInt () throws CorruptIndexException, Exception {
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.INT,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.INT,4.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.SHORT, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.SHORT, 3.0);
   }
 
-  /** Test that CustomScoreQuery of Type.FLOAT returns the expected scores. */
-  public void testCustomScoreFloat () throws CorruptIndexException, Exception {
+  /**
+   * Test that CustomScoreQuery of Type.INT returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreInt() throws Exception, ParseException {
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.INT, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.INT, 4.0);
+  }
+
+  /**
+   * Test that CustomScoreQuery of Type.FLOAT returns the expected scores.
+   */
+  @Test
+  public void testCustomScoreFloat() throws Exception, ParseException {
     // INT field can be parsed as float
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.FLOAT,1.0);
-    doTestCustomScore(INT_FIELD,FieldScoreQuery.Type.FLOAT,5.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.FLOAT, 1.0);
+    doTestCustomScore(INT_FIELD, FieldScoreQuery.Type.FLOAT, 5.0);
     // same values, but in flot format
-    doTestCustomScore(FLOAT_FIELD,FieldScoreQuery.Type.FLOAT,1.0);
-    doTestCustomScore(FLOAT_FIELD,FieldScoreQuery.Type.FLOAT,6.0);
+    doTestCustomScore(FLOAT_FIELD, FieldScoreQuery.Type.FLOAT, 1.0);
+    doTestCustomScore(FLOAT_FIELD, FieldScoreQuery.Type.FLOAT, 6.0);
   }
 
   // must have static class otherwise serialization tests fail
+  @SuppressWarnings({"SerializableHasSerializationMethods", "serial"})
   private static class CustomAddQuery extends CustomScoreQuery {
     // constructor
-    CustomAddQuery (Query q, ValueSourceQuery qValSrc) {
-      super(q,qValSrc);
+    CustomAddQuery(Query q, ValueSourceQuery qValSrc) {
+      super(q, qValSrc);
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#name() */
     @Override
     public String name() {
       return "customAdd";
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#customScore(int, float, float) */
     @Override
     public float customScore(int doc, float subQueryScore, float valSrcScore) {
       return subQueryScore + valSrcScore;
     }
+
     /* (non-Javadoc)@see org.apache.lucene.search.function.CustomScoreQuery#customExplain(int, org.apache.lucene.search.Explanation, org.apache.lucene.search.Explanation)*/
     @Override
     public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl) {
-      float valSrcScore = valSrcExpl==null ? 0 : valSrcExpl.getValue();
-      Explanation exp = new Explanation( valSrcScore + subQueryExpl.getValue(), "custom score: sum of:");
+      float valSrcScore = valSrcExpl == null ? 0 : valSrcExpl.getValue();
+      Explanation exp = new Explanation(valSrcScore + subQueryExpl.getValue(), "custom score: sum of:");
       exp.addDetail(subQueryExpl);
       if (valSrcExpl != null) {
         exp.addDetail(valSrcExpl);
       }
-      return exp;      
-    } 
+      return exp;
+    }
   }
-  
+
   // must have static class otherwise serialization tests fail
+  @SuppressWarnings({"SerializableHasSerializationMethods", "serial"})
   private static class CustomMulAddQuery extends CustomScoreQuery {
     // constructor
     CustomMulAddQuery(Query q, ValueSourceQuery qValSrc1, ValueSourceQuery qValSrc2) {
-      super(q,new ValueSourceQuery[]{qValSrc1,qValSrc2});
+      super(q, new ValueSourceQuery[]{qValSrc1, qValSrc2});
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#name() */
     @Override
     public String name() {
       return "customMulAdd";
     }
+
     /*(non-Javadoc) @see org.apache.lucene.search.function.CustomScoreQuery#customScore(int, float, float) */
     @Override
     public float customScore(int doc, float subQueryScore, float valSrcScores[]) {
@@ -120,7 +135,8 @@
         return subQueryScore + valSrcScores[0];
       }
       return (subQueryScore + valSrcScores[0]) * valSrcScores[1]; // we know there are two
-    } 
+    }
+
     /* (non-Javadoc)@see org.apache.lucene.search.function.CustomScoreQuery#customExplain(int, org.apache.lucene.search.Explanation, org.apache.lucene.search.Explanation)*/
     @Override
     public Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpls[]) {
@@ -137,67 +153,67 @@
       Explanation exp2 = new Explanation(valSrcExpls[1].getValue() * exp.getValue(), "custom score: product of:");
       exp2.addDetail(valSrcExpls[1]);
       exp2.addDetail(exp);
-      return exp2;      
-    } 
+      return exp2;
+    }
   }
-  
+
   // Test that FieldScoreQuery returns docs with expected score.
-  private void doTestCustomScore (String field, FieldScoreQuery.Type tp, double dboost) throws CorruptIndexException, Exception {
+  private void doTestCustomScore(String field, FieldScoreQuery.Type tp, double dboost) throws Exception, ParseException {
     float boost = (float) dboost;
     IndexSearcher s = new IndexSearcher(dir, true);
-    FieldScoreQuery qValSrc = new FieldScoreQuery(field,tp); // a query that would score by the field
-    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD,anlzr); 
+    FieldScoreQuery qValSrc = new FieldScoreQuery(field, tp); // a query that would score by the field
+    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD, anlzr);
     String qtxt = "first aid text"; // from the doc texts in FunctionQuerySetup.
-    
+
     // regular (boolean) query.
-    Query q1 = qp.parse(qtxt); 
+    Query q1 = qp.parse(qtxt);
     log(q1);
-    
+
     // custom query, that should score the same as q1.
-    CustomScoreQuery q2CustomNeutral = new CustomScoreQuery(q1);
+    Query q2CustomNeutral = new CustomScoreQuery(q1);
     q2CustomNeutral.setBoost(boost);
     log(q2CustomNeutral);
-    
+
     // custom query, that should (by default) multiply the scores of q1 by that of the field
-    CustomScoreQuery q3CustomMul = new CustomScoreQuery(q1,qValSrc);
+    CustomScoreQuery q3CustomMul = new CustomScoreQuery(q1, qValSrc);
     q3CustomMul.setStrict(true);
     q3CustomMul.setBoost(boost);
     log(q3CustomMul);
-    
+
     // custom query, that should add the scores of q1 to that of the field
-    CustomScoreQuery q4CustomAdd = new CustomAddQuery(q1,qValSrc); 
+    CustomScoreQuery q4CustomAdd = new CustomAddQuery(q1, qValSrc);
     q4CustomAdd.setStrict(true);
     q4CustomAdd.setBoost(boost);
     log(q4CustomAdd);
 
     // custom query, that multiplies and adds the field score to that of q1
-    CustomScoreQuery q5CustomMulAdd = new CustomMulAddQuery(q1,qValSrc,qValSrc);
+    CustomScoreQuery q5CustomMulAdd = new CustomMulAddQuery(q1, qValSrc, qValSrc);
     q5CustomMulAdd.setStrict(true);
     q5CustomMulAdd.setBoost(boost);
     log(q5CustomMulAdd);
 
     // do al the searches 
-    TopDocs td1 = s.search(q1,null,1000);
-    TopDocs td2CustomNeutral = s.search(q2CustomNeutral,null,1000);
-    TopDocs td3CustomMul = s.search(q3CustomMul,null,1000);
-    TopDocs td4CustomAdd = s.search(q4CustomAdd,null,1000);
-    TopDocs td5CustomMulAdd = s.search(q5CustomMulAdd,null,1000);
-    
+    TopDocs td1 = s.search(q1, null, 1000);
+    TopDocs td2CustomNeutral = s.search(q2CustomNeutral, null, 1000);
+    TopDocs td3CustomMul = s.search(q3CustomMul, null, 1000);
+    TopDocs td4CustomAdd = s.search(q4CustomAdd, null, 1000);
+    TopDocs td5CustomMulAdd = s.search(q5CustomMulAdd, null, 1000);
+
     // put results in map so we can verify the scores although they have changed
-    HashMap h1 = topDocsToMap(td1);
-    HashMap h2CustomNeutral = topDocsToMap(td2CustomNeutral);
-    HashMap h3CustomMul = topDocsToMap(td3CustomMul);
-    HashMap h4CustomAdd = topDocsToMap(td4CustomAdd);
-    HashMap h5CustomMulAdd = topDocsToMap(td5CustomMulAdd);
+    Map<Integer,Float> h1               = topDocsToMap(td1);
+    Map<Integer,Float> h2CustomNeutral  = topDocsToMap(td2CustomNeutral);
+    Map<Integer,Float> h3CustomMul      = topDocsToMap(td3CustomMul);
+    Map<Integer,Float> h4CustomAdd      = topDocsToMap(td4CustomAdd);
+    Map<Integer,Float> h5CustomMulAdd   = topDocsToMap(td5CustomMulAdd);
     
     verifyResults(boost, s, 
         h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd,
         q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd);
   }
-  
+
   // verify results are as expected.
   private void verifyResults(float boost, IndexSearcher s, 
-      HashMap h1, HashMap h2customNeutral, HashMap h3CustomMul, HashMap h4CustomAdd, HashMap h5CustomMulAdd,
+      Map<Integer,Float> h1, Map<Integer,Float> h2customNeutral, Map<Integer,Float> h3CustomMul, Map<Integer,Float> h4CustomAdd, Map<Integer,Float> h5CustomMulAdd,
       Query q1, Query q2, Query q3, Query q4, Query q5) throws Exception {
     
     // verify numbers of matches
@@ -214,38 +230,36 @@
     QueryUtils.check(q5,s);
 
     // verify scores ratios
-    for (Iterator it = h1.keySet().iterator(); it.hasNext();) {
-      Integer x = (Integer) it.next();
+    for (final Integer doc : h1.keySet()) {
 
-      int doc =  x.intValue();
       log("doc = "+doc);
 
       float fieldScore = expectedFieldScore(s.getIndexReader().document(doc).get(ID_FIELD));
-      log("fieldScore = "+fieldScore);
-      assertTrue("fieldScore should not be 0",fieldScore>0);
+      log("fieldScore = " + fieldScore);
+      assertTrue("fieldScore should not be 0", fieldScore > 0);
 
-      float score1 = ((Float)h1.get(x)).floatValue();
+      float score1 = h1.get(doc);
       logResult("score1=", s, q1, doc, score1);
       
-      float score2 = ((Float)h2customNeutral.get(x)).floatValue();
+      float score2 = h2customNeutral.get(doc);
       logResult("score2=", s, q2, doc, score2);
       assertEquals("same score (just boosted) for neutral", boost * score1, score2, TEST_SCORE_TOLERANCE_DELTA);
 
-      float score3 = ((Float)h3CustomMul.get(x)).floatValue();
+      float score3 = h3CustomMul.get(doc);
       logResult("score3=", s, q3, doc, score3);
       assertEquals("new score for custom mul", boost * fieldScore * score1, score3, TEST_SCORE_TOLERANCE_DELTA);
       
-      float score4 = ((Float)h4CustomAdd.get(x)).floatValue();
+      float score4 = h4CustomAdd.get(doc);
       logResult("score4=", s, q4, doc, score4);
       assertEquals("new score for custom add", boost * (fieldScore + score1), score4, TEST_SCORE_TOLERANCE_DELTA);
       
-      float score5 = ((Float)h5CustomMulAdd.get(x)).floatValue();
+      float score5 = h5CustomMulAdd.get(doc);
       logResult("score5=", s, q5, doc, score5);
       assertEquals("new score for custom mul add", boost * fieldScore * (score1 + fieldScore), score5, TEST_SCORE_TOLERANCE_DELTA);
     }
   }
 
-  private void logResult(String msg, IndexSearcher s, Query q, int doc, float score1) throws IOException {
+  private void logResult(String msg, Searcher s, Query q, int doc, float score1) throws IOException {
     log(msg+" "+score1);
     log("Explain by: "+q);
     log(s.explain(q,doc));
@@ -253,10 +267,10 @@
 
   // since custom scoring modifies the order of docs, map results 
   // by doc ids so that we can later compare/verify them 
-  private HashMap topDocsToMap(TopDocs td) {
-    HashMap h = new HashMap(); 
+  private Map<Integer,Float> topDocsToMap(TopDocs td) {
+    Map<Integer,Float> h = new HashMap<Integer,Float>();
     for (int i=0; i<td.totalHits; i++) {
-      h.put(Integer.valueOf(td.scoreDocs[i].doc), Float.valueOf(td.scoreDocs[i].score));
+      h.put(td.scoreDocs[i].doc, td.scoreDocs[i].score);
     }
     return h;
   }

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestDocValues.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestDocValues.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestDocValues.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestDocValues.java Fri Dec 11 16:22:30 2009
@@ -17,19 +17,17 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
-import junit.framework.Assert;
+import org.apache.lucene.util.LuceneTestCaseJ4;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 /**
  * DocValues TestCase  
  */
-public class TestDocValues extends LuceneTestCase {
-
-  /* @override constructor */
-  public TestDocValues(String name) {
-    super(name);
-  }
+public class TestDocValues extends LuceneTestCaseJ4 {
 
+  @Test
   public void testGetMinValue() {
     float[] innerArray = new float[] { 1.0f, 2.0f, -1.0f, 100.0f };
     DocValuesTestImpl docValues = new DocValuesTestImpl(innerArray);
@@ -42,7 +40,7 @@
     assertTrue("max is NaN - no values in inner array", Float.isNaN(docValues
         .getMinValue()));
   }
-
+  @Test
   public void testGetMaxValue() {
     float[] innerArray = new float[] { 1.0f, 2.0f, -1.0f, 10.0f };
     DocValuesTestImpl docValues = new DocValuesTestImpl(innerArray);
@@ -67,6 +65,7 @@
         .getMaxValue()));
   }
 
+  @Test
   public void testGetAverageValue() {
     float[] innerArray = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
     DocValuesTestImpl docValues = new DocValuesTestImpl(innerArray);
@@ -98,7 +97,6 @@
     /**
      * @see org.apache.lucene.search.function.DocValues#floatVal(int)
      */
-    /* @Override */
     @Override
     public float floatVal(int doc) {
       return innerArray[doc];
@@ -107,7 +105,6 @@
     /**
      * @see org.apache.lucene.search.function.DocValues#toString(int)
      */
-    /* @Override */
     @Override
     public String toString(int doc) {
       return Integer.toString(doc);

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java?rev=889683&r1=889682&r2=889683&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java Fri Dec 11 16:22:30 2009
@@ -18,14 +18,16 @@
  */
 
 import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TopDocs;
+import org.junit.Test;
+import static org.junit.Assert.*;
 
 /**
  * Test FieldScoreQuery search.
@@ -38,32 +40,32 @@
  * <p>
  * The exact score tests use TopDocs top to verify the exact score.  
  */
+@SuppressWarnings({"UseOfSystemOutOrSystemErr"})
 public class TestFieldScoreQuery extends FunctionTestSetup {
 
-  /* @override constructor */
-  public TestFieldScoreQuery(String name) {
-    super(name);
-  }
-
   /** Test that FieldScoreQuery of Type.BYTE returns docs in expected order. */
-  public void testRankByte () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankByte () throws Exception {
     // INT field values are small enough to be parsed as byte
     doTestRank(INT_FIELD,FieldScoreQuery.Type.BYTE);
   }
 
   /** Test that FieldScoreQuery of Type.SHORT returns docs in expected order. */
-  public void testRankShort () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankShort () throws Exception {
     // INT field values are small enough to be parsed as short
     doTestRank(INT_FIELD,FieldScoreQuery.Type.SHORT);
   }
 
   /** Test that FieldScoreQuery of Type.INT returns docs in expected order. */
-  public void testRankInt () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankInt () throws Exception {
     doTestRank(INT_FIELD,FieldScoreQuery.Type.INT);
   }
 
   /** Test that FieldScoreQuery of Type.FLOAT returns docs in expected order. */
-  public void testRankFloat () throws CorruptIndexException, Exception {
+  @Test
+  public void testRankFloat () throws Exception {
     // INT field can be parsed as float
     doTestRank(INT_FIELD,FieldScoreQuery.Type.FLOAT);
     // same values, but in flot format
@@ -71,7 +73,7 @@
   }
 
   // Test that FieldScoreQuery returns docs in expected order.
-  private void doTestRank (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
+  private void doTestRank (String field, FieldScoreQuery.Type tp) throws Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     Query q = new FieldScoreQuery(field,tp);
     log("test: "+q);
@@ -89,24 +91,28 @@
   }
 
   /** Test that FieldScoreQuery of Type.BYTE returns the expected scores. */
-  public void testExactScoreByte () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreByte () throws Exception {
     // INT field values are small enough to be parsed as byte
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.BYTE);
   }
 
   /** Test that FieldScoreQuery of Type.SHORT returns the expected scores. */
-  public void testExactScoreShort () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreShort () throws  Exception {
     // INT field values are small enough to be parsed as short
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.SHORT);
   }
 
   /** Test that FieldScoreQuery of Type.INT returns the expected scores. */
-  public void testExactScoreInt () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreInt () throws  Exception {
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.INT);
   }
 
   /** Test that FieldScoreQuery of Type.FLOAT returns the expected scores. */
-  public void testExactScoreFloat () throws CorruptIndexException, Exception {
+  @Test
+  public void testExactScoreFloat () throws  Exception {
     // INT field can be parsed as float
     doTestExactScore(INT_FIELD,FieldScoreQuery.Type.FLOAT);
     // same values, but in flot format
@@ -114,40 +120,44 @@
   }
 
   // Test that FieldScoreQuery returns docs with expected score.
-  private void doTestExactScore (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
+  private void doTestExactScore (String field, FieldScoreQuery.Type tp) throws Exception {
     IndexSearcher s = new IndexSearcher(dir, true);
     Query q = new FieldScoreQuery(field,tp);
     TopDocs td = s.search(q,null,1000);
     assertEquals("All docs should be matched!",N_DOCS,td.totalHits);
     ScoreDoc sd[] = td.scoreDocs;
-    for (int i=0; i<sd.length; i++) {
-      float score = sd[i].score;
-      log(s.explain(q,sd[i].doc));
-      String id = s.getIndexReader().document(sd[i].doc).get(ID_FIELD);
+    for (ScoreDoc aSd : sd) {
+      float score = aSd.score;
+      log(s.explain(q, aSd.doc));
+      String id = s.getIndexReader().document(aSd.doc).get(ID_FIELD);
       float expectedScore = expectedFieldScore(id); // "ID7" --> 7.0
-      assertEquals("score of "+id+" shuould be "+expectedScore+" != "+score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
+      assertEquals("score of " + id + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
     }
   }
 
   /** Test that FieldScoreQuery of Type.BYTE caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingByte () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingByte () throws  Exception {
     // INT field values are small enough to be parsed as byte
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.BYTE);
   }
 
   /** Test that FieldScoreQuery of Type.SHORT caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingShort () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingShort () throws  Exception {
     // INT field values are small enough to be parsed as short
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.SHORT);
   }
 
   /** Test that FieldScoreQuery of Type.INT caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingInt () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingInt () throws Exception {
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.INT);
   }
 
   /** Test that FieldScoreQuery of Type.FLOAT caches/reuses loaded values and consumes the proper RAM resources. */
-  public void testCachingFloat () throws CorruptIndexException, Exception {
+  @Test
+  public void testCachingFloat () throws  Exception {
     // INT field values can be parsed as float
     doTestCaching(INT_FIELD,FieldScoreQuery.Type.FLOAT);
     // same values, but in flot format
@@ -155,9 +165,9 @@
   }
 
   // Test that values loaded for FieldScoreQuery are cached properly and consumes the proper RAM resources.
-  private void doTestCaching (String field, FieldScoreQuery.Type tp) throws CorruptIndexException, Exception {
+  private void doTestCaching (String field, FieldScoreQuery.Type tp) throws Exception {
     // prepare expected array types for comparison
-    HashMap expectedArrayTypes = new HashMap();
+    HashMap<FieldScoreQuery.Type,Object> expectedArrayTypes = new HashMap<FieldScoreQuery.Type,Object>();
     expectedArrayTypes.put(FieldScoreQuery.Type.BYTE, new byte[0]);
     expectedArrayTypes.put(FieldScoreQuery.Type.SHORT, new short[0]);
     expectedArrayTypes.put(FieldScoreQuery.Type.INT, new int[0]);
@@ -223,7 +233,7 @@
   }
 
   private String testName() {
-    return getClass().getName()+"."+getName();
+    return getClass().getName()+"."+ getName();
   }
 
 }



Mime
View raw message