fix formatting no functionnal changes

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1199825 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-11-09 16:20:20 +00:00
parent 14b5f5d731
commit f92d281874
1 changed files with 28 additions and 29 deletions

View File

@ -20,7 +20,6 @@ package org.apache.archiva.rest.services;
import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.rest.api.model.ArtifactTransferRequest; import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.RepositoriesService; import org.apache.archiva.rest.api.services.RepositoriesService;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -39,35 +38,35 @@ public class CopyArtifactTest
static final String SOURCE_REPO_ID = "test-origin-repo"; static final String SOURCE_REPO_ID = "test-origin-repo";
private void initSourceTargetRepo( ) protected void initSourceTargetRepo()
throws Exception throws Exception
{ {
File targetRepo = new File( "target/test-repo-copy" ); File targetRepo = new File( "target/test-repo-copy" );
if ( targetRepo.exists( ) ) if ( targetRepo.exists() )
{ {
FileUtils.deleteDirectory( targetRepo ); FileUtils.deleteDirectory( targetRepo );
} }
assertFalse( targetRepo.exists( ) ); assertFalse( targetRepo.exists() );
targetRepo.mkdirs( ); targetRepo.mkdirs();
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null ) if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null )
{ {
getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( TARGET_REPO_ID, true ); getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( TARGET_REPO_ID, true );
assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) ); assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) );
} }
ManagedRepository managedRepository = getTestManagedRepository( ); ManagedRepository managedRepository = getTestManagedRepository();
managedRepository.setId( TARGET_REPO_ID ); managedRepository.setId( TARGET_REPO_ID );
managedRepository.setLocation( targetRepo.getCanonicalPath( ) ); managedRepository.setLocation( targetRepo.getCanonicalPath() );
managedRepository.setCronExpression( "* * * * * ?" ); managedRepository.setCronExpression( "* * * * * ?" );
getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository );
assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) ); assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) );
File originRepo = new File( "target/test-origin-repo" ); File originRepo = new File( "target/test-origin-repo" );
if ( originRepo.exists( ) ) if ( originRepo.exists() )
{ {
FileUtils.deleteDirectory( originRepo ); FileUtils.deleteDirectory( originRepo );
} }
assertFalse( originRepo.exists( ) ); assertFalse( originRepo.exists() );
FileUtils.copyDirectory( new File( "src/test/repo-with-osgi" ), originRepo ); FileUtils.copyDirectory( new File( "src/test/repo-with-osgi" ), originRepo );
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) != null ) if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) != null )
@ -76,19 +75,19 @@ public class CopyArtifactTest
assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) ); assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) );
} }
managedRepository = getTestManagedRepository( ); managedRepository = getTestManagedRepository();
managedRepository.setId( SOURCE_REPO_ID ); managedRepository.setId( SOURCE_REPO_ID );
managedRepository.setLocation( originRepo.getCanonicalPath( ) ); managedRepository.setLocation( originRepo.getCanonicalPath() );
getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository );
assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) ); assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SOURCE_REPO_ID ) );
getArchivaAdministrationService( ).addKnownContentConsumer( "create-missing-checksums" ); getArchivaAdministrationService().addKnownContentConsumer( "create-missing-checksums" );
getArchivaAdministrationService( ).addKnownContentConsumer( "metadata-updater" ); getArchivaAdministrationService().addKnownContentConsumer( "metadata-updater" );
} }
public void clean( ) public void clean()
throws Exception throws Exception
{ {
@ -106,17 +105,17 @@ public class CopyArtifactTest
} }
@Test @Test
public void copyToAnEmptyRepo( ) public void copyToAnEmptyRepo()
throws Exception throws Exception
{ {
try try
{ {
initSourceTargetRepo( ); initSourceTargetRepo();
// START SNIPPET: copy-artifact // START SNIPPET: copy-artifact
// configure the artifact you want to copy // configure the artifact you want to copy
// if package ommited default will be jar // if package ommited default will be jar
ArtifactTransferRequest artifactTransferRequest = new ArtifactTransferRequest( ); ArtifactTransferRequest artifactTransferRequest = new ArtifactTransferRequest();
artifactTransferRequest.setGroupId( "org.apache.karaf.features" ); artifactTransferRequest.setGroupId( "org.apache.karaf.features" );
artifactTransferRequest.setArtifactId( "org.apache.karaf.features.core" ); artifactTransferRequest.setArtifactId( "org.apache.karaf.features.core" );
artifactTransferRequest.setVersion( "2.2.2" ); artifactTransferRequest.setVersion( "2.2.2" );
@ -130,32 +129,32 @@ public class CopyArtifactTest
assertTrue( res ); assertTrue( res );
String targetRepoPath = getManagedRepositoriesService( authorizationHeader ).getManagedRepository( String targetRepoPath = getManagedRepositoriesService( authorizationHeader ).getManagedRepository(
TARGET_REPO_ID ).getLocation( ); TARGET_REPO_ID ).getLocation();
File artifact = new File( targetRepoPath, 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" ); "/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, 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" ); "/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 !! // TODO find a way to force metadata generation and test it !!
} }
finally finally
{ {
clean( ); clean();
} }
} }
@Test( expected = ServerWebApplicationException.class ) @Test( expected = ServerWebApplicationException.class )
public void copyNonExistingArtifact( ) public void copyNonExistingArtifact()
throws Throwable throws Throwable
{ {
try try
{ {
initSourceTargetRepo( ); initSourceTargetRepo();
ArtifactTransferRequest artifactTransferRequest = new ArtifactTransferRequest( ); ArtifactTransferRequest artifactTransferRequest = new ArtifactTransferRequest();
artifactTransferRequest.setGroupId( "org.apache.karaf.features" ); artifactTransferRequest.setGroupId( "org.apache.karaf.features" );
artifactTransferRequest.setArtifactId( "org.apache.karaf.features.core" ); artifactTransferRequest.setArtifactId( "org.apache.karaf.features.core" );
artifactTransferRequest.setVersion( "3.0.6552" ); artifactTransferRequest.setVersion( "3.0.6552" );
@ -167,21 +166,21 @@ public class CopyArtifactTest
} }
catch ( ServerWebApplicationException e ) catch ( ServerWebApplicationException e )
{ {
assertTrue( StringUtils.contains( e.getMessage( ), "cannot find artifact" ) ); assertTrue( StringUtils.contains( e.getMessage(), "cannot find artifact" ) );
throw e; throw e;
} }
finally finally
{ {
clean( ); clean();
} }
} }
//@Test //@Test
public void copyToAnExistingRepo( ) public void copyToAnExistingRepo()
throws Exception throws Exception
{ {
initSourceTargetRepo( ); initSourceTargetRepo();
clean( ); clean();
} }
} }