lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r515249 - /lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
Date Tue, 06 Mar 2007 18:52:33 GMT
Author: mikemccand
Date: Tue Mar  6 10:52:32 2007
New Revision: 515249

URL: http://svn.apache.org/viewvc?view=rev&rev=515249
Log:
Fixing backwards compatibility unit test to make its test dirs under tempDir

Modified:
    lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?view=diff&rev=515249&r1=515248&r2=515249
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Tue
Mar  6 10:52:32 2007
@@ -43,15 +43,19 @@
 
   /* Unzips dirName + ".zip" --> dirName, removing dirName
      first */
-  public void unzip(String dirName) throws IOException {
-    rmDir(dirName);
+  public void unzip(String zipName, String destDirName) throws IOException {
 
     Enumeration entries;
     ZipFile zipFile;
-    zipFile = new ZipFile(dirName + ".zip");
+    zipFile = new ZipFile(zipName + ".zip");
 
     entries = zipFile.entries();
+
+    String dirName = fullDir(destDirName);
+
     File fileDir = new File(dirName);
+    rmDir(dirName);
+
     fileDir.mkdir();
 
     while (entries.hasMoreElements()) {
@@ -89,9 +93,9 @@
     String[] oldNames = {"prelockless.cfs", "prelockless.nocfs"};
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
-      unzip(dirName);
-      searchIndex(dirName);
-      rmDir(dirName);
+      unzip(dirName, oldNames[i]);
+      searchIndex(oldNames[i]);
+      rmDir(oldNames[i]);
     }
   }
 
@@ -99,9 +103,9 @@
     String[] oldNames = {"prelockless.cfs", "prelockless.nocfs"};
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
-      unzip(dirName);
-      changeIndexNoAdds(dirName);
-      rmDir(dirName);
+      unzip(dirName, oldNames[i]);
+      changeIndexNoAdds(oldNames[i]);
+      rmDir(oldNames[i]);
     }
   }
 
@@ -109,9 +113,9 @@
     String[] oldNames = {"prelockless.cfs", "prelockless.nocfs"};
     for(int i=0;i<oldNames.length;i++) {
       String dirName = "src/test/org/apache/lucene/index/index." + oldNames[i];
-      unzip(dirName);
-      changeIndexWithAdds(dirName);
-      rmDir(dirName);
+      unzip(dirName, oldNames[i]);
+      changeIndexWithAdds(oldNames[i]);
+      rmDir(oldNames[i]);
     }
   }
 
@@ -119,6 +123,8 @@
     //QueryParser parser = new QueryParser("contents", new WhitespaceAnalyzer());
     //Query query = parser.parse("handle:1");
 
+    dirName = fullDir(dirName);
+
     Directory dir = FSDirectory.getDirectory(dirName);
     IndexSearcher searcher = new IndexSearcher(dir);
     
@@ -137,6 +143,8 @@
    * setNorm, and search */
   public void changeIndexWithAdds(String dirName) throws IOException {
 
+    dirName = fullDir(dirName);
+
     Directory dir = FSDirectory.getDirectory(dirName);
     // open writer
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
@@ -194,6 +202,8 @@
    * setNorm, and search */
   public void changeIndexNoAdds(String dirName) throws IOException {
 
+    dirName = fullDir(dirName);
+
     Directory dir = FSDirectory.getDirectory(dirName);
 
     // make sure searching sees right # hits
@@ -238,6 +248,8 @@
 
   public void createIndex(String dirName, boolean doCFS) throws IOException {
 
+    dirName = fullDir(dirName);
+
     Directory dir = FSDirectory.getDirectory(dirName);
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
     writer.setUseCompoundFile(doCFS);
@@ -265,7 +277,7 @@
   public void testExactFileNames() throws IOException {
 
     String outputDir = "lucene.backwardscompat0.index";
-    Directory dir = FSDirectory.getDirectory(outputDir);
+    Directory dir = FSDirectory.getDirectory(fullDir(outputDir));
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
     for(int i=0;i<35;i++) {
       addDoc(writer, i);
@@ -342,8 +354,8 @@
     writer.addDocument(doc);
   }
 
-  private void rmDir(String dir) {
-    File fileDir = new File(dir);
+  private void rmDir(String dir) throws IOException {
+    File fileDir = new File(fullDir(dir));
     if (fileDir.exists()) {
       File[] files = fileDir.listFiles();
       if (files != null) {
@@ -353,5 +365,9 @@
       }
       fileDir.delete();
     }
+  }
+
+  public static String fullDir(String dirName) throws IOException {
+    return new File(System.getProperty("tempDir"), dirName).getCanonicalPath();
   }
 }



Mime
View raw message