aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zma...@apache.org
Subject aurora git commit: Drop commons-io dependency.
Date Tue, 29 Sep 2015 21:14:01 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 5627611d2 -> 745654b04


Drop commons-io dependency.

This drops the commons-io dependency by replacing the uses with a built in Junit
rule.

Testing Done:
./gradlew clean test

Reviewed at https://reviews.apache.org/r/38841/


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

Branch: refs/heads/master
Commit: 745654b049aac97a2564730aa8a4aa64de802e35
Parents: 5627611
Author: Zameer Manji <zmanji@apache.org>
Authored: Tue Sep 29 14:13:49 2015 -0700
Committer: Zameer Manji <zmanji@apache.org>
Committed: Tue Sep 29 14:13:49 2015 -0700

----------------------------------------------------------------------
 build.gradle                                    |  1 -
 .../zookeeper/testing/BaseZooKeeperTest.java    |  9 ++++-
 .../zookeeper/testing/ZooKeeperTestServer.java  | 36 ++++----------------
 .../aurora/scheduler/app/SchedulerIT.java       | 14 +++-----
 .../scheduler/storage/backup/RecoveryTest.java  | 12 ++++---
 .../storage/backup/StorageBackupTest.java       | 11 +++---
 6 files changed, 33 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/745654b0/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 5195cca..0401a9c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -159,7 +159,6 @@ project(':commons') {
     compile "com.sun.jersey:jersey-json:${jerseyRev}"
     compile "com.sun.jersey:jersey-server:${jerseyRev}"
     compile "com.sun.jersey:jersey-servlet:${jerseyRev}"
-    compile "commons-io:commons-io:2.1"
     compile "commons-lang:commons-lang:${commonsLangRev}"
     compile "javax.servlet:servlet-api:${servletRev}"
     compile "joda-time:joda-time:2.3"

http://git-wip-us.apache.org/repos/asf/aurora/blob/745654b0/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/BaseZooKeeperTest.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/BaseZooKeeperTest.java
b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/BaseZooKeeperTest.java
index 170d37b..3242035 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/BaseZooKeeperTest.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/BaseZooKeeperTest.java
@@ -22,6 +22,8 @@ import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.testing.TearDownTestCase;
 import org.apache.aurora.common.zookeeper.ZooKeeperClient;
 import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
 
 /**
  * A baseclass for in-process zookeeper tests.
@@ -32,6 +34,8 @@ public abstract class BaseZooKeeperTest extends TearDownTestCase {
 
   private final Amount<Integer, Time> defaultSessionTimeout;
   private ZooKeeperTestServer zkTestServer;
+  @Rule
+  public TemporaryFolder tmpFolder = new TemporaryFolder();
 
   /**
    * Creates a test case where the test server uses its
@@ -52,7 +56,10 @@ public abstract class BaseZooKeeperTest extends TearDownTestCase {
 
   @Before
   public final void setUp() throws Exception {
-    zkTestServer = new ZooKeeperTestServer(defaultSessionTimeout);
+    zkTestServer = new ZooKeeperTestServer(
+        defaultSessionTimeout,
+        tmpFolder.newFolder(),
+        tmpFolder.newFolder());
     addTearDown(zkTestServer::stop);
     zkTestServer.startNetwork();
   }

http://git-wip-us.apache.org/repos/asf/aurora/blob/745654b0/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
index ac5d64a..03d47c3 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
@@ -22,12 +22,10 @@ import java.util.LinkedList;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import com.google.common.io.Files;
 
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
 import org.apache.aurora.common.zookeeper.ZooKeeperClient;
-import org.apache.commons.io.FileUtils;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.ZooKeeperServer.BasicDataTreeBuilder;
@@ -40,10 +38,6 @@ import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
  */
 public class ZooKeeperTestServer {
 
-  /**
-   * The default session timeout for clients created by servers constructed with
-   * {@link #ZooKeeperTestServer()}.
-   */
   public static final Amount<Integer, Time> DEFAULT_SESSION_TIMEOUT =
       Amount.of(100, Time.MILLISECONDS);
 
@@ -54,23 +48,20 @@ public class ZooKeeperTestServer {
   private final LinkedList<Runnable> cleanupActions = Lists.newLinkedList();
 
   /**
-   * @throws IOException if there was aproblem creating the server's database
-   */
-  public ZooKeeperTestServer() throws IOException {
-    this(DEFAULT_SESSION_TIMEOUT);
-  }
-
-  /**
    * @param defaultSessionTimeout the default session timeout for clients created with
    *     {@link #createClient()}.
    * @throws IOException if there was aproblem creating the server's database
    */
-  public ZooKeeperTestServer(Amount<Integer, Time> defaultSessionTimeout) throws IOException
{
+  public ZooKeeperTestServer(
+      Amount<Integer, Time> defaultSessionTimeout,
+      File dataDir,
+      File snapDir) throws IOException {
+
     this.defaultSessionTimeout = Preconditions.checkNotNull(defaultSessionTimeout);
 
     zooKeeperServer =
         new ZooKeeperServer(
-            new FileTxnSnapLog(createTempDir(), createTempDir()),
+            new FileTxnSnapLog(dataDir, snapDir),
             new BasicDataTreeBuilder()) {
 
           // TODO(John Sirois): Introduce a builder to configure the in-process server if
and when
@@ -198,19 +189,4 @@ public class ZooKeeperTestServer {
   private void checkEphemeralPortAssigned() {
     Preconditions.checkState(port > 0, "startNetwork must be called first");
   }
-
-  private File createTempDir() {
-    final File tempDir = Files.createTempDir();
-    cleanupActions.addFirst(new Runnable() {
-      @Override
-      public void run() {
-        try {
-          FileUtils.deleteDirectory(tempDir);
-        } catch (IOException e) {
-          // No-op.
-        }
-      }
-    });
-    return tempDir;
-  }
 }

http://git-wip-us.apache.org/repos/asf/aurora/blob/745654b0/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java b/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
index 1530ef8..f63d6f1 100644
--- a/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java
@@ -33,7 +33,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.hash.Hashing;
-import com.google.common.io.Files;
 import com.google.common.util.concurrent.Atomics;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
@@ -99,7 +98,9 @@ import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 import org.easymock.IMocksControl;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 import static org.apache.aurora.common.testing.easymock.EasyMockTest.createCapture;
 import static org.apache.aurora.gen.apiConstants.THRIFT_API_VERSION;
@@ -146,6 +147,8 @@ public class SchedulerIT extends BaseZooKeeperTest {
   private ZooKeeperClient zkClient;
   private File backupDir;
   private Lifecycle lifecycle;
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   @Before
   public void mySetUp() throws Exception {
@@ -161,14 +164,7 @@ public class SchedulerIT extends BaseZooKeeperTest {
         control.verify();
       }
     });
-    backupDir = Files.createTempDir();
-    addTearDown(new TearDown() {
-      @Override
-      public void tearDown() throws Exception {
-        org.apache.commons.io.FileUtils.deleteDirectory(backupDir);
-      }
-    });
-
+    backupDir = temporaryFolder.newFolder();
     driver = control.createMock(SchedulerDriver.class);
     // This is necessary to allow driver to block, otherwise it would stall other mocks.
     EasyMock.makeThreadSafe(driver, false);

http://git-wip-us.apache.org/repos/asf/aurora/blob/745654b0/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java b/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
index 1e4e625..97647ac 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/backup/RecoveryTest.java
@@ -14,10 +14,10 @@
 package org.apache.aurora.scheduler.storage.backup;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.concurrent.ScheduledExecutorService;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.io.Files;
 
 import org.apache.aurora.common.base.Command;
 import org.apache.aurora.common.quantity.Amount;
@@ -42,10 +42,11 @@ import org.apache.aurora.scheduler.storage.backup.StorageBackup.StorageBackupImp
 import org.apache.aurora.scheduler.storage.backup.TemporaryStorage.TemporaryStorageFactory;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.apache.aurora.scheduler.testing.FakeScheduledExecutor;
-import org.apache.commons.io.FileUtils;
 import org.easymock.Capture;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 import static org.apache.aurora.gen.apiConstants.CURRENT_API_VERSION;
 import static org.easymock.EasyMock.capture;
@@ -67,11 +68,12 @@ public class RecoveryTest extends EasyMockTest {
   private FakeClock clock;
   private StorageBackupImpl storageBackup;
   private RecoveryImpl recovery;
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   @Before
-  public void setUp() {
-    final File backupDir = Files.createTempDir();
-    addTearDown(() -> FileUtils.deleteDirectory(backupDir));
+  public void setUp() throws IOException {
+    final File backupDir = temporaryFolder.newFolder();
     snapshotStore = createMock(new Clazz<SnapshotStore<Snapshot>>() { });
     distributedStore = createMock(DistributedSnapshotStore.class);
     primaryStorage = createMock(Storage.class);

http://git-wip-us.apache.org/repos/asf/aurora/blob/745654b0/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
b/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
index 18dbd2f..7b3f185 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/backup/StorageBackupTest.java
@@ -14,6 +14,7 @@
 package org.apache.aurora.scheduler.storage.backup;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.ScheduledExecutorService;
 
@@ -43,9 +44,10 @@ import org.apache.aurora.scheduler.storage.SnapshotStore;
 import org.apache.aurora.scheduler.storage.backup.StorageBackup.StorageBackupImpl;
 import org.apache.aurora.scheduler.storage.backup.StorageBackup.StorageBackupImpl.BackupConfig;
 import org.apache.aurora.scheduler.testing.FakeScheduledExecutor;
-import org.apache.commons.io.FileUtils;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 import static org.easymock.EasyMock.expect;
 import static org.junit.Assert.assertEquals;
@@ -60,14 +62,15 @@ public class StorageBackupTest extends EasyMockTest {
   private FakeClock clock;
   private BackupConfig config;
   private StorageBackupImpl storageBackup;
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   @Before
-  public void setUp() {
+  public void setUp() throws IOException {
     delegate = createMock(new Clazz<SnapshotStore<Snapshot>>() { });
-    final File backupDir = Files.createTempDir();
+    final File backupDir = temporaryFolder.newFolder();
     ScheduledExecutorService executor = createMock(ScheduledExecutorService.class);
     clock = FakeScheduledExecutor.scheduleExecutor(executor);
-    addTearDown(() -> FileUtils.deleteDirectory(backupDir));
     config = new BackupConfig(backupDir, MAX_BACKUPS, INTERVAL);
     clock.advance(Amount.of(365 * 30L, Time.DAYS));
     storageBackup = new StorageBackupImpl(delegate, clock, config, executor);


Mime
View raw message