aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-10-11 19:26:31 +0000
committerOlivier Lamy <olamy@apache.org>2012-10-11 19:26:31 +0000
commitdb43bb93394bd38dde8b01a3b5927648c2ac9a91 (patch)
treefab4686b1c70184783a21d3330fb245d6cee93d0
parentfce214d021f886fccdcb54e3d2cc11d8f9c25fc0 (diff)
downloadarchiva-db43bb93394bd38dde8b01a3b5927648c2ac9a91.tar.gz
archiva-db43bb93394bd38dde8b01a3b5927648c2ac9a91.zip
add unit test to ensure we delete artifact without setting the packaging
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1397249 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java72
1 files changed, 69 insertions, 3 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
index 3a7416c97..827802fde 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
@@ -43,7 +43,7 @@ public class RepositoriesServiceTest
extends AbstractArchivaRestTest
{
- @Test( expected = ServerWebApplicationException.class )
+ @Test ( expected = ServerWebApplicationException.class )
public void scanRepoKarmaFailed()
throws Exception
{
@@ -79,7 +79,7 @@ public class RepositoriesServiceTest
assertTrue( service.scanRepository( repoId, true ) );
}
- @Test( expected = ServerWebApplicationException.class )
+ @Test ( expected = ServerWebApplicationException.class )
public void deleteArtifactKarmaFailed()
throws Exception
{
@@ -104,7 +104,7 @@ public class RepositoriesServiceTest
}
}
- @Test( expected = ServerWebApplicationException.class )
+ @Test ( expected = ServerWebApplicationException.class )
public void deleteWithRepoNull()
throws Exception
{
@@ -129,6 +129,72 @@ public class RepositoriesServiceTest
}
+ /**
+ * delete a version of an artifact without packaging
+ *
+ * @throws Exception
+ */
+ @Test
+ public void deleteArtifactVersion()
+ throws Exception
+ {
+ initSourceTargetRepo();
+
+ BrowseService browseService = getBrowseService( authorizationHeader, false );
+
+ List<Artifact> artifacts =
+ browseService.getArtifactDownloadInfos( "org.apache.karaf.features", "org.apache.karaf.features.core",
+ "2.2.2", SOURCE_REPO_ID );
+
+ log.info( "artifacts: {}", artifacts );
+
+ Assertions.assertThat( artifacts ).isNotNull().isNotEmpty().hasSize( 2 );
+
+ VersionsList versionsList =
+ browseService.getVersionsList( "org.apache.karaf.features", "org.apache.karaf.features.core",
+ SOURCE_REPO_ID );
+ Assertions.assertThat( versionsList.getVersions() ).isNotNull().isNotEmpty().hasSize( 2 );
+
+ log.info( "artifacts.size: {}", artifacts.size() );
+
+ try
+ {
+ File artifactFile = new File(
+ "target/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar" );
+
+ assertTrue( "artifact not exists:" + artifactFile.getPath(), artifactFile.exists() );
+
+ Artifact artifact = new Artifact();
+ artifact.setGroupId( "org.apache.karaf.features" );
+ artifact.setArtifactId( "org.apache.karaf.features.core" );
+ artifact.setVersion( "2.2.2" );
+ artifact.setContext( SOURCE_REPO_ID );
+
+ RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader );
+
+ repositoriesService.deleteArtifact( artifact );
+
+ assertFalse( "artifact not deleted exists:" + artifactFile.getPath(), artifactFile.exists() );
+
+ artifacts =
+ browseService.getArtifactDownloadInfos( "org.apache.karaf.features", "org.apache.karaf.features.core",
+ "2.2.2", SOURCE_REPO_ID );
+
+ Assertions.assertThat( artifacts ).isNotNull().isEmpty();
+
+ versionsList = browseService.getVersionsList( "org.apache.karaf.features", "org.apache.karaf.features.core",
+ SOURCE_REPO_ID );
+
+ Assertions.assertThat( versionsList.getVersions() ).isNotNull().isNotEmpty().hasSize( 1 );
+
+ }
+ finally
+ {
+ cleanRepos();
+ }
+ }
+
+
@Test
public void deleteArtifact()
throws Exception