You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2010/10/20 14:44:39 UTC

svn commit: r1025539 [10/10] - in /lucene/dev/branches/docvalues: ./ lucene/ lucene/contrib/ lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ lucene/contrib/highlighter/src/test/ lucene/contrib/instantiated/src/test/org/apach...

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestIndexSearcher.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestIndexSearcher.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestIndexSearcher.java Wed Oct 20 12:44:28 2010
@@ -16,20 +16,22 @@
  */
 package org.apache.solr.search;
 
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.function.ValueSource;
 import org.apache.solr.search.function.DocValues;
+import org.junit.BeforeClass;
 
 import java.util.Map;
 import java.io.IOException;
 
-public class TestIndexSearcher extends AbstractSolrTestCase {
+public class TestIndexSearcher extends SolrTestCaseJ4 {
 
-  public String getSchemaFile() { return "schema11.xml"; }
-  public String getSolrConfigFile() { return "solrconfig.xml"; }
-  public String getCoreName() { return "basic"; }
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig.xml","schema.xml");
+  }
 
   private String getStringVal(SolrQueryRequest sqr, String field, int doc) throws IOException {
     SchemaField sf = sqr.getSchema().getField(field);
@@ -109,7 +111,7 @@ public class TestIndexSearcher extends A
     assertU(delI("1"));
     assertU(commit());
     SolrQueryRequest sr6 = req("q","foo");
-    SolrIndexReader r6 = sr4.getSearcher().getReader();
+    SolrIndexReader r6 = sr6.getSearcher().getReader();
     assertEquals(1, r6.getLeafReaders()[0].numDocs()); // only a single doc left in the first segment
     assertTrue( !r5.getLeafReaders()[0].equals(r6.getLeafReaders()[0]) );  // readers now different
 

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestRangeQuery.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestRangeQuery.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/search/TestRangeQuery.java Wed Oct 20 12:44:28 2010
@@ -18,6 +18,7 @@ package org.apache.solr.search;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -261,11 +262,13 @@ public class TestRangeQuery extends Solr
       SolrQueryResponse last=null;
       for (String q : qs) {
         // System.out.println("QUERY="+q);
-        SolrQueryResponse qr = h.queryAndResponse(handler, req("q",q,"rows","1000"));
+        SolrQueryRequest req = req("q",q,"rows","1000");
+        SolrQueryResponse qr = h.queryAndResponse(handler, req);
         if (last != null) {
           // we only test if the same docs matched since some queries will include factors like idf, etc.
           sameDocs((DocSet)qr.getValues().get("response"), (DocSet)last.getValues().get("response"));
         }
+        req.close();
         last = qr;
       }
     }
@@ -277,9 +280,7 @@ public class TestRangeQuery extends Solr
     assertEquals(a.size(), b.size());
     while (i.hasNext()) {
       int doc = i.nextDoc();
-      if (!b.exists(doc)) {
-        TestCase.fail("Missing doc " + doc);
-      }
+      assertTrue(b.exists(doc));
       // System.out.println("MATCH! " + doc);
     }
     return true;

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java Wed Oct 20 12:44:28 2010
@@ -38,6 +38,7 @@ import org.apache.solr.common.params.Mul
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.ContentStream;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.request.SolrQueryRequest;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -73,14 +74,15 @@ public class SolrRequestParserTest exten
     
     // Make sure it got a single stream in and out ok
     List<ContentStream> streams = new ArrayList<ContentStream>();
-    parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
+    SolrQueryRequest req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
     assertEquals( 1, streams.size() );
     assertEquals( body1, IOUtils.toString( streams.get(0).getStream() ) );
-    
+    req.close();
+
     // Now add three and make sure they come out ok
     streams = new ArrayList<ContentStream>();
     args.put( CommonParams.STREAM_BODY, new String[] {body1,body2,body3} );
-    parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
+    req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
     assertEquals( 3, streams.size() );
     ArrayList<String> input  = new ArrayList<String>();
     ArrayList<String> output = new ArrayList<String>();
@@ -94,15 +96,17 @@ public class SolrRequestParserTest exten
     Collections.sort( input );
     Collections.sort( output );
     assertEquals( input.toString(), output.toString() );
-    
+    req.close();
+
     // set the contentType and make sure tat gets set
     String ctype = "text/xxx";
     streams = new ArrayList<ContentStream>();
     args.put( CommonParams.STREAM_CONTENTTYPE, new String[] {ctype} );
-    parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
+    req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
     for( ContentStream s : streams ) {
       assertEquals( ctype, s.getContentType() );
     }
+    req.close();
   }
   
   @Test
@@ -119,8 +123,7 @@ public class SolrRequestParserTest exten
       txt = IOUtils.toString( connection.getInputStream());
     }
     catch( Exception ex ) {
-      // TODO - should it fail/skip?
-      fail( "this test only works if you have a network connection." );
+      assumeNoException("Unable to connect to " + url + " to run the test.", ex);
       return;
     }
 
@@ -131,9 +134,10 @@ public class SolrRequestParserTest exten
     
     // Make sure it got a single stream in and out ok
     List<ContentStream> streams = new ArrayList<ContentStream>();
-    parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
+    SolrQueryRequest req = parser.buildRequestFrom( core, new MultiMapSolrParams( args ), streams );
     assertEquals( 1, streams.size() );
     assertEquals( txt, IOUtils.toString( streams.get(0).getStream() ) );
+    req.close();
   }
   
   @Test

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java Wed Oct 20 12:44:28 2010
@@ -21,10 +21,11 @@ import java.util.Collection;
 import java.util.Map;
 
 import org.apache.lucene.analysis.Token;
-import org.apache.lucene.index.IndexReader;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.util.RefCounted;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -59,9 +60,9 @@ public class DirectSolrSpellCheckerTest 
     SolrCore core = h.getCore();
     checker.init(spellchecker, core);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("fob");
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     Map<String, Integer> suggestions = result.get(tokens.iterator().next());
@@ -74,5 +75,6 @@ public class DirectSolrSpellCheckerTest 
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
+    searcher.decref();
   }
 }

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java Wed Oct 20 12:44:28 2010
@@ -20,7 +20,8 @@ package org.apache.solr.spelling;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
-import org.apache.lucene.index.IndexReader;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.util.RefCounted;
 import org.apache.lucene.analysis.Token;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -78,9 +79,9 @@ public class FileBasedSpellCheckerTest e
     assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
     checker.build(core, null);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("fob");
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     Map<String, Integer> suggestions = result.get(tokens.iterator().next());
@@ -93,7 +94,7 @@ public class FileBasedSpellCheckerTest e
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
-
+    searcher.decref();
 
   }
 
@@ -117,10 +118,10 @@ public class FileBasedSpellCheckerTest e
     assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
     checker.build(core, null);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("Solar");
 
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     //should be lowercased, b/c we are using a lowercasing analyzer
@@ -136,6 +137,7 @@ public class FileBasedSpellCheckerTest e
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
+    searcher.decref();
   }
 
   /**
@@ -161,9 +163,9 @@ public class FileBasedSpellCheckerTest e
     assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
     checker.build(core, null);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("solar");
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     //should be lowercased, b/c we are using a lowercasing analyzer
@@ -179,5 +181,6 @@ public class FileBasedSpellCheckerTest e
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(spellOpts.tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
+    searcher.decref();
   }
 }

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java Wed Oct 20 12:44:28 2010
@@ -33,6 +33,7 @@ import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.component.SearchComponent;
 import org.apache.solr.handler.component.SpellCheckComponent;
 import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestHandler;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.BeforeClass;
@@ -73,7 +74,9 @@ public class SpellCheckCollatorTest exte
 		SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
 		SolrQueryResponse rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		NamedList values = rsp.getValues();
 		NamedList spellCheck = (NamedList) values.get("spellcheck");
 		NamedList suggestions = (NamedList) spellCheck.get("suggestions");
@@ -104,7 +107,9 @@ public class SpellCheckCollatorTest exte
 		SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
 		SolrQueryResponse rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		NamedList values = rsp.getValues();
 		NamedList spellCheck = (NamedList) values.get("spellcheck");
 		NamedList suggestions = (NamedList) spellCheck.get("suggestions");
@@ -117,7 +122,9 @@ public class SpellCheckCollatorTest exte
 		handler = core.getRequestHandler("spellCheckCompRH1");
 		rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		values = rsp.getValues();
 		spellCheck = (NamedList) values.get("spellcheck");
 		suggestions = (NamedList) spellCheck.get("suggestions");
@@ -147,7 +154,9 @@ public class SpellCheckCollatorTest exte
 		SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
 		SolrQueryResponse rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		NamedList values = rsp.getValues();
 		NamedList spellCheck = (NamedList) values.get("spellcheck");
 		NamedList suggestions = (NamedList) spellCheck.get("suggestions");
@@ -162,7 +171,9 @@ public class SpellCheckCollatorTest exte
 		handler = core.getRequestHandler("spellCheckCompRH");
 		rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+    req.close();
 		values = rsp.getValues();
 		spellCheck = (NamedList) values.get("spellcheck");
 		suggestions = (NamedList) spellCheck.get("suggestions");
@@ -178,7 +189,9 @@ public class SpellCheckCollatorTest exte
 		handler = core.getRequestHandler("spellCheckCompRH");
 		rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		values = rsp.getValues();
 		spellCheck = (NamedList) values.get("spellcheck");
 		suggestions = (NamedList) spellCheck.get("suggestions");
@@ -195,7 +208,9 @@ public class SpellCheckCollatorTest exte
 		handler = core.getRequestHandler("spellCheckCompRH");
 		rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		values = rsp.getValues();
 		spellCheck = (NamedList) values.get("spellcheck");
 		suggestions = (NamedList) spellCheck.get("suggestions");

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java Wed Oct 20 12:44:28 2010
@@ -20,16 +20,12 @@ package org.apache.solr.spelling.suggest
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.SpellingParams;
-import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.spelling.suggest.Lookup.LookupResult;
 import org.apache.solr.spelling.suggest.jaspell.JaspellLookup;
 import org.apache.solr.spelling.suggest.tst.TSTLookup;
-import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.TermFreqIterator;
-import org.apache.solr.util.TestHarness;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.*;
 
 import java.util.HashMap;
 import java.util.List;

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java Wed Oct 20 12:44:28 2010
@@ -30,6 +30,7 @@ import org.apache.solr.common.util.Conte
 import org.apache.solr.common.util.ContentStreamBase;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.XmlUpdateRequestHandler;
+import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequestBase;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.Before;
@@ -60,6 +61,15 @@ public class SignatureUpdateProcessorFac
     processor = "dedupe"; // set the default that most tests expect
   }
 
+  void checkNumDocs(int n) {
+    SolrQueryRequest req = req();
+    try {
+      assertEquals(n, req.getSearcher().getReader().numDocs());
+    } finally {
+      req.close();
+    }
+  }
+
   @Test
   public void testDupeDetection() throws Exception {
     SolrCore core = h.getCore();
@@ -79,14 +89,14 @@ public class SignatureUpdateProcessorFac
 
     addDoc(commit());
 
-    assertEquals(1l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(1);
 
     addDoc(adoc("id", "3b", "v_t", "Hello Dude man!", "t_field",
         "fake value galore"));
 
     addDoc(commit());
 
-    assertEquals(2l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(2);
 
     assertU(adoc("id", "5a", "name", "ali babi", "v_t", "MMMMM"));
 
@@ -96,14 +106,14 @@ public class SignatureUpdateProcessorFac
 
     addDoc(commit());
 
-    assertEquals(3l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(3);
 
     addDoc(adoc("id", "same", "name", "baryy white", "v_t", "random1"));
     addDoc(adoc("id", "same", "name", "bishop black", "v_t", "random2"));
 
     addDoc(commit());
 
-    assertEquals(4l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(4);
     factory.setEnabled(false);
   }
 
@@ -180,7 +190,7 @@ public class SignatureUpdateProcessorFac
 
     assertU(commit());
 
-    assertEquals(1l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(1);
     factory.setEnabled(false);
   }
 
@@ -191,16 +201,14 @@ public class SignatureUpdateProcessorFac
   public void testNonIndexedSignatureField() throws Exception {
     SolrCore core = h.getCore();
 
-    assertEquals("docs found when none are expected at start",
-                 0l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(0);    
 
     processor = "stored_sig";
     addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'"));
     addDoc(adoc("id", "2b", "v_t", "Hello Dude man!", "name", "ali babi'"));
     addDoc(commit());
 
-    assertEquals("did not find exepcted docs",
-                 2l, core.getSearcher().get().getReader().numDocs());
+    checkNumDocs(2);
   }
 
   @Test
@@ -235,5 +243,6 @@ public class SignatureUpdateProcessorFac
     streams.add(new ContentStreamBase.StringStream(doc));
     req.setContentStreams(streams);
     handler.handleRequestBody(req, new SolrQueryResponse());
+    req.close();
   }
 }

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/DateMathParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/DateMathParserTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/DateMathParserTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/DateMathParserTest.java Wed Oct 20 12:44:28 2010
@@ -19,7 +19,6 @@ package org.apache.solr.util;
 
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.util.DateMathParser;
-import org.junit.runner.RunWith;
 
 import java.text.SimpleDateFormat;
 import java.text.DateFormat;
@@ -35,7 +34,6 @@ import java.text.ParseException;
 /**
  * Tests that the functions in DateMathParser
  */
-@RunWith(LuceneTestCase.LocalizedTestCaseRunner.class)
 public class DateMathParserTest extends LuceneTestCase {
 
   public static TimeZone UTC = TimeZone.getTimeZone("UTC");

Modified: lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java (original)
+++ lucene/dev/branches/docvalues/solr/src/test/org/apache/solr/util/SolrPluginUtilsTest.java Wed Oct 20 12:44:28 2010
@@ -66,7 +66,8 @@ public class SolrPluginUtilsTest extends
     assertU("", adoc("id", "3235", "val_t", "quick green fox"));
     assertU("", adoc("id", "3236", "val_t", "quick brown fox"));
     commit();
-    SolrIndexSearcher srchr = h.getCore().getSearcher().get();
+    RefCounted<SolrIndexSearcher> holder = h.getCore().getSearcher();
+    SolrIndexSearcher srchr = holder.get();
     SolrIndexSearcher.QueryResult qr = new SolrIndexSearcher.QueryResult();
     SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
     cmd.setQuery(new MatchAllDocsQuery());
@@ -82,7 +83,7 @@ public class SolrPluginUtilsTest extends
     for (SolrDocument document : list) {
       assertNotNull(document.get("val_t"));
     }
-
+    holder.decref();
   }
 
   @Test

Modified: lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-altdirectory.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-altdirectory.xml?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-altdirectory.xml (original)
+++ lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-altdirectory.xml Wed Oct 20 12:44:28 2010
@@ -17,388 +17,8 @@
  limitations under the License.
 -->
 
-<!-- $Id$
-     $Source$
-     $Name$
-  -->
-
 <config>
-
-  <jmx />
-
-  <!-- Used to specify an alternate directory to hold all index data.
-       It defaults to "index" if not present, and should probably
-       not be changed if replication is in use. -->
-  <dataDir>${solr.data.dir:./solr/data}</dataDir>
-
-  <indexDefaults>
-   <!-- Values here affect all index writers and act as a default
-   unless overridden. -->
-    <!-- Values here affect all index writers and act as a default unless overridden. -->
-    <useCompoundFile>false</useCompoundFile>
-    <mergeFactor>10</mergeFactor>
-    <!-- If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first.
-     -->
-    <!--<maxBufferedDocs>1000</maxBufferedDocs>-->
-    <!-- Tell Lucene when to flush documents to disk.
-    Giving Lucene more memory for indexing means faster indexing at the cost of more RAM
-
-    If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first.
-
-    -->
-    <ramBufferSizeMB>32</ramBufferSizeMB>
-    <maxMergeDocs>2147483647</maxMergeDocs>
-    <maxFieldLength>10000</maxFieldLength>
-    <writeLockTimeout>1000</writeLockTimeout>
-    <commitLockTimeout>10000</commitLockTimeout>
-
-    <!--
-     Expert:
-     The Merge Policy in Lucene controls how merging is handled by Lucene.  The default in 2.3 is the LogByteSizeMergePolicy, previous
-     versions used LogDocMergePolicy.
-
-     LogByteSizeMergePolicy chooses segments to merge based on their size.  The Lucene 2.2 default, LogDocMergePolicy chose when
-     to merge based on number of documents
-
-     Other implementations of MergePolicy must have a no-argument constructor
-     -->
-    <mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy"/>
-
-    <!--
-     Expert:
-     The Merge Scheduler in Lucene controls how merges are performed.  The ConcurrentMergeScheduler (Lucene 2.3 default)
-      can perform merges in the background using separate threads.  The SerialMergeScheduler (Lucene 2.2 default) does not.
-     -->
-    <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>
-    <!-- these are global... can't currently override per index -->
-    <writeLockTimeout>1000</writeLockTimeout>
-    <commitLockTimeout>10000</commitLockTimeout>
-
-    <lockType>single</lockType>
-  </indexDefaults>
-
-  <mainIndex>
-    <!-- lucene options specific to the main on-disk lucene index -->
-    <useCompoundFile>false</useCompoundFile>
-    <mergeFactor>10</mergeFactor>
-    <ramBufferSizeMB>32</ramBufferSizeMB>
-    <maxMergeDocs>2147483647</maxMergeDocs>
-    <maxFieldLength>10000</maxFieldLength>
-
-    <unlockOnStartup>true</unlockOnStartup>
-  </mainIndex>
-
-  <updateHandler class="solr.DirectUpdateHandler2">
-
-    <!-- autocommit pending docs if certain criteria are met 
-    <autoCommit> 
-      <maxDocs>10000</maxDocs>
-      <maxTime>3600000</maxTime> 
-    </autoCommit>
-    -->
-    <!-- represents a lower bound on the frequency that commits may
-    occur (in seconds). NOTE: not yet implemented
-    
-    <commitIntervalLowerBound>0</commitIntervalLowerBound>
-    -->
-
-    <!-- The RunExecutableListener executes an external command.
-         exe - the name of the executable to run
-         dir - dir to use as the current working directory. default="."
-         wait - the calling thread waits until the executable returns. default="true"
-         args - the arguments to pass to the program.  default=nothing
-         env - environment variables to set.  default=nothing
-      -->
-    <!-- A postCommit event is fired after every commit
-    <listener event="postCommit" class="solr.RunExecutableListener">
-      <str name="exe">/var/opt/resin3/__PORT__/scripts/solr/snapshooter</str>
-      <str name="dir">/var/opt/resin3/__PORT__</str>
-      <bool name="wait">true</bool>
-      <arr name="args"> <str>arg1</str> <str>arg2</str> </arr>
-      <arr name="env"> <str>MYVAR=val1</str> </arr>
-    </listener>
-    -->
-
-
-  </updateHandler>
-
-  <directoryFactory name="DirectoryFactory" class="org.apache.solr.core.AlternateDirectoryTest$TestFSDirectoryFactory">
-    <!-- Parameters as required by the implementation -->
-  </directoryFactory>
-  
-  
-  <indexReaderFactory name="IndexReaderFactory" class="org.apache.solr.core.AlternateIndexReaderTest$TestIndexReaderFactory">
-    <!-- Parameters as required by the implementation -->
-  </indexReaderFactory >
-
-  <query>
-    <!-- Maximum number of clauses in a boolean query... can affect
-        range or wildcard queries that expand to big boolean
-        queries.  An exception is thrown if exceeded.
-    -->
-    <maxBooleanClauses>1024</maxBooleanClauses>
-
-
-    <!-- Cache specification for Filters or DocSets - unordered set of *all* documents
-         that match a particular query.
-      -->
-    <filterCache
-      class="solr.search.LRUCache"
-      size="512"
-      initialSize="512"
-      autowarmCount="256"/>
-
-    <queryResultCache
-      class="solr.search.LRUCache"
-      size="512"
-      initialSize="512"
-      autowarmCount="1024"/>
-
-    <documentCache
-      class="solr.search.LRUCache"
-      size="512"
-      initialSize="512"
-      autowarmCount="0"/>
-
-    <!-- If true, stored fields that are not requested will be loaded lazily.
-    -->
-    <enableLazyFieldLoading>true</enableLazyFieldLoading>
-
-    <!--
-
-    <cache name="myUserCache"
-      class="solr.search.LRUCache"
-      size="4096"
-      initialSize="1024"
-      autowarmCount="1024"
-      regenerator="MyRegenerator"
-      />
-    -->
-
-
-    <useFilterForSortedQuery>true</useFilterForSortedQuery>
-
-    <queryResultWindowSize>10</queryResultWindowSize>
-
-    <!-- set maxSize artificially low to exercise both types of sets -->
-    <HashDocSet maxSize="3" loadFactor="0.75"/>
-
-
-    <!-- boolToFilterOptimizer converts boolean clauses with zero boost
-         into cached filters if the number of docs selected by the clause exceeds
-         the threshold (represented as a fraction of the total index)
-    -->
-    <boolTofilterOptimizer enabled="false" cacheSize="32" threshold=".05"/>
-
-
-    <!-- a newSearcher event is fired whenever a new searcher is being prepared
-         and there is a current searcher handling requests (aka registered). -->
-    <!-- QuerySenderListener takes an array of NamedList and executes a
-         local query request for each NamedList in sequence. -->
-    <!--
-    <listener event="newSearcher" class="solr.QuerySenderListener">
-      <arr name="queries">
-        <lst> <str name="q">solr</str> <str name="start">0</str> <str name="rows">10</str> </lst>
-        <lst> <str name="q">rocks</str> <str name="start">0</str> <str name="rows">10</str> </lst>
-      </arr>
-    </listener>
-    -->
-
-    <!-- a firstSearcher event is fired whenever a new searcher is being
-         prepared but there is no current registered searcher to handle
-         requests or to gain prewarming data from. -->
-    <!--
-    <listener event="firstSearcher" class="solr.QuerySenderListener">
-      <arr name="queries">
-        <lst> <str name="q">fast_warm</str> <str name="start">0</str> <str name="rows">10</str> </lst>
-      </arr>
-    </listener>
-    -->
-
-
-  </query>
-
-
-  <!-- An alternate set representation that uses an integer hash to store filters (sets of docids).
-       If the set cardinality <= maxSize elements, then HashDocSet will be used instead of the bitset
-       based HashBitset. -->
-
-  <!-- requestHandler plugins... incoming queries will be dispatched to the
-     correct handler based on the qt (query type) param matching the
-     name of registered handlers.
-      The "standard" request handler is the default and will be used if qt
-     is not specified in the request.
-  -->
-  <requestHandler name="standard" class="solr.StandardRequestHandler">
-  	<bool name="httpCaching">true</bool>
-  </requestHandler>
-  <requestHandler name="dismaxOldStyleDefaults"
-                  class="solr.DisMaxRequestHandler" >
-     <!-- for historic reasons, DisMaxRequestHandler will use all of
-          it's init params as "defaults" if there is no "defaults" list
-          specified
-     -->
-     <float name="tie">0.01</float>
-     <str name="qf">
-        text^0.5 features_t^1.0 subject^1.4 title_stemmed^2.0
-     </str>
-     <str name="pf">
-        text^0.2 features_t^1.1 subject^1.4 title_stemmed^2.0 title^1.5
-     </str>
-     <str name="bf">
-        ord(weight)^0.5 recip(rord(iind),1,1000,1000)^0.3
-     </str>
-     <str name="mm">
-        3&lt;-1 5&lt;-2 6&lt;90%
-     </str>
-     <int name="ps">100</int>
-  </requestHandler>
-  <requestHandler name="dismax" class="solr.DisMaxRequestHandler" >
-    <lst name="defaults">
-     <str name="q.alt">*:*</str>
-     <float name="tie">0.01</float>
-     <str name="qf">
-        text^0.5 features_t^1.0 subject^1.4 title_stemmed^2.0
-     </str>
-     <str name="pf">
-        text^0.2 features_t^1.1 subject^1.4 title_stemmed^2.0 title^1.5
-     </str>
-     <str name="bf">
-        ord(weight)^0.5 recip(rord(iind),1,1000,1000)^0.3
-     </str>
-     <str name="mm">
-        3&lt;-1 5&lt;-2 6&lt;90%
-     </str>
-     <int name="ps">100</int>
-    </lst>
-  </requestHandler>
-  <requestHandler name="old" class="solr.tst.OldRequestHandler" >
-    <int name="myparam">1000</int>
-    <float name="ratio">1.4142135</float>
-    <arr name="myarr"><int>1</int><int>2</int></arr>
-    <str>foo</str>
-  </requestHandler>
-  <requestHandler name="oldagain" class="solr.tst.OldRequestHandler" >
-    <lst name="lst1"> <str name="op">sqrt</str> <int name="val">2</int> </lst>
-    <lst name="lst2"> <str name="op">log</str> <float name="val">10</float> </lst>
-  </requestHandler>
-
-  <requestHandler name="test" class="solr.tst.TestRequestHandler" />
-
-  <!-- test query parameter defaults -->
-  <requestHandler name="defaults" class="solr.StandardRequestHandler">
-    <lst name="defaults">
-      <int name="rows">4</int>
-      <bool name="hl">true</bool>
-      <str name="hl.fl">text,name,subject,title,whitetok</str>
-    </lst>
-  </requestHandler>
-
-  <!-- test query parameter defaults -->
-  <requestHandler name="lazy" class="solr.StandardRequestHandler" startup="lazy">
-    <lst name="defaults">
-      <int name="rows">4</int>
-      <bool name="hl">true</bool>
-      <str name="hl.fl">text,name,subject,title,whitetok</str>
-    </lst>
-  </requestHandler>
-
-  <requestHandler name="/update"     class="solr.XmlUpdateRequestHandler"          />
-  <requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy">
-  	<bool name="httpCaching">false</bool>
-  </requestHandler>
-
-  <searchComponent name="spellcheck" class="org.apache.solr.handler.component.SpellCheckComponent">
-    <str name="queryAnalyzerFieldType">lowerfilt</str>
-
-    <lst name="spellchecker">
-      <str name="name">default</str>
-      <str name="field">lowerfilt</str>
-      <str name="spellcheckIndexDir">spellchecker1</str>
-      <str name="buildOnCommit">true</str>
-    </lst>
-    <!-- Example of using different distance measure -->
-    <lst name="spellchecker">
-      <str name="name">jarowinkler</str>
-      <str name="field">lowerfilt</str>
-      <!-- Use a different Distance Measure -->
-      <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
-      <str name="spellcheckIndexDir">spellchecker2</str>
-
-    </lst>
-    <lst name="spellchecker">
-      <str name="classname">solr.FileBasedSpellChecker</str>
-      <str name="name">external</str>
-      <str name="sourceLocation">spellings.txt</str>
-      <str name="characterEncoding">UTF-8</str>
-      <str name="spellcheckIndexDir">spellchecker3</str>
-    </lst>
-  </searchComponent>
-  <!--
-  The SpellingQueryConverter to convert raw (CommonParams.Q) queries into tokens.  Uses a simple regular expression
-   to strip off field markup, boosts, ranges, etc. but it is not guaranteed to match an exact parse from the query parser.
-   -->
-  <queryConverter name="queryConverter" class="org.apache.solr.spelling.SpellingQueryConverter"/>
-
-  <requestHandler name="spellCheckCompRH" class="org.apache.solr.handler.component.SearchHandler">
-    <lst name="defaults">
-      <!-- omp = Only More Popular -->
-      <str name="spellcheck.onlyMorePopular">false</str>
-      <!-- exr = Extended Results -->
-      <str name="spellcheck.extendedResults">false</str>
-      <!--  The number of suggestions to return -->
-      <str name="spellcheck.count">1</str>
-    </lst>
-    <arr name="last-components">
-      <str>spellcheck</str>
-    </arr>
-  </requestHandler>
-
-  <searchComponent class="solr.HighlightComponent" name="highlight">
-  <highlighting>
-   <!-- Configure the standard fragmenter -->
-   <fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
-    <lst name="defaults">
-     <int name="hl.fragsize">100</int>
-    </lst>
-   </fragmenter>
-
-   <fragmenter name="regex" class="org.apache.solr.highlight.RegexFragmenter">
-    <lst name="defaults">
-     <int name="hl.fragsize">70</int>
-    </lst>
-   </fragmenter>
-
-   <!-- Configure the standard formatter -->
-   <formatter name="html" class="org.apache.solr.highlight.HtmlFormatter" default="true">
-    <lst name="defaults">
-     <str name="hl.simple.pre"><![CDATA[<em>]]></str>
-     <str name="hl.simple.post"><![CDATA[</em>]]></str>
-    </lst>
-   </formatter>
-  </highlighting>
-  </searchComponent>
-
-
-  <!-- enable streaming for testing... -->
-  <requestDispatcher handleSelect="true" >
-    <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
-    <httpCaching lastModifiedFrom="openTime" etagSeed="Solr" never304="false">
-      <cacheControl>max-age=30, public</cacheControl>
-    </httpCaching>
-  </requestDispatcher>
-
-  <admin>
-    <defaultQuery>solr</defaultQuery>
-    <gettableFiles>solrconfig.xml scheam.xml admin-extra.html</gettableFiles>
-  </admin>
-
-  <!-- test getting system property -->
-  <propTest attr1="${solr.test.sys.prop1}-$${literal}"
-            attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>
-
-  <queryParser name="foo" class="FooQParserPlugin"/>
-
-
-
+  <requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>
+  <directoryFactory name="DirectoryFactory" class="org.apache.solr.core.AlternateDirectoryTest$TestFSDirectoryFactory"></directoryFactory>
+  <indexReaderFactory name="IndexReaderFactory" class="org.apache.solr.core.AlternateDirectoryTest$TestIndexReaderFactory"></indexReaderFactory >
 </config>

Modified: lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-spellchecker.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-spellchecker.xml?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-spellchecker.xml (original)
+++ lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig-spellchecker.xml Wed Oct 20 12:44:28 2010
@@ -101,6 +101,9 @@
       <str name="lookupImpl">org.apache.solr.spelling.suggest.jaspell.JaspellLookup</str>
       <str name="field">suggest</str>
       <str name="buildOnCommit">true</str>
+
+      <!-- Suggester properties -->
+      <str name="threshold">0.0</str>
 <!--
       <str name="sourceLocation">american-english</str>
 -->

Modified: lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig.xml?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig.xml (original)
+++ lucene/dev/branches/docvalues/solr/src/test/test-files/solr/conf/solrconfig.xml Wed Oct 20 12:44:28 2010
@@ -340,13 +340,13 @@
       <str name="name">default</str>
       <str name="field">lowerfilt</str>
       <str name="spellcheckIndexDir">spellchecker1</str>
-      <str name="buildOnCommit">true</str>
+      <str name="buildOnCommit">false</str>
     </lst>
     <lst name="spellchecker">
 			<str name="name">multipleFields</str>
 			<str name="field">lowerfilt1and2</str>
 			<str name="spellcheckIndexDir">spellcheckerMultipleFields</str>
-			<str name="buildOnCommit">true</str>
+			<str name="buildOnCommit">false</str>
    	</lst>
     <!-- Example of using different distance measure -->
     <lst name="spellchecker">
@@ -375,14 +375,14 @@
         3. A fully qualified class name
        -->
       <str name="comparatorClass">freq</str>
-      <str name="buildOnCommit">true</str>
+      <str name="buildOnCommit">false</str>
     </lst>
     <lst name="spellchecker">
       <str name="name">fqcn</str>
       <str name="field">lowerfilt</str>
       <str name="spellcheckIndexDir">spellcheckerFQCN</str>
       <str name="comparatorClass">org.apache.solr.spelling.SampleComparator</str>
-      <str name="buildOnCommit">true</str>
+      <str name="buildOnCommit">false</str>
     </lst>
     <lst name="spellchecker">
       <str name="name">perDict</str>

Propchange: lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 20 12:44:28 2010
@@ -1,3 +1,4 @@
 /lucene/dev/branches/branch_3x/solr/src/webapp/src/org/apache/solr/client/solrj/embedded:949730,961612,979161,980654,982195,987811,988512
 /lucene/dev/branches/preflexfixes/solr/src/webapp/src/org/apache/solr/client/solrj/embedded:967125-979432
+/lucene/dev/trunk/solr/src/webapp/src/org/apache/solr/client/solrj/embedded:1021635-1024556,1025532-1025536
 /lucene/solr/trunk/src/webapp/src/org/apache/solr/client/solrj/embedded:922950-923910,923912-925091

Modified: lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java (original)
+++ lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java Wed Oct 20 12:44:28 2010
@@ -143,8 +143,9 @@ public class EmbeddedSolrServer extends 
       throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+path );
     }
 
+    SolrQueryRequest req = null;
     try {
-      SolrQueryRequest req = _parser.buildRequestFrom( core, params, request.getContentStreams() );
+      req = _parser.buildRequestFrom( core, params, request.getContentStreams() );
       req.getContext().put( "path", path );
       SolrQueryResponse rsp = new SolrQueryResponse();
       core.execute( handler, req, rsp );
@@ -216,14 +217,10 @@ public class EmbeddedSolrServer extends 
         catch (Exception ex) {
           throw new RuntimeException(ex);
         }
-        finally {
-          req.close();
-        }
       }
       
       // Now write it out
       NamedList<Object> normalized = getParsedResponse(req, rsp);
-      req.close();
       return normalized;
     }
     catch( IOException iox ) {
@@ -233,6 +230,7 @@ public class EmbeddedSolrServer extends 
       throw new SolrServerException( ex );
     }
     finally {
+      if (req != null) req.close();
       core.close();
     }
   }

Modified: lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java (original)
+++ lucene/dev/branches/docvalues/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/JettySolrRunner.java Wed Oct 20 12:44:28 2010
@@ -18,8 +18,6 @@
 package org.apache.solr.client.solrj.embedded;
 
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.Random;
 
 import javax.servlet.http.HttpServlet;
@@ -27,9 +25,12 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.solr.servlet.SolrDispatchFilter;
+import org.mortbay.component.LifeCycle;
+import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.Server;
-import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.servlet.Context;
 import org.mortbay.jetty.servlet.FilterHolder;
 import org.mortbay.jetty.servlet.HashSessionIdManager;
@@ -40,112 +41,107 @@ import org.mortbay.log.Logger;
  * 
  * @since solr 1.3
  */
-public class JettySolrRunner 
-{
+public class JettySolrRunner {
   Server server;
+
   FilterHolder dispatchFilter;
+
   String context;
-  
-  public JettySolrRunner( String context, int port )
-  {
-    this.init( context, port );
-  }
-
-  public JettySolrRunner( String context, int port, String solrConfigFilename )
-  {
-    this.init( context, port );
-    if (solrConfigFilename != null)
-      dispatchFilter.setInitParameter("solrconfig-filename", solrConfigFilename);
-  }
-  
-//  public JettySolrRunner( String context, String home, String dataDir, int port, boolean log )
-//  {
-//    if(!log) {
-//      System.setProperty("org.mortbay.log.class", NoLog.class.getName() );
-//      System.setProperty("java.util.logging.config.file", home+"/conf/logging.properties");
-//      NoLog noLogger = new NoLog();
-//      org.mortbay.log.Log.setLog(noLogger);
-//    }
-//
-//    // Initalize JNDI
-//    Config.setInstanceDir(home);
-//    new SolrCore(dataDir, new IndexSchema(home+"/conf/schema.xml"));
-//    this.init( context, port );
-//  }
-  
-  private void init( String context, int port )
-  {
+
+  private String solrConfigFilename;
+
+  private boolean waitOnSolr = false;
+
+  public JettySolrRunner(String context, int port) {
+    this.init(context, port);
+  }
+
+  public JettySolrRunner(String context, int port, String solrConfigFilename) {
+    this.init(context, port);
+    this.solrConfigFilename = solrConfigFilename;
+  }
+
+  private void init(String context, int port) {
     this.context = context;
-    server = new Server( port );    
-    if (System.getProperty("jetty.insecurerandom") != null)
+    server = new Server(port);
+    server.setStopAtShutdown(true);
+    if (System.getProperty("jetty.testMode") != null) {
+      SelectChannelConnector connector = new SelectChannelConnector();
+      connector.setPort(port);
+      connector.setReuseAddress(true);
+      server.setConnectors(new Connector[] { connector });
       server.setSessionIdManager(new HashSessionIdManager(new Random()));
+    }
 
-    server.setStopAtShutdown( true );
-    
     // Initialize the servlets
-    Context root = new Context( server, context, Context.SESSIONS );
-    
+    final Context root = new Context(server, context, Context.SESSIONS);
+    server.addLifeCycleListener(new LifeCycle.Listener() {
+
+      public void lifeCycleStopping(LifeCycle arg0) {
+        System.clearProperty("hostPort");
+      }
+
+      public void lifeCycleStopped(LifeCycle arg0) {}
+
+      public void lifeCycleStarting(LifeCycle arg0) {
+        synchronized (JettySolrRunner.this) {
+          waitOnSolr = true;
+          JettySolrRunner.this.notify();
+        }
+      }
+
+      public void lifeCycleStarted(LifeCycle arg0) {
+        System.setProperty("hostPort", Integer.toString(getLocalPort()));
+        if (solrConfigFilename != null)
+          System.setProperty("solrconfig", solrConfigFilename);
+        dispatchFilter = root.addFilter(SolrDispatchFilter.class, "*",
+            Handler.REQUEST);
+        if (solrConfigFilename != null)
+          System.clearProperty("solrconfig");
+      }
+
+      public void lifeCycleFailure(LifeCycle arg0, Throwable arg1) {
+        System.clearProperty("hostPort");
+      }
+    });
+
     // for some reason, there must be a servlet for this to get applied
-    root.addServlet( Servlet404.class, "/*" );
-    dispatchFilter = root.addFilter( SolrDispatchFilter.class, "*", Handler.REQUEST );
+    root.addServlet(Servlet404.class, "/*");
+
   }
 
-  //------------------------------------------------------------------------------------------------
-  //------------------------------------------------------------------------------------------------
-  
-  public void start() throws Exception
-  {
+  // ------------------------------------------------------------------------------------------------
+  // ------------------------------------------------------------------------------------------------
+
+  public void start() throws Exception {
     start(true);
   }
 
-  public void start(boolean waitForSolr) throws Exception
-  {
-    if(!server.isRunning() ) {
+  public void start(boolean waitForSolr) throws Exception {
+    if (!server.isRunning()) {
       server.start();
     }
-    if (waitForSolr) waitForSolr(context);
+    synchronized (JettySolrRunner.this) {
+      int cnt = 0;
+      while (!waitOnSolr) {
+        this.wait(100);
+        if (cnt++ == 5) {
+          throw new RuntimeException("Jetty/Solr unresponsive");
+        }
+      }
+    }
   }
 
-
-  public void stop() throws Exception
-  {
-    if( server.isRunning() ) {
+  public void stop() throws Exception {
+    if (server.isRunning()) {
       server.stop();
       server.join();
     }
   }
 
-  /** Waits until a ping query to the solr server succeeds,
-   * retrying every 200 milliseconds up to 2 minutes.
-   */
-  public void waitForSolr(String context) throws Exception
-  {
-    int port = getLocalPort();
-
-    // A raw term query type doesn't check the schema
-    URL url = new URL("http://localhost:"+port+context+"/select?q={!raw+f=junit_test_query}ping");
-
-    Exception ex = null;
-    // Wait for a total of 20 seconds: 100 tries, 200 milliseconds each
-    for (int i=0; i<600; i++) {
-      try {
-        InputStream stream = url.openStream();
-        stream.close();
-      } catch (IOException e) {
-        // e.printStackTrace();
-        ex = e;
-        Thread.sleep(200);
-        continue;
-      }
-
-      return;
-    }
-
-    throw new RuntimeException("Jetty/Solr unresponsive",ex);
-  }
-
   /**
    * Returns the Local Port of the first Connector found for the jetty Server.
+   * 
    * @exception RuntimeException if there is no Connector
    */
   public int getLocalPort() {
@@ -156,80 +152,78 @@ public class JettySolrRunner 
     return conns[0].getLocalPort();
   }
 
-  //--------------------------------------------------------------
-  //--------------------------------------------------------------
-    
-  /** 
+  // --------------------------------------------------------------
+  // --------------------------------------------------------------
+
+  /**
    * This is a stupid hack to give jetty something to attach to
    */
-  public static class Servlet404 extends HttpServlet
-  {
+  public static class Servlet404 extends HttpServlet {
     @Override
-    public void service(HttpServletRequest req, HttpServletResponse res ) throws IOException
-    {
-      res.sendError( 404, "Can not find: "+req.getRequestURI() );
+    public void service(HttpServletRequest req, HttpServletResponse res)
+        throws IOException {
+      res.sendError(404, "Can not find: " + req.getRequestURI());
     }
   }
-  
+
   /**
-   * A main class that starts jetty+solr 
-   * This is useful for debugging
+   * A main class that starts jetty+solr This is useful for debugging
    */
-  public static void main( String[] args )
-  {
+  public static void main(String[] args) {
     try {
-      JettySolrRunner jetty = new JettySolrRunner( "/solr", 3456 );
+      JettySolrRunner jetty = new JettySolrRunner("/solr", 3456);
       jetty.start();
-    }
-    catch( Exception ex ) {
+    } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
 }
 
+class NoLog implements Logger {
+  private static boolean debug = System.getProperty("DEBUG", null) != null;
 
-class NoLog implements Logger
-{    
-  private static boolean debug = System.getProperty("DEBUG",null)!=null;
   private final String name;
-      
-  public NoLog()
-  {
+
+  public NoLog() {
     this(null);
   }
-  
-  public NoLog(String name)
-  {    
-    this.name=name==null?"":name;
-  }
-  
-  public boolean isDebugEnabled()
-  {
+
+  public NoLog(String name) {
+    this.name = name == null ? "" : name;
+  }
+
+  public boolean isDebugEnabled() {
     return debug;
   }
-  
-  public void setDebugEnabled(boolean enabled)
-  {
-    debug=enabled;
-  }
-  
-  public void info(String msg,Object arg0, Object arg1) {}
-  public void debug(String msg,Throwable th){}
-  public void debug(String msg,Object arg0, Object arg1){}
-  public void warn(String msg,Object arg0, Object arg1){}
-  public void warn(String msg, Throwable th){}
-
-  public Logger getLogger(String name)
-  {
-    if ((name==null && this.name==null) ||
-      (name!=null && name.equals(this.name)))
+
+  public void setDebugEnabled(boolean enabled) {
+    debug = enabled;
+  }
+
+  public void info(String msg, Object arg0, Object arg1) {
+  }
+
+  public void debug(String msg, Throwable th) {
+  }
+
+  public void debug(String msg, Object arg0, Object arg1) {
+  }
+
+  public void warn(String msg, Object arg0, Object arg1) {
+  }
+
+  public void warn(String msg, Throwable th) {
+  }
+
+  public Logger getLogger(String name) {
+    if ((name == null && this.name == null)
+        || (name != null && name.equals(this.name)))
       return this;
     return new NoLog(name);
   }
-  
+
   @Override
-  public String toString()
-  {
-    return "NOLOG["+name+"]";
+  public String toString() {
+    return "NOLOG[" + name + "]";
   }
 }

Modified: lucene/dev/branches/docvalues/solr/src/webapp/web/admin/index.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/branches/docvalues/solr/src/webapp/web/admin/index.jsp?rev=1025539&r1=1025538&r2=1025539&view=diff
==============================================================================
--- lucene/dev/branches/docvalues/solr/src/webapp/web/admin/index.jsp (original)
+++ lucene/dev/branches/docvalues/solr/src/webapp/web/admin/index.jsp Wed Oct 20 12:44:28 2010
@@ -50,6 +50,7 @@
     [<a href="stats.jsp">Statistics</a>]
     [<a href="registry.jsp">Info</a>]
     [<a href="distributiondump.jsp">Distribution</a>]
+    [<a href="zookeeper.jsp">ZooKeeper</a>]
     [<a href="ping">Ping</a>]
     [<a href="logging">Logging</a>]
   </td>