mirror of https://github.com/apache/archiva.git
[MRM-1276] Selenium tests need a clean up
-transferred the contents of src/test/it-resources to src/test/resources git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@928992 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d19e50fef1
commit
edf2cd3a40
|
@ -247,22 +247,22 @@
|
|||
<configuration>
|
||||
<tasks>
|
||||
<copy todir="${project.build.directory}/appserver-base">
|
||||
<fileset dir="src/test/it-resources/appserver-base" />
|
||||
<fileset dir="src/test/resources/appserver-base" />
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/repository">
|
||||
<fileset dir="src/test/it-resources/repository" />
|
||||
<fileset dir="src/test/resources/repository" />
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/index">
|
||||
<fileset dir="src/test/it-resources/index" />
|
||||
<fileset dir="src/test/resources/index" />
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/snapshots">
|
||||
<fileset dir="src/test/it-resources/snapshots" />
|
||||
<fileset dir="src/test/resources/snapshots" />
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/projects">
|
||||
<fileset dir="src/test/it-resources/projects" />
|
||||
<fileset dir="src/test/resources/projects" />
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/local-repo">
|
||||
<fileset dir="src/test/it-resources/local-repo" />
|
||||
<fileset dir="src/test/resources/local-repo" />
|
||||
</copy>
|
||||
</tasks>
|
||||
</configuration>
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractArchivaTestCase
|
||||
extends AbstractSeleniumTestCase
|
||||
{
|
||||
private String baseUrl = "http://localhost:9696/archiva";
|
||||
|
||||
protected String getApplicationName()
|
||||
{
|
||||
return "Archiva";
|
||||
}
|
||||
|
||||
protected String getInceptionYear()
|
||||
{
|
||||
return "2005";
|
||||
}
|
||||
|
||||
protected void postAdminUserCreation()
|
||||
{
|
||||
if ( getTitle().equals( getTitlePrefix() + "Configuration" ) )
|
||||
{
|
||||
//Add Managed Repository
|
||||
setFieldValue( "id", "test-repository" );
|
||||
setFieldValue( "urlName", "test-repository" );
|
||||
setFieldValue( "name", "Web UI Test Managed Repository" );
|
||||
setFieldValue( "directory", getBasedir() + "/target/repository" );
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
|
||||
//Set Index location
|
||||
assertPage( "Configuration" );
|
||||
setFieldValue( "indexPath", getBasedir() + "/target/index" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
assertPage( "Administration" );
|
||||
}
|
||||
}
|
||||
|
||||
public void assertHeader()
|
||||
{
|
||||
assertTrue( "banner is missing", getSelenium().isElementPresent( "xpath=//div[@id='banner']" ) );
|
||||
assertTrue( "bannerLeft is missing",
|
||||
getSelenium().isElementPresent( "xpath=//div[@id='banner']" + "/span[@id='bannerLeft']" ) );
|
||||
assertTrue( "bannerLeft link is missing", getSelenium().isElementPresent(
|
||||
"xpath=//div[@id='banner']" + "/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='" + 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";
|
||||
}
|
||||
}
|
|
@ -1,608 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import com.thoughtworks.selenium.DefaultSelenium;
|
||||
import com.thoughtworks.selenium.Selenium;
|
||||
import junit.framework.TestCase;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractSeleniumTestCase
|
||||
extends TestCase
|
||||
{
|
||||
public static final String CHECKBOX_CHECK = "on";
|
||||
|
||||
public static final String CHECKBOX_UNCHECK = "off";
|
||||
|
||||
private Selenium sel;
|
||||
|
||||
protected String adminUsername;
|
||||
|
||||
protected String adminPassword;
|
||||
|
||||
protected String adminFullName = getApplicationName() + " Admin";
|
||||
|
||||
protected String adminEmail = "admin@localhost.localdomain";
|
||||
|
||||
protected String maxWaitTimeInMs;
|
||||
|
||||
protected String baseUrl;
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
Properties p = new Properties();
|
||||
p.load ( this.getClass().getClassLoader().getResourceAsStream( "it.properties" ) );
|
||||
|
||||
baseUrl = p.getProperty( "BASE_URL" );
|
||||
maxWaitTimeInMs = p.getProperty( "MAX_WAIT_TIME_IN_MS" );
|
||||
adminUsername = p.getProperty( "ADMIN_USERNAME" );
|
||||
adminPassword = p.getProperty( "ADMIN_PASSWORD" );
|
||||
String seleniumHost = p.getProperty( "SELENIUM_HOST" );
|
||||
int seleniumPort = Integer.parseInt( (p.getProperty( "SELENIUM_PORT" ) ) );
|
||||
|
||||
String browser = System.getProperty( "browser" );
|
||||
if ( StringUtils.isEmpty( browser ) )
|
||||
{
|
||||
browser = p.getProperty( "SELENIUM_BROWSER" );
|
||||
}
|
||||
|
||||
sel = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
|
||||
sel.start();
|
||||
initialize();
|
||||
}
|
||||
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
sel.stop();
|
||||
}
|
||||
|
||||
public Selenium getSelenium()
|
||||
{
|
||||
return sel;
|
||||
}
|
||||
|
||||
public abstract String getBaseUrl();
|
||||
|
||||
/**
|
||||
* We create an admin user if it doesn't exist
|
||||
*/
|
||||
protected void initialize()
|
||||
{
|
||||
open( getWebContext() );
|
||||
|
||||
if ( getTitle().endsWith( "Create Admin User" ) )
|
||||
{
|
||||
assertCreateAdminUserPage();
|
||||
submitCreateAdminUserPage( adminFullName, adminEmail, adminPassword, adminPassword );
|
||||
assertLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
postAdminUserCreation();
|
||||
logout();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* where webapp initial configurations can be done
|
||||
*/
|
||||
protected void postAdminUserCreation()
|
||||
{
|
||||
if ( getTitle().endsWith( "Continuum - Configuration" ) )
|
||||
{
|
||||
setFieldValue("baseUrl", baseUrl);
|
||||
clickButtonWithValue( "Save" );
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getApplicationName();
|
||||
|
||||
/**
|
||||
* some webapps have
|
||||
*
|
||||
* @return the page prefix set by the webapp
|
||||
*/
|
||||
protected String getTitlePrefix()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
protected abstract String getInceptionYear();
|
||||
|
||||
protected String getWebContext()
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
|
||||
public void open( String url )
|
||||
{
|
||||
sel.open( url );
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return sel.getTitle();
|
||||
}
|
||||
|
||||
public String getHtmlContent()
|
||||
{
|
||||
return getSelenium().getHtmlSource();
|
||||
}
|
||||
|
||||
public void assertTextPresent( String text )
|
||||
{
|
||||
assertTrue( "'" + text + "' isn't present.", sel.isTextPresent( text ) );
|
||||
}
|
||||
|
||||
public void assertTextNotPresent( String text )
|
||||
{
|
||||
assertFalse( "'" + text + "' is present.", sel.isTextPresent( text ) );
|
||||
}
|
||||
|
||||
public void assertElementPresent( String elementLocator )
|
||||
{
|
||||
assertTrue( "'" + elementLocator + "' isn't present.", isElementPresent( elementLocator ) );
|
||||
}
|
||||
|
||||
public void assertElementNotPresent( String elementLocator )
|
||||
{
|
||||
assertFalse( "'" + elementLocator + "' is present.", isElementPresent( elementLocator ) );
|
||||
}
|
||||
|
||||
public void assertLinkPresent( String text )
|
||||
{
|
||||
assertTrue( "The link '" + text + "' isn't present.", isElementPresent( "link=" + text ) );
|
||||
}
|
||||
|
||||
public void assertLinkNotPresent( String text )
|
||||
{
|
||||
assertFalse( "The link '" + text + "' is present.", isElementPresent( "link=" + text ) );
|
||||
}
|
||||
|
||||
public void assertImgWithAlt( String alt )
|
||||
{
|
||||
assertElementPresent( "//img[@alt='" + alt + "']" );
|
||||
}
|
||||
|
||||
public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column )
|
||||
{
|
||||
String locator = "//tr[" + row + "]/td[" + column + "]/";
|
||||
locator += isALink ? "a/" : "";
|
||||
locator += "img[@alt='" + alt + "']";
|
||||
|
||||
assertElementPresent( locator );
|
||||
}
|
||||
|
||||
public void assertCellValueFromTable( String expected, String tableElement, int row, int column )
|
||||
{
|
||||
assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
|
||||
}
|
||||
|
||||
public boolean isTextPresent( String text )
|
||||
{
|
||||
return sel.isTextPresent( text );
|
||||
}
|
||||
|
||||
public boolean isLinkPresent( String text )
|
||||
{
|
||||
return isElementPresent( "link=" + text );
|
||||
}
|
||||
|
||||
public boolean isElementPresent( String locator )
|
||||
{
|
||||
return sel.isElementPresent( locator );
|
||||
}
|
||||
|
||||
public void waitPage()
|
||||
{
|
||||
waitPage( 180000 );
|
||||
}
|
||||
|
||||
public void waitPage( int nbMillisecond )
|
||||
{
|
||||
sel.waitForPageToLoad( String.valueOf( nbMillisecond ) );
|
||||
}
|
||||
|
||||
public void assertPage( String title )
|
||||
{
|
||||
assertEquals( getTitlePrefix() + title, getTitle() );
|
||||
assertHeader();
|
||||
assertFooter();
|
||||
}
|
||||
|
||||
public abstract void assertHeader();
|
||||
|
||||
|
||||
public void assertFooter()
|
||||
{
|
||||
int currentYear = Calendar.getInstance().get( Calendar.YEAR );
|
||||
assertTrue( getSelenium().getText( "xpath=//div[@id='footer']/div[1]" ).endsWith(
|
||||
"Copyright © " + getInceptionYear() + "-" + currentYear + " The Apache Software Foundation" ) );
|
||||
}
|
||||
|
||||
public String getFieldValue( String fieldName )
|
||||
{
|
||||
return sel.getValue( fieldName );
|
||||
}
|
||||
|
||||
public String getCellValueFromTable( String tableElement, int row, int column )
|
||||
{
|
||||
return getSelenium().getTable( tableElement + "." + row + "." + column );
|
||||
}
|
||||
|
||||
public void selectValue( String locator, String value )
|
||||
{
|
||||
getSelenium().select( locator, "label=" + value );
|
||||
}
|
||||
|
||||
public void submit()
|
||||
{
|
||||
clickLinkWithXPath( "//input[@type='submit']" );
|
||||
}
|
||||
|
||||
public void assertButtonWithValuePresent( String text )
|
||||
{
|
||||
assertTrue( "'" + text + "' button isn't present", isButtonWithValuePresent( text ) );
|
||||
}
|
||||
|
||||
public void assertButtonWithValueNotPresent( String text )
|
||||
{
|
||||
assertFalse( "'" + text + "' button is present", isButtonWithValuePresent( text ) );
|
||||
}
|
||||
|
||||
public boolean isButtonWithValuePresent( String text )
|
||||
{
|
||||
return isElementPresent( "//button[@value='" + text + "']" ) || isElementPresent( "//input[@value='" + text + "']" );
|
||||
}
|
||||
|
||||
public void clickButtonWithValue( String text )
|
||||
{
|
||||
clickButtonWithValue( text, true );
|
||||
}
|
||||
|
||||
public void clickButtonWithValue( String text, boolean wait )
|
||||
{
|
||||
assertButtonWithValuePresent( text );
|
||||
|
||||
if ( isElementPresent( "//button[@value='" + text + "']" ) )
|
||||
{
|
||||
clickLinkWithXPath( "//button[@value='" + text + "']", wait );
|
||||
}
|
||||
else
|
||||
{
|
||||
clickLinkWithXPath( "//input[@value='" + text + "']", wait );
|
||||
}
|
||||
}
|
||||
|
||||
public void clickSubmitWithLocator( String locator )
|
||||
{
|
||||
clickLinkWithLocator( locator );
|
||||
}
|
||||
|
||||
public void clickSubmitWithLocator( String locator, boolean wait )
|
||||
{
|
||||
clickLinkWithLocator( locator, wait );
|
||||
}
|
||||
|
||||
public void clickImgWithAlt( String alt )
|
||||
{
|
||||
clickLinkWithLocator( "//img[@alt='" + alt + "']" );
|
||||
}
|
||||
|
||||
public void clickLinkWithText( String text )
|
||||
{
|
||||
clickLinkWithText( text, true );
|
||||
}
|
||||
|
||||
public void clickLinkWithText( String text, boolean wait )
|
||||
{
|
||||
clickLinkWithLocator( "link=" + text, wait );
|
||||
}
|
||||
|
||||
public void clickLinkWithXPath( String xpath )
|
||||
{
|
||||
clickLinkWithXPath( xpath, true );
|
||||
}
|
||||
|
||||
public void clickLinkWithXPath( String xpath, boolean wait )
|
||||
{
|
||||
clickLinkWithLocator( "xpath=" + xpath, wait );
|
||||
}
|
||||
|
||||
public void clickLinkWithLocator( String locator )
|
||||
{
|
||||
clickLinkWithLocator( locator, true );
|
||||
}
|
||||
|
||||
public void clickLinkWithLocator( String locator, boolean wait )
|
||||
{
|
||||
assertElementPresent( locator );
|
||||
sel.click( locator );
|
||||
if ( wait )
|
||||
{
|
||||
waitPage();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldValues( Map fieldMap )
|
||||
{
|
||||
Map.Entry entry;
|
||||
|
||||
for ( Iterator entries = fieldMap.entrySet().iterator(); entries.hasNext(); )
|
||||
{
|
||||
entry = (Map.Entry) entries.next();
|
||||
|
||||
sel.type( (String) entry.getKey(), (String) entry.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldValue( String fieldName, String value )
|
||||
{
|
||||
sel.type( fieldName, value );
|
||||
}
|
||||
|
||||
public void checkField( String locator )
|
||||
{
|
||||
sel.check( locator );
|
||||
}
|
||||
|
||||
public void uncheckField( String locator )
|
||||
{
|
||||
sel.uncheck( locator );
|
||||
}
|
||||
|
||||
public boolean isChecked( String locator )
|
||||
{
|
||||
return sel.isChecked( locator );
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Login
|
||||
//////////////////////////////////////
|
||||
public void goToLoginPage()
|
||||
{
|
||||
clickLinkWithText( "Login" );
|
||||
|
||||
assertLoginPage();
|
||||
}
|
||||
|
||||
public void login( String username, String password )
|
||||
{
|
||||
login( username, password, true, "Login Page" );
|
||||
}
|
||||
|
||||
public void login( String username, String password, boolean valid, String assertReturnPage )
|
||||
{
|
||||
if ( isLinkPresent( "Login" ) )
|
||||
{
|
||||
goToLoginPage();
|
||||
|
||||
submitLoginPage( username, password, false, valid, assertReturnPage );
|
||||
}
|
||||
}
|
||||
|
||||
public void assertLoginPage()
|
||||
{
|
||||
assertPage( "Login Page" );
|
||||
assertTextPresent( "Login" );
|
||||
assertTextPresent( "Username" );
|
||||
assertTextPresent( "Password" );
|
||||
assertTextPresent( "Remember Me" );
|
||||
assertFalse( isChecked( "rememberMe" ) );
|
||||
}
|
||||
|
||||
public void submitLoginPage( String username, String password )
|
||||
{
|
||||
submitLoginPage( username, password, false, true, "Login Page" );
|
||||
}
|
||||
|
||||
public void submitLoginPage( String username, String password, boolean validUsernamePassword )
|
||||
{
|
||||
submitLoginPage( username, password, false, validUsernamePassword, "Login Page" );
|
||||
}
|
||||
|
||||
public void submitLoginPage( String username, String password, boolean rememberMe, boolean validUsernamePassword,
|
||||
String assertReturnPage )
|
||||
{
|
||||
assertLoginPage();
|
||||
setFieldValue( "username", username );
|
||||
setFieldValue( "password", password );
|
||||
if ( rememberMe )
|
||||
{
|
||||
checkField( "rememberMe" );
|
||||
}
|
||||
clickButtonWithValue( "Login" );
|
||||
|
||||
if ( validUsernamePassword )
|
||||
{
|
||||
//assertTextPresent( "Current User:" );
|
||||
assertTextPresent( username );
|
||||
assertLinkPresent( "Edit Details" );
|
||||
assertLinkPresent( "Logout" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( "Login Page".equals( assertReturnPage ) )
|
||||
{
|
||||
assertLoginPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
assertPage( assertReturnPage );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAuthenticated()
|
||||
{
|
||||
return !( isLinkPresent( "Login" ) && isLinkPresent( "Register" ) );
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Logout
|
||||
//////////////////////////////////////
|
||||
public void logout()
|
||||
{
|
||||
assertTrue( "User wasn't authenticated.", isAuthenticated() );
|
||||
clickLinkWithText( "Logout" );
|
||||
assertFalse( "The user is always authenticated after a logout.", isAuthenticated() );
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// My Account
|
||||
//////////////////////////////////////
|
||||
public void goToMyAccount()
|
||||
{
|
||||
clickLinkWithText( "Edit Details" );
|
||||
}
|
||||
|
||||
public void assertMyAccountDetails( String username, String newFullName, String newEmailAddress )
|
||||
throws Exception
|
||||
{
|
||||
assertPage( "Account Details" );
|
||||
|
||||
//isTextPresent( "Username" );
|
||||
assertTextPresent( "Username:" );
|
||||
assertElementPresent( "registerForm_user_username" );
|
||||
assertCellValueFromTable( username, "//form/table", 0, 1 );
|
||||
|
||||
assertTextPresent( "Full Name*:" );
|
||||
assertElementPresent( "user.fullName" );
|
||||
assertEquals( newFullName, getFieldValue( "user.fullName" ) );
|
||||
|
||||
assertTextPresent( "Email Address*:" );
|
||||
assertElementPresent( "user.email" );
|
||||
assertEquals( newEmailAddress, getFieldValue( "user.email" ) );
|
||||
|
||||
assertTextPresent("Current Password*:");
|
||||
assertElementPresent("oldPassword");
|
||||
|
||||
assertTextPresent( "New Password*:" );
|
||||
assertElementPresent( "user.password" );
|
||||
|
||||
assertTextPresent( "Confirm Password*:" );
|
||||
assertElementPresent( "user.confirmPassword" );
|
||||
|
||||
assertTextPresent( "Last Password Change" );
|
||||
assertElementPresent( "registerForm_user_timestampLastPasswordChange" );
|
||||
|
||||
}
|
||||
|
||||
public void editMyUserInfo( String newFullName, String newEmailAddress, String oldPassword, String newPassword,
|
||||
String confirmNewPassword )
|
||||
{
|
||||
goToMyAccount();
|
||||
|
||||
setFieldValue( "user.fullName", newFullName );
|
||||
setFieldValue( "user.email", newEmailAddress );
|
||||
setFieldValue( "oldPassword", oldPassword );
|
||||
setFieldValue( "user.password", newPassword );
|
||||
setFieldValue( "user.confirmPassword", confirmNewPassword );
|
||||
clickButtonWithValue( "Submit" );
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Users
|
||||
//////////////////////////////////////
|
||||
public void assertUsersListPage()
|
||||
{
|
||||
assertPage( "[Admin] User List" );
|
||||
}
|
||||
|
||||
public void assertCreateUserPage()
|
||||
{
|
||||
assertPage( "[Admin] User Create" );
|
||||
assertTextPresent( "Username" );
|
||||
assertTextPresent( "Full Name" );
|
||||
assertTextPresent( "Email Address" );
|
||||
assertTextPresent( "Password" );
|
||||
assertTextPresent( "Confirm Password" );
|
||||
}
|
||||
|
||||
public void assertUserRolesPage()
|
||||
{
|
||||
assertPage( "[Admin] User Edit" );
|
||||
assertTextPresent( "[Admin] User Roles" );
|
||||
assertTextPresent( "Assigned Roles" );
|
||||
assertTextPresent( "Available Roles" );
|
||||
}
|
||||
|
||||
public void assertDeleteUserPage( String username )
|
||||
{
|
||||
assertPage( "[Admin] User Delete" );
|
||||
assertTextPresent( "[Admin] User Delete" );
|
||||
assertTextPresent( "The following user will be deleted: " + username );
|
||||
assertButtonWithValuePresent( "Delete User" );
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Create Admin User
|
||||
//////////////////////////////////////
|
||||
public void assertCreateAdminUserPage()
|
||||
{
|
||||
assertPage( "Create Admin User" );
|
||||
assertTextPresent( "Create Admin User" );
|
||||
assertTextPresent( "Username" );
|
||||
assertElementPresent( "user.username" );
|
||||
assertTextPresent( "Full Name" );
|
||||
assertElementPresent( "user.fullName" );
|
||||
assertTextPresent( "Email Address" );
|
||||
assertElementPresent( "user.email" );
|
||||
assertTextPresent( "Password" );
|
||||
assertElementPresent( "user.password" );
|
||||
assertTextPresent( "Confirm Password" );
|
||||
assertElementPresent( "user.confirmPassword" );
|
||||
}
|
||||
|
||||
public void submitCreateAdminUserPage( String fullName, String email, String password, String confirmPassword )
|
||||
{
|
||||
setFieldValue( "user.fullName", fullName );
|
||||
setFieldValue( "user.email", email );
|
||||
setFieldValue( "user.password", password );
|
||||
setFieldValue( "user.confirmPassword", confirmPassword );
|
||||
submit();
|
||||
waitPage();
|
||||
}
|
||||
|
||||
public String getBasedir()
|
||||
{
|
||||
String basedir = System.getProperty( "basedir" );
|
||||
|
||||
if ( basedir == null )
|
||||
{
|
||||
basedir = new File( "" ).getAbsolutePath();
|
||||
}
|
||||
|
||||
return basedir;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,193 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Archiva's webapp UI test for browsing the indexed repository.
|
||||
*
|
||||
*/
|
||||
public class BrowseRepositoryTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
private void browseArtifact()
|
||||
{
|
||||
clickLinkWithText( "Browse" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertLinkPresent( "org.apache.maven.archiva.web.test/" );
|
||||
|
||||
clickLinkWithText( "org.apache.maven.archiva.web.test/" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertTextPresent( "Artifacts" );
|
||||
assertLinkPresent( "artifact-a/" );
|
||||
|
||||
clickLinkWithText( "artifact-a/" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertTextPresent( "Versions" );
|
||||
assertLinkPresent( "1.0/" );
|
||||
|
||||
clickLinkWithText( "1.0/" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertLinkPresent( "Main" );
|
||||
}
|
||||
|
||||
public void testBrowseArtifactInfo()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
assertTextPresent( "Info" );
|
||||
assertLinkPresent( "Dependencies" );
|
||||
assertLinkPresent( "Dependency Tree" );
|
||||
assertLinkPresent( "Used By" );
|
||||
assertLinkPresent( "Mailing Lists" );
|
||||
|
||||
assertEquals("Group ID", getSelenium().getTable("//table[1].0.0"));
|
||||
assertEquals("org.apache.maven.archiva.web.test", getSelenium().getTable("//table[1].0.1"));
|
||||
assertEquals("Artifact ID", getSelenium().getTable("//table[1].1.0"));
|
||||
assertEquals("artifact-a", getSelenium().getTable("//table[1].1.1"));
|
||||
assertEquals("Version", getSelenium().getTable("//table[1].2.0"));
|
||||
assertEquals("1.0", getSelenium().getTable("//table[1].2.1"));
|
||||
assertEquals("Packaging", getSelenium().getTable("//table[1].3.0"));
|
||||
assertEquals("jar", getSelenium().getTable("//table[1].3.1"));
|
||||
}
|
||||
|
||||
public void testBrowseArtifactDependencies()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
clickLinkWithText( "Dependencies" );
|
||||
assertLinkPresent( "Info" );
|
||||
assertTextPresent( "Dependencies" );
|
||||
assertLinkPresent( "Dependency Tree" );
|
||||
assertLinkPresent( "Used By" );
|
||||
assertLinkPresent( "Mailing Lists" );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertLinkPresent( "artifact-b" );
|
||||
}
|
||||
|
||||
public void testBrowseArtifactDependencyTree()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
clickLinkWithText( "Dependency Tree" );
|
||||
assertLinkPresent( "Info" );
|
||||
assertLinkPresent( "Dependencies" );
|
||||
assertTextPresent( "Dependency Tree" );
|
||||
assertLinkPresent( "Used By" );
|
||||
assertLinkPresent( "Mailing Lists" );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertLinkPresent( "artifact-b" );
|
||||
assertLinkPresent( "artifact-c" );
|
||||
}
|
||||
|
||||
public void testBrowseArtifactUsedBy()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
clickLinkWithText( "Used By" );
|
||||
assertLinkPresent( "Info" );
|
||||
assertLinkPresent( "Dependencies" );
|
||||
assertLinkPresent( "Dependency Tree" );
|
||||
assertTextPresent( "Used By" );
|
||||
assertLinkPresent( "Mailing Lists" );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertLinkPresent( "artifact-s" );
|
||||
}
|
||||
|
||||
public void testBrowseArtifactMailingLists()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
clickLinkWithText( "Mailing Lists" );
|
||||
assertLinkPresent( "Info" );
|
||||
assertLinkPresent( "Dependencies" );
|
||||
assertLinkPresent( "Dependency Tree" );
|
||||
assertLinkPresent( "Used By" );
|
||||
assertTextPresent( "Mailing Lists" );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertTextPresent( "No mailing lists" );
|
||||
}
|
||||
|
||||
public void testBrowseUpRepositoryDirectory()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
assertLinkPresent( "artifact-a" );
|
||||
|
||||
clickLinkWithText( "artifact-a" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertTextPresent( "Versions" );
|
||||
assertLinkPresent( "1.0/" );
|
||||
assertLinkPresent( "test" );
|
||||
|
||||
clickLinkWithText( "test" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertTextPresent( "Artifacts" );
|
||||
assertLinkPresent( "artifact-a/" );
|
||||
assertLinkPresent( "web" );
|
||||
|
||||
clickLinkWithText( "web" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertTextPresent( "Groups" );
|
||||
assertLinkPresent( "org.apache.maven.archiva.web.test/" );
|
||||
assertLinkPresent( "[top]" );
|
||||
|
||||
clickLinkWithText( "[top]" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "Browse Repository" );
|
||||
assertTextPresent( "Groups" );
|
||||
assertLinkPresent( "org.apache.maven.archiva.web.test/" );
|
||||
}
|
||||
|
||||
public void testBrowseDependencyArtifact()
|
||||
{
|
||||
browseArtifact();
|
||||
|
||||
clickLinkWithText( "Dependencies" );
|
||||
assertPage( "Browse Repository" );
|
||||
assertTextPresent( "artifact-a" );
|
||||
assertLinkPresent( "artifact-b" );
|
||||
|
||||
clickLinkWithText( "artifact-b" );
|
||||
assertEquals("Group ID", getSelenium().getTable("//table[1].0.0"));
|
||||
assertEquals("org.apache.maven.archiva.web.test", getSelenium().getTable("//table[1].0.1"));
|
||||
assertEquals("Artifact ID", getSelenium().getTable("//table[1].1.0"));
|
||||
assertEquals("artifact-b", getSelenium().getTable("//table[1].1.1"));
|
||||
assertEquals("Version", getSelenium().getTable("//table[1].2.0"));
|
||||
assertEquals("2.0", getSelenium().getTable("//table[1].2.1"));
|
||||
assertEquals("Packaging", getSelenium().getTable("//table[1].3.0"));
|
||||
assertEquals("jar", getSelenium().getTable("//table[1].3.1"));
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
public class LoginTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
public void testBadLogin()
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( "badUsername", "badPassword", false );
|
||||
assertTextPresent( "You have entered an incorrect username and/or password" );
|
||||
}
|
||||
|
||||
public void testUserLogin()
|
||||
{
|
||||
createUser( "test-user", "temp-pass" );
|
||||
|
||||
goToLoginPage();
|
||||
submitLoginPage( "test-user", "temp-pass" );
|
||||
|
||||
// change of password required for new users
|
||||
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 )
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
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( "[Admin] User List" );
|
||||
//assertLinkPresent( username );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
private void deleteUser( String username )
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
clickLinkWithText( "User Management" );
|
||||
assertPage( "[Admin] User List" );
|
||||
assertLinkPresent( username );
|
||||
|
||||
//this does not work bec the image is pointing to /archiva/archiva/images/pss/admin/delete.gif
|
||||
// when ran in selenium
|
||||
// clickLinkWithXPath( "//a[@href='/security/userdelete.action?username=" + username + "']" );
|
||||
//so instead we use this
|
||||
open( "/archiva/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();
|
||||
}
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Archiva's webapp UI test for adding/editing/deleting managed repositories.
|
||||
*
|
||||
*/
|
||||
public class ManagedRepositoryTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
private static final String TEST_REPOSITORY_ID = "test-repository-id";
|
||||
|
||||
private static final String TEST_REPOSITORY_URL = "test-repository-url";
|
||||
|
||||
private static final String TEST_REPOSITORY_NAME = "test-repository-name";
|
||||
|
||||
private static final String TEST_REPOSITORY_DIRECTORY = "test-repository-directory";
|
||||
|
||||
|
||||
private void clickManagedRepositories()
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
clickLinkWithText( "Managed Repositories" );
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Administration" );
|
||||
}
|
||||
|
||||
private void createManagedRepository( String id, String url, String name, String directory )
|
||||
{
|
||||
clickManagedRepositories();
|
||||
|
||||
clickLinkWithText( "Add Repository" );
|
||||
assertTextPresent( "Configuration" );
|
||||
|
||||
setFieldValue( "addRepository_id", id );
|
||||
setFieldValue( "urlName", url );
|
||||
setFieldValue( "addRepository_name", name );
|
||||
setFieldValue( "addRepository_directory", directory );
|
||||
|
||||
clickButtonWithValue( "Add Repository", false );
|
||||
}
|
||||
|
||||
private void removeManagedRepository( String id )
|
||||
{
|
||||
logout();
|
||||
|
||||
clickManagedRepositories();
|
||||
|
||||
clickLinkWithLocator( "//a[contains(@href, '/admin/deleteRepository!input.action?repoId=" + id + "')]" );
|
||||
clickLinkWithLocator( "deleteRepository_operationdelete-contents", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextNotPresent( TEST_REPOSITORY_ID );
|
||||
}
|
||||
|
||||
public void testAddRepositoryWithValidValues()
|
||||
{
|
||||
createManagedRepository( TEST_REPOSITORY_ID, TEST_REPOSITORY_URL, TEST_REPOSITORY_NAME, TEST_REPOSITORY_DIRECTORY );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_ID );
|
||||
|
||||
removeManagedRepository( TEST_REPOSITORY_ID );
|
||||
}
|
||||
|
||||
public void testAddRepositoryWithInvalidValues()
|
||||
{
|
||||
createManagedRepository( "", "", "", "" );
|
||||
|
||||
assertTextPresent( "You must enter the repository identifier." );
|
||||
assertTextPresent( "You must enter the url name." );
|
||||
assertTextPresent( "You must enter the repository name." );
|
||||
assertTextPresent( "You must enter the repository directory." );
|
||||
}
|
||||
|
||||
public void testEditRepositoryWithValidValues()
|
||||
{
|
||||
createManagedRepository( TEST_REPOSITORY_ID, TEST_REPOSITORY_URL, TEST_REPOSITORY_NAME, TEST_REPOSITORY_DIRECTORY );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_NAME );
|
||||
|
||||
clickLinkWithLocator( "//a[contains(@href, '/admin/editRepository!input.action?repoId=" + TEST_REPOSITORY_ID + "')]" );
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Configuration" );
|
||||
|
||||
assertTextPresent( "Edit Managed Repository" );
|
||||
assertEquals( TEST_REPOSITORY_URL, getFieldValue( "urlName" ) );
|
||||
assertEquals( TEST_REPOSITORY_NAME, getFieldValue( "editRepository_name" ) );
|
||||
assertTrue( getFieldValue( "editRepository_directory" ).endsWith( TEST_REPOSITORY_DIRECTORY ) );
|
||||
|
||||
setFieldValue( "urlName", "edited-" + TEST_REPOSITORY_URL );
|
||||
setFieldValue( "editRepository_name", "edited-" + TEST_REPOSITORY_NAME );
|
||||
setFieldValue( "editRepository_directory", "edited-" + TEST_REPOSITORY_DIRECTORY );
|
||||
|
||||
clickButtonWithValue( "Update Repository" );
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_ID );
|
||||
assertTextPresent( "edited-" + TEST_REPOSITORY_NAME );
|
||||
|
||||
removeManagedRepository( TEST_REPOSITORY_ID );
|
||||
}
|
||||
|
||||
public void testEditRepositoryWithInvalidValues()
|
||||
{
|
||||
createManagedRepository( TEST_REPOSITORY_ID, TEST_REPOSITORY_URL, TEST_REPOSITORY_NAME, TEST_REPOSITORY_DIRECTORY );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_NAME );
|
||||
|
||||
clickLinkWithLocator( "//a[contains(@href, '/admin/editRepository!input.action?repoId=" + TEST_REPOSITORY_ID + "')]" );
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Configuration" );
|
||||
|
||||
assertTextPresent( "Edit Managed Repository" );
|
||||
assertEquals( TEST_REPOSITORY_URL, getFieldValue( "urlName" ) );
|
||||
assertEquals( TEST_REPOSITORY_NAME, getFieldValue( "editRepository_name" ) );
|
||||
assertTrue( getFieldValue( "editRepository_directory" ).endsWith( TEST_REPOSITORY_DIRECTORY ) );
|
||||
|
||||
setFieldValue( "urlName", "" );
|
||||
setFieldValue( "editRepository_name", "" );
|
||||
setFieldValue( "editRepository_directory", "" );
|
||||
|
||||
clickButtonWithValue( "Update Repository", false );
|
||||
assertTextPresent( "You must enter the url name." );
|
||||
assertTextPresent( "You must enter the repository name." );
|
||||
assertTextPresent( "You must enter the repository directory." );
|
||||
|
||||
removeManagedRepository( TEST_REPOSITORY_ID );
|
||||
}
|
||||
|
||||
public void testDeleteRepositoryButLeaveUnmodified()
|
||||
{
|
||||
createManagedRepository( TEST_REPOSITORY_ID, TEST_REPOSITORY_URL, TEST_REPOSITORY_NAME, TEST_REPOSITORY_DIRECTORY );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_ID );
|
||||
|
||||
clickLinkWithLocator( "//a[contains(@href, '/admin/deleteRepository!input.action?repoId=" + TEST_REPOSITORY_ID + "')]" );
|
||||
clickLinkWithLocator( "deleteRepository_operationunmodified", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_ID );
|
||||
|
||||
removeManagedRepository( TEST_REPOSITORY_ID );
|
||||
}
|
||||
|
||||
public void testDeleteRepositoryAndContents()
|
||||
{
|
||||
createManagedRepository( TEST_REPOSITORY_ID, TEST_REPOSITORY_URL, TEST_REPOSITORY_NAME, TEST_REPOSITORY_DIRECTORY );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_ID );
|
||||
|
||||
removeManagedRepository( TEST_REPOSITORY_ID );
|
||||
}
|
||||
|
||||
public void testDeleteRepositoryButLeaveContentsUnmodified()
|
||||
{
|
||||
createManagedRepository( TEST_REPOSITORY_ID, TEST_REPOSITORY_URL, TEST_REPOSITORY_NAME, TEST_REPOSITORY_DIRECTORY );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( TEST_REPOSITORY_ID );
|
||||
|
||||
clickLinkWithLocator( "//a[contains(@href, '/admin/deleteRepository!input.action?repoId=" + TEST_REPOSITORY_ID + "')]" );
|
||||
clickLinkWithLocator( "deleteRepository_operationdelete-entry", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextNotPresent( TEST_REPOSITORY_ID );
|
||||
}
|
||||
}
|
|
@ -1,396 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.codehaus.plexus.util.cli.CommandLineUtils;
|
||||
import org.codehaus.plexus.util.cli.Commandline;
|
||||
import org.codehaus.plexus.util.cli.StreamConsumer;
|
||||
import org.codehaus.plexus.util.cli.WriterStreamConsumer;
|
||||
import org.codehaus.plexus.commandline.ExecutableResolver;
|
||||
import org.codehaus.plexus.commandline.DefaultExecutableResolver;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.jdom.xpath.XPath;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Writer;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.BufferedReader;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
/**
|
||||
* Test maven connection to archiva
|
||||
*
|
||||
*/
|
||||
public class MavenConnectionTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
public static final String PATH_TO_ARCHIVA_XML = "/target/appserver-base/conf/archiva.xml";
|
||||
|
||||
public static final String PATH_TO_SETTINGS_XML = "/target/local-repo/settings.xml";
|
||||
|
||||
public static final String NEW_LOCAL_REPO_VALUE = "/target/local-repo";
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
String newValue = getBasedir() + NEW_LOCAL_REPO_VALUE;
|
||||
updateXml( new File( getBasedir(), PATH_TO_ARCHIVA_XML ), newValue );
|
||||
updateXml( new File( getBasedir(), PATH_TO_SETTINGS_XML ), newValue );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update localRepository element value
|
||||
*
|
||||
* @param f
|
||||
* @param newValue
|
||||
* @throws Exception
|
||||
*/
|
||||
private void updateXml( File f, String newValue )
|
||||
throws Exception
|
||||
{
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
FileReader reader = new FileReader( f );
|
||||
Document document = builder.build( reader );
|
||||
|
||||
Element localRepository =
|
||||
(Element) XPath.newInstance( "./" + "localRepository" ).selectSingleNode( document.getRootElement() );
|
||||
localRepository.setText( newValue );
|
||||
|
||||
// re-write xml file
|
||||
FileWriter writer = new FileWriter( f );
|
||||
XMLOutputter output = new XMLOutputter();
|
||||
output.output( document, writer );
|
||||
}
|
||||
|
||||
private void clickManagedRepositories()
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
clickLinkWithText( "Managed Repositories" );
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Administration" );
|
||||
}
|
||||
|
||||
private void removeManagedRepository( String id )
|
||||
{
|
||||
clickManagedRepositories();
|
||||
|
||||
clickLinkWithLocator( "//a[contains(@href, '/admin/deleteRepository!input.action?repoId=" + id + "')]" );
|
||||
clickLinkWithLocator( "deleteRepository_operationdelete-contents", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Click Settings from the navigation menu
|
||||
*/
|
||||
private void clickProxiedRepositories()
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
clickLinkWithText( "Proxied Repositories" );
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Proxied Repositories" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the created test repo
|
||||
*/
|
||||
protected void removeProxiedRepository()
|
||||
{
|
||||
if ( !isLinkPresent( "Login" ) )
|
||||
{
|
||||
logout();
|
||||
}
|
||||
|
||||
clickProxiedRepositories();
|
||||
|
||||
if ( isTextPresent( "Delete Repository " ) )
|
||||
{
|
||||
clickLinkWithText( "Delete Repository" );
|
||||
assertPage( "Configuration" );
|
||||
clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextNotPresent( "Test Proxied Repository" );
|
||||
}
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute 'mvn' from commandline
|
||||
*
|
||||
* @param workingDir
|
||||
* @param outputFile
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private int executeMaven( String workingDir, File outputFile )
|
||||
throws Exception
|
||||
{
|
||||
|
||||
ExecutableResolver executableResolver = new DefaultExecutableResolver();
|
||||
|
||||
String actualExecutable = "mvn";
|
||||
File workingDirectory = new File( workingDir );
|
||||
|
||||
List path = executableResolver.getDefaultPath();
|
||||
|
||||
if ( path == null )
|
||||
{
|
||||
path = Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
File e = executableResolver.findExecutable( "mvn", path );
|
||||
|
||||
if ( e != null )
|
||||
{
|
||||
actualExecutable = e.getAbsolutePath();
|
||||
}
|
||||
|
||||
File actualExecutableFile = new File( actualExecutable );
|
||||
|
||||
if ( !actualExecutableFile.exists() )
|
||||
{
|
||||
actualExecutable = "mvn";
|
||||
}
|
||||
|
||||
// Set command line
|
||||
Commandline cmd = new Commandline();
|
||||
|
||||
cmd.addSystemEnvironment();
|
||||
|
||||
cmd.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );
|
||||
|
||||
cmd.setExecutable( actualExecutable );
|
||||
|
||||
cmd.setWorkingDirectory( workingDirectory.getAbsolutePath() );
|
||||
|
||||
cmd.createArgument().setValue( "clean" );
|
||||
|
||||
cmd.createArgument().setValue( "install" );
|
||||
|
||||
cmd.createArgument().setValue( "-s" );
|
||||
|
||||
cmd.createArgument().setValue( getBasedir() + "/target/local-repo/settings.xml" );
|
||||
|
||||
// Excute command
|
||||
|
||||
Writer writer = new FileWriter( outputFile );
|
||||
|
||||
StreamConsumer consumer = new WriterStreamConsumer( writer );
|
||||
|
||||
int exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer );
|
||||
|
||||
writer.flush();
|
||||
|
||||
writer.close();
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public void testBadDependency()
|
||||
throws Exception
|
||||
{
|
||||
File outputFile = new File( getBasedir(), "/target/projects/bad-dependency/bad-dependency.log" );
|
||||
int exitCode = executeMaven( getBasedir() + "/target/projects/bad-dependency", outputFile );
|
||||
|
||||
assertEquals( 1, exitCode );
|
||||
|
||||
File f = new File( getBasedir(),
|
||||
"/target/local-repo/org/apache/mavem/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" );
|
||||
assertTrue( !f.exists() );
|
||||
|
||||
BufferedReader reader = new BufferedReader( new FileReader( outputFile ) );
|
||||
String str;
|
||||
boolean foundSnapshot = false, foundBadDep = false;
|
||||
|
||||
while ( ( str = reader.readLine() ) != null )
|
||||
{
|
||||
//System.out.println( str );
|
||||
if ( str.indexOf(
|
||||
"mvn install:install-file -DgroupId=org.apache.maven.archiva.web.test -DartifactId=foo-bar" ) != -1 )
|
||||
{
|
||||
foundSnapshot = true;
|
||||
}
|
||||
else if ( str.indexOf(
|
||||
"mvn install:install-file -DgroupId=org.apache.maven.archiva.web.test -DartifactId=bad-dependency" ) !=
|
||||
-1 )
|
||||
{
|
||||
foundBadDep = true;
|
||||
}
|
||||
}
|
||||
|
||||
reader.close();
|
||||
|
||||
assertTrue( foundSnapshot );
|
||||
assertTrue( foundBadDep );
|
||||
}
|
||||
|
||||
/*
|
||||
@todo: commented out since tests are currently failing due to MRM-323
|
||||
|
||||
public void testDownloadArtifactFromManagedRepo()
|
||||
throws Exception
|
||||
{
|
||||
clickManagedRepositories();
|
||||
|
||||
clickLinkWithText( "Add Repository" );
|
||||
assertTextPresent( "Configuration" );
|
||||
|
||||
setFieldValue( "addRepository_id", "snapshots" );
|
||||
setFieldValue( "urlName", "snapshots" );
|
||||
setFieldValue( "addRepository_name", "snapshots-repository" );
|
||||
setFieldValue( "addRepository_directory", getBasedir() + "/target/snapshots" );
|
||||
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
assertPage( "Administration" );
|
||||
|
||||
clickLinkWithText( "User Management" );
|
||||
clickLinkWithLocator( "//a[contains(@href, '/security/useredit.action?username=admin')]" );
|
||||
clickLinkWithText( "Edit Roles" );
|
||||
checkField( "addRolesToUser_addSelectedRolesRepository Observer - snapshots" );
|
||||
checkField( "addRolesToUser_addSelectedRolesRepository Manager - snapshots" );
|
||||
|
||||
clickButtonWithValue( "Add Selected Roles" );
|
||||
assertPage( "[Admin] User List" );
|
||||
|
||||
logout();
|
||||
|
||||
File outputFile = new File( getBasedir(), "/target/projects/bad-dependency/bad-dependency2.log" );
|
||||
int exitCode = executeMaven( getBasedir() + "/target/projects/bad-dependency",
|
||||
outputFile );
|
||||
|
||||
assertEquals( 0, exitCode );
|
||||
|
||||
File f = new File( getBasedir(),
|
||||
"/target/local-repo/org/apache/maven/archiva/web/test/foo-bar-1.0-SNAPSHOT.jar" );
|
||||
assertTrue( f.exists() );
|
||||
|
||||
BufferedReader reader = new BufferedReader( new FileReader( outputFile ) );
|
||||
String str;
|
||||
|
||||
while( ( str = reader.readLine() ) != null)
|
||||
{
|
||||
System.out.println( str );
|
||||
}
|
||||
reader.close();
|
||||
|
||||
removeManagedRepository( "snapshots" );
|
||||
}
|
||||
|
||||
|
||||
public void testDownloadArtifactFromProxiedRepo()
|
||||
throws Exception
|
||||
{
|
||||
//add managed repository
|
||||
clickManagedRepositories();
|
||||
|
||||
clickLinkWithText( "Add Repository" );
|
||||
assertTextPresent( "Configuration" );
|
||||
|
||||
setFieldValue( "addRepository_id", "repository" );
|
||||
setFieldValue( "urlName", "repository" );
|
||||
setFieldValue( "addRepository_name", "repository" );
|
||||
setFieldValue( "addRepository_directory", getBasedir() + "/target/repository" );
|
||||
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
clickLinkWithText( "User Management" );
|
||||
clickLinkWithLocator( "//a[contains(@href, '/security/useredit.action?username=admin')]" );
|
||||
clickLinkWithText( "Edit Roles" );
|
||||
checkField( "addRolesToUser_addSelectedRolesRepository Observer - repository" );
|
||||
checkField( "addRolesToUser_addSelectedRolesRepository Manager - repository" );
|
||||
|
||||
clickButtonWithValue( "Add Selected Roles" );
|
||||
assertPage( "[Admin] User List" );
|
||||
logout();
|
||||
|
||||
//add proxied repository
|
||||
clickProxiedRepositories();
|
||||
clickLinkWithText( "Add Repository" );
|
||||
assertPage( "Configuration" );
|
||||
setFieldValue( "id", "central" );
|
||||
setFieldValue( "name", "Central Repository" );
|
||||
setFieldValue( "url", "http://mirrors.ibiblio.org/pub/mirrors/maven2" );
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Central Repository" );
|
||||
assertLinkPresent( "Edit Repository" );
|
||||
|
||||
logout();
|
||||
|
||||
File outputFile = new File( getBasedir(), "/target/projects/dependency-in-proxied/dependency-in-proxied.log" );
|
||||
int exitCode = executeMaven( getBasedir() + "/target/projects/dependency-in-proxied",
|
||||
outputFile );
|
||||
|
||||
assertEquals( 0, exitCode );
|
||||
|
||||
File f = new File( getBasedir(),"/target/repository/com/lowagie/itext/1.3/itext-1.3.jar" );
|
||||
assertTrue( f.exists() );
|
||||
|
||||
f = new File( getBasedir(), "/target/local-repo/com/lowagie/itext/1.3/itext-1.3.jar" );
|
||||
assertTrue( f.exists() );
|
||||
|
||||
|
||||
BufferedReader reader = new BufferedReader( new FileReader( outputFile ) );
|
||||
String str;
|
||||
|
||||
while( ( str = reader.readLine() ) != null)
|
||||
{
|
||||
System.out.println( str );
|
||||
}
|
||||
reader.close();
|
||||
|
||||
removeProxiedRepository();
|
||||
removeManagedRepository( "repository" );
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
|
@ -1,232 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test archiva proxied repositories configuration
|
||||
*
|
||||
*/
|
||||
public class ProxiedRepositoryTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void initialize()
|
||||
{
|
||||
super.initialize();
|
||||
|
||||
createTestRepo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a proxied repo which will be used for testing
|
||||
*/
|
||||
private void createTestRepo()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
|
||||
if ( isTextPresent( "There are no proxied repositories configured yet." ) )
|
||||
{
|
||||
clickLinkWithText( "Add Repository" );
|
||||
assertPage( "Configuration" );
|
||||
setFieldValue( "id", "test-proxied" );
|
||||
setFieldValue( "name", "Test Proxied Repository" );
|
||||
setFieldValue( "url", "http://test.com/test-proxied" );
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Test Proxied Repository" );
|
||||
assertLinkPresent( "Edit Repository" );
|
||||
}
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add proxied repo with invalid data
|
||||
*/
|
||||
public void testInvalidAddProxiedRepoConfiguration()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
|
||||
clickLinkWithText( "Add Repository" );
|
||||
assertPage( "Configuration" );
|
||||
|
||||
clickButtonWithValue( "Add Repository", false );
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "You must enter the repository identifier." );
|
||||
assertTextPresent( "You must enter the repository name." );
|
||||
assertTextPresent( "You must enter the repository URL." );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit proxied repo with valid data
|
||||
*/
|
||||
public void testValidEditProxiedRepoConfiguration()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
clickLinkWithText( "Edit Repository" );
|
||||
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Edit Proxied Repository" );
|
||||
setFieldValue( "name", "Test Valid" );
|
||||
setFieldValue( "url", "http://valid.org/test-valid" );
|
||||
clickButtonWithValue( "Update Repository" );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Test Valid" );
|
||||
assertLinkPresent( "Edit Repository" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test edit proxied repo with invalid data
|
||||
*/
|
||||
public void testInvalidEditProxiedRepoConfiguration()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
clickLinkWithText( "Edit Repository" );
|
||||
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Edit Proxied Repository" );
|
||||
setFieldValue( "name", "" );
|
||||
setFieldValue( "url", "" );
|
||||
clickButtonWithValue( "Update Repository", false );
|
||||
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "You must enter the repository name." );
|
||||
assertTextPresent( "You must enter the repository URL." );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete repository, unmodified entry and contents
|
||||
*/
|
||||
public void testDeleteRepoUnmodified()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
clickLinkWithText( "Delete Repository" );
|
||||
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Delete Proxied Repository" );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Test Proxied Repository" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete repository including contents
|
||||
*/
|
||||
public void testDeleteRepoRemoveFromDisk()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
clickLinkWithText( "Delete Repository" );
|
||||
|
||||
assertPage( "Configuration" );
|
||||
clickLinkWithLocator( "deleteProxiedRepository_operationdelete-contents", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextNotPresent( "Test Proxied Repository" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete repository, unmodified contents/entry deleted
|
||||
*/
|
||||
public void testDeleteRepoUnmodifiedContents()
|
||||
{
|
||||
clickProxiedRepositories();
|
||||
clickLinkWithText( "Delete Repository" );
|
||||
|
||||
assertPage( "Configuration" );
|
||||
clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextNotPresent( "Test Proxied Repository" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Click Settings from the navigation menu
|
||||
*/
|
||||
private void clickProxiedRepositories()
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
clickLinkWithText( "Proxied Repositories" );
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( "Proxied Repositories" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the created test repo
|
||||
*/
|
||||
protected void removeTestRepo()
|
||||
{
|
||||
if ( !isLinkPresent( "Login" ) )
|
||||
{
|
||||
logout();
|
||||
}
|
||||
|
||||
clickProxiedRepositories();
|
||||
|
||||
if ( isTextPresent( "Delete Repository " ) )
|
||||
{
|
||||
clickLinkWithText( "Delete Repository" );
|
||||
assertPage( "Configuration" );
|
||||
clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
|
||||
clickButtonWithValue( "Go" );
|
||||
|
||||
assertPage( "Administration" );
|
||||
assertTextNotPresent( "Test Proxied Repository" );
|
||||
}
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert to original value
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
removeTestRepo();
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
public class SearchTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
private static int PAGE_LOAD_WAIT = 1500;
|
||||
|
||||
public void testSearchNonExistingArtifact()
|
||||
{
|
||||
searchForArtifact( "asdf" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertTextPresent( "No results found" );
|
||||
}
|
||||
|
||||
public void testSearchExistingArtifact()
|
||||
{
|
||||
searchForArtifact( "artifact-a" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertPage( "Search Results" );
|
||||
|
||||
assertTextPresent( "artifact-a" );
|
||||
}
|
||||
|
||||
public void testViewSearchedArtifact()
|
||||
{
|
||||
// test viewing artifact (header link) listed in search results
|
||||
|
||||
searchForArtifact( "artifact-a" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
getSelenium().click( "link=artifact-a" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
|
||||
assertTextPresent( "artifact-a" );
|
||||
|
||||
//test viewing artifact listed in search results
|
||||
|
||||
searchForArtifact( "artifact-a" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
clickLinkWithText( "1.0" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
|
||||
assertTextPresent( "Artifact ID" );
|
||||
|
||||
assertTextPresent( "artifact-a" );
|
||||
|
||||
assertTextPresent( "Version" );
|
||||
|
||||
assertTextPresent( "1.0" );
|
||||
}
|
||||
|
||||
public void testBrowseSearchedArtifact()
|
||||
{
|
||||
// test viewing artifact listed in search results
|
||||
|
||||
searchForArtifact( "artifact-a" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
getSelenium().click("//p[1]/span/a[1]");
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
|
||||
assertTextPresent( "artifact-a" );
|
||||
}
|
||||
|
||||
public void testBrowseRepoFromSearchResults()
|
||||
{
|
||||
searchForArtifact( "artifact-a" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
clickLinkWithText( "[top]" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertPage( "Browse Repository" );
|
||||
}
|
||||
|
||||
private void searchForArtifact( String artifactId )
|
||||
{
|
||||
if ( !"Maven Archiva :: Quick Search".equals( getSelenium().getTitle() ) )
|
||||
{
|
||||
clickLinkWithText( "Search" );
|
||||
|
||||
waitPage( PAGE_LOAD_WAIT );
|
||||
|
||||
assertPage( "Quick Search" );
|
||||
}
|
||||
|
||||
setFieldValue( "quickSearch_q", artifactId );
|
||||
|
||||
clickButtonWithValue( "Submit" );
|
||||
}
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
package org.apache.maven.archiva.web.test;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Test archiva 'Settings'
|
||||
*
|
||||
*/
|
||||
public class SettingsTest
|
||||
extends AbstractArchivaTestCase
|
||||
{
|
||||
/*
|
||||
public void testRunIndexer()
|
||||
{
|
||||
clickSettings();
|
||||
|
||||
clickLinkWithText( "Run Now" );
|
||||
waitPage();
|
||||
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
} */
|
||||
|
||||
public void testEditIndexDirectory()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
|
||||
setFieldValue( "indexPath", getBasedir() + "/target/web-ui-index" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
assertTextPresent( getBasedir() + "/target/web-ui-index" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
public void testValidIndexSchedule()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
|
||||
setFieldValue( "second", "*" );
|
||||
setFieldValue( "minute", "*" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
public void testInvalidIndexSchedule()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
setFieldValue( "second", "asdf" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Invalid Cron Expression" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
public void testEditProxyHost()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
|
||||
setFieldValue( "proxy.host", "asdf" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
public void testValidProxyPort()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
|
||||
setFieldValue( "proxy.port", "32143" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
public void testInvalidProxyPort()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
setFieldValue( "proxy.port", "asdf" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Configuration" );
|
||||
assertTextPresent( "Port" );
|
||||
assertTextPresent( "Invalid field value for field \"proxy.port\"" );
|
||||
|
||||
setFieldValue( "proxy.port", "-1" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
public void testEditProxyCredentials()
|
||||
{
|
||||
clickEditConfiguration();
|
||||
|
||||
setFieldValue( "proxy.username", "asdf" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Click Edit Configuration link
|
||||
*/
|
||||
private void clickEditConfiguration()
|
||||
{
|
||||
clickSettings();
|
||||
|
||||
clickLinkWithText( "Edit Configuration" );
|
||||
assertPage( "Configuration" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Click Settings from the navigation menu
|
||||
*/
|
||||
private void clickSettings()
|
||||
{
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
clickLinkWithText( "Settings" );
|
||||
assertPage( "Administration" );
|
||||
}
|
||||
|
||||
public void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
clickEditConfiguration();
|
||||
setFieldValue( "indexPath", getBasedir() + "/target/web-ui-index" );
|
||||
setFieldValue( "second", "0" );
|
||||
setFieldValue( "minute", "0,30" );
|
||||
setFieldValue( "hour", "*" );
|
||||
setFieldValue( "dayOfMonth", "*" );
|
||||
setFieldValue( "month", "*" );
|
||||
setFieldValue( "dayOfWeek", "?" );
|
||||
setFieldValue( "year", "" );
|
||||
setFieldValue( "proxy.port", "8080" );
|
||||
setFieldValue( "proxy.host", "" );
|
||||
setFieldValue( "proxy.username", "" );
|
||||
setFieldValue( "proxy.password", "" );
|
||||
clickButtonWithValue( "Save Configuration" );
|
||||
waitPage();
|
||||
assertPage( "Administration" );
|
||||
|
||||
logout();
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue