From 378090d19855d0acc4b9613f8569a8a7d52d31ee Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 12 Feb 2010 13:36:08 +0000 Subject: [PATCH] make sure we always use a valid path in the upload form git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@909402 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/archiva/web/test/BrowseTest.java | 11 +++------- .../web/test/parent/AbstractArchivaTest.java | 21 ++++++++++++++++++- .../AbstractArtifactManagementTest.java | 14 ++----------- 3 files changed, 25 insertions(+), 21 deletions(-) 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 92b69fa05..a82a8f584 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 @@ -48,10 +48,6 @@ public class BrowseTest @Test(groups = {"requiresUpload"}) 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 @@ -64,10 +60,10 @@ public class BrowseTest String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" ); + String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar"; // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well) // upload a snapshot artifact to repository 'releases' - addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(), - releasesRepo ); + addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo ); assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" ); goToBrowsePage(); @@ -77,8 +73,7 @@ public class BrowseTest 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 ); + addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo ); assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" ); goToBrowsePage(); 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 dbe8caac9..356caf966 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 @@ -1,6 +1,7 @@ package org.apache.archiva.web.test.parent; import java.io.File; +import java.io.IOException; import org.apache.archiva.web.test.XPathExpressionUtil; @@ -495,7 +496,25 @@ public abstract class AbstractArchivaTest checkField( "generatePom" ); } - setFieldValue( "artifact", artifactFilePath ); + String path; + if ( artifactFilePath != null && artifactFilePath.trim().length() > 0 ) + { + File f = new File( artifactFilePath ); + try + { + path = f.getCanonicalPath(); + } + catch ( IOException e ) + { + path = f.getAbsolutePath(); + } + } + else + { + path = artifactFilePath; + } + + setFieldValue( "artifact", path ); setFieldValue( "repositoryId", repositoryId ); clickButtonWithValue( "Submit" ); 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 f92ea26c6..29486cd10 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 @@ -1,8 +1,6 @@ package org.apache.archiva.web.test.parent; -import java.io.*; - -public abstract class AbstractArtifactManagementTest +public abstract class AbstractArtifactManagementTest extends AbstractArchivaTest { @@ -32,15 +30,7 @@ public abstract class AbstractArtifactManagementTest public String getArtifactFilePath() { - File f = new File( "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" ); - try - { - return f.getCanonicalPath(); - } - catch ( IOException e ) - { - return f.getAbsolutePath(); - } + return "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar"; } public String getRepositoryId() -- 2.39.5