lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1130042 - in /lucene/dev/trunk: lucene/src/test-framework/org/apache/lucene/util/ solr/ solr/contrib/analysis-extras/ solr/contrib/clustering/ solr/contrib/dataimporthandler/ solr/contrib/extraction/ solr/contrib/uima/ solr/src/test-framew...
Date Wed, 01 Jun 2011 08:22:24 GMT
Author: rmuir
Date: Wed Jun  1 08:22:23 2011
New Revision: 1130042

URL: http://svn.apache.org/viewvc?rev=1130042&view=rev
Log:
SOLR-2279: use Lucene's MockDirectoryWrapper in Solr tests

Added:
    lucene/dev/trunk/solr/src/test/org/apache/solr/core/MockDirectoryFactory.java   (with
props)
Modified:
    lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/trunk/solr/build.xml
    lucene/dev/trunk/solr/common-build.xml
    lucene/dev/trunk/solr/contrib/analysis-extras/build.xml
    lucene/dev/trunk/solr/contrib/clustering/build.xml
    lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml
    lucene/dev/trunk/solr/contrib/extraction/build.xml
    lucene/dev/trunk/solr/contrib/uima/build.xml
    lucene/dev/trunk/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java
    lucene/dev/trunk/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/TestSolrCoreProperties.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java

Modified: lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
(original)
+++ lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
Wed Jun  1 08:22:23 2011
@@ -221,7 +221,7 @@ public abstract class LuceneTestCase ext
   private static TimeZone timeZone;
   private static TimeZone savedTimeZone;
 
-  private static Map<MockDirectoryWrapper,StackTraceElement[]> stores;
+  protected static Map<MockDirectoryWrapper,StackTraceElement[]> stores;
 
   private static final String[] TEST_CODECS = new String[] {"MockSep", "MockFixedIntBlock",
"MockVariableIntBlock", "MockRandom"};
 

Modified: lucene/dev/trunk/solr/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/build.xml (original)
+++ lucene/dev/trunk/solr/build.xml Wed Jun  1 08:22:23 2011
@@ -463,9 +463,8 @@
       <sysproperty key="testmethod" value="${testmethod}"/>
       <!-- set whether or not nightly tests should run -->
       <sysproperty key="tests.nightly" value="${tests.nightly}"/>
-      <!-- TODO: why is this unconditionally set to "" above? disable for now
-         <jvmarg line="${dir.prop}"/>
-      -->
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
 
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>

Modified: lucene/dev/trunk/solr/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/common-build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/common-build.xml (original)
+++ lucene/dev/trunk/solr/common-build.xml Wed Jun  1 08:22:23 2011
@@ -68,6 +68,7 @@
   <property name="tests.seed" value="random" />
   <property name="tests.nightly" value="false" />
   <property name="tests.verbose" value="false" />
+  <property name="tests.directory" value="random" />
 
   <condition property="dir.prop" value="-Dsolr.directoryFactory=solr.StandardDirectoryFactory">
     <isset property="use.fsdir"/>

Modified: lucene/dev/trunk/solr/contrib/analysis-extras/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/analysis-extras/build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/analysis-extras/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/analysis-extras/build.xml Wed Jun  1 08:22:23 2011
@@ -159,6 +159,8 @@
       <sysproperty key="jetty.testMode" value="1"/>
       <sysproperty key="tempDir" file="${junit.output.dir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>
       <classpath refid="test.classpath"/>

Modified: lucene/dev/trunk/solr/contrib/clustering/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/clustering/build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/clustering/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/clustering/build.xml Wed Jun  1 08:22:23 2011
@@ -131,6 +131,8 @@
       <sysproperty key="jetty.testMode" value="1"/>
       <sysproperty key="tempDir" file="${junit.output.dir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>
       <classpath refid="test.classpath"/>

Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml Wed Jun  1 08:22:23 2011
@@ -183,6 +183,8 @@
       <sysproperty key="jetty.testMode" value="1"/>
       <sysproperty key="tempDir" file="${tempDir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>
       <classpath refid="test.classpath"/>
@@ -245,6 +247,8 @@
       <sysproperty key="jetty.testMode" value="1"/>
       <sysproperty key="tempDir" file="${tempDir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>
       <classpath refid="test.extras.classpath"/>

Modified: lucene/dev/trunk/solr/contrib/extraction/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/extraction/build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/extraction/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/extraction/build.xml Wed Jun  1 08:22:23 2011
@@ -128,6 +128,8 @@
       <sysproperty key="jetty.testMode" value="1"/>
       <sysproperty key="tempDir" file="${tempDir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>
       <classpath refid="test.classpath"/>

Modified: lucene/dev/trunk/solr/contrib/uima/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/uima/build.xml?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/uima/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/uima/build.xml Wed Jun  1 08:22:23 2011
@@ -124,6 +124,8 @@
       <sysproperty key="jetty.insecurerandom" value="1"/>
       <sysproperty key="tempDir" file="${tempDir}"/>
       <sysproperty key="testmethod" value="${testmethod}"/>
+      <sysproperty key="tests.directory" value="${tests.directory}"/>
+      <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
       <jvmarg line="${args}"/>
       <formatter classname="${junit.details.formatter}" usefile="false" if="junit.details"/>
       <classpath refid="test.classpath"/>

Modified: lucene/dev/trunk/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java Wed Jun 
1 08:22:23 2011
@@ -19,6 +19,7 @@
 package org.apache.solr;
 
 
+import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.noggit.CharArr;
 import org.apache.noggit.JSONUtil;
@@ -72,6 +73,16 @@ public abstract class SolrTestCaseJ4 ext
     resetExceptionIgnores();
     endTrackingSearchers();
   }
+  
+  // SOLR-2279: hack to shut these directories down
+  // we still keep the ability to track open index files this way
+  public static void closeDirectories() throws Exception {
+    for (MockDirectoryWrapper d : stores.keySet()) {
+      if (d.isOpen()) {
+        d.close();
+      }
+    }
+  }
 
   @Override
   public void setUp() throws Exception {
@@ -270,6 +281,7 @@ public abstract class SolrTestCaseJ4 ext
   public static void deleteCore() throws Exception {
     log.info("###deleteCore" );
     if (h != null) { h.close(); }
+    closeDirectories();
     if (dataDir != null) {
       String skip = System.getProperty("solr.test.leavedatadir");
       if (null != skip && 0 != skip.trim().length()) {

Modified: lucene/dev/trunk/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java
(original)
+++ lucene/dev/trunk/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java
Wed Jun  1 08:22:23 2011
@@ -191,6 +191,7 @@ public abstract class AbstractSolrTestCa
     }
 
     if (h != null) { h.close(); }
+    SolrTestCaseJ4.closeDirectories();
     String skip = System.getProperty("solr.test.leavedatadir");
     if (null != skip && 0 != skip.trim().length()) {
       System.err.println("NOTE: per solr.test.leavedatadir, dataDir will not be removed:
" + dataDir.getAbsolutePath());

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/TestSolrCoreProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/TestSolrCoreProperties.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/TestSolrCoreProperties.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/TestSolrCoreProperties.java Wed Jun  1
08:22:23 2011
@@ -59,6 +59,7 @@ public class TestSolrCoreProperties exte
   @Override
   public void tearDown() throws Exception {
     solrJetty.stop();
+    SolrTestCaseJ4.closeDirectories();
     AbstractSolrTestCase.recurseDelete(homeDir);
     super.tearDown();
   }

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
(original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
Wed Jun  1 08:22:23 2011
@@ -78,6 +78,7 @@ public class JettyWebappTest extends Luc
     try {
       server.stop();
     } catch( Exception ex ) {}
+    SolrTestCaseJ4.closeDirectories();
     super.tearDown();
   }
   

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
(original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
Wed Jun  1 08:22:23 2011
@@ -33,6 +33,8 @@ public class MergeIndexesEmbeddedTest ex
 
   @Override
   public void setUp() throws Exception {
+    // TODO: fix this test to use MockDirectoryFactory
+    System.clearProperty("solr.directoryFactory");
     super.setUp();
 
     File home = new File(getSolrHome());

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java?rev=1130042&r1=1130041&r2=1130042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java
(original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java
Wed Jun  1 08:22:23 2011
@@ -38,6 +38,8 @@ public class MultiCoreExampleJettyTest e
   
   @Override public void setUp() throws Exception 
   {    
+    // TODO: fix this test to use MockDirectoryFactory
+    System.clearProperty("solr.directoryFactory");
     super.setUp();
 
     jetty = new JettySolrRunner( context, 0 );

Added: lucene/dev/trunk/solr/src/test/org/apache/solr/core/MockDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/core/MockDirectoryFactory.java?rev=1130042&view=auto
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/core/MockDirectoryFactory.java (added)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/core/MockDirectoryFactory.java Wed Jun
 1 08:22:23 2011
@@ -0,0 +1,35 @@
+package org.apache.solr.core;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+
+/**
+ * Opens a directory with {@link LuceneTestCase#newFSDirectory(File)}
+ */
+public class MockDirectoryFactory extends DirectoryFactory {
+
+  @Override
+  public Directory open(String path) throws IOException {
+    return LuceneTestCase.newFSDirectory(new File(path));
+  }
+}



Mime
View raw message