<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
- <type>jar</type>
- <classifier>jdk15</classifier>
<scope>test</scope>
- <optional>false</optional>
+ <classifier>jdk15</classifier>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-command-line</artifactId>
<artifactId>activation</artifactId>
</dependency>
</dependencies>
+
<build>
<testSourceDirectory>src/test/testng</testSourceDirectory>
<testResources>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>selenium-maven-plugin</artifactId>
- <version>1.0-rc-1</version>
- <executions>
- <execution>
- <id>start-selenium</id>
- <phase>pre-integration-test</phase>
- <goals>
- <goal>start-server</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <background>true</background>
- </configuration>
- </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<name>browser</name>
<value>${selenium.browser}</value>
</property>
+ <property>
+ <name>baseUrl</name>
+ <value>${baseUrl}</value>
+ </property>
</systemProperties>
</configuration>
</execution>
</plugin>
</plugins>
</build>
+
<profiles>
<profile>
<id>create-container</id>
<id>existing-container</id>
<activation>
<property>
- <name>container</name>
- <value>existing</value>
+ <name>!baseUrl</name>
+ </property>
+ </activation>
+ <properties>
+ <baseUrl>http://localhost:9696/archiva/</baseUrl>
+ </properties>
+ </profile>
+ <profile>
+ <id>start-selenium</id>
+ <activation>
+ <property>
+ <name>!seleniumHost</name>
</property>
</activation>
- <!-- edit src/test/resources/testng.properties as needed -->
+ <properties>
+ <seleniumHost>localhost</seleniumHost>
+ <seleniumPort>4444</seleniumPort>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start-server</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <port>${seleniumPort}</port>
+ <logOutput>true</logOutput>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</profile>
<profile>
<id>tomcat5x</id>
# properties for integration tests
-BASE_URL=http://localhost:9696/archiva
MAX_WAIT_TIME_IN_MS=60000
ADMIN_USERNAME=admin
<listeners>
<listener class-name="org.apache.archiva.web.test.listener.CaptureScreenShotsListener"/>
</listeners>
- <test name="BasicTest" enabled="true">
- <groups>
- <run>
- <include name="about" />
- </run>
- </groups>
- <packages>
- <package name="org.apache.archiva.web.test" />
- </packages>
- </test>
+
<test name="AdminTest" enabled="true">
<groups>
<run>
+ <include name="about" />
<include name= "login" />
<include name= "userroles" />
<include name= "artifactmanagement" />
<include name= "virtualrepository" />
<include name= "networkproxies" />
<include name= "repository" />
+ <include name= "appearance" />
+ <include name= "findartifact" />
+ <include name= "legacysupport" />
</run>
</groups>
<packages>
<package name="org.apache.archiva.web.test" />
</packages>
</test>
-</suite>
+</suite>
\ No newline at end of file
--- /dev/null
+package org.apache.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.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "appearance" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
+public class AppearanceTest extends AbstractArchivaTest
+{
+ public void testAddAppearanceNullValues()
+ {
+ goToAppearancePage();
+ clickLinkWithText( "Edit" );
+ addEditAppearance( "", "", "" );
+ assertTextPresent( "You must enter a name" );
+ }
+
+ @Test( dependsOnMethods = { "testAddAppearanceNullValues" })
+ public void testAddAppearanceValidValues()
+ {
+ addEditAppearance( "The Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" );
+ assertTextPresent( "The Apache Software Foundation" );
+ }
+
+ @Test( dependsOnMethods = { "testAddAppearanceValidValues" })
+ public void testEditAppearance()
+ {
+ clickLinkWithText( "Edit" );
+ addEditAppearance( "Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" );
+ assertTextPresent( "Apache Software Foundation" );
+ }
+
+}
\ No newline at end of file
* under the License.
*/
-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;
-
import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.input.SAXBuilder;
-import org.jdom.output.XMLOutputter;
-import org.jdom.xpath.XPath;
-import org.codehaus.plexus.commandline.ExecutableResolver;
-import org.codehaus.plexus.commandline.DefaultExecutableResolver;
-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;
@Test( groups = { "about" }, alwaysRun = true )
public class ArchivaAdminTest
extends AbstractArchivaTest
{
- 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";
+ @Override
+ @AfterTest
+ public void close()
+ throws Exception
+ {
+ super.close();
+ }
- public static final String NEW_LOCAL_REPO_VALUE = "/target/local-repo";
-
+ @Override
@BeforeSuite
- public void initializeArchiva()
+ public void open()
throws Exception
{
super.open();
+ }
+
+ @BeforeTest
+ @Parameters( { "baseUrl", "browser", "seleniumHost", "seleniumPort" } )
+ public void initializeArchiva( String baseUrl, String browser, @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort ) throws Exception
+ {
+ super.open( baseUrl, browser, seleniumHost, seleniumPort );
getSelenium().open( baseUrl );
String title = getSelenium().getTitle();
if ( title.equals( "Apache Archiva \\ Create Admin User" ) )
{
assertCreateAdmin();
- String fullname = p.getProperty( "ADMIN_FULLNAME" );
- String username = p.getProperty( "ADMIN_USERNAME" );
- String mail = p.getProperty( "ADMIN_EMAIL" );
- String password = p.getProperty( "ADMIN_PASSWORD" );
+ String fullname = getProperty( "ADMIN_FULLNAME" );
+ String username = getProperty( "ADMIN_USERNAME" );
+ String mail = getProperty( "ADMIN_EMAIL" );
+ String password = getProperty( "ADMIN_PASSWORD" );
submitAdminData( fullname, mail, password );
assertAuthenticatedPage( username );
submit();
clickLinkWithText( "Logout" );
}
- super.close();
- }
-
- @BeforeTest( groups = { "about" } )
- public void open()
- throws Exception
- {
- super.open();
- 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 clickRepositories()
- {
- goToLoginPage();
- submitLoginPage( getAdminUsername() , getAdminPassword() );
- clickLinkWithText( "Repositories" );
- assertPage( "Apache Archiva \\ Administration" );
- assertTextPresent( "Administration - Repositories" );
- }
-
- private void removedManagedRepository( String id)
- {
- clickRepositories();
- clickLinkWithLocator( "//a[contains(@href, '/admin/confirmDeleteRepository.action?repoid=" + id + "')]" );
- clickButtonWithValue( "Delete Configuration and Contents" );
- }*/
-
- 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 );
-
- Assert.assertEquals( 1, exitCode );
-
- File f = new File( getBasedir(),
- "/target/local-repo/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" );
- Assert.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();
-
- Assert.assertTrue( foundSnapshot );
- Assert.assertTrue( foundBadDep );
- }*/
-
- public void displayLandingPage()
- {
- getSelenium().open( baseUrl );
- getSelenium().waitForPageToLoad( maxWaitTimeInMs );
- assertPage( "Apache Archiva \\ Quick Search" );
- }
-
- @Override
- @AfterTest( groups = { "about" } )
- public void close()
- throws Exception
- {
- super.close();
- }
-}
\ No newline at end of file
+}
import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
import org.testng.annotations.Test;
-@Test( groups = { "userroles" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+@Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class ArtifactManagementTest
extends AbstractArtifactManagementTest
{
public void testAddArtifactValidValues1()
{
- String groupId = p.getProperty( "GROUPID1" );
- String artifactId = p.getProperty( "ARTIFACTID1" );
- String version = p.getProperty( "VERSION1" );
- String packaging = p.getProperty( "PACKAGING1" );
- String repositoryId = p.getProperty( "REPOSITORYID1" );
+ String groupId = getProperty( "GROUPID1" );
+ String artifactId = getProperty( "ARTIFACTID1" );
+ String version = getProperty( "VERSION1" );
+ String packaging = getProperty( "PACKAGING1" );
+ String repositoryId = getProperty( "REPOSITORYID1" );
addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId );
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
}
{
goToBrowsePage();
assertBrowsePage();
- clickLinkWithText( p.getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
+ clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( "Artifacts" );
}
-}
\ No newline at end of file
+}
--- /dev/null
+package org.apache.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.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "findartifact" }, dependsOnMethods = { "testAddArtifactValidValues1" }, sequential = true )
+public class FindArtifactTest
+ extends AbstractArchivaTest
+{
+ public void testFindArtifactNullValues()
+ {
+ goToFindArtifactPage();
+ clickButtonWithValue( "Search" );
+ assertTextPresent( "You must select a file, or enter the checksum. If the file was given and you receive this message, there may have been an error generating the checksum." );
+ }
+
+ @Test( dependsOnMethods = { "testFindArtifactNullValues" })
+ public void testFindArtifactUsingChecksum()
+ {
+ setFieldValue( "checksumSearch_q" , "8e896baea663a45d7bd2737f8e464481" );
+ clickButtonWithValue( "Search" );
+ assertTextPresent( "No results found" );
+ }
+}
--- /dev/null
+package org.apache.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.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "legacysupport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
+public class LegacySupportTest
+ extends AbstractArtifactManagementTest
+{
+ public void testAddLegacyArtifact_NullValues()
+ {
+ goToLegacySupportPage();
+ clickLinkWithText( "Add" );
+ addLegacyArtifactPath( "" , "" , "" , "" , "" , "");
+ assertTextPresent( "You must enter a legacy path." );
+ assertTextPresent( "You must enter a groupId." );
+ assertTextPresent( "You must enter an artifactId." );
+ assertTextPresent( "You must enter a version." );
+ assertTextPresent( "You must enter a type." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullValues" })
+ public void testAddLegacyArtifact_NullLegacyPath()
+ {
+ addLegacyArtifactPath( "" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "You must enter a legacy path." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullLegacyPath" })
+ public void testAddLegacyArtifact_NullGroupId()
+ {
+ addLegacyArtifactPath( "test" , "" , "test" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "You must enter a groupId." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullGroupId" })
+ public void testAddLegacyArtifact_NullArtifactId()
+ {
+ addLegacyArtifactPath( "test" , "test" , "" , "1.0-SNAPSHOT" , "testing" , "jar");
+ assertTextPresent( "You must enter an artifactId." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullArtifactId" })
+ public void testAddLegacyArtifact_NullVersion()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "" , "testing" , "jar");
+ assertTextPresent( "You must enter a version." );
+ }
+
+ @Test( dependsOnMethods = { "testAddLegacyArtifact_NullVersion" })
+ public void testAddLegacyArtifact_NullType()
+ {
+ addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "");
+ assertTextPresent( "You must enter a type." );
+ }
+}
public void testWithBadPassword()
{
goToLoginPage();
- getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+ getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
getSelenium().type( "loginForm_password", "badPassword" );
getSelenium().click( "loginForm__login" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
public void testWithEmptyPassword()
{
goToLoginPage();
- getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+ getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
getSelenium().click( "loginForm__login" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
assertTextPresent( "You have entered an incorrect username and/or password" );
public void testWithCorrectUsernamePassword()
{
goToLoginPage();
- getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
- getSelenium().type( "loginForm_password", p.getProperty( "ADMIN_PASSWORD" ) );
+ getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+ getSelenium().type( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
getSelenium().click( "loginForm__login" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
assertTextPresent( "Edit Details" );
assertTextPresent( "Logout" );
- assertTextPresent( p.getProperty( "ADMIN_USERNAME" ) );
+ assertTextPresent( getProperty( "ADMIN_USERNAME" ) );
}
@BeforeTest
{
super.close();
}
-}
\ No newline at end of file
+}
@Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
public void testRepositoryStatisticsWithoutDate()
{
- String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ;
+ String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
compareRepositories( "label=" + repositoryName, "", "" );
//TODO
//assertTextPresent( "Statistics Report" );
@Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
public void testRepositoryStatisticsEndEarlierThanStart()
{
- String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ;
- String startDate = p.getProperty( "END_DATE" );
- String endDate = p.getProperty( "START_DATE" );
+ String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
+ String startDate = getProperty( "END_DATE" );
+ String endDate = getProperty( "START_DATE" );
compareRepositories( "label=" + repositoryName, startDate, endDate );
//assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
assertPage( "Apache Archiva \\ Reports" );
@Test(dependsOnMethods = { "testAddArtifactValidValues" } )
public void testRepositoryStatistics()
{
- String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ;
- String startDate = p.getProperty( "START_DATE" );
- String endDate = p.getProperty( "END_DATE" );
+ String repositoryName = getProperty( "REPOSITORY_NAME" ) ;
+ String startDate = getProperty( "START_DATE" );
+ String endDate = getProperty( "END_DATE" );
compareRepositories( "label=" + repositoryName, startDate, endDate );
//assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
//assertPage( "Apache Archiva \\ Reports" );
public void testRepositoryHealthWithoutDefect()
{
goToReportsPage();
- String groupId = p.getProperty( "ARTIFACT_GROUPID" );
+ String groupId = getProperty( "ARTIFACT_GROUPID" );
getSelenium().type( "generateReport_groupId" , groupId );
clickButtonWithValue( "Show Report" );
assertPage( "Apache Archiva \\ Reports" );
public void testSearchNonExistingArtifact()
throws Exception
{
- searchForArtifact( p.getProperty( "SEARCH_BAD_ARTIFACT" ) );
+ searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
assertTextPresent( "No results found" );
}
@Test (dependsOnMethods = { "testAddArtifactValidValues" } )
public void testSearchExistingArtifact()
{
- searchForArtifact( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
+ searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
assertTextPresent( "Results" );
assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" );
@Test (dependsOnMethods = { "testAddArtifactValidValues" } )
public void testViewSearchedArtifact()
{
- searchForArtifact( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
- clickLinkWithText( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
+ searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
+ clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) );
assertPage( "Apache Archiva \\ Browse Repository" );
- assertTextPresent( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
- clickLinkWithText( p.getProperty( "ARTIFACT_VERSION" ) + "/" );
+ assertTextPresent( getProperty( "ARTIFACT_ARTIFACTID" ) );
+ clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" );
}
-}
\ No newline at end of file
+}
public void testBasicAddDeleteUser()
{
- username = p.getProperty( "GUEST_USERNAME" );
- fullname = p.getProperty( "GUEST_FULLNAME" );
+ username = getProperty( "GUEST_USERNAME" );
+ fullname = getProperty( "GUEST_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword(), true);
deleteUser( username, fullname, getUserEmail() );
@Test (dependsOnMethods = { "testBasicAddDeleteUser" } )
public void testUserWithGuestRole()
{
- username = p.getProperty("GUEST_USERNAME");
- fullname = p.getProperty("GUEST_FULLNAME");
+ username = getProperty("GUEST_USERNAME");
+ fullname = getProperty("GUEST_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithGuestRole" } )
public void testUserWithRegisteredUserRole()
{
- username = p.getProperty("REGISTERED_USERNAME");
- fullname = p.getProperty("REGISTERED_FULLNAME");
+ username = getProperty("REGISTERED_USERNAME");
+ fullname = getProperty("REGISTERED_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } )
public void testUserWithSysAdminUserRole()
{
- username = p.getProperty("SYSAD_USERNAME");
- fullname = p.getProperty("SYSAD_FULLNAME");
+ username = getProperty("SYSAD_USERNAME");
+ fullname = getProperty("SYSAD_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } )
public void testUserWithUserAdminUserRole()
{
- username = p.getProperty("USERADMIN_USERNAME");
- fullname = p.getProperty("USERADMIN_FULLNAME");
+ username = getProperty("USERADMIN_USERNAME");
+ fullname = getProperty("USERADMIN_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } )
public void testUserWithGlobalRepoManagerRole()
{
- username = p.getProperty("GLOBALREPOMANAGER_USERNAME");
- fullname = p.getProperty("GLOBALREPOMANAGER_FULLNAME");
+ username = getProperty("GLOBALREPOMANAGER_USERNAME");
+ fullname = getProperty("GLOBALREPOMANAGER_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
public void testUserWithGlobalRepoObserverRole()
{
- username = p.getProperty("GLOBALREPOOBSERVER_USERNAME");
- fullname = p.getProperty("GLOBALREPOOBSERVER_FULLNAME");
+ username = getProperty("GLOBALREPOOBSERVER_USERNAME");
+ fullname = getProperty("GLOBALREPOOBSERVER_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
public void testUserWithRepoManagerInternalRole()
{
- username = p.getProperty("REPOMANAGER_INTERNAL_USERNAME");
- fullname = p.getProperty("REPOMANAGER_INTERNAL_FULLNAME");
+ username = getProperty("REPOMANAGER_INTERNAL_USERNAME");
+ fullname = getProperty("REPOMANAGER_INTERNAL_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
/*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
public void testUserWithRepoManagerSnapshotsRole()
{
- username = p.getProperty("REPOMANAGER_SNAPSHOTS_USERNAME");
- fullname = p.getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME");
+ username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME");
+ fullname = getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
public void testUserWithRepoObserverInternalRole()
{
- username = p.getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
- fullname = p.getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
+ username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
+ fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
/*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
public void testUserWithRepoObserverSnapshotsRole()
{
- username = p.getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
- fullname = p.getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
+ username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
+ fullname = getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
public String getUserEmail()
{
- String email = p.getProperty("USERROLE_EMAIL");
+ String email = getProperty("USERROLE_EMAIL");
return email;
}
public String getUserRolePassword()
{
- String password = p.getProperty("USERROLE_PASSWORD");
+ String password = getProperty("USERROLE_PASSWORD");
return password;
}
public String getUserRoleNewPassword()
{
- String password_new = p.getProperty( "NEW_USERROLE_PASSWORD" );
+ String password_new = getProperty( "NEW_USERROLE_PASSWORD" );
return password_new;
}
public String getAdminUsername()
{
- String adminUsername = p.getProperty( "ADMIN_USERNAME" );
+ String adminUsername = getProperty( "ADMIN_USERNAME" );
return adminUsername;
}
public String getAdminPassword()
{
- String adminPassword = p.getProperty( "ADMIN_PASSWORD" );
+ String adminPassword = getProperty( "ADMIN_PASSWORD" );
return adminPassword;
}
assertLinkPresent( navmenu );
}
}
-/* //Find Artifact
+ //Find Artifact
public void goToFindArtifactPage()
{
clickLinkWithText( "Find Artifact" );
public void assertFindArtifactPage()
{
- //assertPage( "Apache Archiva \\ Find Artifact" );
+ assertPage( "Apache Archiva \\ Find Artifact" );
assertTextPresent( "Find Artifact" );
- assertTextPresent( "Search For" );
+ assertTextPresent( "Search for:" );
assertElementPresent( "f" );
- assertTextPresent( "Checksum" );
+ assertTextPresent( "Checksum:" );
assertElementPresent( "q" );
assertButtonWithValuePresent( "Search" );
- assertTextPresent( "This allows you to search the repository using the checksum of an artifact that you are trying to identify. You can either specify the checksum to look for directly, or scan a local artifact file. " );
- assertTextPresent( "Tï scan a local file, select the file you would like to locate in the remote repository. Ôhe entire file will not be uploaded$to the server. See the progress bar below for progress of locally creating a checksum that is uploaded to the server ifter you hit ");
+ assertTextPresent( "This allows you to search the repository using the checksum of an artifact that you are trying to identify. You can either specify the checksum to look for directly, or scan a local artifact file." );
}
//Appearance
public void assertAppearancePage()
{
- //assertPage( "Apache Archiva \\ Configure Appearance" );
- String appearance = "Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organizations Information,Name,URL,Logo URL";
+ assertPage( "Apache Archiva \\ Configure Appearance" );
+ String appearance = "Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organization Information,Name,URL,Logo URL";
String[] arrayAppearance = appearance.split( "," );
for ( String appear : arrayAppearance )
assertTextPresent( appear );
assertLinkPresent( "Change your appearance" );
}
+ public void addEditAppearance( String name, String url, String logoUrl )
+ {
+ setFieldValue( "organisationName" , name );
+ setFieldValue( "organisationUrl" , url );
+ setFieldValue( "organisationLogo" , logoUrl );
+ clickButtonWithValue( "Save" );
+ }
+
//Upload Artifact
public void goToUploadArtifactPage()
{
for ( String uploadelements : arrayUploadElements )
assertElementPresent( uploadelements );
assertButtonWithValuePresent( "Submit" );
- } */
+ }
}
public String getGroupId()
{
- String groupId = p.getProperty( "GROUPID" ) ;
+ String groupId = getProperty( "GROUPID" ) ;
return groupId;
}
public String getArtifactId()
{
- String artifactId = p.getProperty( "GROUPID" ) ;
+ String artifactId = getProperty( "GROUPID" ) ;
return artifactId;
}
public String getVersion()
{
- String version = p.getProperty( "VERSION" ) ;
+ String version = getProperty( "VERSION" ) ;
return version;
}
public String getPackaging()
{
- String packaging = p.getProperty( "PACKAGING" ) ;
+ String packaging = getProperty( "PACKAGING" ) ;
return packaging;
}
public String getRepositoryId()
{
- String repositoryId = p.getProperty( "REPOSITORYID" ) ;
+ String repositoryId = getProperty( "REPOSITORYID" ) ;
return repositoryId;
}
assertElementPresent( "repositoryId" );
assertButtonWithValuePresent( "Submit" );
}
+
+ // Legacy Support
+ public void goToLegacySupportPage()
+ {
+ clickLinkWithText( "Legacy Support" );
+ assertLegacySupportPage();
+ }
+
+ public void assertLegacySupportPage()
+ {
+ assertPage( "Apache Archiva \\ Administration - Legacy Support" );
+ assertTextPresent( "Administration - Legacy Artifact Path Resolution" );
+ assertTextPresent( "Path Mappings" );
+ assertLinkPresent( "Add" );
+ }
+
+ public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, String classifier, String type)
+ {
+ assertAddLegacyArtifactPathPage();
+ setFieldValue( "legacyArtifactPath.path" , path );
+ setFieldValue( "groupId" , groupId );
+ setFieldValue( "artifactId" , artifactId );
+ setFieldValue( "version" , version );
+ setFieldValue( "classifier" , classifier );
+ setFieldValue( "type" , type );
+ clickButtonWithValue( "Add Legacy Artifact Path" );
+ }
+
+ public void assertAddLegacyArtifactPathPage()
+ {
+ assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" );
+ assertTextPresent( "Admin: Add Legacy Artifact Path" );
+ assertTextPresent( "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." );
+ String element = "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type";
+ String[] arrayElement = element.split( "," );
+ for ( String arrayelement : arrayElement )
+ assertElementPresent( arrayelement );
+ assertButtonWithValuePresent( "Add Legacy Artifact Path" );
+ }
}
* under the License.
*/
-import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
-import org.codehaus.plexus.util.StringUtils;
-
+import org.apache.commons.io.IOUtils;
import org.testng.Assert;
+
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public abstract class AbstractSeleniumTest {
- public static String baseUrl;
+ public static String baseUrl;
public static String maxWaitTimeInMs;
- private static ThreadLocal<Selenium> selenium;
+ private static ThreadLocal<Selenium> selenium = new ThreadLocal<Selenium>();
public static Properties p;
-
+
+ private final static String PROPERTIES_SEPARATOR = "=";
+
public void open()
throws Exception
{
p = new Properties();
p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) );
- baseUrl = p.getProperty( "BASE_URL" );
- maxWaitTimeInMs = p.getProperty( "MAX_WAIT_TIME_IN_MS" );
+ //baseUrl = getProperty( "BASE_URL" );
+ maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" );
+
+
+ }
- String seleniumHost = p.getProperty( "SELENIUM_HOST" );
- int seleniumPort = Integer.parseInt( ( p.getProperty( "SELENIUM_PORT" ) ) );
+ /**
+ * Initialize selenium
+ */
+ public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort )
+ throws Exception
+ {
+ this.baseUrl = baseUrl;
- String seleniumBrowser = System.getProperty( "browser" );
- if ( StringUtils.isEmpty( seleniumBrowser ) )
+ if ( getSelenium() == null )
{
- seleniumBrowser = p.getProperty( "SELENIUM_BROWSER" );
+ DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
+ s.start();
+ selenium.set( s );
}
+ }
+
+ public static Selenium getSelenium()
+ {
+ return selenium == null ? null : selenium.get();
+ }
+
+ protected String getProperty( String key )
+ {
+ return p.getProperty( key );
+ }
+
+ protected String getEscapeProperty( String key )
+ {
+ InputStream input = this.getClass().getClassLoader().getResourceAsStream( "testng.properties" );
+ String value = null;
+ List<String> lines;
+ try
+ {
+ lines = IOUtils.readLines( input );
+ }
+ catch ( IOException e )
+ {
+ lines = new ArrayList<String>();
+ }
+ for ( String l : lines )
+ {
+ if ( l != null && l.startsWith( key ) )
+ {
+ int indexSeparator = l.indexOf( PROPERTIES_SEPARATOR );
+ value = l.substring( indexSeparator + 1 ).trim();
+ break;
+ }
+ }
+ return value;
+ }
- final Selenium s = new DefaultSelenium( seleniumHost, seleniumPort, seleniumBrowser, baseUrl );
- selenium = new ThreadLocal<Selenium>()
- {
- protected Selenium initialValue()
- {
- return s;
- }
- };
- getSelenium().start();
- }
-
- public static Selenium getSelenium()
- {
- return selenium.get();
- }
- public void close()
- throws Exception
- {
- getSelenium().stop();
- }
+ /**
+ * Close selenium session. Called from AfterSuite method of sub-class
+ */
+ public void close()
+ throws Exception
+ {
+ if ( getSelenium() != null )
+ {
+ getSelenium().stop();
+ selenium.set( null );
+ }
+ }
// *******************************************************
// Auxiliar methods. This method help us and simplify test.