Author: tomekr
Date: Wed Sep 21 09:04:17 2016
New Revision: 1761700

URL: http://svn.apache.org/viewvc?rev=1761700&view=rev
Log:
OAK-4831: Don't break the upgrade tests if the directory can't be cleaned-up

Modified:
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/SameNodeSiblingsTest.java
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java
    
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentTarNodeStoreContainer.java

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/SameNodeSiblingsTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/SameNodeSiblingsTest.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/SameNodeSiblingsTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/SameNodeSiblingsTest.java
 Wed Sep 21 09:04:17 2016
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertEqu
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.Set;
 
 import javax.jcr.Credentials;
@@ -43,8 +45,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.io.Files;
-
 public class SameNodeSiblingsTest {
 
     public static final Credentials CREDENTIALS = new 
SimpleCredentials("admin", "admin".toCharArray());
@@ -53,7 +53,7 @@ public class SameNodeSiblingsTest {
 
     @Before
     public void createCrx2RepoDir() throws IOException {
-        crx2RepoDir = Files.createTempDir();
+        crx2RepoDir = Files.createTempDirectory(Paths.get("target"), 
"repo-crx2").toFile();
     }
 
     @After

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileBlobStoreContainer.java
 Wed Sep 21 09:04:17 2016
@@ -18,19 +18,21 @@ package org.apache.jackrabbit.oak.upgrad
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.blob.FileBlobStore;
 
-import com.google.common.io.Files;
+import static 
org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer.deleteRecursive;
 
 public class FileBlobStoreContainer implements BlobStoreContainer {
 
     private final File directory;
 
-    public FileBlobStoreContainer() {
-        this.directory = Files.createTempDir();
+    public FileBlobStoreContainer() throws IOException {
+        this.directory = Files.createTempDirectory(Paths.get("target"), 
"repo-fbs").toFile();
     }
 
     @Override
@@ -44,7 +46,7 @@ public class FileBlobStoreContainer impl
 
     @Override
     public void clean() throws IOException {
-        FileUtils.deleteDirectory(directory);
+        deleteRecursive(directory);
     }
 
     @Override

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/FileDataStoreContainer.java
 Wed Sep 21 09:04:17 2016
@@ -18,13 +18,16 @@ package org.apache.jackrabbit.oak.upgrad
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.upgrade.cli.blob.FileDataStoreFactory;
 
 import com.google.common.io.Closer;
-import com.google.common.io.Files;
+
+import static 
org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer.deleteRecursive;
 
 public class FileDataStoreContainer implements BlobStoreContainer {
 
@@ -32,8 +35,8 @@ public class FileDataStoreContainer impl
 
     private final Closer closer;
     
-    public FileDataStoreContainer() {
-        this.directory = Files.createTempDir();
+    public FileDataStoreContainer() throws IOException {
+        this.directory = Files.createTempDirectory(Paths.get("target"), 
"repo-fds").toFile();
         this.closer = Closer.create();
     }
 
@@ -49,7 +52,7 @@ public class FileDataStoreContainer impl
 
     @Override
     public void clean() throws IOException {
-        FileUtils.deleteDirectory(directory);
+        deleteRecursive(directory);
     }
 
     @Override

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/JdbcNodeStoreContainer.java
 Wed Sep 21 09:04:17 2016
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.upgrad
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -26,7 +28,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.io.Closer;
-import com.google.common.io.Files;
+
+import static 
org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer.deleteRecursive;
 
 public class JdbcNodeStoreContainer implements NodeStoreContainer {
 
@@ -46,10 +49,10 @@ public class JdbcNodeStoreContainer impl
         this(new DummyBlobStoreContainer());
     }
 
-    public JdbcNodeStoreContainer(BlobStoreContainer blob) {
+    public JdbcNodeStoreContainer(BlobStoreContainer blob) throws IOException {
         this.blob = blob;
-        this.h2Dir = Files.createTempDir();
-        this.jdbcUri = String.format("jdbc:h2:%s", h2Dir.getPath() + 
"/JdbcNodeStoreContainer");
+        this.h2Dir = Files.createTempDirectory(Paths.get("target"), 
"repo-h2").toFile();
+        this.jdbcUri = String.format("jdbc:h2:%s", h2Dir.getAbsolutePath() + 
"/JdbcNodeStoreContainer");
         this.jdbcFactory = new JdbcFactory(jdbcUri, 2, "sa", "sa");
     }
 
@@ -73,7 +76,7 @@ public class JdbcNodeStoreContainer impl
 
     @Override
     public void clean() throws IOException {
-        FileUtils.deleteDirectory(h2Dir);
+        deleteRecursive(h2Dir);
         blob.clean();
     }
 

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/S3DataStoreContainer.java
 Wed Sep 21 09:04:17 2016
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.upgrad
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
@@ -26,7 +28,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.io.Closer;
-import com.google.common.io.Files;
+
+import static 
org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer.deleteRecursive;
 
 public class S3DataStoreContainer implements BlobStoreContainer {
 
@@ -39,7 +42,7 @@ public class S3DataStoreContainer implem
     private final Closer closer;
 
     public S3DataStoreContainer(String configFile) throws IOException {
-        this.directory = Files.createTempDir();
+        this.directory = Files.createTempDirectory(Paths.get("target"), 
"repo-s3").toFile();
         this.factory = new S3DataStoreFactory(configFile, directory.getPath(), 
false);
         this.closer = Closer.create();
     }
@@ -60,7 +63,7 @@ public class S3DataStoreContainer implem
 
     @Override
     public void clean() throws IOException {
-        FileUtils.deleteDirectory(directory);
+        deleteRecursive(directory);
     }
 
     @Override

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentNodeStoreContainer.java
 Wed Sep 21 09:04:17 2016
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.upgrad
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Paths;
 
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
@@ -50,7 +51,7 @@ public class SegmentNodeStoreContainer i
 
     private SegmentNodeStoreContainer(BlobStoreContainer blob, File directory) 
throws IOException {
         this.blob = blob;
-        this.directory = directory == null ? 
java.nio.file.Files.createTempDirectory(Paths.get("target"), 
"segment").toFile() : directory;
+        this.directory = directory == null ? 
Files.createTempDirectory(Paths.get("target"), "repo-segment").toFile() : 
directory;
     }
     @Override
     public NodeStore open() throws IOException {

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentTarNodeStoreContainer.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentTarNodeStoreContainer.java?rev=1761700&r1=1761699&r2=1761700&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentTarNodeStoreContainer.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentTarNodeStoreContainer.java
 Wed Sep 21 09:04:17 2016
@@ -59,7 +59,7 @@ public class SegmentTarNodeStoreContaine
 
     private SegmentTarNodeStoreContainer(BlobStoreContainer blob, File 
directory) throws IOException {
         this.blob = blob;
-        this.directory = directory == null ? 
Files.createTempDirectory(Paths.get("target"), "segment-tar").toFile() : 
directory;
+        this.directory = directory == null ? 
Files.createTempDirectory(Paths.get("target"), "repo-segment-tar").toFile() : 
directory;
     }
 
     @Override


Reply via email to