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" } )
40 public class LoginTest
41 extends AbstractArchivaTest
43 public void testWithBadUsername()
46 getSelenium().type( "loginForm_username", "badUsername" );
47 getSelenium().click( "loginForm__login" );
48 getSelenium().waitForPageToLoad( maxWaitTimeInMs );
49 assertTextPresent( "You have entered an incorrect username and/or password" );
52 @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
53 public void testWithBadPassword()
56 getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
57 getSelenium().type( "loginForm_password", "badPassword" );
58 getSelenium().click( "loginForm__login" );
59 getSelenium().waitForPageToLoad( maxWaitTimeInMs );
60 assertTextPresent( "You have entered an incorrect username and/or password" );
63 @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
64 public void testWithEmptyUsername()
67 getSelenium().type( "loginForm_password", "password" );
68 getSelenium().click( "loginForm__login" );
69 getSelenium().waitForPageToLoad( maxWaitTimeInMs );
70 assertTextPresent( "User Name is required" );
73 @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
74 public void testWithEmptyPassword()
77 getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
78 getSelenium().click( "loginForm__login" );
79 getSelenium().waitForPageToLoad( maxWaitTimeInMs );
80 assertTextPresent( "You have entered an incorrect username and/or password" );
83 @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
84 public void testWithCorrectUsernamePassword()
87 getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
88 getSelenium().type( "loginForm_password", p.getProperty( "ADMIN_PASSWORD" ) );
89 getSelenium().click( "loginForm__login" );
90 getSelenium().waitForPageToLoad( maxWaitTimeInMs );
91 assertTextPresent( "Edit Details" );
92 assertTextPresent( "Logout" );
93 assertTextPresent( p.getProperty( "ADMIN_USERNAME" ) );