You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by bu...@apache.org on 2010/07/22 21:34:52 UTC
svn commit: r966819 [19/20] - in /lucene/dev/branches/realtime_search: ./
lucene/ lucene/backwards/ lucene/contrib/ lucene/contrib/benchmark/conf/
lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/
lucene/contrib/benchmark/src/...
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/update/DirectUpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/update/DirectUpdateHandler.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/update/DirectUpdateHandler.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/update/DirectUpdateHandler.java Thu Jul 22 19:34:35 2010
@@ -22,10 +22,12 @@ package org.apache.solr.update;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.Term;
+import org.apache.lucene.index.MultiFields;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.Query;
+import org.apache.lucene.util.BytesRef;
import java.util.HashSet;
import java.util.concurrent.Future;
@@ -35,7 +37,6 @@ import java.net.URL;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.search.QueryParsing;
-import org.apache.solr.update.UpdateHandler;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
@@ -113,15 +114,16 @@ public class DirectUpdateHandler extends
closeWriter();
openSearcher();
IndexReader ir = searcher.getReader();
- TermDocs tdocs = null;
- boolean exists=false;
- try {
- tdocs = ir.termDocs(idTerm(indexedId));
- if (tdocs.next()) exists=true;
- } finally {
- try { if (tdocs != null) tdocs.close(); } catch (Exception e) {}
+ Term idTerm = idTerm(indexedId);
+ DocsEnum tdocs = MultiFields.getTermDocsEnum(ir,
+ MultiFields.getDeletedDocs(ir),
+ idTerm.field(),
+ idTerm.bytes());
+ if (tdocs != null) {
+ return tdocs.nextDoc() != DocsEnum.NO_MORE_DOCS;
+ } else {
+ return false;
}
- return exists;
}
@@ -130,16 +132,11 @@ public class DirectUpdateHandler extends
closeWriter(); openSearcher();
IndexReader ir = searcher.getReader();
- TermDocs tdocs = null;
int num=0;
- try {
- Term term = new Term(idField.getName(), indexedId);
- num = ir.deleteDocuments(term);
- if (core.log.isTraceEnabled()) {
- core.log.trace( core.getLogId()+"deleted " + num + " docs matching id " + idFieldType.indexedToReadable(indexedId));
- }
- } finally {
- try { if (tdocs != null) tdocs.close(); } catch (Exception e) {}
+ Term term = new Term(idField.getName(), indexedId);
+ num = ir.deleteDocuments(term);
+ if (core.log.isTraceEnabled()) {
+ core.log.trace( core.getLogId()+"deleted " + num + " docs matching id " + idFieldType.indexedToReadable(indexedId));
}
return num;
}
@@ -265,8 +262,6 @@ public class DirectUpdateHandler extends
SolrException.log(log,e);
}
}
-
- return;
}
/**
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/HighFrequencyDictionary.java Thu Jul 22 19:34:35 2010
@@ -21,19 +21,18 @@ import java.io.IOException;
import java.util.Iterator;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermEnum;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.MultiFields;
import org.apache.lucene.search.spell.Dictionary;
import org.apache.lucene.util.StringHelper;
+import org.apache.lucene.util.BytesRef;
/**
* HighFrequencyDictionary: terms taken from the given field
* of a Lucene index, which appear in a number of documents
* above a given threshold.
*
- * When using IndexReader.terms(Term) the code must not call next() on TermEnum
- * as the first call to TermEnum, see: http://issues.apache.org/jira/browse/LUCENE-6
- *
* Threshold is a value in [0..1] representing the minimum
* number of documents (of the total) where a term should appear.
*
@@ -55,41 +54,34 @@ public class HighFrequencyDictionary imp
}
final class HighFrequencyIterator implements Iterator {
- private TermEnum termEnum;
- private Term actualTerm;
+ private TermsEnum termsEnum;
+ private BytesRef actualTerm;
private boolean hasNextCalled;
private int minNumDocs;
HighFrequencyIterator() {
try {
- termEnum = reader.terms(new Term(field, ""));
+ Terms terms = MultiFields.getTerms(reader, field);
+ if (terms != null) {
+ termsEnum = terms.iterator();
+ }
minNumDocs = (int)(thresh * (float)reader.numDocs());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
- private boolean isFrequent(Term term) {
- try {
- return reader.docFreq(term) >= minNumDocs;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ private boolean isFrequent(int freq) {
+ return freq >= minNumDocs;
}
public Object next() {
- if (!hasNextCalled) {
- hasNext();
+ if (!hasNextCalled && !hasNext()) {
+ return null;
}
hasNextCalled = false;
- try {
- termEnum.next();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- return (actualTerm != null) ? actualTerm.text() : null;
+ return (actualTerm != null) ? actualTerm.utf8ToString() : null;
}
public boolean hasNext() {
@@ -98,35 +90,28 @@ public class HighFrequencyDictionary imp
}
hasNextCalled = true;
- do {
- actualTerm = termEnum.term();
+ if (termsEnum == null) {
+ return false;
+ }
- // if there are no words return false
- if (actualTerm == null) {
- return false;
- }
+ while(true) {
- String currentField = actualTerm.field();
+ try {
+ actualTerm = termsEnum.next();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
- // if the next word doesn't have the same field return false
- if (currentField != field) { // intern'd comparison
- actualTerm = null;
+ // if there are no words return false
+ if (actualTerm == null) {
return false;
}
// got a valid term, does it pass the threshold?
- if (isFrequent(actualTerm)) {
+ if (isFrequent(termsEnum.docFreq())) {
return true;
}
-
- // term not up to threshold
- try {
- termEnum.next();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- } while (true);
+ }
}
public void remove() {
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/util/SolrPluginUtils.java Thu Jul 22 19:34:35 2010
@@ -842,7 +842,7 @@ public class SolrPluginUtils {
* DisjunctionMaxQuery. (so yes: aliases which point at other
* aliases should work)
*/
- protected Query getFieldQuery(String field, String queryText)
+ protected Query getFieldQuery(String field, String queryText, boolean quoted)
throws ParseException {
if (aliases.containsKey(field)) {
@@ -857,7 +857,7 @@ public class SolrPluginUtils {
for (String f : a.fields.keySet()) {
- Query sub = getFieldQuery(f,queryText);
+ Query sub = getFieldQuery(f,queryText,quoted);
if (null != sub) {
if (null != a.fields.get(f)) {
sub.setBoost(a.fields.get(f));
@@ -870,7 +870,7 @@ public class SolrPluginUtils {
} else {
try {
- return super.getFieldQuery(field, queryText);
+ return super.getFieldQuery(field, queryText, quoted);
} catch (Exception e) {
return null;
}
Modified: lucene/dev/branches/realtime_search/solr/src/maven/solr-core-pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/maven/solr-core-pom.xml.template?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/maven/solr-core-pom.xml.template (original)
+++ lucene/dev/branches/realtime_search/solr/src/maven/solr-core-pom.xml.template Thu Jul 22 19:34:35 2010
@@ -26,13 +26,13 @@
<parent>
<groupId>org.apache.solr</groupId>
<artifactId>solr-parent</artifactId>
- <version>@maven_version@</version>
+ <version>@version@</version>
</parent>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<name>Apache Solr Core</name>
- <version>@maven_version@</version>
+ <version>@version@</version>
<description>Apache Solr Server</description>
<packaging>jar</packaging>
@@ -42,49 +42,44 @@
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
- <version>@maven_version@</version>
+ <version>@version@</version>
</dependency>
<!-- Lucene -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
- <version>2.9.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-snowball</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-misc</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spellchecker</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spatial</artifactId>
- <version>2.9.1</version>
+ <version>@version@</version>
</dependency>
<!-- Apache Commons -->
@@ -104,6 +99,11 @@
<version>1.4</version>
</dependency>
<dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
@@ -113,7 +113,7 @@
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-commons-csv</artifactId>
- <version>@maven_version@</version>
+ <version>@version@</version>
</dependency>
<!-- Stax : we could exclude this because already dependancy of solrj -->
Propchange: lucene/dev/branches/realtime_search/solr/src/maven/solr-core-pom.xml.template
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 22 19:34:35 2010
@@ -1,2 +1,3 @@
-/lucene/dev/branches/branch_3x/solr/src/maven/solr-core-pom.xml.template:949730
+/lucene/dev/branches/branch_3x/solr/src/maven/solr-core-pom.xml.template:949730,961612
+/lucene/dev/trunk/solr/src/maven/solr-core-pom.xml.template:953476-966816
/lucene/solr/trunk/src/maven/solr-core-pom.xml.template:922950-923910,923912-925091
Modified: lucene/dev/branches/realtime_search/solr/src/maven/solr-parent-pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/maven/solr-parent-pom.xml.template?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/maven/solr-parent-pom.xml.template (original)
+++ lucene/dev/branches/realtime_search/solr/src/maven/solr-parent-pom.xml.template Thu Jul 22 19:34:35 2010
@@ -32,7 +32,7 @@
<groupId>org.apache.solr</groupId>
<artifactId>solr-parent</artifactId>
<name>Apache Solr Parent POM</name>
- <version>@maven_version@</version>
+ <version>@version@</version>
<description>Apache Solr Parent POM</description>
<url>http://lucene.apache.org/solr</url>
<packaging>pom</packaging>
Modified: lucene/dev/branches/realtime_search/solr/src/maven/solr-solrj-pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/maven/solr-solrj-pom.xml.template?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/maven/solr-solrj-pom.xml.template (original)
+++ lucene/dev/branches/realtime_search/solr/src/maven/solr-solrj-pom.xml.template Thu Jul 22 19:34:35 2010
@@ -26,13 +26,13 @@
<parent>
<groupId>org.apache.solr</groupId>
<artifactId>solr-parent</artifactId>
- <version>@maven_version@</version>
+ <version>@version@</version>
</parent>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<name>Apache Solr Solrj</name>
- <version>@maven_version@</version>
+ <version>@version@</version>
<description>Apache Solr Solrj</description>
<packaging>jar</packaging>
Propchange: lucene/dev/branches/realtime_search/solr/src/maven/solr-solrj-pom.xml.template
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 22 19:34:35 2010
@@ -1,2 +1,3 @@
-/lucene/dev/branches/branch_3x/solr/src/maven/solr-solrj-pom.xml.template:949730
+/lucene/dev/branches/branch_3x/solr/src/maven/solr-solrj-pom.xml.template:949730,961612
+/lucene/dev/trunk/solr/src/maven/solr-solrj-pom.xml.template:953476-966816
/lucene/solr/trunk/src/maven/solr-solrj-pom.xml.template:922950-923910,923912-925091
Modified: lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/index.xml Thu Jul 22 19:34:35 2010
@@ -50,7 +50,7 @@ customization is required.
</p>
<p>
- For more information about Solr, please see the <a href="http://wiki.apache.org/solr">Solr wiki</a>.
+ For more information about Solr, please see the <a href="http://wiki.apache.org/solr/FrontPage">Solr wiki</a>.
</p>
</section>
@@ -59,13 +59,30 @@ customization is required.
<ul>
<li>Download Solr <a href="ext:releases">here</a></li>
<li>Check out the <a href="tutorial.html">tutorial</a></li>
- <li>Read the <a href="http://wiki.apache.org/solr">Solr wiki</a> to learn more</li>
+ <li>Read the <a href="http://wiki.apache.org/solr/FrontPage">Solr wiki</a> to learn more</li>
<li>Join the <a href="mailing_lists.html">community</a></li>
<li><a href="http://wiki.apache.org/solr/HowToContribute">Give Back</a>! (Optional, but encouraged!)</li>
</ul>
</section>
<section id="news">
<title>News</title>
+ <section>
+ <title>25 June 2010 - Solr 1.4.1 Released</title>
+ <p>
+ Solr 1.4.1 has been released and is now available for public
+ <a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">download</a>!
+
+ Solr 1.4.1 is a bug fix release for Solr 1.4 that includes many
+ Solr bug fixes as well as Lucene bug fixes from Lucene 2.9.3.
+ </p>
+
+ <p>
+ See the <a
+ href="http://svn.apache.org/repos/asf/lucene/solr/tags/release-1.4.1/CHANGES.txt">release notes</a>
+ for more details.
+ </p>
+
+ </section>
<section>
<title>7 May 2010 - Apache Lucene Eurocon 2010 Coming to Prague May 18-21</title>
<p>
Modified: lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/site.xml Thu Jul 22 19:34:35 2010
@@ -83,7 +83,7 @@ See http://forrest.apache.org/docs/linki
<lucene href="http://lucene.apache.org/java/" />
<lucene_who href="http://lucene.apache.org/java/docs/whoweare.html" />
<nutch href="http://lucene.apache.org/nutch/" />
- <wiki href="http://wiki.apache.org/solr/" />
+ <wiki href="http://wiki.apache.org/solr/FrontPage" />
<faq href="http://wiki.apache.org/solr/FAQ" />
<nightly href="http://people.apache.org/builds/lucene/solr/nightly/" />
<releases href="http://www.apache.org/dyn/closer.cgi/lucene/solr/" />
Modified: lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tabs.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tabs.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tabs.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tabs.xml Thu Jul 22 19:34:35 2010
@@ -38,7 +38,7 @@
-->
<tab id="" label="Main" dir=""/>
- <tab id="wiki" label="Wiki" href="http://wiki.apache.org/solr"/>
+ <tab id="wiki" label="Wiki" href="http://wiki.apache.org/solr/FrontPage"/>
<!--
<tab id="samples" label="Samples" dir="samples" indexfile="sample.html">
Modified: lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tutorial.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tutorial.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tutorial.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/site/src/documentation/content/xdocs/tutorial.xml Thu Jul 22 19:34:35 2010
@@ -495,7 +495,7 @@ in subsequent searches.
<a href="http://wiki.apache.org/solr/StatsComponent">numeric field statistics</a>,
and
<a href="http://wiki.apache.org/solr/ClusteringComponent">search results clustering</a>.
- Explore the <a href="http://wiki.apache.org/solr/">Solr Wiki</a> to find out
+ Explore the <a href="http://wiki.apache.org/solr/FrontPage">Solr Wiki</a> to find out
more details about Solr's many
<a href="features.html">features</a>.
</p>
Propchange: lucene/dev/branches/realtime_search/solr/src/solrj/org/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 22 19:34:35 2010
@@ -1,2 +1,3 @@
-/lucene/dev/branches/branch_3x/solr/src/solrj/org:949730
+/lucene/dev/branches/branch_3x/solr/src/solrj/org:949730,961612
+/lucene/dev/trunk/solr/src/solrj/org:953476-966816
/lucene/solr/trunk/src/solrj/org:922950-923910,923912-925091
Modified: lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java Thu Jul 22 19:34:35 2010
@@ -42,7 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * StreamingHttpSolrServer buffers all added documents and writes them
+ * {@link StreamingUpdateSolrServer} buffers all added documents and writes them
* into open HTTP connections. This class is thread safe.
*
* Although any SolrServer request can be made with this implementation,
@@ -100,79 +100,81 @@ public class StreamingUpdateSolrServer e
PostMethod method = null;
try {
do {
- RequestEntity request = new RequestEntity() {
- // we don't know the length
- public long getContentLength() { return -1; }
- public String getContentType() { return ClientUtils.TEXT_XML; }
- public boolean isRepeatable() { return false; }
-
- public void writeRequest(OutputStream out) throws IOException {
- try {
- OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
- writer.append( "<stream>" ); // can be anything...
- UpdateRequest req = queue.poll( 250, TimeUnit.MILLISECONDS );
- while( req != null ) {
- log.debug( "sending: {}" , req );
- req.writeXML( writer );
-
- // check for commit or optimize
- SolrParams params = req.getParams();
- if( params != null ) {
- String fmt = null;
- if( params.getBool( UpdateParams.OPTIMIZE, false ) ) {
- fmt = "<optimize waitSearcher=\"%s\" waitFlush=\"%s\" />";
- }
- else if( params.getBool( UpdateParams.COMMIT, false ) ) {
- fmt = "<commit waitSearcher=\"%s\" waitFlush=\"%s\" />";
- }
- if( fmt != null ) {
- log.info( fmt );
- writer.write( String.format( fmt,
- params.getBool( UpdateParams.WAIT_SEARCHER, false )+"",
- params.getBool( UpdateParams.WAIT_FLUSH, false )+"") );
+ try {
+ RequestEntity request = new RequestEntity() {
+ // we don't know the length
+ public long getContentLength() { return -1; }
+ public String getContentType() { return ClientUtils.TEXT_XML; }
+ public boolean isRepeatable() { return false; }
+
+ public void writeRequest(OutputStream out) throws IOException {
+ try {
+ OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+ writer.append( "<stream>" ); // can be anything...
+ UpdateRequest req = queue.poll( 250, TimeUnit.MILLISECONDS );
+ while( req != null ) {
+ log.debug( "sending: {}" , req );
+ req.writeXML( writer );
+
+ // check for commit or optimize
+ SolrParams params = req.getParams();
+ if( params != null ) {
+ String fmt = null;
+ if( params.getBool( UpdateParams.OPTIMIZE, false ) ) {
+ fmt = "<optimize waitSearcher=\"%s\" waitFlush=\"%s\" />";
+ }
+ else if( params.getBool( UpdateParams.COMMIT, false ) ) {
+ fmt = "<commit waitSearcher=\"%s\" waitFlush=\"%s\" />";
+ }
+ if( fmt != null ) {
+ log.info( fmt );
+ writer.write( String.format( fmt,
+ params.getBool( UpdateParams.WAIT_SEARCHER, false )+"",
+ params.getBool( UpdateParams.WAIT_FLUSH, false )+"") );
+ }
+ }
+
+ writer.flush();
+ req = queue.poll( 250, TimeUnit.MILLISECONDS );
}
+ writer.append( "</stream>" );
+ writer.flush();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
}
-
- writer.flush();
- req = queue.poll( 250, TimeUnit.MILLISECONDS );
}
- writer.append( "</stream>" );
- writer.flush();
+ };
+
+ method = new PostMethod(_baseURL+updateUrl );
+ method.setRequestEntity( request );
+ method.setFollowRedirects( false );
+ method.addRequestHeader( "User-Agent", AGENT );
+
+ int statusCode = getHttpClient().executeMethod(method);
+ if (statusCode != HttpStatus.SC_OK) {
+ StringBuilder msg = new StringBuilder();
+ msg.append( method.getStatusLine().getReasonPhrase() );
+ msg.append( "\n\n" );
+ msg.append( method.getStatusText() );
+ msg.append( "\n\n" );
+ msg.append( "request: "+method.getURI() );
+ handleError( new Exception( msg.toString() ) );
}
- catch (InterruptedException e) {
- e.printStackTrace();
+ } finally {
+ try {
+ // make sure to release the connection
+ if(method != null)
+ method.releaseConnection();
}
+ catch( Exception ex ){}
}
- };
-
- method = new PostMethod(_baseURL+updateUrl );
- method.setRequestEntity( request );
- method.setFollowRedirects( false );
- method.addRequestHeader( "User-Agent", AGENT );
-
- int statusCode = getHttpClient().executeMethod(method);
- if (statusCode != HttpStatus.SC_OK) {
- StringBuilder msg = new StringBuilder();
- msg.append( method.getStatusLine().getReasonPhrase() );
- msg.append( "\n\n" );
- msg.append( method.getStatusText() );
- msg.append( "\n\n" );
- msg.append( "request: "+method.getURI() );
- handleError( new Exception( msg.toString() ) );
- }
- } while( ! queue.isEmpty());
+ } while( ! queue.isEmpty());
}
catch (Throwable e) {
handleError( e );
}
finally {
- try {
- // make sure to release the connection
- if(method != null)
- method.releaseConnection();
- }
- catch( Exception ex ){}
-
// remove it from the list of running things...
synchronized (runners) {
runners.remove( this );
Modified: lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/solrj/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java Thu Jul 22 19:34:35 2010
@@ -96,6 +96,11 @@ public class JavaBinUpdateRequestCodec {
final NamedList[] namedList = new NamedList[1];
JavaBinCodec codec = new JavaBinCodec() {
+ // NOTE: this only works because this is an anonymous inner class
+ // which will only ever be used on a single stream -- if this class
+ // is ever refactored, this will not work.
+ private boolean seenOuterMostDocIterator = false;
+
public NamedList readNamedList(FastInputStream dis) throws IOException {
int sz = readSize(dis);
NamedList nl = new NamedList();
@@ -110,8 +115,18 @@ public class JavaBinUpdateRequestCodec {
return nl;
}
-
public List readIterator(FastInputStream fis) throws IOException {
+
+ // default behavior for reading any regular Iterator in the stream
+ if (seenOuterMostDocIterator) return super.readIterator(fis);
+
+ // special treatment for first outermost Iterator
+ // (the list of documents)
+ seenOuterMostDocIterator = true;
+ return readOuterMostDocIterator(fis);
+ }
+
+ private List readOuterMostDocIterator(FastInputStream fis) throws IOException {
NamedList params = (NamedList) namedList[0].getVal(0);
updateRequest.setParams(namedListToSolrParams(params));
if (handler == null) return super.readIterator(fis);
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/BaseDistributedSearchTestCase.java Thu Jul 22 19:34:35 2010
@@ -125,7 +125,9 @@ public abstract class BaseDistributedSea
@Override
public void tearDown() throws Exception {
destroyServers();
- AbstractSolrTestCase.recurseDelete(testDir);
+ if (!AbstractSolrTestCase.recurseDelete(testDir)) {
+ System.err.println("!!!! WARNING: best effort to remove " + testDir.getAbsolutePath() + " FAILED !!!!!");
+ }
super.tearDown();
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/ConvertedLegacyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/ConvertedLegacyTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/ConvertedLegacyTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/ConvertedLegacyTest.java Thu Jul 22 19:34:35 2010
@@ -998,7 +998,7 @@ public class ConvertedLegacyTest extends
assertQ(req("id:42 AND subword:IBM's")
,"*[count(//doc)=1]"
);
- assertQ(req("id:42 AND subword:IBM'sx")
+ assertQ(req("id:42 AND subword:\"IBM'sx\"")
,"*[count(//doc)=0]"
);
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/SolrTestCaseJ4.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/SolrTestCaseJ4.java Thu Jul 22 19:34:35 2010
@@ -483,6 +483,7 @@ public class SolrTestCaseJ4 extends Luce
if (f.isDirectory()) {
for (File sub : f.listFiles()) {
if (!recurseDelete(sub)) {
+ System.err.println("!!!! WARNING: best effort to remove " + sub.getAbsolutePath() + " FAILED !!!!!");
return false;
}
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/analysis/DoubleMetaphoneFilterFactoryTest.java Thu Jul 22 19:34:35 2010
@@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
+import org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
public class DoubleMetaphoneFilterFactoryTest extends BaseTokenTestCase {
Propchange: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 22 19:34:35 2010
@@ -1,2 +1,3 @@
-/lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client:949730
+/lucene/dev/branches/branch_3x/solr/src/test/org/apache/solr/client:949730,961612
+/lucene/dev/trunk/solr/src/test/org/apache/solr/client:953476-966816
/lucene/solr/trunk/src/test/org/apache/solr/client:922950-923910,923912-925091
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Thu Jul 22 19:34:35 2010
@@ -271,22 +271,6 @@ abstract public class SolrExampleTests e
assertNotNull("Couldn't upload books.csv", result);
rsp = server.query( new SolrQuery( "*:*") );
Assert.assertEquals( 10, rsp.getResults().getNumFound() );
-
- server.deleteByQuery( "*:*" );// delete everything!
- server.commit();
- rsp = server.query( new SolrQuery( "*:*") );
- Assert.assertEquals( 0, rsp.getResults().getNumFound() );
-
- up = new ContentStreamUpdateRequest("/update/extract");
- up.addFile(new File("mailing_lists.pdf"));
- up.setParam("literal.id", "mailing_lists.pdf");
- up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
- result = server.request(up);
- assertNotNull("Couldn't upload mailing_lists.pdf", result);
- rsp = server.query( new SolrQuery( "*:*") );
- Assert.assertEquals( 1, rsp.getResults().getNumFound() );
-
-
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/SolrExceptionTest.java Thu Jul 22 19:34:35 2010
@@ -21,6 +21,8 @@ import java.net.UnknownHostException;
import junit.framework.TestCase;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrException;
@@ -39,7 +41,10 @@ public class SolrExceptionTest extends T
boolean gotExpectedError = false;
try {
// switched to a local address to avoid going out on the net, ns lookup issues, etc.
- SolrServer client = new CommonsHttpSolrServer("http://localhost:11235/solr/");
+ // set a 1ms timeout to let the connection fail faster.
+ HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
+ httpClient.getParams().setParameter("http.connection.timeout", new Integer(1));
+ SolrServer client = new CommonsHttpSolrServer("http://localhost:11235/solr/", httpClient);
SolrQuery query = new SolrQuery("test123");
client.query(query);
} catch (SolrServerException sse) {
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java Thu Jul 22 19:34:35 2010
@@ -24,6 +24,10 @@ import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
@@ -43,22 +47,33 @@ public class TestUpdateRequestCodec {
updateRequest.deleteById("id:5");
updateRequest.deleteByQuery("2*");
updateRequest.deleteByQuery("1*");
+
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", 1);
doc.addField("desc", "one", 2.0f);
doc.addField("desc", "1");
updateRequest.add(doc);
+
doc = new SolrInputDocument();
doc.addField("id", 2);
doc.setDocumentBoost(10.0f);
doc.addField("desc", "two", 3.0f);
doc.addField("desc", "2");
updateRequest.add(doc);
+
doc = new SolrInputDocument();
doc.addField("id", 3);
doc.addField("desc", "three", 3.0f);
doc.addField("desc", "3");
updateRequest.add(doc);
+
+ doc = new SolrInputDocument();
+ Collection<String> foobar = new HashSet<String>();
+ foobar.add("baz1");
+ foobar.add("baz2");
+ doc.addField("foobar",foobar);
+ updateRequest.add(doc);
+
// updateRequest.setWaitFlush(true);
updateRequest.deleteById("2");
updateRequest.deleteByQuery("id:3");
@@ -69,7 +84,6 @@ public class TestUpdateRequestCodec {
JavaBinUpdateRequestCodec.StreamingDocumentHandler handler = new JavaBinUpdateRequestCodec.StreamingDocumentHandler() {
public void document(SolrInputDocument document, UpdateRequest req) {
Assert.assertNotNull(req.getParams());
-// Assert.assertEquals(Boolean.TRUE, req.getParams().getBool(UpdateParams.WAIT_FLUSH));
docs.add(document);
}
};
@@ -82,20 +96,89 @@ public class TestUpdateRequestCodec {
for (int i = 0; i < updateRequest.getDocuments().size(); i++) {
SolrInputDocument inDoc = updateRequest.getDocuments().get(i);
SolrInputDocument outDoc = updateUnmarshalled.getDocuments().get(i);
- compareDocs(inDoc, outDoc);
+ compareDocs("doc#"+i, inDoc, outDoc);
+ }
+ Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) ,
+ updateRequest.getDeleteById().get(0));
+ Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) ,
+ updateRequest.getDeleteQuery().get(0));
+
+ }
+
+ @Test
+ public void testIteratable() throws IOException {
+ final List<String> values = new ArrayList<String>();
+ values.add("iterItem1");
+ values.add("iterItem2");
+
+ UpdateRequest updateRequest = new UpdateRequest();
+ updateRequest.deleteByQuery("*:*");
+
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", 1);
+ doc.addField("desc", "one", 2.0f);
+ // imagine someone adding a custom Bean that implements Iterable
+ // but is not a Collection
+ doc.addField("iter", new Iterable<String>() {
+ public Iterator<String> iterator() { return values.iterator(); }
+ });
+ doc.addField("desc", "1");
+ updateRequest.add(doc);
+
+ JavaBinUpdateRequestCodec codec = new JavaBinUpdateRequestCodec();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ codec.marshal(updateRequest, baos);
+ final List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
+ JavaBinUpdateRequestCodec.StreamingDocumentHandler handler = new JavaBinUpdateRequestCodec.StreamingDocumentHandler() {
+ public void document(SolrInputDocument document, UpdateRequest req) {
+ Assert.assertNotNull(req.getParams());
+ docs.add(document);
+ }
+ };
+
+ UpdateRequest updateUnmarshalled = codec.unmarshal(new ByteArrayInputStream(baos.toByteArray()) ,handler);
+ Assert.assertNull(updateUnmarshalled.getDocuments());
+ for (SolrInputDocument document : docs) {
+ updateUnmarshalled.add(document);
}
- Assert.assertEquals(updateUnmarshalled.getDeleteById().get(0) , updateRequest.getDeleteById().get(0));
- Assert.assertEquals(updateUnmarshalled.getDeleteQuery().get(0) , updateRequest.getDeleteQuery().get(0));
+
+ SolrInputDocument outDoc = updateUnmarshalled.getDocuments().get(0);
+ SolrInputField iter = outDoc.getField("iter");
+ Assert.assertNotNull("iter field is null", iter);
+ Object iterVal = iter.getValue();
+ Assert.assertTrue("iterVal is not a Collection",
+ iterVal instanceof Collection);
+ Assert.assertEquals("iterVal contents", values, iterVal);
}
- private void compareDocs(SolrInputDocument docA, SolrInputDocument docB) {
- Assert.assertEquals(docA.getDocumentBoost(), docB.getDocumentBoost());
- for (String s : docA.getFieldNames()) {
- SolrInputField fldA = docA.getField(s);
- SolrInputField fldB = docB.getField(s);
- Assert.assertEquals(fldA.getValue(), fldB.getValue());
- Assert.assertEquals(fldA.getBoost(), fldB.getBoost());
+
+
+ private void compareDocs(String m,
+ SolrInputDocument expectedDoc,
+ SolrInputDocument actualDoc) {
+ Assert.assertEquals(expectedDoc.getDocumentBoost(),
+ actualDoc.getDocumentBoost());
+
+ for (String s : expectedDoc.getFieldNames()) {
+ SolrInputField expectedField = expectedDoc.getField(s);
+ SolrInputField actualField = actualDoc.getField(s);
+ Assert.assertEquals(m + ": diff boosts for field: " + s,
+ expectedField.getBoost(), actualField.getBoost());
+ Object expectedVal = expectedField.getValue();
+ Object actualVal = actualField.getValue();
+ if (expectedVal instanceof Set &&
+ actualVal instanceof Collection) {
+ // unmarshaled documents never contain Sets, they are just a
+ // List in an arbitrary order based on what the iterator of
+ // hte original Set returned, so we need a comparison that is
+ // order agnostic.
+ actualVal = new HashSet((Collection) actualVal);
+ m += " (Set comparison)";
+ }
+
+ Assert.assertEquals(m + " diff values for field: " + s,
+ expectedVal, actualVal);
}
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/ResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/ResourceLoaderTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/ResourceLoaderTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/ResourceLoaderTest.java Thu Jul 22 19:34:35 2010
@@ -31,6 +31,7 @@ import org.apache.solr.util.plugin.SolrC
import java.io.File;
import java.io.InputStream;
+import java.nio.charset.CharacterCodingException;
import java.util.Arrays;
import java.util.List;
@@ -117,4 +118,16 @@ public class ResourceLoaderTest extends
assertEquals(1, lines.size());
assertEquals("BOMsAreEvil", lines.get(0));
}
+
+ public void testWrongEncoding() throws Exception {
+ String wrongEncoding = "stopwordsWrongEncoding.txt";
+ SolrResourceLoader loader = new SolrResourceLoader(null);
+ // ensure we get our exception
+ try {
+ List<String> lines = loader.getLines(wrongEncoding);
+ fail();
+ } catch (SolrException expected) {
+ assertTrue(expected.getCause() instanceof CharacterCodingException);
+ }
+ }
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestArbitraryIndexDir.java Thu Jul 22 19:34:35 2010
@@ -47,6 +47,7 @@ import org.xml.sax.SAXException;
public class TestArbitraryIndexDir extends AbstractSolrTestCase{
public void setUp() throws Exception {
+ super.setUp();
dataDir = new File(System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator")
+ getClass().getName() + "-" + System.currentTimeMillis() + System.getProperty("file.separator") + "solr"
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestBadConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestBadConfig.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestBadConfig.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestBadConfig.java Thu Jul 22 19:34:35 2010
@@ -17,12 +17,7 @@
package org.apache.solr.core;
-import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.AbstractSolrTestCase;
-import org.apache.solr.util.TestHarness;
-import org.junit.BeforeClass;
-
-import java.io.File;
public class TestBadConfig extends AbstractSolrTestCase {
@@ -30,22 +25,14 @@ public class TestBadConfig extends Abstr
public String getSolrConfigFile() { return "bad_solrconfig.xml"; }
public void setUp() throws Exception {
-
- dataDir = new File(System.getProperty("java.io.tmpdir")
- + System.getProperty("file.separator")
- + getClass().getName());
- dataDir.mkdirs();
+ ignoreException("unset.sys.property");
try {
- SolrTestCaseJ4.ignoreException("unset.sys.property");
-
- solrConfig = new SolrConfig(getSolrConfigFile());
- h = new TestHarness( dataDir.getAbsolutePath(),
- solrConfig,
- getSchemaFile());
+ super.setUp();
fail("Exception should have been thrown");
} catch (Exception e) {
assertTrue(e.getMessage().contains("unset.sys.property"));
- SolrTestCaseJ4.resetExceptionIgnores();
+ } finally {
+ resetExceptionIgnores();
}
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java Thu Jul 22 19:34:35 2010
@@ -17,26 +17,31 @@
package org.apache.solr.core;
import org.apache.lucene.index.IndexCommit;
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.util.Map;
/**
* @version $Id$
*/
-public class TestSolrDeletionPolicy1 extends AbstractSolrTestCase {
+public class TestSolrDeletionPolicy1 extends SolrTestCaseJ4 {
- @Override
- public String getSchemaFile() {
- return "schema.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-delpolicy1.xml","schema.xml");
}
- @Override
- public String getSolrConfigFile() {
- return "solrconfig-delpolicy1.xml";
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clearIndex();
}
-
+
private void addDocs() {
assertU(adoc("id", String.valueOf(1),
@@ -100,7 +105,7 @@ public class TestSolrDeletionPolicy1 ext
IndexDeletionPolicyWrapper delPolicy = h.getCore().getDeletionPolicy();
addDocs();
Map<Long, IndexCommit> commits = delPolicy.getCommits();
- assertEquals(((SolrDeletionPolicy) (delPolicy.getWrappedDeletionPolicy())).getMaxOptimizedCommitsToKeep(), commits.size());
+ assertTrue(commits.size() <= ((SolrDeletionPolicy) (delPolicy.getWrappedDeletionPolicy())).getMaxOptimizedCommitsToKeep());
}
@Test
@@ -110,7 +115,7 @@ public class TestSolrDeletionPolicy1 ext
Map<Long, IndexCommit> commits = delPolicy.getCommits();
IndexCommit ic = delPolicy.getLatestCommit();
String agestr = ((SolrDeletionPolicy) (delPolicy.getWrappedDeletionPolicy())).getMaxCommitAge().replaceAll("[a-zA-Z]", "").replaceAll("-", "");
- long age = Long.parseLong(agestr) * 1000;
+ long age = Long.parseLong(agestr);
Thread.sleep(age);
assertU(adoc("id", String.valueOf(6),
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/AnalysisRequestHandlerTestBase.java Thu Jul 22 19:34:35 2010
@@ -17,8 +17,10 @@
package org.apache.solr.handler;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.util.AbstractSolrTestCase;
+
+import static org.junit.Assert.*;
/**
* A base class for all analysis request handler tests.
@@ -26,7 +28,7 @@ import org.apache.solr.util.AbstractSolr
* @version $Id$
* @since solr 1.4
*/
-public abstract class AnalysisRequestHandlerTestBase extends AbstractSolrTestCase {
+public abstract class AnalysisRequestHandlerTestBase extends SolrTestCaseJ4 {
protected void assertToken(NamedList token, TokenInfo info) {
assertEquals(info.getText(), token.get("text"));
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/DocumentAnalysisRequestHandlerTest.java Thu Jul 22 19:34:35 2010
@@ -26,6 +26,11 @@ import org.apache.solr.common.util.Conte
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
@@ -40,17 +45,13 @@ public class DocumentAnalysisRequestHand
private DocumentAnalysisRequestHandler handler;
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
handler = new DocumentAnalysisRequestHandler();
@@ -60,6 +61,7 @@ public class DocumentAnalysisRequestHand
/**
* Tests the {@link DocumentAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}
*/
+ @Test
public void testResolveAnalysisRequest() throws Exception {
String docsInput =
@@ -108,6 +110,7 @@ public class DocumentAnalysisRequestHand
* Tests the {@link DocumentAnalysisRequestHandler#handleAnalysisRequest(org.apache.solr.client.solrj.request.DocumentAnalysisRequest,
* org.apache.solr.schema.IndexSchema)}
*/
+ @Test
public void testHandleAnalysisRequest() throws Exception {
SolrInputDocument document = new SolrInputDocument();
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java Thu Jul 22 19:34:35 2010
@@ -25,6 +25,11 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.apache.solr.client.solrj.request.FieldAnalysisRequest;
import org.apache.solr.request.LocalSolrQueryRequest;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.List;
@@ -39,24 +44,21 @@ public class FieldAnalysisRequestHandler
private FieldAnalysisRequestHandler handler;
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
handler = new FieldAnalysisRequestHandler();
}
- @Override
- public String getSchemaFile() {
- return "schema.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
}
/**
* Tests the {@link FieldAnalysisRequestHandler#resolveAnalysisRequest(org.apache.solr.request.SolrQueryRequest)}
*/
+ @Test
public void testResolveAnalysisRequest() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(AnalysisParams.FIELD_NAME, "text,nametext");
@@ -101,6 +103,7 @@ public class FieldAnalysisRequestHandler
* Tests the {@link FieldAnalysisRequestHandler#handleAnalysisRequest(org.apache.solr.client.solrj.request.FieldAnalysisRequest,
* org.apache.solr.schema.IndexSchema)}
*/
+ @Test
public void testHandleAnalysisRequest() throws Exception {
FieldAnalysisRequest request = new FieldAnalysisRequest();
@@ -293,6 +296,7 @@ public class FieldAnalysisRequestHandler
}
+ @Test
public void testCharFilterAnalysis() throws Exception {
FieldAnalysisRequest request = new FieldAnalysisRequest();
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/TestReplicationHandler.java Thu Jul 22 19:34:35 2010
@@ -20,7 +20,9 @@ import org.apache.commons.io.IOUtils;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.TestDistributedSearch;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
@@ -34,33 +36,36 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.io.*;
import java.net.URL;
-import junit.framework.TestCase;
-
/**
* Test for ReplicationHandler
*
* @version $Id$
* @since 1.4
*/
-public class TestReplicationHandler extends TestCase {
+public class TestReplicationHandler extends SolrTestCaseJ4 {
private static final String CONF_DIR = "." + File.separator + "solr" + File.separator + "conf" + File.separator;
private static final String SLAVE_CONFIG = CONF_DIR + "solrconfig-slave.xml";
- JettySolrRunner masterJetty, slaveJetty;
- SolrServer masterClient, slaveClient;
- SolrInstance master = null, slave = null;
-
- String context = "/solr";
+ static JettySolrRunner masterJetty, slaveJetty;
+ static SolrServer masterClient, slaveClient;
+ static SolrInstance master = null, slave = null;
+ static String context = "/solr";
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void beforeClass() throws Exception {
master = new SolrInstance("master", null);
master.setUp();
masterJetty = createJetty(master);
@@ -72,16 +77,26 @@ public class TestReplicationHandler exte
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
}
- @Override
- public void tearDown() throws Exception {
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ masterClient.deleteByQuery("*:*");
+ masterClient.commit();
+ rQuery(0, "*:*", masterClient);
+ slaveClient.deleteByQuery("*:*");
+ slaveClient.commit();
+ rQuery(0, "*:*", slaveClient);
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
masterJetty.stop();
slaveJetty.stop();
master.tearDown();
slave.tearDown();
- super.tearDown();
}
- private JettySolrRunner createJetty(SolrInstance instance) throws Exception {
+ private static JettySolrRunner createJetty(SolrInstance instance) throws Exception {
System.setProperty("solr.solr.home", instance.getHomeDir());
System.setProperty("solr.data.dir", instance.getDataDir());
@@ -91,7 +106,7 @@ public class TestReplicationHandler exte
return jetty;
}
- protected SolrServer createNewSolrServer(int port) {
+ private static SolrServer createNewSolrServer(int port) {
try {
// setup the server...
String url = "http://localhost:" + port + context;
@@ -126,6 +141,21 @@ public class TestReplicationHandler exte
return res;
}
+ /** will sleep up to 30 seconds, looking for expectedDocCount */
+ private NamedList rQuery(int expectedDocCount, String query, SolrServer server) throws Exception {
+ int timeSlept = 0;
+ NamedList res = null;
+ SolrDocumentList docList = null;
+ do {
+ res = query(query, server);
+ docList = (SolrDocumentList) res.get("response");
+ timeSlept += 100;
+ Thread.sleep(100);
+ } while(docList.getNumFound() != expectedDocCount && timeSlept < 30000);
+ return res;
+ }
+
+ @Test
public void testIndexAndConfigReplication() throws Exception {
//add 500 docs to master
@@ -134,24 +164,13 @@ public class TestReplicationHandler exte
masterClient.commit();
- NamedList masterQueryRsp = query("*:*", masterClient);
+ NamedList masterQueryRsp = rQuery(500, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(500, masterQueryResult.getNumFound());
- //sleep for pollinterval time 3s, to let slave pull data.
- Thread.sleep(3000);
//get docs from slave and check if number is equal to master
- NamedList slaveQueryRsp = query("*:*", slaveClient);
+ NamedList slaveQueryRsp = rQuery(500, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
-
- if (slaveQueryResult.getNumFound() == 0) {
- //try sleeping again in case of slower comp
- Thread.sleep(5000);
-
- slaveQueryRsp = query("*:*", slaveClient);
- slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
- }
-
assertEquals(500, slaveQueryResult.getNumFound());
//compare results
@@ -180,15 +199,17 @@ public class TestReplicationHandler exte
index(masterClient, "id", "2000", "name", "name = " + 2000, "newname", "newname = " + 2000);
masterClient.commit();
- //sleep for 3s for replication to happen.
- Thread.sleep(3000);
+ NamedList masterQueryRsp2 = rQuery(1, "*:*", masterClient);
+ SolrDocumentList masterQueryResult2 = (SolrDocumentList) masterQueryRsp2.get("response");
+ assertEquals(1, masterQueryResult2.getNumFound());
- slaveQueryRsp = query("*:*", slaveClient);
+ slaveQueryRsp = rQuery(1, "*:*", slaveClient);
SolrDocument d = ((SolrDocumentList) slaveQueryRsp.get("response")).get(0);
assertEquals("newname = 2000", (String) d.getFieldValue("newname"));
}
+ @Test
public void testIndexAndConfigAliasReplication() throws Exception {
//add 500 docs to master
@@ -197,24 +218,14 @@ public class TestReplicationHandler exte
masterClient.commit();
- NamedList masterQueryRsp = query("*:*", masterClient);
+ NamedList masterQueryRsp = rQuery(500, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(500, masterQueryResult.getNumFound());
- //sleep for pollinterval time 3s, to let slave pull data.
- Thread.sleep(3000);
//get docs from slave and check if number is equal to master
- NamedList slaveQueryRsp = query("*:*", slaveClient);
+ NamedList slaveQueryRsp = rQuery(500, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
- if (slaveQueryResult.getNumFound() == 0) {
- //try sleeping again in case of slower comp
- Thread.sleep(5000);
-
- slaveQueryRsp = query("*:*", slaveClient);
- slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
- }
-
assertEquals(500, slaveQueryResult.getNumFound());
//compare results
@@ -249,20 +260,25 @@ public class TestReplicationHandler exte
//add a doc with new field and commit on master to trigger snappull from slave.
index(masterClient, "id", "2000", "name", "name = " + 2000, "newname", "newname = " + 2000);
masterClient.commit();
-
- //sleep for 3s for replication to happen.
- Thread.sleep(3000);
+
+ NamedList masterQueryRsp2 = rQuery(1, "*:*", masterClient);
+ SolrDocumentList masterQueryResult2 = (SolrDocumentList) masterQueryRsp2.get("response");
+ assertEquals(1, masterQueryResult2.getNumFound());
+
+ NamedList slaveQueryRsp2 = rQuery(1, "*:*", slaveClient);
+ SolrDocumentList slaveQueryResult2 = (SolrDocumentList) slaveQueryRsp2.get("response");
+ assertEquals(1, slaveQueryResult2.getNumFound());
index(slaveClient, "id", "2000", "name", "name = " + 2001, "newname", "newname = " + 2001);
slaveClient.commit();
- slaveQueryRsp = query("*:*", slaveClient);
+ slaveQueryRsp = rQuery(1, "*:*", slaveClient);
SolrDocument d = ((SolrDocumentList) slaveQueryRsp.get("response")).get(0);
assertEquals("newname = 2001", (String) d.getFieldValue("newname"));
}
-
+ @Test
public void testStopPoll() throws Exception {
// Test:
// setup master/slave.
@@ -274,14 +290,12 @@ public class TestReplicationHandler exte
masterClient.commit();
- NamedList masterQueryRsp = query("*:*", masterClient);
+ NamedList masterQueryRsp = rQuery(500, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(500, masterQueryResult.getNumFound());
- //sleep for pollinterval time 3s, to let slave pull data.
- Thread.sleep(3000);
//get docs from slave and check if number is equal to master
- NamedList slaveQueryRsp = query("*:*", slaveClient);
+ NamedList slaveQueryRsp = rQuery(500, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(500, slaveQueryResult.getNumFound());
@@ -300,18 +314,24 @@ public class TestReplicationHandler exte
}
index(masterClient, "id", 501, "name", "name = " + 501);
masterClient.commit();
- //sleep for pollinterval time 3s, to let slave pull data.
+
+ //get docs from master and check if number is equal to master
+ masterQueryRsp = rQuery(501, "*:*", masterClient);
+ masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
+ assertEquals(501, masterQueryResult.getNumFound());
+
+ // NOTE: this test is wierd, we want to verify it DOESNT replicate...
+ // for now, add a sleep for this.., but the logic is wierd.
Thread.sleep(3000);
- //get docs from slave and check if number is equal to master
- slaveQueryRsp = query("*:*", slaveClient);
+
+ //get docs from slave and check if number is not equal to master; polling is disabled
+ slaveQueryRsp = rQuery(500, "*:*", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(500, slaveQueryResult.getNumFound());
- //get docs from slave and check if number is equal to master
- slaveQueryRsp = query("*:*", masterClient);
- slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
- assertEquals(501, slaveQueryResult.getNumFound());
+
}
+ @Test
public void testSnapPullWithMasterUrl() throws Exception {
//change solrconfig on slave
//this has no entry for pollinginterval
@@ -326,7 +346,7 @@ public class TestReplicationHandler exte
masterClient.commit();
- NamedList masterQueryRsp = query("*:*", masterClient);
+ NamedList masterQueryRsp = rQuery(500, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(500, masterQueryResult.getNumFound());
@@ -340,9 +360,9 @@ public class TestReplicationHandler exte
} catch (IOException e) {
//e.printStackTrace();
}
- Thread.sleep(3000);
+
//get docs from slave and check if number is equal to master
- NamedList slaveQueryRsp = query("*:*", slaveClient);
+ NamedList slaveQueryRsp = rQuery(500, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(500, slaveQueryResult.getNumFound());
//compare results
@@ -350,6 +370,7 @@ public class TestReplicationHandler exte
assertEquals(null, cmp);
}
+ @Test
public void testReplicateAfterStartup() throws Exception {
//stop slave
slaveJetty.stop();
@@ -360,7 +381,7 @@ public class TestReplicationHandler exte
masterClient.commit();
- NamedList masterQueryRsp = query("*:*", masterClient);
+ NamedList masterQueryRsp = rQuery(500, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(500, masterQueryResult.getNumFound());
@@ -379,10 +400,8 @@ public class TestReplicationHandler exte
slaveJetty = createJetty(slave);
slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
- //sleep for pollinterval time 3s, to let slave pull data.
- Thread.sleep(3000);
//get docs from slave and check if number is equal to master
- NamedList slaveQueryRsp = query("*:*", slaveClient);
+ NamedList slaveQueryRsp = rQuery(500, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(500, slaveQueryResult.getNumFound());
@@ -392,6 +411,7 @@ public class TestReplicationHandler exte
}
+ @Test
public void testReplicateAfterWrite2Slave() throws Exception {
//add 50 docs to master
int nDocs = 50;
@@ -410,13 +430,13 @@ public class TestReplicationHandler exte
masterClient.commit();
- NamedList masterQueryRsp = query("*:*", masterClient);
+ NamedList masterQueryRsp = rQuery(50, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(nDocs, masterQueryResult.getNumFound());
// Make sure that both the index version and index generation on the slave is
// higher than that of the master, just to make the test harder.
- Thread.sleep(100);
+
index(slaveClient, "id", 551, "name", "name = " + 551);
slaveClient.commit(true, true);
index(slaveClient, "id", 552, "name", "name = " + 552);
@@ -429,7 +449,7 @@ public class TestReplicationHandler exte
slaveClient.commit(true, true);
//this doc is added to slave so it should show an item w/ that result
- NamedList slaveQueryRsp = query("id:555", slaveClient);
+ NamedList slaveQueryRsp = rQuery(1, "id:555", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(1, slaveQueryResult.getNumFound());
@@ -442,14 +462,13 @@ public class TestReplicationHandler exte
//e.printStackTrace();
}
- //sleep for pollinterval time 3s, to let slave pull data.
- Thread.sleep(3000);
//the slave should have done a full copy of the index so the doc with id:555 should not be there in the slave now
- slaveQueryRsp = query("id:555", slaveClient);
+ slaveQueryRsp = rQuery(0, "id:555", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(0, slaveQueryResult.getNumFound());
}
+ @Test
public void testBackup() throws Exception {
masterJetty.stop();
@@ -543,22 +562,24 @@ public class TestReplicationHandler exte
});
assertEquals(1, files.length);
File snapDir = files[0];
-
- IndexSearcher searcher = new IndexSearcher(new SimpleFSDirectory(snapDir.getAbsoluteFile(), null), true);
+ Directory dir = new SimpleFSDirectory(snapDir.getAbsoluteFile());
+ IndexSearcher searcher = new IndexSearcher(dir, true);
TopDocs hits = searcher.search(new MatchAllDocsQuery(), 1);
assertEquals(500, hits.totalHits);
+ searcher.close();
+ dir.close();
}
/* character copy of file using UTF-8 */
- void copyFile(File src, File dst) throws IOException {
+ private static void copyFile(File src, File dst) throws IOException {
copyFile(src, dst, null);
}
/**
* character copy of file using UTF-8. If port is non-null, will be substituted any time "TEST_PORT" is found.
*/
- private void copyFile(File src, File dst, Integer port) throws IOException {
+ private static void copyFile(File src, File dst, Integer port) throws IOException {
BufferedReader in = new BufferedReader(new FileReader(src));
Writer out = new FileWriter(dst);
@@ -572,12 +593,13 @@ public class TestReplicationHandler exte
out.close();
}
- private class SolrInstance extends AbstractSolrTestCase {
+ private static class SolrInstance {
String name;
Integer masterPort;
File homeDir;
File confDir;
+ File dataDir;
/**
* if masterPort is null, this instance is a master -- otherwise this instance is a slave, and assumes the master is
@@ -592,7 +614,6 @@ public class TestReplicationHandler exte
return homeDir.toString();
}
- @Override
public String getSchemaFile() {
return CONF_DIR + "schema-replication1.xml";
}
@@ -605,7 +626,6 @@ public class TestReplicationHandler exte
return dataDir.toString();
}
- @Override
public String getSolrConfigFile() {
String fname = "";
if (null == masterPort)
@@ -644,7 +664,6 @@ public class TestReplicationHandler exte
}
public void tearDown() throws Exception {
- super.tearDown();
AbstractSolrTestCase.recurseDelete(homeDir);
}
}
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java Thu Jul 22 19:34:35 2010
@@ -29,6 +29,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
+import org.apache.solr.common.params.QueryElevationParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj;
@@ -198,10 +199,20 @@ public class QueryElevationComponentTest
,"//result/doc[3]/str[@name='id'][.='b']"
,"//result/doc[4]/str[@name='id'][.='c']"
);
-
+
+ //Test exclusive (not to be confused with exclusion)
+ args.put(QueryElevationParams.EXCLUSIVE, "true");
+ booster.setTopQueryResults( reader, query, new String[] { "x", "a" }, new String[] {} );
+ assertQ( null, req
+ ,"//*[@numFound='2']"
+ ,"//result/doc[1]/str[@name='id'][.='x']"
+ ,"//result/doc[2]/str[@name='id'][.='a']"
+ );
+
// Test exclusion
booster.elevationCache.clear();
args.remove( CommonParams.SORT );
+ args.remove( QueryElevationParams.EXCLUSIVE);
booster.setTopQueryResults( reader, query, new String[] { "x" }, new String[] { "a" } );
assertQ( null, req
,"//*[@numFound='3']"
@@ -209,6 +220,7 @@ public class QueryElevationComponentTest
,"//result/doc[2]/str[@name='id'][.='b']"
,"//result/doc[3]/str[@name='id'][.='c']"
);
+
}
// write a test file to boost some docs