1 package org.apache.archiva.web.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.web.test.parent.AbstractArchivaTest;
23 import org.testng.annotations.AfterTest;
24 import org.testng.annotations.BeforeTest;
25 import org.testng.annotations.Test;
28 * Bug in TestNG. TESTNG-285: @Test(sequential=true) works incorrectly for classes with inheritance
29 * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
30 * Waiting 5.9 release. It's comming soon.
33 * Based on LoginTest of Emmanuel Venisse test.
35 * @author José Morales MartÃnez
39 @Test( groups = { "login" }, dependsOnGroups = {"about"})
40 public class LoginTest
41 extends AbstractArchivaTest
43 @Test(alwaysRun = true)
44 public void testWithBadUsername()
47 setFieldValue( "loginForm_username", "badUsername" );
48 getSelenium().click( "loginSubmit" );
49 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
51 assertElementPresent( "//ul[@class=\'errorMessage\']" );
52 //assertTextPresent( "You have entered an incorrect username and/or password" );
55 @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
56 public void testWithBadPassword()
59 setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
60 setFieldValue( "loginForm_password", "badPassword" );
61 getSelenium().click( "loginSubmit" );
62 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
64 //assertTextPresent( "You have entered an incorrect username and/or password" );
65 //<ul class="errorMessage"><li><span>
66 assertElementPresent( "//ul[@class=\'errorMessage\']" );
69 @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
70 public void testWithEmptyUsername()
73 setFieldValue( "loginForm_password", "password" );
74 getSelenium().click( "loginSubmit" );
75 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
77 //assertTextPresent( "User Name is required" );
78 assertElementPresent( "//tr[@errorFor=\'loginForm_username\']");
81 @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
82 public void testWithEmptyPassword()
85 setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
86 getSelenium().click( "loginSubmit" );
87 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
89 //assertTextPresent( "You have entered an incorrect username and/or password" );
90 assertElementPresent( "//ul[@class=\'errorMessage\']" );
93 @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
94 public void testWithCorrectUsernamePassword()
97 setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
98 setFieldValue( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
99 getSelenium().click( "loginSubmit" );
100 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
102 //assertTextPresent( "Logout" );
103 assertElementPresent( "logoutLink" );
104 //assertTextPresent( "Edit Details" );
105 assertElementPresent( "editUserLink" );
106 assertTextPresent( getProperty( "ADMIN_USERNAME" ) );