lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r949970 - in /lucene/java/branches/lucene_3_0: ./ contrib/ contrib/analyzers/ contrib/highlighter/src/test/ contrib/instantiated/src/test/org/apache/lucene/store/instantiated/ src/java/org/apache/lucene/analysis/ src/java/org/apache/lucene/...
Date Tue, 01 Jun 2010 09:18:35 GMT
Author: mikemccand
Date: Tue Jun  1 09:18:33 2010
New Revision: 949970

URL: http://svn.apache.org/viewvc?rev=949970&view=rev
Log:
LUCENE-2397: port to 3.0.x

Added:
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
      - copied, changed from r935522, lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
Removed:
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
Modified:
    lucene/java/branches/lucene_3_0/   (props changed)
    lucene/java/branches/lucene_3_0/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/build.xml   (props changed)
    lucene/java/branches/lucene_3_0/contrib/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/contrib/analyzers/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/Tokenizer.java   (props
changed)
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/   (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
  (props changed)

Propchange: lucene/java/branches/lucene_3_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene:948430
-/lucene/dev/trunk/lucene:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4:748824
 /lucene/java/branches/lucene_2_9:817269-818600,825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336

Propchange: lucene/java/branches/lucene_3_0/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/CHANGES.txt:948430
-/lucene/dev/trunk/lucene/CHANGES.txt:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/CHANGES.txt:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/CHANGES.txt:817269-818600,825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/CHANGES.txt:818601-821336

Propchange: lucene/java/branches/lucene_3_0/build.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/build.xml:948430
-/lucene/dev/trunk/lucene/build.xml:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/build.xml:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/build.xml:748824
 /lucene/java/branches/lucene_2_9/build.xml:817269-818600,825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/build.xml:818601-821336

Propchange: lucene/java/branches/lucene_3_0/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/contrib:948430
-/lucene/dev/trunk/lucene/contrib:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/contrib:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/contrib:748824
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336

Propchange: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/contrib/CHANGES.txt:948430
-/lucene/dev/trunk/lucene/contrib/CHANGES.txt:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/contrib/CHANGES.txt:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/contrib/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336

Propchange: lucene/java/branches/lucene_3_0/contrib/analyzers/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1 +1 @@
-/lucene/dev/trunk/lucene/contrib/analyzers:929738,948429
+/lucene/dev/trunk/lucene/contrib/analyzers:929738,935522,948429

Propchange: lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/contrib/highlighter/src/test:948430
-/lucene/dev/trunk/lucene/contrib/highlighter/src/test:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/contrib/highlighter/src/test:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/contrib/highlighter/src/test:748824
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336

Propchange: lucene/java/branches/lucene_3_0/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:948430
-/lucene/dev/trunk/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:748824
 /lucene/java/branches/lucene_2_9/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:817269-818600,825998,829134,829816,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java:818601-821336

Propchange: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/Tokenizer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/analysis/Tokenizer.java:948430
-/lucene/dev/trunk/lucene/src/java/org/apache/lucene/analysis/Tokenizer.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/java/org/apache/lucene/analysis/Tokenizer.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/analysis/Tokenizer.java:748824
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/Tokenizer.java:817269-818600,825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/analysis/Tokenizer.java:818601-821336

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java?rev=949970&r1=949969&r2=949970&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java
(original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java
Tue Jun  1 09:18:33 2010
@@ -72,6 +72,10 @@ public class SnapshotDeletionPolicy impl
    *  consume an extra 1X of your total index size, until
    *  you release the snapshot. */
   public synchronized IndexCommit snapshot() {
+    if (lastCommit == null) {
+      throw new IllegalStateException("no index commits to snapshot !");
+    }
+    
     if (snapshot == null)
       snapshot = lastCommit.getSegmentsFileName();
     else

Propchange: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:948430
-/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:817269-818600,825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:818601-821336

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:948430
-/lucene/dev/trunk/lucene/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887347,887532,887602,888247,889431-889432,890967,890988,891189,891209,891363,893093,894348,897672,899627,900196,908477,908975,909360,909398,910034,910078,912407,915399,919060

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/document/TestDateTools.java:948430
-/lucene/dev/trunk/lucene/src/test/org/apache/lucene/document/TestDateTools.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/test/org/apache/lucene/document/TestDateTools.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887347,887532,887602,888247,889431-889432,890967,890988,891189,891209,891363,893093,894348,897672,899627,900196,908477,908975,909360,909398,910034,910078,912407,915399,919060

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/document/TestNumberTools.java:948430
-/lucene/dev/trunk/lucene/src/test/org/apache/lucene/document/TestNumberTools.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/test/org/apache/lucene/document/TestNumberTools.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887347,887532,887602,888247,889431-889432,890967,890988,891189,891209,891363,893093,894348,897672,899627,900196,908477,908975,909360,909398,910034,910078,912407,915399,919060

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1 +1 @@
-/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index:929738,948429
+/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index:929738,935522,948429

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:948430
-/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882672,882807,882888,882977,883074-883075,883554,884870,886257,886911,887347,887532,887602,888247,889431-889432,890967,890988,891189,891209,891363,893093,894348,897672,899627,900196,908477,908975,909360,909398,910034,910078,912407,915399,919060

Copied: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
(from r935522, lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java)
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java?p2=lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java&p1=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java&r1=935522&r2=949970&rev=949970&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
(original)
+++ lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
Tue Jun  1 09:18:33 2010
@@ -17,8 +17,6 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import static org.junit.Assert.*;
-
 import java.util.Collection;
 import java.io.File;
 import java.io.IOException;
@@ -30,26 +28,19 @@ import org.apache.lucene.store.FSDirecto
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.MockRAMDirectory;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.IndexCommit;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.SnapshotDeletionPolicy;
-import org.apache.lucene.util.LuceneTestCaseJ4;
 import org.apache.lucene.util.ThreadInterruptedException;
+import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
-import org.junit.Test;
 
 //
 // This was developed for Lucene In Action,
 // http://lucenebook.com
 //
 
-public class TestSnapshotDeletionPolicy extends LuceneTestCaseJ4 {
-  
+public class TestSnapshotDeletionPolicy extends LuceneTestCase
+{
   public static final String INDEX_PATH = "test.snapshots";
 
-  @Test
   public void testSnapshotDeletionPolicy() throws Exception {
     File dir = _TestUtil.getTempDir(INDEX_PATH);
     try {
@@ -65,15 +56,13 @@ public class TestSnapshotDeletionPolicy 
     dir2.close();
   }
 
-  @Test
   public void testReuseAcrossWriters() throws Exception {
     Directory dir = new MockRAMDirectory();
 
     SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
-    IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
-        TEST_VERSION_CURRENT, 
-        new StandardAnalyzer(TEST_VERSION_CURRENT)).setIndexDeletionPolicy(dp)
-        .setMaxBufferedDocs(2));
+    IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
dp, IndexWriter.MaxFieldLength.UNLIMITED);
+    // Force frequent flushes
+    writer.setMaxBufferedDocs(2);
     Document doc = new Document();
     doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
     for(int i=0;i<7;i++) {
@@ -82,13 +71,12 @@ public class TestSnapshotDeletionPolicy 
         writer.commit();
       }
     }
-    IndexCommit cp = dp.snapshot();
+    IndexCommit cp = (IndexCommit) dp.snapshot();
     copyFiles(dir, cp);
     writer.close();
     copyFiles(dir, cp);
     
-    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
-        new StandardAnalyzer(TEST_VERSION_CURRENT)).setIndexDeletionPolicy(dp));
+    writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
dp, IndexWriter.MaxFieldLength.UNLIMITED);
     copyFiles(dir, cp);
     for(int i=0;i<7;i++) {
       writer.addDocument(doc);
@@ -100,8 +88,7 @@ public class TestSnapshotDeletionPolicy 
     writer.close();
     copyFiles(dir, cp);
     dp.release();
-    writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
-        new StandardAnalyzer(TEST_VERSION_CURRENT)).setIndexDeletionPolicy(dp));
+    writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
dp, IndexWriter.MaxFieldLength.UNLIMITED);
     writer.close();
     try {
       copyFiles(dir, cp);
@@ -117,12 +104,11 @@ public class TestSnapshotDeletionPolicy 
     final long stopTime = System.currentTimeMillis() + 1000;
 
     SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
-    final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(
-        TEST_VERSION_CURRENT, 
-        new StandardAnalyzer(TEST_VERSION_CURRENT)).setIndexDeletionPolicy(dp)
-        .setMaxBufferedDocs(2));
-    writer.commit();
-    
+    final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
dp, IndexWriter.MaxFieldLength.UNLIMITED);
+
+    // Force frequent flushes
+    writer.setMaxBufferedDocs(2);
+
     final Thread t = new Thread() {
         @Override
         public void run() {
@@ -160,7 +146,9 @@ public class TestSnapshotDeletionPolicy 
     do {
       backupIndex(dir, dp);
       Thread.sleep(20);
-    } while(t.isAlive());
+      if (!t.isAlive())
+        break;
+    } while(System.currentTimeMillis() < stopTime);
 
     t.join();
 
@@ -185,7 +173,7 @@ public class TestSnapshotDeletionPolicy 
   public void backupIndex(Directory dir, SnapshotDeletionPolicy dp) throws Exception {
     // To backup an index we first take a snapshot:
     try {
-      copyFiles(dir,  dp.snapshot());
+      copyFiles(dir, (IndexCommit) dp.snapshot());
     } finally {
       // Make sure to release the snapshot, otherwise these
       // files will never be deleted during this IndexWriter
@@ -200,7 +188,7 @@ public class TestSnapshotDeletionPolicy 
     // we take to do the backup, the IndexWriter will
     // never delete the files in the snapshot:
     Collection<String> files = cp.getFileNames();
-    for (final String fileName : files) { 
+    for (final String fileName : files) {
       // NOTE: in a real backup you would not use
       // readFile; you would need to use something else
       // that copies the file to a backup location.  This
@@ -237,13 +225,17 @@ public class TestSnapshotDeletionPolicy 
       input.close();
     }
   }
-  
-  @Test(expected=IllegalStateException.class)
+
   public void testNoCommits() throws Exception {
     // Tests that if there were no commits when snapshot() is called, then
     // IllegalStateException is thrown rather than NPE.
     SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
-    sdp.snapshot();
+    try {
+      sdp.snapshot();
+      fail("expected exception not hit");
+    } catch (IllegalStateException ise) {
+      // expected
+    }
   }
-  
 }
+

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun  1 09:18:33 2010
@@ -1,5 +1,5 @@
 /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java:948430
-/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java:929738,932398,945420,946599,948082,948429
+/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java:929738,932398,935522,945420,946599,948082,948429
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/util/TestAttributeSource.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:817269-818600,825998,829134,829881,831036,896850,909334,940987,948516
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java:818601-821336



Mime
View raw message