From 6317bd9d026d6e8691e88e1a81c6d5a6ae456f80 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 23 Mar 2015 15:00:51 +1100 Subject: [PATCH] add unit test for [MRM-1877] --- .../org/apache/archiva/checksum/ChecksummedFile.java | 5 +++-- .../core/ArtifactMissingChecksumsConsumer.java | 12 +++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java b/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java index 0f36ce1c1..de9484736 100644 --- a/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java +++ b/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java @@ -98,8 +98,9 @@ public class ChecksummedFile File checksumFile = new File( referenceFile.getAbsolutePath() + "." + checksumAlgorithm.getExt() ); Files.deleteIfExists( checksumFile.toPath() ); String checksum = calculateChecksum( checksumAlgorithm ); - Files.write( checksumFile.toPath(), (checksum + " " + referenceFile.getName()).getBytes(), StandardOpenOption.CREATE_NEW ); - //FileUtils.writeStringToFile( checksumFile, checksum + " " + referenceFile.getName() ); + Files.write( checksumFile.toPath(), // + ( checksum + " " + referenceFile.getName() ).getBytes(), // + StandardOpenOption.CREATE_NEW ); return checksumFile; } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java index 9b5510ca2..ebb5997b9 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java @@ -27,10 +27,10 @@ import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.KnownRepositoryContentConsumer; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -42,8 +42,6 @@ import java.util.List; /** * ArtifactMissingChecksumsConsumer - Create missing and/or fix invalid checksums for the artifact. - * - * */ @Service( "knownRepositoryContentConsumer#create-missing-checksums" ) @Scope( "prototype" ) @@ -98,7 +96,7 @@ public class ArtifactMissingChecksumsConsumer { return this.description; } - + @Override public void beginScan( ManagedRepository repo, Date whenGathered ) throws ConsumerException @@ -155,7 +153,7 @@ 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() );//+ "." + File checksumFile = new File( this.repositoryDir, path + "." + checksumAlgorithm.getExt() ); if ( checksumFile.exists() ) { @@ -182,7 +180,7 @@ public class ArtifactMissingChecksumsConsumer try { checksum.createChecksum( checksumAlgorithm ); - log.info( "Created missing checksum file {}", checksumFile.getAbsolutePath() ); + log.info( "Created missing checksum file {}", checksumFile.getAbsolutePath() ); triggerConsumerInfo( "Created missing checksum file " + checksumFile.getAbsolutePath() ); } catch ( IOException e )