- 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
This commit is contained in:
Edwin L. Punzalan 2006-12-24 04:25:44 +00:00
parent a4f0edf9aa
commit bc60ebcc8c
3 changed files with 120 additions and 48 deletions

View File

@ -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>

View 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";
}
}

View 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();
}
}