diff options
author | Brett Porter <brett@apache.org> | 2009-11-25 06:55:27 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-11-25 06:55:27 +0000 |
commit | 8a0aa76e24cdf63a5b9e709ae29457da70ab8580 (patch) | |
tree | afbec44a428bf67c5d5ee075409da8ed3d6805b3 | |
parent | 7a52fa2fbf3d80043f35864bfd301c5cee6811be (diff) | |
parent | 2fa9e76dfcf7ad1020d64a8797d2cd40c9994776 (diff) | |
download | archiva-8a0aa76e24cdf63a5b9e709ae29457da70ab8580.tar.gz archiva-8a0aa76e24cdf63a5b9e709ae29457da70ab8580.zip |
Merged /archiva/trunk:r882384-883981
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@883995 13f79535-47bb-0310-9956-ffa450edef68
33 files changed, 591 insertions, 188 deletions
diff --git a/archiva-docs/src/site/apt/adminguide/repositories.apt b/archiva-docs/src/site/apt/adminguide/repositories.apt index ac9ad7f9b..f4927d6f4 100644 --- a/archiva-docs/src/site/apt/adminguide/repositories.apt +++ b/archiva-docs/src/site/apt/adminguide/repositories.apt @@ -67,6 +67,9 @@ Understanding Repository Configuration of Apache Archiva * <releases included> - specifies whether there are released artifacts in the repository. + * <block re-deployment of released artifacts> - specifies whether released artifacts that are already existing in the repository can be overwritten. + Note that this only take effects for non-snapshot deployments. + * <snapshots included> - specifies whether there are snapshot artifacts in the repository. * <scannable> - specifies whether the repository can be scanned, meaning it is a local repository which can be indexed, browsed, diff --git a/archiva-docs/src/site/apt/userguide/deploy.apt b/archiva-docs/src/site/apt/userguide/deploy.apt index e552df3c5..06099e2cb 100644 --- a/archiva-docs/src/site/apt/userguide/deploy.apt +++ b/archiva-docs/src/site/apt/userguide/deploy.apt @@ -10,6 +10,9 @@ Deploying to Repository * {{{#Web UI} Deploying via the Web UI Form}} + Starting with Archiva 1.2.3, it is possible to block re-deployment of released artifacts to a specific repository. This can be configured through the + repository configuration page by ticking the <<<Block Re-deployment of Released Artifacts>>> checkbox. + [] <<WARNING>> The deployed artifact may not appear immediately in the search results. diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 13ca8bccb..717721c91 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -476,6 +476,13 @@ <defaultValue>true</defaultValue> </field> <field> + <name>blockRedeployments</name> + <version>1.0.0+</version> + <type>boolean</type> + <description>True if re-deployment of artifacts already in the repository will be blocked.</description> + <defaultValue>false</defaultValue> + </field> + <field> <name>snapshots</name> <version>1.0.0+</version> <type>boolean</type> diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml b/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml index 12473f3f1..51b54f82f 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml @@ -9,6 +9,7 @@ <layout>default</layout> <releases>true</releases> <snapshots>false</snapshots> + <blockRedeployments>true</blockRedeployments> <scanned>true</scanned> <refreshCronExpression>0 0 * * * ?</refreshCronExpression> <daysOlder>30</daysOlder> @@ -20,6 +21,7 @@ <layout>default</layout> <releases>false</releases> <snapshots>true</snapshots> + <blockRedeployments>false</blockRedeployments> <scanned>true</scanned> <refreshCronExpression>0 0\,30 * * * ?</refreshCronExpression> <daysOlder>30</daysOlder> diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties index d427a9cbf..3940355ab 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties @@ -95,3 +95,7 @@ NETWORKPROXY_HOSTNAME= NETWORKPROXY_PORT=8080 NETWORKPROXY_USERNAME=admin NETWORKPROXY_PASSWORD=admin123 + +# Browse - MRM-1278 test +SNAPSHOTS_REPOSITORY=snapshots +RELEASES_REPOSITORY=releases diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java index a0104e336..ca03471de 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java @@ -88,6 +88,14 @@ public class ArtifactManagementTest addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); assertTextPresent( "Artifact 'test:test:1.0' was successfully deployed to repository 'internal'" ); } + + //MRM-747 + @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) + public void testAddArtifactBlockRedeployments() + { + addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); + assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." ); + } public void testAddArtifactValidValues1() { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java index c2cf2186d..ab6ba818a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java @@ -19,6 +19,8 @@ package org.apache.archiva.web.test; * under the License. */ +import java.io.File; + import org.apache.archiva.web.test.parent.AbstractBrowseTest; import org.testng.annotations.Test; @@ -42,4 +44,71 @@ public class BrowseTest assertTextPresent( "Artifacts" ); } + // MRM-1278 + public void testCorrectRepositoryInBrowse() + { + File artifact = + new File( getBasedir(), + "/src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" ); + + String releasesRepo = getProperty( "RELEASES_REPOSITORY" ); + + // create releases repository first + goToRepositoriesPage(); + clickLinkWithText( "Add" ); + addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository", + new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository", + "0 0 * * * ?", "", "" ); + assertTextPresent( "Releases Repository" ); + + String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" ); + + // upload a snapshot artifact to repository 'releases' + addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(), + releasesRepo ); + assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" ); + + goToBrowsePage(); + assertBrowsePage(); + assertGroupsPage( "archiva/" ); + assertArtifactsPage( "archiva-webapp/" ); + assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" ); + + // upload a snapshot artifact to repository 'snapshots' + addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", artifact.getPath(), + snapshotsRepo ); + assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" ); + + goToBrowsePage(); + assertBrowsePage(); + assertGroupsPage( "continuum/" ); + assertArtifactsPage( "continuum-core/" ); + assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" ); + } + + private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId, + String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging ) + { + clickLinkWithText( version ); + assertPage( "Apache Archiva \\ Browse Repository" ); + assertTextPresent( artifactInfoRepositoryId ); + assertTextPresent( artifactInfoGroupId ); + assertTextPresent( artifactInfoArtifactId ); + assertTextPresent( artifactInfoVersion ); + assertTextPresent( artifactInfoPackaging ); + } + + private void assertArtifactsPage( String artifactId ) + { + clickLinkWithText( artifactId ); + assertPage( "Apache Archiva \\ Browse Repository" ); + assertTextPresent( "Versions" ); + } + + private void assertGroupsPage( String groupId ) + { + clickLinkWithText( groupId ); + assertPage( "Apache Archiva \\ Browse Repository" ); + assertTextPresent( "Artifacts" ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java index fbeb00cca..a6d2fd122 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java @@ -30,18 +30,18 @@ public class RepositoryTest public void testAddManagedRepoValidValues() { goToRepositoriesPage(); - clickLinkWithText( "Add" ); + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" ); addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" ); clickButtonWithValue( "Save" ); - assertTextPresent( "Managed Repository Sample 1" ); - + assertTextPresent( "Managed Repository Sample 1" ); + assertRepositoriesPage(); } - + @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) public void testAddManagedRepoInvalidValues() - { - //goToRepositoriesPage(); - clickLinkWithText( "Add" ); + { + assertRepositoriesPage(); + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" ); addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" ); assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository name." ); @@ -51,8 +51,7 @@ public class RepositoryTest @Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } ) public void testAddManagedRepoNoIdentifier() - { - //goToRepositoriesPage(); + { addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" ); assertTextPresent( "You must enter a repository identifier." ); } @@ -104,11 +103,10 @@ public class RepositoryTest //assertTextNotPresent( "managedrepo" ); } - @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) + @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } ) public void testAddRemoteRepoNullValues() - { - //goToRepositoriesPage(); - clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" ); + { + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" ); addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" ); assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository name." ); @@ -136,11 +134,10 @@ public class RepositoryTest assertTextPresent( "You must enter a url." ); } - @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) + @Test(dependsOnMethods = { "testDeleteManageRepo" } ) public void testAddRemoteRepoValidValues() - { - goToRepositoriesPage(); - clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" ); + { + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" ); addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" ); assertTextPresent( "Remote Repository Sample" ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java index ddd42ec6e..7fc155b8a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java @@ -40,7 +40,7 @@ public class VirtualRepositoryTest assertTextPresent( "testing" ); } - //@Test(dependsOnMethods = { "testAddRepositoryValidValue" } ) + @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } ) public void testAddRepositoryToRepositoryGroup() { addRepositoryToRepositoryGroup( "testing", "internal" ); @@ -51,15 +51,17 @@ public class VirtualRepositoryTest @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) public void testDeleteRepositoryOfRepositoryGroup() - { + { deleteRepositoryInRepositoryGroups(); assertTextPresent( "Repository Groups" ); assertTextNotPresent( "No Repository Groups Defined." ); + waitPage(); } @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } ) public void testDeleteRepositoryGroup() - { + { + assertRepositoryGroupsPage(); deleteRepositoryGroup( "testing" ); assertTextPresent( "No Repository Groups Defined." ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java index 3b622eae9..95e2fa853 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java @@ -449,25 +449,86 @@ public abstract class AbstractArchivaTest setFieldValue( "organisationLogo" , logoUrl ); clickButtonWithValue( "Save" ); } - - //Upload Artifact - public void goToUploadArtifactPage() - { - clickLinkWithText( "Upload Artifact" ); - assertUploadArtifactPage(); - } - - public void assertUploadArtifactPage() - { - //assertPage( "Apache Archiva \\ Upload Artifact" ); - String uploadArtifact = "Upload Artifact,Group Id*,Artifact Id*,Version*,Packaging*,Classifier,Generate Maven 2 POM,Artifact File*,POM File,Repository Id"; - String[] arrayUploadArtifact = uploadArtifact.split( "," ); - for ( String uploadartifact : arrayUploadArtifact ) - assertTextPresent( uploadartifact ); - String uploadElements = "groupId,artifactId,version,packaging,classifier,generatePom,artifact,pom,repositoryId"; - String[] arrayUploadElements = uploadElements.split( "," ); - for ( String uploadelements : arrayUploadElements ) - assertElementPresent( uploadelements ); - assertButtonWithValuePresent( "Submit" ); - } + + // Upload Artifact + public void goToAddArtifactPage() + { + clickLinkWithText( "Upload Artifact" ); + assertAddArtifactPage(); + } + + public void assertAddArtifactPage() + { + assertPage( "Apache Archiva \\ Upload Artifact" ); + assertTextPresent( "Upload Artifact" ); + + String artifact = + "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:"; + String[] arrayArtifact = artifact.split( "," ); + for ( String arrayartifact : arrayArtifact ) + assertTextPresent( arrayartifact ); + + String artifactElements = + "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0"; + String[] arrayArtifactElements = artifactElements.split( "," ); + for ( String artifactelements : arrayArtifactElements ) + assertElementPresent( artifactelements ); + } + + public void addArtifact( String groupId, String artifactId, String version, String packaging, + String artifactFilePath, String repositoryId ) + { + addArtifact( groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId ); + } + + public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom, + String artifactFilePath, String repositoryId ) + { + goToAddArtifactPage(); + setFieldValue( "groupId", groupId ); + setFieldValue( "artifactId", artifactId ); + setFieldValue( "version", version ); + setFieldValue( "packaging", packaging ); + + if ( generatePom ) + { + checkField( "generatePom" ); + } + + setFieldValue( "artifact", artifactFilePath ); + setFieldValue( "repositoryId", repositoryId ); + + clickButtonWithValue( "Submit" ); + } + + public void goToRepositoriesPage() + { + clickLinkWithText( "Repositories" ); + assertRepositoriesPage(); + } + + public void assertRepositoriesPage() + { + assertPage( "Apache Archiva \\ Administration - Repositories" ); + assertTextPresent( "Administration - Repositories" ); + assertTextPresent( "Managed Repositories" ); + assertTextPresent( "Remote Repositories" ); + } + + public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, + String daysOlder, String retentionCount ) + { + //goToRepositoriesPage(); + //clickLinkWithText( "Add" ); + setFieldValue( "repository.id" , identifier ); + setFieldValue( "repository.name" , name ); + setFieldValue( "repository.location" , directory ); + setFieldValue( "repository.indexDir" , indexDirectory ); + selectValue( "repository.layout", type ); + setFieldValue( "repository.refreshCronExpression" , cron ); + setFieldValue( "repository.daysOlder" , daysOlder ); + setFieldValue( "repository.retentionCount" , retentionCount ); + //TODO + clickButtonWithValue( "Add Repository" ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java index db3bd70b8..830c39cd7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java @@ -43,42 +43,12 @@ public abstract class AbstractArtifactManagementTest return repositoryId; } - public void goToAddArtifactPage() - { - clickLinkWithText( "Upload Artifact" ); - assertAddArtifactPage(); - } - public void goToDeleteArtifactPage() { clickLinkWithText( "Delete Artifact" ); assertDeleteArtifactPage(); } - public void addArtifact( String groupId, String artifactId, String version, String packaging, String artifactFilePath, String repositoryId ) - { - addArtifact(groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId); - } - - public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom, String artifactFilePath, String repositoryId) - { - goToAddArtifactPage(); - setFieldValue( "groupId" , groupId ); - setFieldValue( "artifactId" , artifactId ); - setFieldValue( "version" , version ); - setFieldValue( "packaging" , packaging ); - - if ( generatePom ) - { - checkField( "generatePom" ); - } - - setFieldValue( "artifact" , artifactFilePath ); - setFieldValue( "repositoryId" , repositoryId ); - - clickButtonWithValue( "Submit" ); - } - public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId ) { goToDeleteArtifactPage(); @@ -89,22 +59,6 @@ public abstract class AbstractArtifactManagementTest clickButtonWithValue( "Submit" ) ; } - public void assertAddArtifactPage() - { - assertPage( "Apache Archiva \\ Upload Artifact" ); - assertTextPresent( "Upload Artifact" ); - - String artifact = "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:"; - String[] arrayArtifact = artifact.split( "," ); - for ( String arrayartifact : arrayArtifact ) - assertTextPresent( arrayartifact ); - - String artifactElements = "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0"; - String[] arrayArtifactElements = artifactElements.split( "," ); - for ( String artifactelements : arrayArtifactElements ) - assertElementPresent( artifactelements ); - } - public void assertDeleteArtifactPage() { assertPage( "Apache Archiva \\ Delete Artifact" ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java index 6b0cf721c..cd651e967 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java @@ -212,23 +212,6 @@ public abstract class AbstractRepositoryTest clickButtonWithValue( "Delete" ); } - /////////////////////////////// - // repositories - /////////////////////////////// - public void goToRepositoriesPage() - { - clickLinkWithText( "Repositories" ); - assertRepositoriesPage(); - } - - public void assertRepositoriesPage() - { - assertPage( "Apache Archiva \\ Administration - Repositories" ); - assertTextPresent( "Administration - Repositories" ); - assertTextPresent( "Managed Repositories" ); - assertTextPresent( "Remote Repositories" ); - } - // remote repositories public void assertAddRemoteRepository() { @@ -283,23 +266,6 @@ public abstract class AbstractRepositoryTest clickButtonWithValue( "Update Repository" ); } - // managed repositories - public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount ) - { - //goToRepositoriesPage(); - //clickLinkWithText( "Add" ); - setFieldValue( "repository.id" , identifier ); - setFieldValue( "repository.name" , name ); - setFieldValue( "repository.location" , directory ); - setFieldValue( "repository.indexDir" , indexDirectory ); - selectValue( "repository.layout", type ); - setFieldValue( "repository.refreshCronExpression" , cron ); - setFieldValue( "repository.daysOlder" , daysOlder ); - setFieldValue( "repository.retentionCount" , retentionCount ); - //TODO - clickButtonWithValue( "Add Repository" ); - } - public void editManagedRepository( String fieldName, String value ) { //goToRepositoriesPage(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java index 1fb439012..f1b63ae2a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java @@ -372,7 +372,7 @@ public class ShowArtifactAction this.snapshotVersions = snapshotVersions; } - public MetadataResolver getMetadataRepository() + public MetadataResolver getMetadataResolver() { return metadataResolver; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java index f5155f136..18cb2f64d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java @@ -349,8 +349,17 @@ public class UploadAction try { - copyFile( artifactFile, targetPath, filename, fixChecksums ); - queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) ); + File targetFile = new File( targetPath, filename ); + if( targetFile.exists() && !VersionUtil.isSnapshot( version ) && repoConfig.isBlockRedeployments() ) + { + addActionError( "Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed." ); + return ERROR; + } + else + { + copyFile( artifactFile, targetPath, filename, fixChecksums ); + queueRepositoryTask( repository.getId(), repository.toFile( artifactReference ) ); + } } catch ( IOException ie ) { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java index b51bc7f94..97151c816 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java @@ -52,13 +52,15 @@ public class AddManagedRepositoryAction { this.repository = new ManagedRepositoryConfiguration(); this.repository.setReleases( false ); - this.repository.setScanned( false ); + this.repository.setScanned( false ); + this.repository.setBlockRedeployments( false ); } public String input() { this.repository.setReleases( true ); this.repository.setScanned( true ); + this.repository.setBlockRedeployments( true ); return INPUT; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java index de0cdd242..f128ba152 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java @@ -25,12 +25,19 @@ import com.opensymphony.xwork2.Validateable; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.ArchivaDatabaseException; +import org.apache.maven.archiva.database.ObjectNotFoundException; +import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; +import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint; +import org.apache.maven.archiva.model.RepositoryContentStatistics; import org.apache.maven.archiva.repository.audit.AuditEvent; import org.codehaus.plexus.redback.role.RoleManagerException; import org.codehaus.plexus.scheduler.CronExpressionValidator; import java.io.File; import java.io.IOException; +import java.util.List; /** * AddManagedRepositoryAction @@ -52,6 +59,11 @@ public class EditManagedRepositoryAction private final String action = "editRepository"; + /** + * @plexus.requirement role-hint="jdo" + */ + private ArchivaDAO archivaDAO; + public void prepare() { if ( StringUtils.isNotBlank( repoid ) ) @@ -78,17 +90,22 @@ public class EditManagedRepositoryAction public String confirmUpdate() { - return save(); + // location was changed + return save( true ); } public String commit() - { + { ManagedRepositoryConfiguration existingConfig = archivaConfiguration.getConfiguration().findManagedRepositoryById( repository.getId() ); - + + boolean resetStats = false; + // check if the location was changed if( !StringUtils.equalsIgnoreCase( existingConfig.getLocation().trim(), repository.getLocation().trim() ) ) { + resetStats = true; + File dir = new File( repository.getLocation() ); if( dir.exists() ) { @@ -96,10 +113,10 @@ public class EditManagedRepositoryAction } } - return save(); + return save( resetStats ); } - - private String save() + + private String save( boolean resetStats ) { // Ensure that the fields are valid. Configuration configuration = archivaConfiguration.getConfiguration(); @@ -115,6 +132,7 @@ public class EditManagedRepositoryAction triggerAuditEvent( repository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO ); addRepositoryRoles( repository ); result = saveConfiguration( configuration ); + resetStatistics( resetStats ); } catch ( IOException e ) { @@ -126,6 +144,16 @@ public class EditManagedRepositoryAction addActionError( "Role Manager Exception: " + e.getMessage() ); result = ERROR; } + catch ( ObjectNotFoundException e ) + { + addActionError( e.getMessage() ); + result = ERROR; + } + catch ( ArchivaDatabaseException e ) + { + addActionError( e.getMessage() ); + result = ERROR; + } return result; } @@ -141,6 +169,28 @@ public class EditManagedRepositoryAction } } + private void resetStatistics( boolean reset ) + throws ObjectNotFoundException, ArchivaDatabaseException + { + if ( !reset ) + { + return; + } + + RepositoryContentStatisticsDAO repoContentStatsDao = archivaDAO.getRepositoryContentStatisticsDAO(); + + List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics( + new RepositoryContentStatisticsByRepositoryConstraint( repository.getId() ) ); + + if ( contentStats != null ) + { + for ( RepositoryContentStatistics stats : contentStats ) + { + repoContentStatsDao.deleteRepositoryContentStatistics( stats ); + } + } + } + public String getRepoid() { return repoid; @@ -165,4 +215,11 @@ public class EditManagedRepositoryAction { return action; } + + // for testing + + public void setArchivaDAO( ArchivaDAO archivaDao ) + { + this.archivaDAO = archivaDao; + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index f640639d8..6f4a80950 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -30,14 +30,15 @@ <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:application.properties" /> </bean> - - <bean name="testXmlRpcService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.PingServiceImpl"/> <bean name="xmlRpcUserRepositories" class="org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories"> <constructor-arg ref="userRepositories"/> <constructor-arg ref="xmlRpcAuthenticator"/> </bean> + <!-- Web Service : Ping Service --> + <bean name="pingService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.PingServiceImpl"/> + <!-- Web Services : Search Service --> <bean name="searchService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.SearchServiceImpl"> <constructor-arg ref="xmlRpcUserRepositories"/> @@ -64,6 +65,7 @@ <list> <ref bean="administrationService"/> <ref bean="searchService"/> + <ref bean="pingService"/> </list> </constructor-arg> </bean> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf index 4c7f44191..f040f4962 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/repositoryForm.jspf @@ -28,6 +28,7 @@ <s:textfield name="repository.daysOlder" label="Repository Purge By Days Older Than" size="5"/> <s:textfield name="repository.retentionCount" label="Repository Purge By Retention Count" size="5"/> <s:checkbox name="repository.releases" value="repository.releases" label="Releases Included"/> +<s:checkbox name="repository.blockRedeployments" value="repository.blockRedeployments" label="Block Re-deployment of Released Artifacts"/> <s:checkbox name="repository.snapshots" value="repository.snapshots" label="Snapshots Included"/> <s:checkbox name="repository.scanned" value="repository.scanned" label="Scannable"/> <s:checkbox name="repository.deleteReleasedSnapshots" value="repository.deleteReleasedSnapshots" diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java index 58341922e..5d4ab0853 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java @@ -437,6 +437,6 @@ public class ShowArtifactActionTest { super.setUp(); action = (ShowArtifactAction) lookup( Action.class, ACTION_HINT ); - metadataResolver = (TestMetadataResolver) action.getMetadataRepository(); + metadataResolver = (TestMetadataResolver) action.getMetadataResolver(); } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java index 0902a319a..9131af530 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java @@ -96,6 +96,7 @@ public class UploadActionTest repoConfig.setLayout( "default" ); repoConfig.setLocation( testRepo.getPath() ); repoConfig.setName( REPOSITORY_ID ); + repoConfig.setBlockRedeployments( true ); config.addManagedRepository( repoConfig ); RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration(); @@ -335,7 +336,7 @@ public class UploadActionTest public void testArtifactUploadFailedRepositoryNotFound() throws Exception - { + { setUploadParameters( "1.0", null, new File( getBasedir(), "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null, @@ -404,9 +405,9 @@ public class UploadActionTest true ); ManagedRepositoryContent content = new ManagedDefaultRepositoryContent(); - content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ); - - + ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID ); + repoConfig.setBlockRedeployments( false ); + content.setRepository( repoConfig ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content ); @@ -450,5 +451,81 @@ public class UploadActionTest assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation ); verifyChecksums( repoLocation ); - } + } + + public void testUploadArtifactAlreadyExistingRedeploymentsBlocked() + throws Exception + { + setUploadParameters( "1.0", null, + new File( getBasedir(), + "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null, + true ); + + ManagedRepositoryContent content = new ManagedDefaultRepositoryContent(); + content.setRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 ); + repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 ); + + archivaConfigControl.replay(); + repoFactoryControl.replay(); + + String returnString = uploadAction.doUpload(); + assertEquals( Action.SUCCESS, returnString ); + + setUploadParameters( "1.0", null, + new File( getBasedir(), + "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null, + true ); + + returnString = uploadAction.doUpload(); + assertEquals( Action.ERROR, returnString ); + + archivaConfigControl.verify(); + repoFactoryControl.verify(); + + String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation(); + assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation ); + + verifyChecksums( repoLocation ); + } + + public void testUploadArtifactAlreadyExistingRedeploymentsAllowed() + throws Exception + { + setUploadParameters( "1.0", null, + new File( getBasedir(), + "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null, + true ); + + ManagedRepositoryContent content = new ManagedDefaultRepositoryContent(); + ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID ); + repoConfig.setBlockRedeployments( false ); + content.setRepository( repoConfig ); + + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 ); + repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 ); + + archivaConfigControl.replay(); + repoFactoryControl.replay(); + + String returnString = uploadAction.doUpload(); + assertEquals( Action.SUCCESS, returnString ); + + setUploadParameters( "1.0", null, + new File( getBasedir(), + "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ), null, + true ); + + returnString = uploadAction.doUpload(); + assertEquals( Action.SUCCESS, returnString ); + + archivaConfigControl.verify(); + repoFactoryControl.verify(); + + String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation(); + assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation ); + + verifyChecksums( repoLocation ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java index c3f3dd5b2..e688f8a29 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java @@ -23,6 +23,10 @@ import com.opensymphony.xwork2.Action; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; +import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint; +import org.apache.maven.archiva.model.RepositoryContentStatistics; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.redback.integration.interceptor.SecureActionBundle; @@ -32,7 +36,10 @@ import org.easymock.MockControl; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; +import java.util.Date; +import java.util.List; /** * EditManagedRepositoryActionTest @@ -52,6 +59,14 @@ public class EditManagedRepositoryActionTest private ArchivaConfiguration archivaConfiguration; + private MockControl archivaDaoControl; + + private ArchivaDAO archivaDao; + + private MockControl repoContentStatsDaoControl; + + private RepositoryContentStatisticsDAO repoContentStatsDao; + private static final String REPO_ID = "repo-ident"; private File location; @@ -77,6 +92,13 @@ public class EditManagedRepositoryActionTest roleManager = (RoleManager) roleManagerControl.getMock(); action.setRoleManager( roleManager ); location = getTestFile( "target/test/location" ); + + archivaDaoControl = MockControl.createControl( ArchivaDAO.class ); + archivaDao = (ArchivaDAO) archivaDaoControl.getMock(); + action.setArchivaDAO( archivaDao ); + + repoContentStatsDaoControl = MockControl.createControl( RepositoryContentStatisticsDAO.class ); + repoContentStatsDao = (RepositoryContentStatisticsDAO) repoContentStatsDaoControl.getMock(); } public void testSecureActionBundle() @@ -157,6 +179,66 @@ public class EditManagedRepositoryActionTest roleManagerControl.verify(); archivaConfigurationControl.verify(); } + + public void testEditRepositoryLocationChanged() + throws Exception + { + roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID ); + roleManagerControl.setReturnValue( false ); + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID ); + roleManagerControl.setVoidCallable(); + roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); + roleManagerControl.setReturnValue( false ); + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); + roleManagerControl.setVoidCallable(); + + roleManagerControl.replay(); + + Configuration configuration = createConfigurationForEditing( createRepository() ); + archivaConfiguration.getConfiguration(); + archivaConfigurationControl.setReturnValue( configuration ); + archivaConfigurationControl.setReturnValue( configuration ); + archivaConfigurationControl.setReturnValue( configuration ); + + archivaConfiguration.save( configuration ); + + archivaConfigurationControl.replay(); + + archivaDaoControl.expectAndReturn( archivaDao.getRepositoryContentStatisticsDAO(), repoContentStatsDao ); + + archivaDaoControl.replay(); + + repoContentStatsDao.queryRepositoryContentStatistics( + new RepositoryContentStatisticsByRepositoryConstraint( REPO_ID ) ); + repoContentStatsDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); + + List<RepositoryContentStatistics> repoStats = createRepositoryContentStatisticsList(); + repoContentStatsDaoControl.setReturnValue( repoStats ); + + repoContentStatsDao.deleteRepositoryContentStatistics( repoStats.get( 0 ) ); + repoContentStatsDaoControl.setVoidCallable(); + repoContentStatsDao.deleteRepositoryContentStatistics( repoStats.get( 1 ) ); + repoContentStatsDaoControl.setVoidCallable(); + + repoContentStatsDaoControl.replay(); + + action.setRepoid( REPO_ID ); + action.prepare(); + assertEquals( REPO_ID, action.getRepoid() ); + + ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration(); + populateRepository( repository ); + repository.setLocation( new File( "target/test/location/new" ).getCanonicalPath() ); + action.setRepository( repository ); + String status = action.commit(); + assertEquals( Action.SUCCESS, status ); + assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() ); + + roleManagerControl.verify(); + archivaConfigurationControl.verify(); + archivaDaoControl.verify(); + repoContentStatsDaoControl.verify(); + } private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository, ManagedRepositoryConfiguration actualRepository ) @@ -207,4 +289,29 @@ public class EditManagedRepositoryActionTest repository.setDeleteReleasedSnapshots( true ); } + private List<RepositoryContentStatistics> createRepositoryContentStatisticsList() + { + List<RepositoryContentStatistics> repoStatsList = new ArrayList<RepositoryContentStatistics>(); + + repoStatsList.add( createRepositoryContentStatistics() ); + repoStatsList.add( createRepositoryContentStatistics() ); + + return repoStatsList; + } + + private RepositoryContentStatistics createRepositoryContentStatistics() + { + RepositoryContentStatistics repoStats = new RepositoryContentStatistics(); + repoStats.setRepositoryId( REPO_ID ); + repoStats.setDuration( 1000 ); + repoStats.setTotalArtifactCount( 100 ); + repoStats.setTotalSize( 10 ); + repoStats.setTotalFileCount( 10 ); + repoStats.setTotalProjectCount( 2 ); + repoStats.setTotalGroupCount( 1 ); + repoStats.setNewFileCount( 3 ); + repoStats.setWhenGathered( new Date( System.currentTimeMillis() ) ); + + return repoStats; + } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index ba7915913..c1cd85cf3 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -484,7 +484,7 @@ public class ArchivaDavResourceFactory String resourcePath = logicalResource.getPath(); // check if target repo is enabled for releases - // we suppose that release-artifacts can deployed only to repos enabled for releases + // we suppose that release-artifacts can be deployed only to repos enabled for releases if ( managedRepository.getRepository().isReleases() && !repositoryRequest.isMetadata( resourcePath ) && !repositoryRequest.isSupportFile( resourcePath ) ) { @@ -495,10 +495,10 @@ public class ArchivaDavResourceFactory if ( !VersionUtil.isSnapshot( artifact.getVersion() ) ) { - // check if artifact already exists - if ( managedRepository.hasContent( artifact ) ) + // check if artifact already exists and if artifact re-deployment to the repository is allowed + if ( managedRepository.hasContent( artifact ) && managedRepository.getRepository().isBlockRedeployments() ) { - log.warn( "Overwriting released artifacts is not allowed." ); + log.warn( "Overwriting released artifacts in repository '" + managedRepository.getId() + "' is not allowed." ); throw new DavException( HttpServletResponse.SC_CONFLICT, "Overwriting released artifacts is not allowed." ); } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java index a0ec2c811..c7bccf47e 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/AbstractRepositoryServletTestCase.java @@ -119,12 +119,14 @@ public abstract class AbstractRepositoryServletTestCase response.getResponseCode() ); } - protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location ) + protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location, boolean blockRedeployments ) { ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration(); repo.setId( id ); repo.setName( name ); repo.setLocation( location.getAbsolutePath() ); + repo.setBlockRedeployments( blockRedeployments ); + return repo; } @@ -182,7 +184,7 @@ public abstract class AbstractRepositoryServletTestCase repoRootInternal = new File( appserverBase, "data/repositories/internal" ); Configuration config = archivaConfiguration.getConfiguration(); - config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) ); + config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true ) ); saveConfiguration( archivaConfiguration ); CacheManager.getInstance().removeCache( "url-failures-cache" ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java index 2e8a7ad8e..5f6693d1f 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletDeployTest.java @@ -27,6 +27,8 @@ import java.io.File; import java.io.InputStream; import javax.servlet.http.HttpServletResponse; + +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.webdav.httpunit.MkColMethodWebRequest; @@ -98,6 +100,46 @@ public class RepositoryServletDeployTest assertResponseConflictError( response ); } + public void testReleaseArtifactsRedeploymentIsAllowed() + throws Exception + { + setupCleanRepo( repoRootInternal ); + + ManagedRepositoryConfiguration managedRepo = archivaConfiguration.getConfiguration().findManagedRepositoryById( REPOID_INTERNAL ); + managedRepo.setBlockRedeployments( false ); + + saveConfiguration( archivaConfiguration ); + + String putUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT; + String metadataUrl = "http://machine.com/repository/internal/path/to/artifact/maven-metadata.xml"; + String checksumUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT + ".sha1"; + + InputStream is = getClass().getResourceAsStream( "/artifact.jar" ); + // verify that the file exists in resources-dir + assertNotNull( "artifact.jar inputstream", is ); + + // send request #1 and verify it's successful + WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); + WebResponse response = sc.getResponse( request ); + assertResponseCreated( response ); + + is = getClass().getResourceAsStream( "/artifact.jar.sha1" ); + request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" ); + response = sc.getResponse( request ); + assertResponseCreated( response ); + + is = getClass().getResourceAsStream( "/maven-metadata.xml" ); + request = new PutMethodWebRequest( metadataUrl, is, "application/octet-stream" ); + response = sc.getResponse( request ); + assertResponseCreated( response ); + + // send request #2 and verify if it's still successful + is = getClass().getResourceAsStream( "/artifact.jar" ); + request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" ); + response = sc.getResponse( request ); + assertResponseNoContent( response ); + } + public void testReleaseArtifactsRedeploymentInvalidPath() throws Exception { diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java index 13b8fc871..ca9706a45 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletRepositoryGroupTest.java @@ -90,8 +90,8 @@ public class RepositoryServletRepositoryGroupTest repoRootFirst = new File( appserverBase, "data/repositories/" + MANAGED_REPO_FIRST ); repoRootLast = new File( appserverBase, "data/repositories/" + MANAGED_REPO_LAST ); - configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) ); - configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) ); + configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) ); + configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) ); List<String> managedRepoIds = new ArrayList<String>(); managedRepoIds.add( MANAGED_REPO_FIRST ); @@ -101,11 +101,11 @@ public class RepositoryServletRepositoryGroupTest // Create the repository group with an invalid managed repository repoRootInvalid = new File( appserverBase, "data/repositories/" + MANAGED_REPO_INVALID ); - ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid ); + ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository( MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true ); - configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst ) ); + configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true ) ); configuration.addManagedRepository( managedRepositoryConfiguration ); - configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast ) ); + configuration.addManagedRepository( createManagedRepository( MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true ) ); List<String> invalidManagedRepoIds = new ArrayList<String>(); invalidManagedRepoIds.add( MANAGED_REPO_FIRST ); diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/PingService.java index 5eba5144d..492f655fe 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/PingService.java @@ -21,8 +21,8 @@ package org.apache.archiva.web.xmlrpc.api; import com.atlassian.xmlrpc.ServiceObject; -@ServiceObject("Test") -public interface TestService +@ServiceObject("PingService") +public interface PingService { public String ping(); } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Artifact.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Artifact.java index d55c978f5..7c1176cac 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Artifact.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Artifact.java @@ -75,6 +75,11 @@ public class Artifact { return type; } + + public String getRepositoryId() + { + return repositoryId; + } /*public Date getWhenGathered() { @@ -104,20 +109,16 @@ public class Artifact { this.type = type; } + + @ServiceBeanField( "repositoryId" ) + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } /*@ServiceBeanField( "whenGathered" ) public void setWhenGathered( Date whenGathered ) { this.whenGathered = whenGathered; - }*/ - - public String getRepositoryId() - { - return repositoryId; - } - - public void setRepositoryId( String repositoryId ) - { - this.repositoryId = repositoryId; - } + }*/ } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java index f53041805..15a42a74a 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java @@ -23,6 +23,7 @@ import java.net.URL; import java.util.List; import org.apache.archiva.web.xmlrpc.api.AdministrationService; +import org.apache.archiva.web.xmlrpc.api.PingService; import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; @@ -55,6 +56,10 @@ public class SampleClient { AuthenticationInfo authnInfo = new AuthenticationInfo( args[1], args[2] ); AdministrationService adminService = binder.bind( AdministrationService.class, new URL( args[0] ), authnInfo ); + PingService pingService = binder.bind( PingService.class, new URL( args[0] ), authnInfo ); + + System.out.println( "Ping : " + pingService.ping() ); + List<ManagedRepository> managedRepos = adminService.getAllManagedRepositories(); System.out.println( "\n******** Managed Repositories ********" ); diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java index b7119e067..97fe32990 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/ServiceMethodsPermissionsMapping.java @@ -49,5 +49,6 @@ public class ServiceMethodsPermissionsMapping "SearchService.getArtifactVersions", "SearchService.getArtifactVersionsByDate", "SearchService.getDependencies", "SearchService.getDependencyTree", "SearchService.getDependees" ); - + + public static final String PING = "PingService.ping"; } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java index 19f854461..663a37e09 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java @@ -132,7 +132,11 @@ public class XmlRpcAuthenticator {
throw new XmlRpcException( 401, e.getMessage() );
}
- }
+ }
+ else if ( methodName.equals( ServiceMethodsPermissionsMapping.PING ) )
+ {
+ return new AuthorizationResult( true, username, null );
+ }
else
{
return securitySystem.authorize( session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE );
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java index aa47f5f0e..14b0d2870 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java @@ -19,9 +19,9 @@ package org.apache.archiva.web.xmlrpc.services; * under the License.
*/
-import org.apache.archiva.web.xmlrpc.api.TestService;
+import org.apache.archiva.web.xmlrpc.api.PingService;
-public class PingServiceImpl implements TestService
+public class PingServiceImpl implements PingService
{
public String ping()
{
diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java index 16974f12e..539fd7a66 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java @@ -104,33 +104,35 @@ public class SearchServiceImpl resultHit.setVersion( null ); resultHit.setVersions( filterTimestampedSnapshots( versions ) ); } - + List<String> resultHitVersions = resultHit.getVersions(); if( resultHitVersions != null ) { for( String version : resultHitVersions ) - { + { try { ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version ); + String repoId = repoBrowsing.getRepositoryId( "", observableRepos, resultHit.getGroupId(), resultHit.getArtifactId(), version ); + Artifact artifact = null; if( model == null ) { - artifact = new Artifact( resultHit.getRepositoryId(), resultHit.getGroupId(), resultHit.getArtifactId(), version, "jar" ); + artifact = new Artifact( repoId, resultHit.getGroupId(), resultHit.getArtifactId(), version, "jar" ); } else { - artifact = new Artifact( resultHit.getRepositoryId(), model.getGroupId(), model.getArtifactId(), version, model.getPackaging() ); + artifact = new Artifact( repoId, model.getGroupId(), model.getArtifactId(), version, model.getPackaging() ); } artifacts.add( artifact ); } catch( ObjectNotFoundException e ) - { + { log.debug( "Unable to find pom artifact : " + e.getMessage() ); } catch( ArchivaDatabaseException e ) - { + { log.debug( "Error occurred while getting pom artifact from database : " + e.getMessage() ); } } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java index 6f28bf008..6d7bdf5aa 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java @@ -117,8 +117,8 @@ public class SearchServiceImplTest SearchResultHit resultHit = new SearchResultHit(); resultHit.setGroupId( "org.apache.archiva" ); resultHit.setArtifactId( "archiva-webapp" ); - resultHit.setRepositoryId("repo1.mirror"); resultHit.setVersions( versions ); + resultHit.setRepositoryId( null ); results.addHit( SearchUtil.getHitId( "org.apache.archiva", "archiva-webapp" ), resultHit ); @@ -136,6 +136,8 @@ public class SearchServiceImplTest model.setPackaging( "war" ); repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-webapp", "1.0" ), model ); + + repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, "org.apache.archiva", "archiva-webapp", "1.0" ), "repo1.mirror" ); userReposControl.replay(); searchControl.replay(); @@ -152,12 +154,13 @@ public class SearchServiceImplTest assertNotNull( artifacts ); assertEquals( 1, artifacts.size() ); - Artifact hit = artifacts.get( 0 ); - assertEquals( "org.apache.archiva", hit.getGroupId() ); - assertEquals( "archiva-webapp", hit.getArtifactId() ); - assertEquals( "1.0", hit.getVersion() ); - assertEquals( "war", hit.getType() ); - assertEquals( "repo1.mirror", hit.getRepositoryId() ); + Artifact artifact = artifacts.get( 0 ); + assertEquals( "org.apache.archiva", artifact.getGroupId() ); + assertEquals( "archiva-webapp", artifact.getArtifactId() ); + assertEquals( "1.0", artifact.getVersion() ); + assertEquals( "war", artifact.getType() ); + assertNotNull( "Repository should not be null!", artifact.getRepositoryId() ); + assertEquals( "repo1.mirror", artifact.getRepositoryId() ); } // returned model is null! @@ -175,7 +178,7 @@ public class SearchServiceImplTest versions.add( "1.0" ); SearchResultHit resultHit = new SearchResultHit(); - resultHit.setRepositoryId( "repo1.mirror" ); + resultHit.setRepositoryId( null ); resultHit.setGroupId( "org.apache.archiva" ); resultHit.setArtifactId( "archiva-test" ); resultHit.setVersions( versions ); @@ -191,6 +194,8 @@ public class SearchServiceImplTest repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), null ); + repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), null ); + userReposControl.replay(); searchControl.replay(); repoBrowsingControl.replay(); @@ -206,12 +211,12 @@ public class SearchServiceImplTest assertNotNull( artifacts ); assertEquals( 1, artifacts.size() ); - Artifact hit = artifacts.get( 0 ); - assertEquals( "org.apache.archiva", hit.getGroupId() ); - assertEquals( "archiva-test", hit.getArtifactId() ); - assertEquals( "1.0", hit.getVersion() ); - assertEquals( "jar", hit.getType() ); - assertEquals( "repo1.mirror", hit.getRepositoryId() ); + Artifact artifact = artifacts.get( 0 ); + assertEquals( "org.apache.archiva", artifact.getGroupId() ); + assertEquals( "archiva-test", artifact.getArtifactId() ); + assertEquals( "1.0", artifact.getVersion() ); + assertEquals( "jar", artifact.getType() ); + assertNull( "Repository should be null since the model was not found in the database!", artifact.getRepositoryId() ); } /* @@ -290,7 +295,7 @@ public class SearchServiceImplTest resultHit.setGroupId( "org.apache.archiva" ); resultHit.setArtifactId( "archiva-test" ); resultHit.setVersions( versions ); - resultHit.setRepositoryId("repo1.mirror"); + resultHit.setRepositoryId( null ); results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit ); @@ -309,6 +314,8 @@ public class SearchServiceImplTest repoBrowsingControl.expectAndReturn( repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), model ); + repoBrowsingControl.expectAndReturn( repoBrowsing.getRepositoryId( "", observableRepoIds, "org.apache.archiva", "archiva-test", "1.0" ), "repo1.mirror" ); + userReposControl.replay(); searchControl.replay(); archivaDAOControl.replay(); @@ -323,6 +330,14 @@ public class SearchServiceImplTest assertNotNull( artifacts ); assertEquals( 1, artifacts.size() ); + + Artifact artifact = artifacts.get( 0 ); + assertEquals( "org.apache.archiva", artifact.getGroupId() ); + assertEquals( "archiva-test", artifact.getArtifactId() ); + assertEquals( "1.0", artifact.getVersion() ); + assertEquals( "jar", artifact.getType() ); + assertNotNull( "Repository should not be null!", artifact.getRepositoryId() ); + assertEquals( "repo1.mirror", artifact.getRepositoryId() ); } public void testQuickSearchNoResults( ) |