]> source.dussan.org Git - archiva.git/commitdiff
Migrating consumers to java.nio
authorMartin Stockhammer <martin_s@apache.org>
Sun, 10 Sep 2017 11:41:44 +0000 (13:41 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Sun, 10 Sep 2017 11:41:44 +0000 (13:41 +0200)
17 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRemoveConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/AutoRenameConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurge.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/RetentionCountRepositoryPurge.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/DaysOldRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java

index 1bea8adea2190c9250124d3ea62e759d3448620c..b3150df9530f444c9b0c8a7785741e889a648ea6 100644 (file)
@@ -34,7 +34,10 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import javax.inject.Inject;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Date;
 
 import static org.mockito.Mockito.*;
@@ -69,16 +72,16 @@ public class SimpleArtifactConsumerTest
     }
 
     private void setUpMockRepository()
-        throws RepositoryAdminException
+        throws RepositoryAdminException, IOException
     {
-        File repoDir = new File( "target/test-consumer-repo" );
-        repoDir.mkdirs();
-        repoDir.deleteOnExit();
+        Path repoDir = Paths.get( "target/test-consumer-repo" );
+        Files.createDirectories( repoDir );
+        repoDir.toFile().deleteOnExit();
 
         testRepository = new ManagedRepository();
         testRepository.setName( "Test-Consumer-Repository" );
         testRepository.setId( "test-consumer-repository" );
-        testRepository.setLocation( repoDir.getAbsolutePath() );
+        testRepository.setLocation( repoDir.toAbsolutePath().toString() );
 
         when( managedRepositoryAdmin.getManagedRepository( testRepository.getId() ) ).thenReturn( testRepository );
     }
index 58e93b5ddac6517ce76cb284808dc43a785b38e9..c99ab4bbf1402577ed7fa5230daffdb10c251274 100644 (file)
@@ -34,8 +34,10 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -70,7 +72,7 @@ public class ArtifactMissingChecksumsConsumer
 
     private static final String TYPE_CHECKSUM_CANNOT_CREATE = "checksum-create-failure";
 
-    private File repositoryDir;
+    private Path repositoryDir;
 
     private List<String> includes = new ArrayList<>( 0 );
 
@@ -101,7 +103,7 @@ public class ArtifactMissingChecksumsConsumer
     public void beginScan( ManagedRepository repo, Date whenGathered )
         throws ConsumerException
     {
-        this.repositoryDir = new File( repo.getLocation( ) );
+        this.repositoryDir = Paths.get( repo.getLocation( ) );
     }
 
     @Override
@@ -152,19 +154,19 @@ public class ArtifactMissingChecksumsConsumer
 
     private void createFixChecksum( String path, ChecksumAlgorithm checksumAlgorithm )
     {
-        File artifactFile = new File( this.repositoryDir, path );
-        File checksumFile = new File( this.repositoryDir, path + "." + checksumAlgorithm.getExt( ) );
+        Path artifactFile = repositoryDir.resolve(path);
+        Path checksumFile = repositoryDir.resolve(path + "." + checksumAlgorithm.getExt( ) );
 
-        if ( checksumFile.exists( ) )
+        if ( Files.exists(checksumFile) )
         {
-            checksum = new ChecksummedFile( artifactFile.toPath() );
+            checksum = new ChecksummedFile( artifactFile);
             try
             {
                 if ( !checksum.isValidChecksum( checksumAlgorithm ) )
                 {
                     checksum.fixChecksums( new ChecksumAlgorithm[]{checksumAlgorithm} );
-                    log.info( "Fixed checksum file {}", checksumFile.getAbsolutePath( ) );
-                    triggerConsumerInfo( "Fixed checksum file " + checksumFile.getAbsolutePath( ) );
+                    log.info( "Fixed checksum file {}", checksumFile.toAbsolutePath( ) );
+                    triggerConsumerInfo( "Fixed checksum file " + checksumFile.toAbsolutePath( ) );
                 }
             }
             catch ( IOException e )
@@ -174,14 +176,14 @@ public class ArtifactMissingChecksumsConsumer
                     ": " + e.getMessage( ) );
             }
         }
-        else if ( !checksumFile.exists( ) )
+        else if ( !Files.exists(checksumFile) )
         {
-            checksum = new ChecksummedFile( artifactFile.toPath() );
+            checksum = new ChecksummedFile( artifactFile);
             try
             {
                 checksum.createChecksum( checksumAlgorithm );
-                log.info( "Created missing checksum file {}", checksumFile.getAbsolutePath( ) );
-                triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath( ) );
+                log.info( "Created missing checksum file {}", checksumFile.toAbsolutePath( ) );
+                triggerConsumerInfo( "Created missing checksum file " + checksumFile.toAbsolutePath( ) );
             }
             catch ( IOException e )
             {
@@ -192,9 +194,9 @@ public class ArtifactMissingChecksumsConsumer
         }
         else
         {
-            log.warn( "Checksum file {} is not a file. ", checksumFile.getAbsolutePath( ) );
+            log.warn( "Checksum file {} is not a file. ", checksumFile.toAbsolutePath( ) );
             triggerConsumerWarning( TYPE_CHECKSUM_NOT_FILE,
-                "Checksum file " + checksumFile.getAbsolutePath( ) + " is not a file." );
+                "Checksum file " + checksumFile.toAbsolutePath( ) + " is not a file." );
         }
     }
 
index 9b74798fd45d23364e2ac66e44c415a4e6fd6066..e7aa8cb6661a8a68c1f85412c95b0eb79069faa9 100644 (file)
@@ -35,7 +35,10 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -74,7 +77,7 @@ public class AutoRemoveConsumer
     @Inject
     private FileTypes filetypes;
 
-    private File repositoryDir;
+    private Path repositoryDir;
 
     private List<String> includes = new ArrayList<>( 0 );
 
@@ -94,7 +97,7 @@ public class AutoRemoveConsumer
     public void beginScan( ManagedRepository repository, Date whenGathered )
         throws ConsumerException
     {
-        this.repositoryDir = new File( repository.getLocation( ) );
+        this.repositoryDir = Paths.get( repository.getLocation( ) );
     }
 
     @Override
@@ -132,12 +135,20 @@ public class AutoRemoveConsumer
     public void processFile( String path )
         throws ConsumerException
     {
-        File file = new File( this.repositoryDir, path );
-        if ( file.exists( ) )
+        Path file = this.repositoryDir.resolve(path );
+        if ( Files.exists(file) )
         {
-            log.info( "(Auto) Removing File: {}", file.getAbsolutePath( ) );
-            triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath( ) );
-            file.delete( );
+            log.info( "(Auto) Removing File: {}", file.toAbsolutePath( ) );
+            triggerConsumerInfo( "(Auto) Removing File: " + file.toAbsolutePath( ) );
+            try
+            {
+                Files.deleteIfExists( file );
+            }
+            catch ( IOException e )
+            {
+                log.error("Could not delete file {}: {}", file, e.getMessage(), e);
+                throw new ConsumerException( "Could not delete file "+file );
+            }
         }
     }
 
index 977ad42fd593da399cf0f85766141bba9a68321c..1317682f2768c1f019ada514dc14fc7463d1d2f4 100644 (file)
@@ -21,6 +21,7 @@ package org.apache.archiva.consumers.core;
 
 import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.consumers.AbstractMonitoredConsumer;
+import org.apache.archiva.consumers.Consumer;
 import org.apache.archiva.consumers.ConsumerException;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.commons.io.FileUtils;
@@ -29,8 +30,10 @@ import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
 
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -55,7 +58,7 @@ public class AutoRenameConsumer
 
     private static final String RENAME_FAILURE = "rename_failure";
 
-    private File repositoryDir;
+    private Path repositoryDir;
 
     private List<String> includes = new ArrayList<>( 3 );
 
@@ -88,7 +91,7 @@ public class AutoRenameConsumer
     public void beginScan( ManagedRepository repository, Date whenGathered )
         throws ConsumerException
     {
-        this.repositoryDir = new File( repository.getLocation( ) );
+        this.repositoryDir = Paths.get( repository.getLocation( ) );
     }
 
     @Override
@@ -126,8 +129,8 @@ public class AutoRenameConsumer
     public void processFile( String path )
         throws ConsumerException
     {
-        File file = new File( this.repositoryDir, path );
-        if ( file.exists( ) )
+        Path file = this.repositoryDir.resolve( path );
+        if ( Files.exists(file) )
         {
             Iterator<String> itExtensions = this.extensionRenameMap.keySet( ).iterator( );
             while ( itExtensions.hasNext( ) )
@@ -137,11 +140,11 @@ public class AutoRenameConsumer
                 {
                     String fixedExtension = this.extensionRenameMap.get( extension );
                     String correctedPath = path.substring( 0, path.length( ) - extension.length( ) ) + fixedExtension;
-                    File to = new File( this.repositoryDir, correctedPath );
+                    Path to = repositoryDir.resolve(correctedPath);
                     try
                     {
                         // Rename the file.
-                        FileUtils.moveFile( file, to );
+                        FileUtils.moveFile( file.toFile(), to.toFile() );
                     }
                     catch ( IOException e )
                     {
@@ -152,9 +155,17 @@ public class AutoRenameConsumer
                 }
             }
 
-            log.info( "(Auto) Removing File: {} ", file.getAbsolutePath( ) );
-            triggerConsumerInfo( "(Auto) Removing File: " + file.getAbsolutePath( ) );
-            file.delete( );
+            log.info( "(Auto) Removing File: {} ", file.toAbsolutePath( ) );
+            triggerConsumerInfo( "(Auto) Removing File: " + file.toAbsolutePath( ) );
+            try
+            {
+                Files.delete( file );
+            }
+            catch ( IOException e )
+            {
+                log.error("Could not delete file {}: {}", file, e.getMessage(), e);
+                throw new ConsumerException( "File deletion failed "+file );
+            }
         }
     }
 
index 4d1c58e7c5dcbbece31d3dfc60d4efcc5dc1273e..263e0422cdc9adb70286e54706e7b107c1edac2c 100644 (file)
@@ -43,8 +43,10 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -89,7 +91,7 @@ public class MetadataUpdaterConsumer
 
     private ManagedRepositoryContent repository;
 
-    private File repositoryDir;
+    private Path repositoryDir;
 
     private List<String> includes = new ArrayList<>( 0 );
 
@@ -119,7 +121,7 @@ public class MetadataUpdaterConsumer
         try
         {
             this.repository = repositoryFactory.getManagedRepositoryContent( repoConfig.getId( ) );
-            this.repositoryDir = new File( repository.getRepoRoot( ) );
+            this.repositoryDir = Paths.get( repository.getRepoRoot( ) );
             this.scanStartTimestamp = System.currentTimeMillis( );
         }
         catch ( RepositoryNotFoundException e )
@@ -200,9 +202,9 @@ public class MetadataUpdaterConsumer
         {
             String metadataPath = this.metadataTools.toPath( projectRef );
 
-            File projectMetadata = new File( this.repositoryDir, metadataPath );
+            Path projectMetadata = this.repositoryDir.resolve( metadataPath );
 
-            if ( projectMetadata.exists( ) && ( projectMetadata.lastModified( ) >= this.scanStartTimestamp ) )
+            if ( Files.exists(projectMetadata) && ( Files.getLastModifiedTime( projectMetadata).toMillis() >= this.scanStartTimestamp ) )
             {
                 // This metadata is up to date. skip it.
                 log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) );
@@ -251,9 +253,9 @@ public class MetadataUpdaterConsumer
         {
             String metadataPath = this.metadataTools.toPath( versionRef );
 
-            File projectMetadata = new File( this.repositoryDir, metadataPath );
+            Path projectMetadata = this.repositoryDir.resolve( metadataPath );
 
-            if ( projectMetadata.exists( ) && ( projectMetadata.lastModified( ) >= this.scanStartTimestamp ) )
+            if ( Files.exists(projectMetadata) && ( Files.getLastModifiedTime( projectMetadata ).toMillis() >= this.scanStartTimestamp ) )
             {
                 // This metadata is up to date. skip it.
                 log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( versionRef ) );
index 8e2a92607a6af66bd2f76a173b81bd9b0734a174..e0d80214bc1bf7127a9b7da5b76496d5c537db4d 100644 (file)
@@ -36,9 +36,10 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -76,7 +77,7 @@ public class ValidateChecksumConsumer
     @Inject
     private DigesterUtils digesterUtils;
 
-    private File repositoryDir;
+    private Path repositoryDir;
 
     private List<String> includes;
 
@@ -96,7 +97,7 @@ public class ValidateChecksumConsumer
     public void beginScan( ManagedRepository repository, Date whenGathered )
         throws ConsumerException
     {
-        this.repositoryDir = new File( repository.getLocation( ) );
+        this.repositoryDir = Paths.get( repository.getLocation( ) );
     }
 
     @Override
@@ -134,10 +135,10 @@ public class ValidateChecksumConsumer
     public void processFile( String path )
         throws ConsumerException
     {
-        File checksumFile = new File( this.repositoryDir, path );
+        Path checksumFile = this.repositoryDir.resolve( path );
         try
         {
-            if ( !checksum.isValidChecksum( checksumFile ) )
+            if ( !checksum.isValidChecksum( checksumFile.toFile() ) )
             {
                 log.warn( "The checksum for {} is invalid.", checksumFile );
                 triggerConsumerWarning( NOT_VALID_CHECKSUM, "The checksum for " + checksumFile + " is invalid." );
index 14b0d4d4ee26ebb09c141823272414a73b5449e5..97280273bdf2ae87d79518626fa0c8620e002629 100644 (file)
@@ -40,8 +40,10 @@ import org.apache.archiva.repository.layout.LayoutException;
 import org.apache.archiva.repository.metadata.MetadataTools;
 import org.apache.archiva.repository.metadata.RepositoryMetadataException;
 
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -93,9 +95,9 @@ public class CleanupReleasedSnapshotsRepositoryPurge
     {
         try
         {
-            File artifactFile = new File( repository.getRepoRoot( ), path );
+            Path artifactFile = Paths.get( repository.getRepoRoot( ), path );
 
-            if ( !artifactFile.exists( ) )
+            if ( !Files.exists(artifactFile) )
             {
                 // Nothing to do here, file doesn't exist, skip it.
                 return;
@@ -164,7 +166,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
                 {
                     listener.deleteArtifact( metadataRepository, repository.getId( ), artifactRef.getGroupId( ),
                         artifactRef.getArtifactId( ), artifactRef.getVersion( ),
-                        artifactFile.getName( ) );
+                        artifactFile.getFileName().toString() );
                 }
                 metadataRepository.removeProjectVersion( repository.getId( ), artifactRef.getGroupId( ),
                     artifactRef.getArtifactId( ), artifactRef.getVersion( ) );
index f893ca5115762dcb41d37d2b20cda9daab6f27ec..155e5f620c3ad00c95ab6fa7ea37ccc2d65caaf0 100644 (file)
@@ -30,10 +30,10 @@ import org.apache.archiva.repository.events.RepositoryListener;
 import org.apache.archiva.repository.layout.LayoutException;
 import org.apache.commons.lang.time.DateUtils;
 
-import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -73,9 +73,9 @@ public class DaysOldRepositoryPurge
     {
         try
         {
-            File artifactFile = new File( repository.getRepoRoot( ), path );
+            Path artifactFile = Paths.get( repository.getRepoRoot( ), path );
 
-            if ( !artifactFile.exists( ) )
+            if ( !Files.exists(artifactFile) )
             {
                 return;
             }
@@ -112,7 +112,7 @@ public class DaysOldRepositoryPurge
                 }
 
                 ArtifactReference newArtifactReference = repository.toArtifactReference(
-                    artifactFile.getAbsolutePath( ) );
+                    artifactFile.toAbsolutePath( ).toString() );
                 newArtifactReference.setVersion( version );
 
                 Path newArtifactFile = repository.toFile( newArtifactReference );
index 98357b30a4d2ce6aac99eca76b44f957560a7602..98929bad819bd6e879b4ce7280c4903a91928314 100644 (file)
@@ -29,7 +29,9 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
 import org.apache.archiva.repository.events.RepositoryListener;
 import org.apache.archiva.repository.layout.LayoutException;
 
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -57,9 +59,9 @@ public class RetentionCountRepositoryPurge
     {
         try
         {
-            File artifactFile = new File( repository.getRepoRoot( ), path );
+            Path artifactFile = Paths.get( repository.getRepoRoot( ), path );
 
-            if ( !artifactFile.exists( ) )
+            if ( !Files.exists(artifactFile) )
             {
                 return;
             }
index e90315082bc2dc3178be2d0f368dac09954f1113..b473b1db5e46f518ab18ef8dad4fc468b556c867 100644 (file)
@@ -37,7 +37,9 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
-import java.io.File;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -46,7 +48,7 @@ import static org.junit.Assert.assertFalse;
 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
 public abstract class AbstractArtifactConsumerTest
 {
-    private File repoLocation;
+    private Path repoLocation;
 
     protected KnownRepositoryContentConsumer consumer;
 
@@ -69,7 +71,7 @@ public abstract class AbstractArtifactConsumerTest
         assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
         fileType.addPattern( "**/*.xml" );
 
-        repoLocation = new File( "target/test-" + getName() + "/test-repo" );
+        repoLocation = Paths.get( "target/test-" + getName() + "/test-repo" );
     }
 
     @After
@@ -86,11 +88,11 @@ public abstract class AbstractArtifactConsumerTest
     @Test
     public void testConsumption()
     {
-        File localFile =
-            new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
+        Path localFile =
+            repoLocation.resolve( "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" );
 
         ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
-        BaseFile baseFile = new BaseFile( repoLocation, localFile );
+        BaseFile baseFile = new BaseFile( repoLocation.toFile(), localFile.toFile() );
         predicate.setBasefile( baseFile );
 
         assertFalse( predicate.evaluate( consumer ) );
@@ -99,11 +101,11 @@ public abstract class AbstractArtifactConsumerTest
     @Test
     public void testConsumptionOfOtherMetadata()
     {
-        File localFile =
-            new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
+        Path localFile =
+            repoLocation.resolve( "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" );
 
         ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
-        BaseFile baseFile = new BaseFile( repoLocation, localFile );
+        BaseFile baseFile = new BaseFile( repoLocation.toFile(), localFile.toFile() );
         predicate.setBasefile( baseFile );
 
         assertFalse( predicate.evaluate( consumer ) );
index 824e7678d19e19b3ec59d25c4e10cf3ccab03660..4e2e664dda8fbe9cf9e6e542a0b02ea44b7423ff 100644 (file)
@@ -9,7 +9,6 @@ import org.assertj.core.api.Assertions;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -50,7 +49,7 @@ public class ArtifactMissingChecksumsConsumerTest
         repoConfig.setId( "test-repo" );
         repoConfig.setName( "Test Repository" );
         repoConfig.setLayout( "default" );
-        repoConfig.setLocation( new File( "target/test-classes/test-repo/" ).getPath() );
+        repoConfig.setLocation( Paths.get( "target/test-classes/test-repo/" ).toString() );
 
         consumer = applicationContext.getBean( "knownRepositoryContentConsumer#create-missing-checksums",
                                                KnownRepositoryContentConsumer.class );
@@ -60,7 +59,7 @@ public class ArtifactMissingChecksumsConsumerTest
     public void testNoExistingChecksums()
         throws Exception
     {
-        String path = "/no-checksums-artifact/1.0/no-checksums-artifact-1.0.jar";
+        String path = "no-checksums-artifact/1.0/no-checksums-artifact-1.0.jar";
 
         Path sha1Path = Paths.get( repoConfig.getLocation(), path + ".sha1" );
         Path md5FilePath = Paths.get( repoConfig.getLocation(), path + ".md5" );
@@ -94,12 +93,12 @@ public class ArtifactMissingChecksumsConsumerTest
     public void testExistingIncorrectChecksums()
         throws Exception
     {
-        File newLocation = new File( "target/test-repo" );
-        FileUtils.deleteDirectory( newLocation );
-        FileUtils.copyDirectory( new File( repoConfig.getLocation() ), newLocation );
-        repoConfig.setLocation( newLocation.getAbsolutePath() );
+        Path newLocation = Paths.get( "target/test-repo" );
+        org.apache.archiva.common.utils.FileUtils.deleteDirectory( newLocation );
+        FileUtils.copyDirectory( Paths.get(repoConfig.getLocation() ).toFile(), newLocation.toFile() );
+        repoConfig.setLocation( newLocation.toAbsolutePath().toString() );
 
-        String path = "/incorrect-checksums/1.0/incorrect-checksums-1.0.jar";
+        String path = "incorrect-checksums/1.0/incorrect-checksums-1.0.jar";
 
         Path sha1Path = Paths.get( repoConfig.getLocation(), path + ".sha1" );
 
index ad02d11f7db5f30d5320a6627e5ce5344c956d0d..e3fee9408362c4ffb43a43899078dfd4b741eecc 100644 (file)
@@ -41,7 +41,6 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
-import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -164,7 +163,7 @@ public abstract class AbstractRepositoryPurgeTest
         config.setName( repoName );
         config.setDaysOlder( TEST_DAYS_OLDER );
         String path = AbstractRepositoryPurgeTest.fixPath(
-            new File( "target/test-" + getName() + "/" + repoId ).getAbsolutePath() );
+            Paths.get( "target/test-" + getName() + "/" + repoId ).toAbsolutePath().toString() );
         config.setLocation( path );
         config.setReleases( true );
         config.setSnapshots( true );
@@ -188,17 +187,17 @@ public abstract class AbstractRepositoryPurgeTest
 
     protected void assertDeleted( String path )
     {
-        assertFalse( "File should have been deleted: " + path, new File( path ).exists() );
+        assertFalse( "File should have been deleted: " + path, Files.exists(Paths.get( path )) );
     }
 
     protected void assertExists( String path )
     {
-        assertTrue( "File should exist: " + path, new File( path ).exists() );
+        assertTrue( "File should exist: " + path, Files.exists(Paths.get(path)) );
     }
 
-    protected File getTestRepoRoot()
+    protected Path getTestRepoRoot()
     {
-        return new File( "target/test-" + getName() + "/" + TEST_REPO_ID );
+        return Paths.get( "target/test-" + getName() + "/" + TEST_REPO_ID );
     }
 
     protected Path getTestRepoRootPath() {
@@ -209,20 +208,20 @@ public abstract class AbstractRepositoryPurgeTest
         throws Exception
     {
         removeMavenIndexes();
-        File testDir = new File( AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot().getAbsolutePath() ) );
-        FileUtils.deleteDirectory( testDir );
-        File sourceDir = new File( new File( "target/test-classes/" + TEST_REPO_ID ).getAbsolutePath() );
-        FileUtils.copyDirectory( sourceDir, testDir );
+        Path testDir = Paths.get( AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot().toAbsolutePath().toString() ) );
+        org.apache.archiva.common.utils.FileUtils.deleteDirectory( testDir );
+        Path sourceDir = Paths.get( Paths.get( "target/test-classes/" + TEST_REPO_ID ).toAbsolutePath().toString() );
+        FileUtils.copyDirectory( sourceDir.toFile(), testDir.toFile() );
 
-        File releasesTestDir = new File( AbstractRepositoryPurgeTest.fixPath(
-            new File( "target/test-" + getName() + "/" + RELEASES_TEST_REPO_ID ).getAbsolutePath() ) );
+        Path releasesTestDir = Paths.get( AbstractRepositoryPurgeTest.fixPath(
+            Paths.get( "target/test-" + getName() + "/" + RELEASES_TEST_REPO_ID ).toAbsolutePath().toString() ) );
 
-        FileUtils.deleteDirectory( releasesTestDir );
-        File sourceReleasesDir =
-            new File( new File( "target/test-classes/" + RELEASES_TEST_REPO_ID ).getAbsolutePath() );
-        FileUtils.copyDirectory( sourceReleasesDir, releasesTestDir );
+        org.apache.archiva.common.utils.FileUtils.deleteDirectory( releasesTestDir );
+        Path sourceReleasesDir =
+            Paths.get( Paths.get( "target/test-classes/" + RELEASES_TEST_REPO_ID ).toAbsolutePath().toString() );
+        FileUtils.copyDirectory( sourceReleasesDir.toFile(), releasesTestDir.toFile() );
 
-        return AbstractRepositoryPurgeTest.fixPath( testDir.getAbsolutePath() );
+        return AbstractRepositoryPurgeTest.fixPath( testDir.toAbsolutePath().toString() );
     }
 
     public String getName()
index c3e650daef3d2b8937a88c9faad370276e00a942..0b575151ac7b1d4b28db0b68d127f3ac8cf35907 100644 (file)
@@ -35,9 +35,10 @@ import org.junit.Test;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
-import java.io.File;
 import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -160,9 +161,9 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
         assertExists( projectRoot + "/2.3/maven-plugin-plugin-2.3.pom.sha1" );
 
         // check if metadata file was updated
-        File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
+        Path artifactMetadataFile = Paths.get( projectRoot + "/maven-metadata.xml" );
 
-        String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
+        String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
 
         String expectedVersions =
             "<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
@@ -188,20 +189,20 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
         // test listeners for the correct artifacts
         listenerControl.replay();
 
-        File file = new File( repoRoot, INDEX_PATH );
-        if ( !file.exists() )
+        Path file = Paths.get(repoRoot, INDEX_PATH );
+        if ( !Files.exists(file) )
         {
             // help windauze to create directory with .
-            file.getParentFile().mkdirs();
-            file.createNewFile();
+            Files.createDirectories( file.getParent() );
+            Files.createFile( file );
         }
-        assertTrue( file.exists() );
+        assertTrue( Files.exists(file) );
 
         repoPurge.process( INDEX_PATH );
 
         listenerControl.verify();
 
-        assertTrue( file.exists() );
+        assertTrue( Files.exists(file) );
     }
 
     @Test
@@ -266,7 +267,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
         assertDeleted( projectRoot + "/1.0-SNAPSHOT/released-artifact-in-diff-repo-1.0-SNAPSHOT.pom.sha1" );
 
         String releasesProjectRoot =
-            AbstractRepositoryPurgeTest.fixPath( new File( "target/test-" + getName() + "/releases-test-repo-one" ).getAbsolutePath()
+            AbstractRepositoryPurgeTest.fixPath( Paths.get( "target/test-" + getName() + "/releases-test-repo-one" ).toAbsolutePath().toString()
                 + "/org/apache/archiva/released-artifact-in-diff-repo" );
 
         // check if the released version was not removed
@@ -350,9 +351,9 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
         assertExists( projectRoot + "/2.0.4-SNAPSHOT/maven-source-plugin-2.0.4-SNAPSHOT.pom.sha1" );
 
         // check if metadata file was not updated (because nothing was removed)
-        File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
+        Path artifactMetadataFile = Paths.get( projectRoot + "/maven-metadata.xml" );
 
-        String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
+        String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
 
         String expectedVersions = "<expected><versions><version>2.0.3-SNAPSHOT</version>"
             + "<version>2.0.4-SNAPSHOT</version></versions></expected>";
index 7ec3c3c011e2c12f95d07495aae0a6ebfa88bf82..0f41f6c32adf960346c0bfba32aa8d137951f2ee 100644 (file)
@@ -27,8 +27,11 @@ import org.junit.After;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.FileTime;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Collections;
@@ -47,13 +50,13 @@ public class DaysOldRepositoryPurgeTest
 {
     private static final int OLD_TIMESTAMP = 1179382029;
 
-    private void setLastModified( String dirPath, long lastModified )
+    private void setLastModified( String dirPath, long lastModified ) throws IOException
     {
-        File dir = new File( dirPath );
-        File[] contents = dir.listFiles();
-        for ( File content : contents )
+        Path dir = Paths.get( dirPath );
+        Path[] contents = Files.list( dir ).toArray(Path[]::new );
+        for ( Path content : contents )
         {
-            content.setLastModified( lastModified );
+            Files.setLastModifiedTime( content, FileTime.fromMillis( lastModified ));
         }
     }
 
@@ -257,16 +260,16 @@ public class DaysOldRepositoryPurgeTest
 
         for ( int i = 5; i <= 7; i++ )
         {
-            File jarFile = new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".jar" );
-            jarFile.createNewFile();
-            File pomFile = new File( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".pom" );
-            pomFile.createNewFile();
+            Path jarFile = Paths.get( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".jar" );
+            Files.createFile( jarFile );
+            Path pomFile = Paths.get( versionRoot, "/plexus-utils-1.4.3-" + timestamp + "-" + i + ".pom" );
+            Files.createFile(pomFile);
 
             // set timestamp to older than 100 days for the first build, but ensure the filename timestamp is honoured instead
             if ( i == 5 )
             {
-                jarFile.setLastModified( OLD_TIMESTAMP );
-                pomFile.setLastModified( OLD_TIMESTAMP );
+                Files.setLastModifiedTime( jarFile, FileTime.fromMillis( OLD_TIMESTAMP ));
+                Files.setLastModifiedTime( pomFile, FileTime.fromMillis( OLD_TIMESTAMP ));
             }
         }
 
index b4ef96da514378e3da71f8e6357aafafffc24c7e..f052915ea60730e170f74f70803b8b630fd37d91 100644 (file)
@@ -33,17 +33,21 @@ import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.model.MetadataFacet;
 import org.apache.archiva.mock.MockRepositorySessionFactory;
-import org.apache.commons.io.FileUtils;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.test.context.ContextConfiguration;
 
-import java.io.File;
+import java.io.IOException;
 import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.FileTime;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -60,6 +64,8 @@ import static org.mockito.Mockito.*;
 public class RepositoryPurgeConsumerTest
     extends AbstractRepositoryPurgeTest
 {
+    private static final Logger log = LoggerFactory.getLogger( RepositoryPurgeConsumerTest.class );
+
     @Before
     @Override
     public void setUp()
@@ -124,24 +130,33 @@ public class RepositoryPurgeConsumerTest
             applicationContext.getBean( "knownRepositoryContentConsumer#repository-purge",
                                         KnownRepositoryContentConsumer.class );
 
-        File repoLocation = new File( "target/test-" + getName() + "/test-repo" );
+        Path repoLocation = Paths.get( "target/test-" + getName() + "/test-repo" );
 
-        File localFile = new File( repoLocation, path );
+        Path localFile = repoLocation.resolve( path );
 
         ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
-        BaseFile baseFile = new BaseFile( repoLocation, localFile );
+        BaseFile baseFile = new BaseFile( repoLocation.toFile(), localFile.toFile() );
         predicate.setBasefile( baseFile );
 
         assertFalse( predicate.evaluate( repoPurgeConsumer ) );
     }
 
-    private void setLastModified( String path )
+    private void setLastModified( String path ) throws IOException
     {
-        File dir = new File( path );
-        File[] contents = dir.listFiles();
+        Path dir = Paths.get( path );
+        Path[] contents = new Path[0];
+        try
+        {
+            contents = Files.list( dir ).toArray(Path[]::new);
+        }
+        catch ( IOException e )
+        {
+            log.error("Could not list files {}: {}", dir, e.getMessage(), e);
+            contents = new Path[0];
+        }
         for ( int i = 0; i < contents.length; i++ )
         {
-            contents[i].setLastModified( 1179382029 );
+            Files.setLastModifiedTime( contents[i], FileTime.fromMillis( 1179382029 ) );
         }
     }
 
@@ -400,9 +415,9 @@ public class RepositoryPurgeConsumerTest
         assertExists( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
 
         // check if metadata file wasn't updated
-        File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
+        Path artifactMetadataFile = Paths.get( projectRoot + "/maven-metadata.xml" );
 
-        String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
+        String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
 
         String expectedVersions = "<expected><versions><version>2.3-SNAPSHOT</version></versions></expected>";
 
@@ -459,9 +474,9 @@ public class RepositoryPurgeConsumerTest
         assertDeleted( projectRoot + "/2.3-SNAPSHOT/maven-plugin-plugin-2.3-SNAPSHOT.pom.sha1" );
 
         // check if metadata file was updated
-        File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
+        Path artifactMetadataFile = Paths.get( projectRoot + "/maven-metadata.xml" );
 
-        String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
+        String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
 
         String expectedVersions =
             "<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
index 8399af0bc1e00159599193a682cd14ee95d3c735..56fdf79944fbd410c8e5519952b7dbf859043d24 100644 (file)
@@ -44,7 +44,8 @@ import org.springframework.stereotype.Service;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Named;
-import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -65,7 +66,7 @@ public class NexusIndexerConsumer
 
     private FileTypes filetypes;
 
-    private File managedRepository;
+    private Path managedRepository;
 
     private ArchivaTaskScheduler<ArtifactIndexingTask> scheduler;
 
@@ -112,7 +113,7 @@ public class NexusIndexerConsumer
         throws ConsumerException
     {
         this.repository = repository;
-        managedRepository = new File( repository.getLocation() );
+        managedRepository = Paths.get( repository.getLocation() );
 
         try
         {
@@ -136,7 +137,7 @@ public class NexusIndexerConsumer
         else
         {
             this.repository = repository;
-            managedRepository = new File( repository.getLocation() );
+            managedRepository = Paths.get( repository.getLocation() );
         }
     }
 
@@ -144,10 +145,10 @@ public class NexusIndexerConsumer
     public void processFile( String path )
         throws ConsumerException
     {
-        File artifactFile = new File( managedRepository, path );
+        Path artifactFile = managedRepository.resolve(path);
 
         ArtifactIndexingTask task =
-            new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD, getIndexingContext() );
+            new ArtifactIndexingTask( repository, artifactFile.toFile(), ArtifactIndexingTask.Action.ADD, getIndexingContext() );
         try
         {
             log.debug( "Queueing indexing task '{}' to add or update the artifact in the index.", task );
@@ -169,11 +170,11 @@ public class NexusIndexerConsumer
         }
         else
         {
-            File artifactFile = new File( managedRepository, path );
+            Path artifactFile = managedRepository.resolve(path);
 
             // specify in indexing task that this is not a repo scan request!
             ArtifactIndexingTask task =
-                new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD,
+                new ArtifactIndexingTask( repository, artifactFile.toFile(), ArtifactIndexingTask.Action.ADD,
                                           getIndexingContext(), false );
             // only update index we don't need to scan the full repo here
             task.setOnlyUpdate( true );
index 91d0c107ce6f48b50dcc5031316c6a001a3cf9a3..7d6ea28eacbe7cdb668f578c8c628e966405030f 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.commons.io.FileUtils;
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexCreator;
 import org.junit.After;
@@ -39,8 +38,10 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
-import java.io.File;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashSet;
@@ -58,7 +59,7 @@ public class NexusIndexerConsumerTest
     private final class ArchivaTaskSchedulerStub
         implements ArchivaTaskScheduler<ArtifactIndexingTask>
     {
-        Set<File> indexed = new HashSet<>();
+        Set<Path> indexed = new HashSet<>();
 
         @Override
         public void queueTask( ArtifactIndexingTask task )
@@ -67,7 +68,7 @@ public class NexusIndexerConsumerTest
             switch ( task.getAction() )
             {
                 case ADD:
-                    indexed.add( task.getResourceFile() );
+                    indexed.add( task.getResourceFile().toPath() );
                     break;
                 case DELETE:
                     indexed.remove( task.getResourceFile() );
@@ -141,13 +142,13 @@ public class NexusIndexerConsumerTest
         throws Exception
     {
         // delete created index in the repository
-        File indexDir = new File( repositoryConfig.getLocation(), ".indexer" );
-        FileUtils.deleteDirectory( indexDir );
-        assertFalse( indexDir.exists() );
+        Path indexDir = Paths.get( repositoryConfig.getLocation(), ".indexer" );
+        org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDir );
+        assertFalse( Files.exists(indexDir) );
 
-        indexDir = new File( repositoryConfig.getLocation(), ".index" );
-        FileUtils.deleteDirectory( indexDir );
-        assertFalse( indexDir.exists() );
+        indexDir = Paths.get( repositoryConfig.getLocation(), ".index" );
+        org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDir );
+        assertFalse( Files.exists(indexDir) );
 
         super.tearDown();
     }
@@ -156,7 +157,7 @@ public class NexusIndexerConsumerTest
     public void testIndexerIndexArtifact()
         throws Exception
     {
-        File artifactFile = new File( repositoryConfig.getLocation(),
+        Path artifactFile = Paths.get( repositoryConfig.getLocation(),
                                       "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
 
         // begin scan
@@ -173,7 +174,7 @@ public class NexusIndexerConsumerTest
     public void testIndexerArtifactAlreadyIndexed()
         throws Exception
     {
-        File artifactFile = new File( repositoryConfig.getLocation(),
+        Path artifactFile = Paths.get( repositoryConfig.getLocation(),
                                       "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
 
         // begin scan
@@ -199,7 +200,7 @@ public class NexusIndexerConsumerTest
     public void testIndexerIndexArtifactThenPom()
         throws Exception
     {
-        File artifactFile = new File( repositoryConfig.getLocation(),
+        Path artifactFile = Paths.get( repositoryConfig.getLocation(),
                                       "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
 
         // begin scan
@@ -212,7 +213,7 @@ public class NexusIndexerConsumerTest
         assertTrue( scheduler.indexed.contains( artifactFile ) );
 
         artifactFile =
-            new File( repositoryConfig.getLocation(), "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
+            Paths.get( repositoryConfig.getLocation(), "org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml" );
 
         // scan and index again
         now = Calendar.getInstance().getTime();