--- /dev/null
+package org.apache.archiva.web.test.parent;
+
+public abstract class AbstractRepositoryTest
+ extends AbstractArchivaTest
+{
+ // Repository Groups
+ public void goToRepositoryGroupsPage()
+ {
+ clickLinkWithText( "Repository Groups" );
+ assertRepositoryGroupsPage();
+ }
+
+ public void assertRepositoryGroupsPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Groups" );
+ assertTextPresent( "Administration - Repository Groups" );
+ assertTextPresent( "Identifier*:" );
+ assertElementPresent( "repositoryGroup.id" );
+ assertButtonWithValuePresent( "Add Group" );
+ assertTextPresent( "Repository Groups" );
+ }
+
+ public void assertAddedRepositoryLink( String repositoryGroupName)
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Groups" );
+ String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
+ String baseUrlValue = "archiva";
+ String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue);
+ assertTextPresent( repositoryGroupLink );
+ }
+
+ public void assertAddedRepositoryToRepositoryGroups( String repositoryName)
+ {
+ assertPage( "Apache Archiva \\ Administration - Repository Groups" );
+ assertTextPresent( repositoryName );
+ assertTextPresent( "Archiva Managed Internal Repository" );
+ assertAddedRepositoryLink( repositoryName );
+ }
+
+ public void assertDeleteRepositoryGroupPage( String repositoryName)
+ {
+ assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
+ assertTextPresent( "WARNING: This operation can not be undone." );
+ assertTextPresent( "Are you sure you want to delete the following repository group?" );
+ assertTextPresent( "ID: " + repositoryName );
+ assertButtonWithValuePresent( "Confirm" );
+ assertButtonWithValuePresent( "Cancel" );
+ }
+
+ public void addRepositoryGroup( String repoGroupName )
+ {
+ goToRepositoryGroupsPage();
+ setFieldValue( "repositoryGroup.id", repoGroupName );
+ clickButtonWithValue( "Add Group" );
+ }
+
+ public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
+ {
+ goToRepositoryGroupsPage();
+ String s = getSelenium().getBodyText();
+ if ( s.contains( "No Repository Groups Defined." ) )
+ {
+ setFieldValue( "repositoryGroup.id" , repositoryGroupName );
+ clickButtonWithValue( "Add Group" );
+ //assertAddedRepositoryLink( repositoryGroupName );
+
+ selectValue( "addRepositoryToGroup_repoId" , repositoryName );
+ clickButtonWithValue( "Add Repository" );
+ assertAddedRepositoryToRepositoryGroups( repositoryName );
+ }
+ else
+ {
+ //assertAddedRepositoryLink( repositoryGroupName );
+ selectValue( "addRepositoryToGroup_repoId" , repositoryName );
+ clickButtonWithValue( "Add Repository" );
+ }
+ }
+
+ public void deleteRepositoryInRepositoryGroups()
+ {
+ getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
+ }
+
+ public void deleteRepositoryGroup( String repositoryName )
+ {
+ //goToRepositoryGroupsPage();
+ getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
+ waitPage();
+ assertDeleteRepositoryGroupPage( repositoryName );
+ clickButtonWithValue( "Confirm" );
+ }
+
+ ///////////////////////////////
+ // proxy connectors
+ ///////////////////////////////
+ public void goToProxyConnectorsPage()
+ {
+ clickLinkWithText( "Proxy Connectors" );
+ assertProxyConnectorsPage();
+ }
+
+ public void assertProxyConnectorsPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
+ assertTextPresent( "Administration - Proxy Connectors" );
+ assertTextPresent( "Repository Proxy Connectors" );
+ assertTextPresent( "internal" );
+ assertTextPresent( "Archiva Managed Internal Repository" );
+ assertTextPresent( "Proxy Connector" );
+ assertTextPresent( "Central Repository" );
+ assertTextPresent( "Java.net Repository for Maven 2" );
+ }
+
+ public void assertAddProxyConnectorPage()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
+ assertTextPresent( "Admin: Add Proxy Connector" );
+ String proxy = "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set.";
+ String[] arrayProxy = proxy.split( "," );
+ for ( String arrayproxy : arrayProxy )
+ assertTextPresent( arrayproxy );
+ /*String proxyElements = "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry";
+ String[] arrayProxyElements = proxyElements.split( "," );
+ for ( String arrayproxyelements : arrayProxyElements )
+ assertTextPresent( arrayproxyelements );*/
+ assertButtonWithValuePresent( "Add Property" );
+ assertButtonWithValuePresent( "Add Pattern" );
+ assertButtonWithValuePresent( "Add Proxy Connector" );
+ }
+
+ // this only fills in the values of required fields in adding Proxy Connectors
+ public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
+ {
+ goToProxyConnectorsPage();
+ clickLinkWithText( "Add" );
+ assertAddProxyConnectorPage();
+ selectValue( "connector.proxyId" , networkProxy );
+ selectValue( "connector.sourceRepoId" , managedRepo );
+ selectValue( "connector.targetRepoId" , remoteRepo );
+ }
+
+ public void deleteProxyConnector()
+ {
+ goToProxyConnectorsPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
+ assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
+ clickButtonWithValue( "Delete" );
+ assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
+ }
+
+ ///////////////////////////////
+ // network proxies
+ ///////////////////////////////
+ public void goToNetworkProxiesPage()
+ {
+ clickLinkWithText( "Network Proxies" );
+ assertNetworkProxiesPage();
+ }
+
+ public void assertNetworkProxiesPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+ assertTextPresent( "Administration - Network Proxies" );
+ assertTextPresent( "Network Proxies" );
+ assertLinkPresent( "Add Network Proxy" );
+ }
+
+ public void assertAddNetworkProxy()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
+ assertTextPresent( "Admin: Add Network Proxy" );
+ assertTextPresent( "Add network proxy:" );
+ assertTextPresent( "Identifier*:" );
+ assertTextPresent( "Protocol*:" );
+ assertTextPresent( "Hostname*:" );
+ assertTextPresent( "Port*:" );
+ assertTextPresent( "Username:" );
+ assertTextPresent( "Password:" );
+ assertButtonWithValuePresent( "Save Network Proxy" );
+ }
+
+ public void addNetworkProxyWithAccount( String identifier, String protocol, String hostname, String port, String username, String password )
+ {
+ goToNetworkProxiesPage();
+ clickLinkWithText( "Add Network Proxy" );
+ assertAddNetworkProxy();
+ setFieldValue( "proxy.id" , identifier );
+ setFieldValue( "proxy.protocol" , protocol );
+ setFieldValue( "proxy.host" , hostname );
+ setFieldValue( "proxy.port" , port );
+ setFieldValue( "proxy.username" , username );
+ setFieldValue( "proxy.password" , password );
+ clickButtonWithValue( "Save Network Proxy" );
+ }
+
+ public void editNetworkProxies( String fieldName, String value)
+ {
+ goToNetworkProxiesPage();
+ clickLinkWithText( "Edit Network Proxy" );
+ setFieldValue( fieldName, value);
+ clickButtonWithValue( "Save Network Proxy" );
+ }
+
+ public void deleteNetworkProxy()
+ {
+ goToNetworkProxiesPage();
+ clickLinkWithText( "Delete Network Proxy" );
+ assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
+ clickButtonWithValue( "Delete" );
+ }
+
+ ///////////////////////////////
+ // repositories
+ ///////////////////////////////
+ public void goToRepositoriesPage()
+ {
+ clickLinkWithText( "Repositories" );
+ assertRepositoriesPage();
+ }
+
+ public void assertRepositoriesPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Repositories" );
+ assertTextPresent( "Administration - Repositories" );
+ assertTextPresent( "Managed Repositories" );
+ assertTextPresent( "Remote Repositories" );
+ }
+
+ // remote repositories
+ public void assertAddRemoteRepository()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
+ String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
+ String[] arrayRemote = remote.split( "," );
+ for ( String arrayremote : arrayRemote )
+ assertTextPresent( arrayremote );
+ String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
+ String[] arrayRemoteElements = remoteElements.split( "," );
+ for ( String arrayremotelement : arrayRemoteElements )
+ assertElementPresent( arrayremotelement );
+ }
+
+ public void assertDeleteRemoteRepositoryPage()
+ {
+ assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
+ assertTextPresent( "Admin: Delete Remote Repository" );
+ assertTextPresent( "WARNING: This operation can not be undone." );
+ assertTextPresent( "Are you sure you want to delete the following remote repository?" );
+ assertButtonWithValuePresent( "Confirm" );
+ assertButtonWithValuePresent( "Cancel" );
+ }
+
+ public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/a" );
+ assertAddRemoteRepository();
+ setFieldValue( "addRemoteRepository_repository_id" , identifier );
+ setFieldValue( "addRemoteRepository_repository_name" , name );
+ setFieldValue( "addRemoteRepository_repository_url" , url );
+ setFieldValue( "addRemoteRepository_repository_username" , username );
+ setFieldValue( "addRemoteRepository_repository_password" , password );
+ setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
+ selectValue( "addRemoteRepository_repository_layout" , type );
+ clickButtonWithValue( "Add Repository" );
+ }
+
+ public void deleteRemoteRepository()
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
+ assertDeleteRemoteRepositoryPage();
+ clickButtonWithValue( "Confirm" );
+ }
+
+ public void editRemoteRepository( String fieldName, String value)
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
+ setFieldValue( fieldName, value );
+ clickButtonWithValue( "Update Repository" );
+ }
+
+ // managed repositories
+ public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount )
+ {
+ goToRepositoriesPage();
+ clickLinkWithText( "Add" );
+ setFieldValue( "repository.id" , identifier );
+ setFieldValue( "repository.name" , name );
+ setFieldValue( "repository.location" , directory );
+ setFieldValue( "repository.indexDir" , indexDirectory );
+ selectValue( "repository.layout", type );
+ setFieldValue( "repository.refreshCronExpression" , cron );
+ setFieldValue( "repository.daysOlder" , daysOlder );
+ setFieldValue( "repository.retentionCount" , retentionCount );
+ //TODO
+ clickButtonWithValue( "Add Repository" );
+ }
+
+ public void editManagedRepository( String fieldName, String value )
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/div[1]/a[1]/img" );
+ assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
+ setFieldValue(fieldName, value);
+ //TODO
+ clickButtonWithValue( "Update Repository" );
+ }
+
+ public void deleteManagedRepository()
+ {
+ goToRepositoriesPage();
+ clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/div[1]/a[2]" );
+ assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
+ clickButtonWithValue( "Delete Configuration Only" );
+ }
+}
\ No newline at end of file
* under the License.
*/
+import java.io.File;
import java.util.Arrays;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
// Auxiliar methods. This method help us and simplify test.
// *******************************************************
+ public void captureScreenshot()
+ {
+ Date t = new Date();
+ File f = new File( "" );
+ String baseDir = f.getAbsolutePath();
+ String time = t.toString();
+ getSelenium().windowMaximize();
+ getSelenium().windowFocus();
+ getSelenium().captureScreenshot( baseDir + "/target/screenshots/" + getClass() + "-" + time + ".png" );
+ }
+
public void assertFieldValue( String fieldValue, String fieldName )
{
- assertElementPresent( fieldName );
- Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
+ try
+ {
+ assertElementPresent( fieldName );
+ Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ assertElementPresent( fieldName );
+ Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
+ }
}
public void assertPage( String title )
{
- Assert.assertEquals( getSelenium().getTitle(), title );
+ try
+ {
+ Assert.assertEquals( getSelenium().getTitle(), title );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertEquals( getSelenium().getTitle(), title );
+ }
}
public String getTitle()
public void assertTextPresent( String text )
{
- Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
+ try
+ {
+ Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
+ }
}
public void assertTextNotPresent( String text )
{
- Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
+ try
+ {
+ Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
+ }
}
public void assertElementPresent( String elementLocator )
{
- Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
+ try
+ {
+ Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
+ }
}
public void assertElementNotPresent( String elementLocator )
{
- Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
+ try
+ {
+ Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
+ }
}
public void assertLinkPresent( String text )
{
- Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isî't present." );
+ try
+ {
+ Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isî't present." );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isî't present." );
+ }
}
public void assertLinkNotPresent( String text )
{
- Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." );
+ try
+ {
+ Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." );
+ }
}
public void assertImgWithAlt( String alt )
{
- assertElementPresent( "/¯img[@alt='" + alt + "']" );
+ try
+ {
+ assertElementPresent( "/¯img[@alt='" + alt + "']" );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ assertElementPresent( "/¯img[@alt='" + alt + "']" );
+ }
}
public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column )
locator += isALink ? "a/" : "";
locator += "img[@alt='" + alt + "']";
- assertElementPresent( locator );
+ try
+ {
+ assertElementPresent( locator );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ assertElementPresent( locator );
+ }
}
public void assertCellValueFromTable( String expected, String tableElement, int row, int column )
{
- Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
+ try
+ {
+ Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
+ }
}
public boolean isTextPresent( String text )
public void assertButtonWithValuePresent( String text )
{
- Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
+ try
+ {
+ Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
+ }
}
public void assertButtonWithIdPresent( String id )
{
- Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
+ try
+ {
+ Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
+ }
}
public void assertButtonWithValueNotPresent( String text )
{
- Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
+ try
+ {
+ Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
+ }
}
public boolean isButtonWithValuePresent( String text )
public void assertIsChecked( String locator )
{
- Assert.assertTrue( getSelenium().isChecked( locator ) );
+ try
+ {
+ Assert.assertTrue( getSelenium().isChecked( locator ) );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertTrue( getSelenium().isChecked( locator ) );
+ }
}
public void assertIsNotChecked( String locator )
{
- Assert.assertFalse( getSelenium().isChecked( locator ) );
+ try
+ {
+ Assert.assertFalse( getSelenium().isChecked( locator ) );
+ }
+ catch ( java.lang.AssertionError e)
+ {
+ captureScreenshot();
+ Assert.assertFalse( getSelenium().isChecked( locator ) );
+ }
}
}
\ No newline at end of file