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( "user-login-form-username", "badUsername" );
50 assertElementPresent( "//ul[@class=\'errorMessage\']" );
51 //assertTextPresent( "You have entered an incorrect username and/or password" );
54 @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
55 public void testWithBadPassword()
58 setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
59 setFieldValue( "loginForm_password", "badPassword" );
60 getSelenium().click( "loginSubmit" );
61 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
63 //assertTextPresent( "You have entered an incorrect username and/or password" );
64 //<ul class="errorMessage"><li><span>
65 assertElementPresent( "//ul[@class=\'errorMessage\']" );
68 @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
69 public void testWithEmptyUsername()
72 setFieldValue( "loginForm_password", "password" );
73 getSelenium().click( "loginSubmit" );
74 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
76 //assertTextPresent( "User Name is required" );
77 assertElementPresent( "//tr[@errorFor=\'loginForm_username\']");
80 @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
81 public void testWithEmptyPassword()
84 setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
85 getSelenium().click( "loginSubmit" );
86 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
88 //assertTextPresent( "You have entered an incorrect username and/or password" );
89 assertElementPresent( "//ul[@class=\'errorMessage\']" );
92 @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
93 public void testWithCorrectUsernamePassword()
96 setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
97 setFieldValue( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
98 getSelenium().click( "loginSubmit" );
99 //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
101 //assertTextPresent( "Logout" );
102 assertElementPresent( "logoutLink" );
103 //assertTextPresent( "Edit Details" );
104 assertElementPresent( "editUserLink" );
105 assertTextPresent( getProperty( "ADMIN_USERNAME" ) );