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.
34 * Based on LoginTest of Emmanuel Venisse test.
36 * @author José Morales MartÃnez
40 @Test( groups = { "login" }, dependsOnGroups = { "about" } )
41 public class LoginTest
42 extends AbstractArchivaTest
44 @Test( alwaysRun = true )
45 public void testWithBadUsername()
48 setFieldValue( "user-login-form-username", "badUsername" );
49 clickLinkWithLocator( "modal-login-ok", true );
50 assertTextPresent( "This field is required." );
54 @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
55 public void testWithBadPassword()
58 setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
59 setFieldValue( "user-login-form-password", "badPassword" );
60 clickLinkWithLocator( "modal-login-ok", true );
61 assertTextPresent( "You have entered an incorrect username and/or password" );
64 @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
65 public void testWithEmptyUsername()
68 setFieldValue( "user-login-form-password", "password" );
69 clickLinkWithLocator( "modal-login-ok", true );
70 //assertTextPresent( "User Name is required" );
71 assertTextPresent( "This field is required." );
74 @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
75 public void testWithEmptyPassword()
78 setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
79 clickLinkWithLocator( "modal-login-ok", true );
80 //assertTextPresent( "You have entered an incorrect username and/or password" );
81 assertTextPresent( "This field is required." );
84 @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
85 public void testWithCorrectUsernamePassword()
88 setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
89 setFieldValue( "user-login-form-password", getProperty( "ADMIN_PASSWORD" ) );
90 clickLinkWithLocator( "modal-login-ok", true );
92 assertUserLoggedIn( getProperty( "ADMIN_USERNAME" ) );