flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject git commit: FLUME-1553. TestFileChannelEncrytion should be refactored to use TestFileChannelBase.
Date Mon, 10 Sep 2012 23:51:48 GMT
Updated Branches:
  refs/heads/flume-1.3.0 cf8399c89 -> fff0372f2


FLUME-1553. TestFileChannelEncrytion should be refactored to use TestFileChannelBase.

(Brock Noland via Hari Shreedharan)


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

Branch: refs/heads/flume-1.3.0
Commit: fff0372f2232b70e427a890d34190d62b51cd4cd
Parents: cf8399c
Author: Hari Shreedharan <harishreedharan@gmail.com>
Authored: Mon Sep 10 16:50:46 2012 -0700
Committer: Hari Shreedharan <harishreedharan@gmail.com>
Committed: Mon Sep 10 16:51:34 2012 -0700

----------------------------------------------------------------------
 .../apache/flume/channel/file/TestFileChannel.java |    2 +-
 .../flume/channel/file/TestFileChannelBase.java    |    2 +-
 .../file/TestFileChannelFormatRegression.java      |    2 +-
 .../flume/channel/file/TestFileChannelRestart.java |    2 +-
 .../channel/file/TestFileChannelRollback.java      |    2 +-
 .../file/encryption/TestFileChannelEncryption.java |   63 ++++-----------
 6 files changed, 22 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/fff0372f/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java
b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java
index 7c1aaab..16157d5 100644
--- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java
+++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannel.java
@@ -56,7 +56,7 @@ public class TestFileChannel extends TestFileChannelBase {
           .getLogger(TestFileChannel.class);
 
   @Before
-  public void setup() {
+  public void setup() throws Exception {
     super.setup();
   }
   @After

http://git-wip-us.apache.org/repos/asf/flume/blob/fff0372f/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelBase.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelBase.java
b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelBase.java
index 4655978..3da09ab 100644
--- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelBase.java
+++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelBase.java
@@ -39,7 +39,7 @@ public class TestFileChannelBase {
   protected String dataDir;
 
   @Before
-  public void setup() {
+  public void setup() throws Exception {
     baseDir = Files.createTempDir();
     checkpointDir = new File(baseDir, "chkpt");
     Assert.assertTrue(checkpointDir.mkdirs() || checkpointDir.isDirectory());

http://git-wip-us.apache.org/repos/asf/flume/blob/fff0372f/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelFormatRegression.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelFormatRegression.java
b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelFormatRegression.java
index 8fc0faf..184f956 100644
--- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelFormatRegression.java
+++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelFormatRegression.java
@@ -41,7 +41,7 @@ public class TestFileChannelFormatRegression extends TestFileChannelBase
{
       .getLogger(TestFileChannelFormatRegression.class);
 
   @Before
-  public void setup() {
+  public void setup() throws Exception {
     super.setup();
   }
 

http://git-wip-us.apache.org/repos/asf/flume/blob/fff0372f/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRestart.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRestart.java
b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRestart.java
index cf61aed..90d5aed 100644
--- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRestart.java
+++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRestart.java
@@ -40,7 +40,7 @@ public class TestFileChannelRestart extends TestFileChannelBase {
       .getLogger(TestFileChannelRestart.class);
 
   @Before
-  public void setup() {
+  public void setup() throws Exception {
     super.setup();
   }
 

http://git-wip-us.apache.org/repos/asf/flume/blob/fff0372f/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRollback.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRollback.java
b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRollback.java
index 5b1a088..23fc64b 100644
--- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRollback.java
+++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/TestFileChannelRollback.java
@@ -41,7 +41,7 @@ public class TestFileChannelRollback extends TestFileChannelBase {
       .getLogger(TestFileChannelRollback.class);
 
   @Before
-  public void setup() {
+  public void setup() throws Exception {
     super.setup();
   }
 

http://git-wip-us.apache.org/repos/asf/flume/blob/fff0372f/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/encryption/TestFileChannelEncryption.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/encryption/TestFileChannelEncryption.java
b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/encryption/TestFileChannelEncryption.java
index 7d7a825..493dac7 100644
--- a/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/encryption/TestFileChannelEncryption.java
+++ b/flume-ng-channels/flume-file-channel/src/test/java/org/apache/flume/channel/file/encryption/TestFileChannelEncryption.java
@@ -24,11 +24,10 @@ import java.io.File;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.flume.ChannelException;
 import org.apache.flume.FlumeException;
-import org.apache.flume.channel.file.FileChannel;
 import org.apache.flume.channel.file.FileChannelConfiguration;
+import org.apache.flume.channel.file.TestFileChannelBase;
 import org.apache.flume.channel.file.TestUtils;
 import org.junit.After;
 import org.junit.Assert;
@@ -42,31 +41,16 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.io.Files;
 
-public class TestFileChannelEncryption {
+public class TestFileChannelEncryption extends TestFileChannelBase {
   protected static final Logger LOGGER =
       LoggerFactory.getLogger(TestFileChannelEncryption.class);
-  private FileChannel channel;
-  private File baseDir;
-  private File checkpointDir;
-  private File[] dataDirs;
-  private String dataDir;
   private File keyStoreFile;
   private File keyStorePasswordFile;
   private Map<String, File> keyAliasPassword;
 
   @Before
   public void setup() throws Exception {
-    baseDir = Files.createTempDir();
-    checkpointDir = new File(baseDir, "chkpt");
-    Assert.assertTrue(checkpointDir.mkdirs() || checkpointDir.isDirectory());
-    dataDirs = new File[3];
-    dataDir = "";
-    for (int i = 0; i < dataDirs.length; i++) {
-      dataDirs[i] = new File(baseDir, "data" + (i+1));
-      Assert.assertTrue(dataDirs[i].mkdirs() || dataDirs[i].isDirectory());
-      dataDir += dataDirs[i].getAbsolutePath() + ",";
-    }
-    dataDir = dataDir.substring(0, dataDir.length() - 1);
+    super.setup();
     keyStorePasswordFile = new File(baseDir, "keyStorePasswordFile");
     Files.write("keyStorePassword", keyStorePasswordFile, Charsets.UTF_8);
     keyStoreFile = new File(baseDir, "keyStoreFile");
@@ -77,10 +61,7 @@ public class TestFileChannelEncryption {
   }
   @After
   public void teardown() {
-    if(channel != null && channel.isOpen()) {
-      channel.stop();
-    }
-    FileUtils.deleteQuietly(baseDir);
+    super.teardown();
   }
   private Map<String, String> getOverrides() throws Exception {
     Map<String, String> overrides = Maps.newHashMap();
@@ -106,8 +87,7 @@ public class TestFileChannelEncryption {
   @Test
   public void testBasicEncyrptionDecryption() throws Exception {
     Map<String, String> overrides = getOverridesForEncryption();
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, overrides);
+    channel = createFileChannel(overrides);
     channel.start();
     Assert.assertTrue(channel.isOpen());
     Set<String> in = Sets.newHashSet();
@@ -130,8 +110,7 @@ public class TestFileChannelEncryption {
   @Test
   public void testEncryptedChannelWithoutEncryptionConfigFails() throws Exception {
     Map<String, String> overrides = getOverridesForEncryption();
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, overrides);
+    channel = createFileChannel(overrides);
     channel.start();
     Assert.assertTrue(channel.isOpen());
     Set<String> in = Sets.newHashSet();
@@ -145,8 +124,7 @@ public class TestFileChannelEncryption {
     }
     channel.stop();
     Map<String, String> noEncryptionOverrides = getOverrides();
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, noEncryptionOverrides);
+    channel = createFileChannel(noEncryptionOverrides);
     channel.start();
 
     if(channel.isOpen()) {
@@ -161,8 +139,7 @@ public class TestFileChannelEncryption {
   @Test
   public void testUnencyrptedAndEncryptedLogs() throws Exception {
     Map<String, String> noEncryptionOverrides = getOverrides();
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, noEncryptionOverrides);
+    channel = createFileChannel(noEncryptionOverrides);
     channel.start();
     Assert.assertTrue(channel.isOpen());
     Set<String> in = Sets.newHashSet();
@@ -181,8 +158,7 @@ public class TestFileChannelEncryption {
     // now we have logs with no encryption and the channel is half full
     channel.stop();
     Map<String, String> overrides = getOverridesForEncryption();
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, overrides);
+    channel = createFileChannel(overrides);
     channel.start();
     Assert.assertTrue(channel.isOpen());
     try {
@@ -202,8 +178,7 @@ public class TestFileChannelEncryption {
     overrides.put(EncryptionConfiguration.ENCRYPTION_PREFIX + "." +
         EncryptionConfiguration.KEY_PROVIDER, "invalid");
     try {
-      channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-          dataDir, overrides);
+      channel = createFileChannel(overrides);
       Assert.fail();
     } catch(FlumeException ex) {
       Assert.assertEquals("java.lang.ClassNotFoundException: invalid",
@@ -216,8 +191,7 @@ public class TestFileChannelEncryption {
     overrides.put(EncryptionConfiguration.ENCRYPTION_PREFIX + "." +
         EncryptionConfiguration.KEY_PROVIDER, String.class.getName());
     try {
-      channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-          dataDir, overrides);
+      channel = createFileChannel(overrides);
       Assert.fail();
     } catch(FlumeException ex) {
       Assert.assertEquals("Unable to instantiate Builder from java.lang.String",
@@ -229,8 +203,7 @@ public class TestFileChannelEncryption {
     Map<String, String> overrides = getOverridesForEncryption();
     overrides.put(EncryptionConfiguration.ENCRYPTION_PREFIX + "." +
         EncryptionConfiguration.CIPHER_PROVIDER, "invalid");
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, overrides);
+    channel = createFileChannel(overrides);
     channel.start();
     Assert.assertFalse(channel.isOpen());
   }
@@ -239,8 +212,7 @@ public class TestFileChannelEncryption {
     Map<String, String> overrides = getOverridesForEncryption();
     overrides.put(EncryptionConfiguration.ENCRYPTION_PREFIX + "." +
         EncryptionConfiguration.CIPHER_PROVIDER, String.class.getName());
-    channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-        dataDir, overrides);
+    channel = createFileChannel(overrides);
     channel.start();
     Assert.assertFalse(channel.isOpen());
   }
@@ -250,8 +222,7 @@ public class TestFileChannelEncryption {
     overrides.put(EncryptionConfiguration.ENCRYPTION_PREFIX + "." +
         EncryptionConfiguration.JCE_FILE_KEY_STORE_FILE, "/path/does/not/exist");
     try {
-      channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-          dataDir, overrides);
+      channel = createFileChannel(overrides);
       Assert.fail();
     } catch(RuntimeException ex) {
       Assert.assertEquals("java.io.FileNotFoundException: /path/does/not/exist " +
@@ -262,10 +233,10 @@ public class TestFileChannelEncryption {
   public void testMissingKeyStorePasswordFile() throws Exception {
     Map<String, String> overrides = getOverridesForEncryption();
     overrides.put(EncryptionConfiguration.ENCRYPTION_PREFIX + "." +
-        EncryptionConfiguration.JCE_FILE_KEY_STORE_PASSWORD_FILE, "/path/does/not/exist");
+        EncryptionConfiguration.JCE_FILE_KEY_STORE_PASSWORD_FILE,
+          "/path/does/not/exist");
     try {
-      channel = TestUtils.createFileChannel(checkpointDir.getAbsolutePath(),
-          dataDir, overrides);
+      channel = createFileChannel(overrides);
       Assert.fail();
     } catch(RuntimeException ex) {
       Assert.assertEquals("java.io.FileNotFoundException: /path/does/not/exist " +


Mime
View raw message