commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1650847 - in /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test: HdfsFileProviderTest.java HdfsFileProviderTestCase.java
Date Sun, 11 Jan 2015 01:24:28 GMT
Author: ecki
Date: Sun Jan 11 01:24:27 2015
New Revision: 1650847

URL: http://svn.apache.org/r1650847
Log:
[tests][hdfs] make DfsMiniCluster start up more robust by cleaning test data dir

Modified:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTest.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTestCase.java

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTest.java?rev=1650847&r1=1650846&r2=1650847&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTest.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTest.java
Sun Jan 11 01:24:27 2015
@@ -17,10 +17,12 @@
 package org.apache.commons.vfs2.provider.hdfs.test;
 
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.Map;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.vfs2.CacheStrategy;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.commons.vfs2.FileSystemException;
@@ -75,12 +77,17 @@ public class HdfsFileProviderTest
     protected static Configuration conf;
     protected static DefaultFileSystemManager vfs;
     protected static MiniDFSCluster cluster;
-    static
+
+    @BeforeClass
+    public static void setUp() throws Exception
     {
         Logger.getRootLogger().setLevel(Level.ERROR);
 
         // Put the MiniDFSCluster directory in the target directory
-        System.setProperty("test.build.data", "target/build/test/data");
+        File data = new File("target/test/hdfstestdata").getAbsoluteFile();
+        data.mkdirs();
+        System.setProperty("test.build.data", data.toString());
+        FileUtils.cleanDirectory(data);
 
         // Setup HDFS
         conf = new Configuration();
@@ -90,68 +97,10 @@ public class HdfsFileProviderTest
 
         setUmask(conf);
 
-        try
-        {
-            cluster = new MiniDFSCluster(PORT, conf, 1, true, true, true, null, null, null,
null);
-            cluster.waitActive();
-        }
-        catch (final IOException e)
-        {
-            throw new RuntimeException("Error setting up mini cluster", e);
-        }
+        cluster = new MiniDFSCluster(PORT, conf, 1, true, true, true, null, null, null, null);
+        cluster.waitActive();
 
         // Set up the VFS
-        vfs = new DefaultFileSystemManager();
-        try
-        {
-            vfs.setFilesCache(new DefaultFilesCache());
-            vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
-            vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
-            vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
-            vfs.addProvider("ram", new org.apache.commons.vfs2.provider.ram.RamFileProvider());
-            vfs.addProvider("file", new org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider());
-            vfs.addProvider("jar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
-            vfs.addProvider("http", new org.apache.commons.vfs2.provider.http.HttpFileProvider());
-            vfs.addProvider("https", new org.apache.commons.vfs2.provider.https.HttpsFileProvider());
-            vfs.addProvider("ftp", new org.apache.commons.vfs2.provider.ftp.FtpFileProvider());
-            vfs.addProvider("ftps", new org.apache.commons.vfs2.provider.ftps.FtpsFileProvider());
-            vfs.addProvider("war", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
-            vfs.addProvider("par", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
-            vfs.addProvider("ear", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
-            vfs.addProvider("sar", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
-            vfs.addProvider("ejb3", new org.apache.commons.vfs2.provider.jar.JarFileProvider());
-            vfs.addProvider("tmp", new org.apache.commons.vfs2.provider.temp.TemporaryFileProvider());
-            vfs.addProvider("tar", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
-            vfs.addProvider("tbz2", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
-            vfs.addProvider("tgz", new org.apache.commons.vfs2.provider.tar.TarFileProvider());
-            vfs.addProvider("bz2", new org.apache.commons.vfs2.provider.bzip2.Bzip2FileProvider());
-            vfs.addProvider("hdfs", new HdfsFileProvider());
-            vfs.addExtensionMap("jar", "jar");
-            vfs.addExtensionMap("zip", "zip");
-            vfs.addExtensionMap("gz", "gz");
-            vfs.addExtensionMap("tar", "tar");
-            vfs.addExtensionMap("tbz2", "tar");
-            vfs.addExtensionMap("tgz", "tar");
-            vfs.addExtensionMap("bz2", "bz2");
-            vfs.addMimeTypeMap("application/x-tar", "tar");
-            vfs.addMimeTypeMap("application/x-gzip", "gz");
-            vfs.addMimeTypeMap("application/zip", "zip");
-            vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
-            vfs.setFilesCache(new SoftRefFilesCache());
-            vfs.setReplicator(new DefaultFileReplicator());
-            vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
-            vfs.init();
-        }
-        catch (final FileSystemException e)
-        {
-            throw new RuntimeException("Error setting up VFS", e);
-        }
-
-    }
-
-    @BeforeClass
-    public static void setUp() throws Exception
-    {
         manager = new DefaultFileSystemManager();
         manager.addProvider("hdfs", new HdfsFileProvider());
         manager.init();

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTestCase.java?rev=1650847&r1=1650846&r2=1650847&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTestCase.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/hdfs/test/HdfsFileProviderTestCase.java
Sun Jan 11 01:24:27 2015
@@ -22,6 +22,7 @@ import java.io.IOException;
 import junit.framework.Test;
 
 import org.apache.commons.AbstractVfsTestCase;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.commons.vfs2.FileSystemManager;
 import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
@@ -92,7 +93,10 @@ public class HdfsFileProviderTestCase ex
             Logger.getRootLogger().setLevel(Level.OFF);
 
             // Put the MiniDFSCluster directory in the target directory
-            System.setProperty("test.build.data", "target/build/test2/data");
+            File data = new File("target/test/hdfstestcasedata").getAbsoluteFile();
+            data.mkdirs();
+            System.setProperty("test.build.data", data.toString());
+            FileUtils.cleanDirectory(data);
 
             // Setup HDFS
             conf = new Configuration();



Mime
View raw message