ACCUMULO-2356 Remove terrible static blocks and use BeforeClass annotations.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8d94812c Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8d94812c Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8d94812c Branch: refs/heads/master Commit: 8d94812cb7c15bc13e93a148573c58357120d7df Parents: 884b69a Author: Josh Elser <els...@apache.org> Authored: Tue Feb 11 22:52:33 2014 -0500 Committer: Josh Elser <els...@apache.org> Committed: Tue Feb 11 22:52:33 2014 -0500 ---------------------------------------------------------------------- .../providers/ReadOnlyHdfsFileProviderTest.java | 2 +- .../vfs/providers/VfsClassLoaderTest.java | 2 +- .../apache/accumulo/test/AccumuloDFSBase.java | 26 ++++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/8d94812c/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/ReadOnlyHdfsFileProviderTest.java ---------------------------------------------------------------------- diff --git a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/ReadOnlyHdfsFileProviderTest.java b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/ReadOnlyHdfsFileProviderTest.java index 1247376..8873d17 100644 --- a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/ReadOnlyHdfsFileProviderTest.java +++ b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/ReadOnlyHdfsFileProviderTest.java @@ -34,7 +34,7 @@ import org.junit.Test; public class ReadOnlyHdfsFileProviderTest extends AccumuloDFSBase { - private static final String TEST_DIR1 = HDFS_URI + "/test-dir"; + private static final String TEST_DIR1 = getHdfsUri() + "/test-dir"; private static final Path DIR1_PATH = new Path("/test-dir"); private static final String TEST_FILE1 = TEST_DIR1 + "/accumulo-test-1.jar"; private static final Path FILE1_PATH = new Path(DIR1_PATH, "accumulo-test-1.jar"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/8d94812c/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/VfsClassLoaderTest.java ---------------------------------------------------------------------- diff --git a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/VfsClassLoaderTest.java b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/VfsClassLoaderTest.java index 0497a49..4f0f0e9 100644 --- a/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/VfsClassLoaderTest.java +++ b/start/src/test/java/org/apache/accumulo/start/classloader/vfs/providers/VfsClassLoaderTest.java @@ -33,7 +33,7 @@ import org.junit.Test; public class VfsClassLoaderTest extends AccumuloDFSBase { - private static final Path TEST_DIR = new Path(HDFS_URI + "/test-dir"); + private static final Path TEST_DIR = new Path(getHdfsUri() + "/test-dir"); private FileSystem hdfs = null; private VFSClassLoader cl = null; http://git-wip-us.apache.org/repos/asf/accumulo/blob/8d94812c/start/src/test/java/org/apache/accumulo/test/AccumuloDFSBase.java ---------------------------------------------------------------------- diff --git a/start/src/test/java/org/apache/accumulo/test/AccumuloDFSBase.java b/start/src/test/java/org/apache/accumulo/test/AccumuloDFSBase.java index a29bf7e..eccdfc2 100644 --- a/start/src/test/java/org/apache/accumulo/test/AccumuloDFSBase.java +++ b/start/src/test/java/org/apache/accumulo/test/AccumuloDFSBase.java @@ -33,24 +33,25 @@ import org.apache.commons.vfs2.impl.FileContentInfoFilenameFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.MiniDFSCluster; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import org.junit.AfterClass; +import org.junit.BeforeClass; public class AccumuloDFSBase { - // Turn off the MiniDFSCluster logging - static { - System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); - } - protected static Configuration conf = null; protected static DefaultFileSystemManager vfs = null; protected static MiniDFSCluster cluster = null; - protected static final URI HDFS_URI; + private static URI HDFS_URI; + + protected static URI getHdfsUri() { + return HDFS_URI; + } - static { - Logger.getRootLogger().setLevel(Level.ERROR); + @BeforeClass + public static void miniDfsClusterSetup() { + // System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); + // Logger.getRootLogger().setLevel(Level.ERROR); // Put the MiniDFSCluster directory in the target directory System.setProperty("test.build.data", "target/build/test/data"); @@ -138,4 +139,9 @@ public class AccumuloDFSBase { } + @AfterClass + public static void tearDownMiniDfsCluster() { + cluster.shutdown(); + } + }