You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2019/05/11 12:55:08 UTC

[maven-indexer] 02/02: [MINDEXER-117] Integration test for index temporary directory

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MINDEXER-117
in repository https://gitbox.apache.org/repos/asf/maven-indexer.git

commit 4b44144d8fd66698ae73e7ebc7793c249aa7e435
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat May 11 14:53:23 2019 +0200

    [MINDEXER-117] Integration test for index temporary directory
---
 .../updater/DefaultIndexUpdaterEmbeddingIT.java    | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterEmbeddingIT.java b/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterEmbeddingIT.java
index 83f719d..b1161b4 100644
--- a/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterEmbeddingIT.java
+++ b/indexer-core/src/test/java/org/apache/maven/index/updater/DefaultIndexUpdaterEmbeddingIT.java
@@ -119,6 +119,46 @@ public class DefaultIndexUpdaterEmbeddingIT
         }
     }
 
+    public void testIndexTempDirB()
+            throws IOException, UnsupportedExistingLuceneIndexException, ComponentLookupException
+    {
+        File basedir = Files.createTempDirectory( "nexus-indexer." ).toFile();
+        basedir.delete();
+        basedir.mkdirs();
+
+        File indexTempDir = Files.createTempDirectory("index-temp" ).toFile();
+        indexTempDir.delete();
+        // temp dir should not exists
+        assertFalse( indexTempDir.exists());
+
+        try
+        {
+            IndexingContext ctx = newTestContext( basedir, baseUrl );
+
+            IndexUpdateRequest updateRequest =
+                    new IndexUpdateRequest( ctx, wagonHelper.getWagonResourceFetcher( new TransferListenerFixture(), null,
+                            null ) );
+            updateRequest.setIndexTempDir( indexTempDir );
+
+            updater.fetchAndUpdateIndex( updateRequest );
+
+            // dir should still exists after retrival
+            assertTrue( indexTempDir.exists() );
+            indexTempDir.delete();
+            ctx.close( false );
+        }
+        finally
+        {
+            try
+            {
+                FileUtils.forceDelete( basedir );
+            }
+            catch ( IOException e )
+            {
+            }
+        }
+    }
+
     public void testBasicAuthenticatedIndexRetrieval()
         throws IOException, UnsupportedExistingLuceneIndexException, ComponentLookupException
     {