]> source.dussan.org Git - archiva.git/commitdiff
- updated license header
authorEdwin L. Punzalan <epunzalan@apache.org>
Sun, 24 Dec 2006 04:25:44 +0000 (04:25 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Sun, 24 Dec 2006 04:25:44 +0000 (04:25 +0000)
- made some tests pass

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@489979 13f79535-47bb-0310-9956-ffa450edef68

archiva-webapp-test/pom.xml
archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java
archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java

index da44137591e42e9e5b06c221c7d2f148e5e0cb20..d9df433dfb0fdfe4c94402b931cda166ff672564 100644 (file)
             <log>${project.build.directory}/logs/${container.name}.log</log>
             <output>${project.build.directory}/logs/${container.name}.out</output>
             <timeout>600000</timeout>
+            <systemProperties>
+              <appserver.base>${project.build.directory}</appserver.base>
+            </systemProperties>
           </container>
           <configuration>
             <home>${project.build.directory}/${container.name}conf</home>
index 5cb1c8d071f9480df1f46e3b9a69cf1048716fc7..1fa2d0e142120f2638a6323623daa4093c7cb9ea 100644 (file)
@@ -1,26 +1,26 @@
 package org.apache.maven.archiva.web.test;
 
 /*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
-import com.thoughtworks.selenium.Selenium;
 import org.apache.maven.shared.web.test.AbstractSeleniumTestCase;
 
-import java.util.Calendar;
-
 /**
  * @author Edwin Punzalan
  */
@@ -29,8 +29,6 @@ public abstract class AbstractArchivaTestCase
 {
     private String baseUrl = "http://localhost:9595/archiva";
 
-    public static final String CREATE_ADMIN_USER_PAGE_TITLE = "Maven Archiva :: Create Admin User";
-
     protected String getApplicationName()
     {
         return "Archiva";
@@ -41,6 +39,25 @@ public abstract class AbstractArchivaTestCase
         return "2005";
     }
 
+    protected void postAdminUserCreation()
+    {
+        if ( getTitle().equals( getTitlePrefix() + "Configuration" ) )
+        {
+            //Add Managed Repository
+            setFieldValue( "id", "web-ui" );
+            setFieldValue( "urlName", "web-ui" );
+            setFieldValue( "name", "Web UI Test Managed Repository" );
+            setFieldValue( "directory", getBasedir() + "target/web-ui-dir" );
+            clickButtonWithValue( "AddRepository" );
+
+            //Set Index location
+            assertPage( "Configuration" );
+            setFieldValue( "indexPath", getBasedir() + "target/web-ui-index" );
+            clickButtonWithValue( "Save Configuration" );
+            assertPage( "Administration" );
+        }
+    }
+
     public void assertHeader()
     {
         assertTrue( "banner is missing" , getSelenium().isElementPresent( "xpath=//div[@id='banner']" ) );
@@ -50,13 +67,23 @@ public abstract class AbstractArchivaTestCase
             "/span[@id='bannerLeft']/a[@href='http://maven.apache.org/archiva/']" ) );
         assertTrue( "bannerLeft img is missing" , getSelenium().isElementPresent( "xpath=//div[@id='banner']" +
             "/span[@id='bannerLeft']/a[@href='http://maven.apache.org/archiva/']" +
-            "/img[@src='http://maven.apache.org/images/maven.jpg']" ) );
+            "/img[@src='" + getWebContext() + "/images/archiva.png']" ) );
 
         assertTrue( "bannerRight is missing",  getSelenium().isElementPresent( "xpath=//div[@id='banner']/span[@id='bannerRight']" ) );
     }
 
+    protected String getTitlePrefix()
+    {
+        return "Maven Archiva :: ";
+    }
+
     public String getBaseUrl()
     {
         return baseUrl;
     }
+
+    protected String getWebContext()
+    {
+        return "/archiva";
+    }
 }
index 1cb0099faaa9a06355782349537f454f896dd061..a86ee7480d56fb5beeb89f2739887be240b2fa60 100644 (file)
@@ -1,23 +1,24 @@
 package org.apache.maven.archiva.web.test;
 
 /*
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
-import com.thoughtworks.selenium.Selenium;
-
 /**
  * @author Edwin Punzalan
  */
@@ -28,36 +29,77 @@ public class LoginTest
     {
         goToLoginPage();
         submitLoginPage( "badUsername", "badPassword", false );
-        assertTextPresent( "Authentication failed" );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
     }
 
     public void testUserLogin()
     {
-        createUser( "user", "user01" );
+        createUser( "test-user", "temp-pass" );
+
         goToLoginPage();
-        submitLoginPage( "user", "user01" );
+        submitLoginPage( "test-user", "temp-pass" );
+
+        if ( getTitle().equals( getTitlePrefix() + "Change Password" ) )
+        {
+            setFieldValue( "existingPassword", "temp-pass" );
+            setFieldValue( "newPassword", "p4ssw0rd" );
+            setFieldValue( "newPasswordConfirm", "p4ssw0rd" );
+            clickButtonWithValue( "Change Password" );
+        }
+
+        logout();
+
+        deleteUser( "test-user" );
     }
 
     private void createUser( String username, String password )
     {
-        Selenium sel = getSelenium();
-
         goToLoginPage();
         submitLoginPage( adminUsername, adminPassword );
 
-        sel.open( "/archiva/security/userlist.action" );
-        assertPage( "Maven Archiva :: [Admin] User List" );
-        assertTextNotPresent( username );
-        sel.open( "/archiva/security/usercreate!show.action" );
-        assertPage( "Maven Archiva :: [Admin] User Create" );
-        sel.type( "user.username", username );
-        sel.type( "user.fullName", username + " FullName" );
-        sel.type( "user.email", username + "@localhost.com" );
-        sel.type( "user.password", password );
-        sel.type( "user.confirmPassword", password );
-        sel.click( "//input[@type='submit' and @value='Create User']" );
+        clickLinkWithText( "User Management" );
+        assertPage( "[Admin] User List" );
+        assertLinkNotPresent( username );
+        clickButtonWithValue( "Create New User" );
+
+        assertPage( "[Admin] User Create" );
+        setFieldValue( "user.username", username );
+        setFieldValue( "user.fullName", username + " FullName" );
+        setFieldValue( "user.email", username + "@localhost.com" );
+        setFieldValue( "user.password", password );
+        setFieldValue( "user.confirmPassword", password );
+        clickButtonWithValue( "Create User" );
         waitPage();
-        assertPage( "Maven Archiva :: [Admin] User List" );
-        assertTextPresent( username );
+        assertPage( "[Admin] User List" );
+        assertLinkPresent( username );
+
+        logout();
+    }
+
+    private void deleteUser( String username )
+    {
+        goToLoginPage();
+        submitLoginPage( adminUsername, adminPassword );
+
+        clickLinkWithText( "User Management" );
+        assertPage( "[Admin] User List" );
+
+        try
+        {
+            Thread.sleep( 15000 );
+        }
+        catch ( InterruptedException e )
+        {
+            e.printStackTrace();
+        }
+
+        assertLinkPresent( username );
+        clickLinkWithXPath( "//a[@href='/security/userdelete.action?username=" + username + "']" );
+        assertPage( "[Admin] User Delete" );
+        assertTextPresent( "The following user will be deleted: " + username );
+        clickButtonWithValue( "Delete User" );
+        assertPage( "[Admin] User List" );
+
+        logout();
     }
 }