From bc60ebcc8cf39b03765e54cdc0793b2227783195 Mon Sep 17 00:00:00 2001 From: "Edwin L. Punzalan" Date: Sun, 24 Dec 2006 04:25:44 +0000 Subject: [PATCH] - updated license header - 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 | 3 + .../web/test/AbstractArchivaTestCase.java | 61 +++++++--- .../maven/archiva/web/test/LoginTest.java | 104 ++++++++++++------ 3 files changed, 120 insertions(+), 48 deletions(-) diff --git a/archiva-webapp-test/pom.xml b/archiva-webapp-test/pom.xml index da4413759..d9df433df 100644 --- a/archiva-webapp-test/pom.xml +++ b/archiva-webapp-test/pom.xml @@ -167,6 +167,9 @@ ${project.build.directory}/logs/${container.name}.log ${project.build.directory}/logs/${container.name}.out 600000 + + ${project.build.directory} + ${project.build.directory}/${container.name}conf diff --git a/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java b/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java index 5cb1c8d07..1fa2d0e14 100644 --- a/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java +++ b/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/AbstractArchivaTestCase.java @@ -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"; + } } diff --git a/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java b/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java index 1cb0099fa..a86ee7480 100644 --- a/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java +++ b/archiva-webapp-test/src/test/it/org/apache/maven/archiva/web/test/LoginTest.java @@ -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(); } } -- 2.39.5