incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [07/30] git commit: Calling close the tests to stop daemon thread correctly.
Date Thu, 07 Nov 2013 02:41:30 GMT
Calling close the tests to stop daemon thread correctly.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/ccb63ee8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/ccb63ee8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/ccb63ee8

Branch: refs/heads/blur-console-v2
Commit: ccb63ee84157a90b506d5d686f7e873ffc1a71bb
Parents: 8eead1f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Oct 20 20:43:37 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Oct 20 20:43:52 2013 -0400

----------------------------------------------------------------------
 .../org/apache/blur/store/BaseDirectoryTestSuite.java    |  5 ++++-
 .../org/apache/blur/store/CacheDirectoryTestSuite.java   | 11 ++++++++---
 .../org/apache/blur/store/HdfsDirectoryTestSuite.java    |  5 +++++
 .../blur/store/SoftlinkHdfsDirectoryTestSuite.java       |  5 +++++
 .../blur/store/blockcache_v2/CacheDirectoryTest.java     | 11 +++++++++--
 5 files changed, 31 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ccb63ee8/blur-store/src/test/java/org/apache/blur/store/BaseDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/BaseDirectoryTestSuite.java b/blur-store/src/test/java/org/apache/blur/store/BaseDirectoryTestSuite.java
index 300394e..2806e39 100644
--- a/blur-store/src/test/java/org/apache/blur/store/BaseDirectoryTestSuite.java
+++ b/blur-store/src/test/java/org/apache/blur/store/BaseDirectoryTestSuite.java
@@ -81,10 +81,13 @@ public abstract class BaseDirectoryTestSuite {
   }
 
   @After
-  public void tearDown() {
+  public void tearDown() throws IOException {
     print(file, "");
+    close();
   }
 
+  protected abstract void close() throws IOException;
+
   private void print(File f, String buf) {
     if (f.isDirectory()) {
       System.out.println(buf + "\\" + f.getName());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ccb63ee8/blur-store/src/test/java/org/apache/blur/store/CacheDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/CacheDirectoryTestSuite.java b/blur-store/src/test/java/org/apache/blur/store/CacheDirectoryTestSuite.java
index ca51d9b..b03053e 100644
--- a/blur-store/src/test/java/org/apache/blur/store/CacheDirectoryTestSuite.java
+++ b/blur-store/src/test/java/org/apache/blur/store/CacheDirectoryTestSuite.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 
 import org.apache.blur.store.blockcache_v2.BaseCache;
 import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
-import org.apache.blur.store.blockcache_v2.Cache;
 import org.apache.blur.store.blockcache_v2.CacheDirectory;
 import org.apache.blur.store.blockcache_v2.FileNameFilter;
 import org.apache.blur.store.blockcache_v2.Quiet;
@@ -32,6 +31,8 @@ import org.apache.lucene.store.FSDirectory;
 
 public abstract class CacheDirectoryTestSuite extends BaseDirectoryTestSuite {
 
+  private BaseCache _cache;
+
   @Override
   protected Directory setupDirectory() throws IOException {
     int totalNumberOfBytes = 1000000;
@@ -70,14 +71,18 @@ public abstract class CacheDirectoryTestSuite extends BaseDirectoryTestSuite
{
         return false;
       }
     };
-    Cache cache = new BaseCache(totalNumberOfBytes, fileBufferSize, cacheBlockSize, readFilter,
writeFilter,quiet,
+    _cache = new BaseCache(totalNumberOfBytes, fileBufferSize, cacheBlockSize, readFilter,
writeFilter,quiet,
         getStore());
     Directory dir = FSDirectory.open(new File(file, "cache"));
 
     BufferStore.init(128, 128);
-    return new CacheDirectory("test", wrapLastModified(dir), cache);
+    return new CacheDirectory("test", wrapLastModified(dir), _cache);
   }
 
   protected abstract STORE getStore();
+  
+  public void close() throws IOException {
+    _cache.close();
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ccb63ee8/blur-store/src/test/java/org/apache/blur/store/HdfsDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/HdfsDirectoryTestSuite.java b/blur-store/src/test/java/org/apache/blur/store/HdfsDirectoryTestSuite.java
index e39147f..4688a7b 100644
--- a/blur-store/src/test/java/org/apache/blur/store/HdfsDirectoryTestSuite.java
+++ b/blur-store/src/test/java/org/apache/blur/store/HdfsDirectoryTestSuite.java
@@ -38,5 +38,10 @@ public class HdfsDirectoryTestSuite extends BaseDirectoryTestSuite {
 
   @Test
   public void runsTheTests() {}
+
+  @Override
+  protected void close() throws IOException {
+    
+  }
   
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ccb63ee8/blur-store/src/test/java/org/apache/blur/store/SoftlinkHdfsDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/SoftlinkHdfsDirectoryTestSuite.java
b/blur-store/src/test/java/org/apache/blur/store/SoftlinkHdfsDirectoryTestSuite.java
index 450afaf..28a49d1 100644
--- a/blur-store/src/test/java/org/apache/blur/store/SoftlinkHdfsDirectoryTestSuite.java
+++ b/blur-store/src/test/java/org/apache/blur/store/SoftlinkHdfsDirectoryTestSuite.java
@@ -40,5 +40,10 @@ public class SoftlinkHdfsDirectoryTestSuite extends BaseDirectoryTestSuite
{
 
   @Test
   public void runsTheTests() {}
+
+  @Override
+  protected void close() throws IOException {
+    
+  }
   
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ccb63ee8/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryTest.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryTest.java
b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryTest.java
index cad9476..8867cff 100644
--- a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryTest.java
+++ b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryTest.java
@@ -43,12 +43,14 @@ import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.Version;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 public class CacheDirectoryTest {
 
   private CacheDirectory _cacheDirectory;
+  private BaseCache _cache;
 
   @Before
   public void setup() {
@@ -85,11 +87,16 @@ public class CacheDirectoryTest {
         return false;
       }
     };
-    Cache cache = new BaseCache(totalNumberOfBytes, fileBufferSize, cacheBlockSize, readFilter,
writeFilter, quiet,
+    _cache = new BaseCache(totalNumberOfBytes, fileBufferSize, cacheBlockSize, readFilter,
writeFilter, quiet,
         STORE.ON_HEAP);
     Directory directory = newDirectory();
     BufferStore.init(128, 128);
-    _cacheDirectory = new CacheDirectory("test", directory, cache);
+    _cacheDirectory = new CacheDirectory("test", directory, _cache);
+  }
+  
+  @After
+  public void tearDown() throws IOException {
+    _cache.close();
   }
 
   private Directory newDirectory() {


Mime
View raw message