You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ep...@apache.org on 2006/12/24 05:25:44 UTC

svn commit: r489979 - in /maven/archiva/trunk/archiva-webapp-test: pom.xml src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java src/test/it/org/apache/maven/archiva/web/test/LoginTest.java

Author: epunzalan
Date: Sat Dec 23 20:25:44 2006
New Revision: 489979

URL: http://svn.apache.org/viewvc?view=rev&rev=489979
Log:
- updated license header
- made some tests pass

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

Modified: maven/archiva/trunk/archiva-webapp-test/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp-test/pom.xml?view=diff&rev=489979&r1=489978&r2=489979
==============================================================================
--- maven/archiva/trunk/archiva-webapp-test/pom.xml (original)
+++ maven/archiva/trunk/archiva-webapp-test/pom.xml Sat Dec 23 20:25:44 2006
@@ -167,6 +167,9 @@
             <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>

Modified: maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java?view=diff&rev=489979&r1=489978&r2=489979
==============================================================================
--- maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java (original)
+++ maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java Sat Dec 23 20:25:44 2006
@@ -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 @@
 {
     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 @@
         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 @@
             "/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";
     }
 }

Modified: maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java?view=diff&rev=489979&r1=489978&r2=489979
==============================================================================
--- maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java (original)
+++ maven/archiva/trunk/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java Sat Dec 23 20:25:44 2006
@@ -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 @@
     {
         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();
     }
 }