diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java index 9eb1faf86..1bf9a544f 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java @@ -19,15 +19,11 @@ package org.apache.archiva.rest.services; */ import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.repository.RepositoryContentFactory; import org.apache.archiva.rest.api.model.ArtifactTransferRequest; import org.apache.archiva.rest.api.services.RepositoriesService; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; import org.junit.Test; -import javax.inject.Inject; import java.io.File; /** @@ -40,35 +36,35 @@ public class CopyArtifactTest static final String SOURCE_REPO_ID = "test-origin-repo"; - private void initSourceTargetRepo() + private void initSourceTargetRepo( ) throws Exception { File targetRepo = new File( "target/test-repo-copy" ); - if ( targetRepo.exists() ) + if ( targetRepo.exists( ) ) { FileUtils.deleteDirectory( targetRepo ); } - assertFalse( targetRepo.exists() ); - targetRepo.mkdirs(); + assertFalse( targetRepo.exists( ) ); + targetRepo.mkdirs( ); if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null ) { getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( TARGET_REPO_ID, true ); assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) ); } - ManagedRepository managedRepository = getTestManagedRepository(); + ManagedRepository managedRepository = getTestManagedRepository( ); managedRepository.setId( TARGET_REPO_ID ); - managedRepository.setLocation( targetRepo.getCanonicalPath() ); + managedRepository.setLocation( targetRepo.getCanonicalPath( ) ); managedRepository.setCronExpression( "* * * * * ?" ); getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) ); File originRepo = new File( "target/test-origin-repo" ); - if ( originRepo.exists() ) + if ( originRepo.exists( ) ) { FileUtils.deleteDirectory( originRepo ); } - assertFalse( originRepo.exists() ); + assertFalse( originRepo.exists( ) ); FileUtils.copyDirectory( new File( "src/test/repo-with-osgi" ), originRepo ); if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) != null ) @@ -77,19 +73,20 @@ public class CopyArtifactTest assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) ); } - managedRepository = getTestManagedRepository(); + managedRepository = getTestManagedRepository( ); managedRepository.setId( SOURCE_REPO_ID ); - managedRepository.setLocation( originRepo.getCanonicalPath() ); + managedRepository.setLocation( originRepo.getCanonicalPath( ) ); getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) ); - getArchivaAdministrationService().addKnownContentConsumer( "create-missing-checksums" ); - getArchivaAdministrationService().addKnownContentConsumer( "metadata-updater" ); + getArchivaAdministrationService( ).addKnownContentConsumer( "create-missing-checksums" ); + getArchivaAdministrationService( ).addKnownContentConsumer( "metadata-updater" ); } - public void clean() throws Exception + public void clean( ) + throws Exception { if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null ) @@ -106,15 +103,15 @@ public class CopyArtifactTest } @Test - public void copyToAnEmptyRepo() + public void copyToAnEmptyRepo( ) throws Exception { - initSourceTargetRepo(); + initSourceTargetRepo( ); // START SNIPPET: copy-artifact // configure the artifact you want to copy // if package ommited default will be jar - ArtifactTransferRequest artifactTransferRequest = new ArtifactTransferRequest(); + ArtifactTransferRequest artifactTransferRequest = new ArtifactTransferRequest( ); artifactTransferRequest.setGroupId( "org.apache.karaf.features" ); artifactTransferRequest.setArtifactId( "org.apache.karaf.features.core" ); artifactTransferRequest.setVersion( "2.2.2" ); @@ -127,26 +124,25 @@ public class CopyArtifactTest // END SNIPPET: copy-artifact assertTrue( res ); - String targetRepoPath = - getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ).getLocation(); + getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ).getLocation( ); File artifact = new File( targetRepoPath, "/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar" ); - assertTrue( artifact.exists() ); + assertTrue( artifact.exists( ) ); File pom = new File( targetRepoPath, "/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.pom" ); - assertTrue( "not exists " + pom.getPath(), pom.exists() ); + assertTrue( "not exists " + pom.getPath( ), pom.exists( ) ); // TODO find a way to force metadata generation and test it !! - clean(); + clean( ); } //@Test - public void copyToAnExistingRepo() + public void copyToAnExistingRepo( ) throws Exception { - initSourceTargetRepo(); - clean(); + initSourceTargetRepo( ); + clean( ); } }