mirror of https://github.com/apache/archiva.git
fix code format
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1178738 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9675668bcb
commit
a30ed7be7f
|
@ -19,15 +19,11 @@ 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.model.ArtifactReference;
|
|
||||||
import org.apache.archiva.repository.RepositoryContentFactory;
|
|
||||||
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
|
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
|
||||||
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.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,35 +36,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()
|
private 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 )
|
||||||
|
@ -77,19 +73,20 @@ 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() throws Exception
|
public void clean( )
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null )
|
if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ) != null )
|
||||||
|
@ -106,15 +103,15 @@ public class CopyArtifactTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void copyToAnEmptyRepo()
|
public void copyToAnEmptyRepo( )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
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" );
|
||||||
|
@ -127,26 +124,25 @@ public class CopyArtifactTest
|
||||||
// END SNIPPET: copy-artifact
|
// END SNIPPET: copy-artifact
|
||||||
assertTrue( res );
|
assertTrue( res );
|
||||||
|
|
||||||
|
|
||||||
String targetRepoPath =
|
String targetRepoPath =
|
||||||
getManagedRepositoriesService( authorizationHeader ).getManagedRepository( TARGET_REPO_ID ).getLocation();
|
getManagedRepositoriesService( authorizationHeader ).getManagedRepository( 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 !!
|
||||||
clean();
|
clean( );
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void copyToAnExistingRepo()
|
public void copyToAnExistingRepo( )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
initSourceTargetRepo();
|
initSourceTargetRepo( );
|
||||||
clean();
|
clean( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue