]> source.dussan.org Git - archiva.git/commitdiff
make sure we always use a valid path in the upload form
authorBrett Porter <brett@apache.org>
Fri, 12 Feb 2010 13:36:08 +0000 (13:36 +0000)
committerBrett Porter <brett@apache.org>
Fri, 12 Feb 2010 13:36:08 +0000 (13:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@909402 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java

index 92b69fa05cfdf78a577896825468cc6a93647695..a82a8f5849256e24457a9eb8b5ffd39d1aa5e416 100644 (file)
@@ -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();
index dbe8caac9c81195c831f536bd86a37b355f4d197..356caf9666dcffd287c75481dac32aeb6a8573f3 100644 (file)
@@ -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" );
index f92ea26c6a293e37304976053ebba0cac7404446..29486cd1031cdfb7427d21c6df344d2adaee4ad3 100644 (file)
@@ -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()