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 * Based on LoginTest of Emmanuel Venisse test.
30 * @author José Morales MartÃnez
34 @Test( groups = { "login" }, dependsOnGroups = { "about" } )
35 public class LoginTest
36 extends AbstractArchivaTest
38 @Test( alwaysRun = true )
39 public void testWithBadUsername()
42 setFieldValue( "user-login-form-username", "badUsername" );
43 clickLinkWithLocator( "modal-login-ok", true );
44 assertTextPresent( "This field is required." );
48 @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
49 public void testWithBadPassword()
52 setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
53 setFieldValue( "user-login-form-password", "badPassword" );
54 clickLinkWithLocator( "modal-login-ok", true );
55 assertTextPresent( "You have entered an incorrect username and/or password" );
58 @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
59 public void testWithEmptyUsername()
62 setFieldValue( "user-login-form-password", "password" );
63 clickLinkWithLocator( "modal-login-ok", true );
64 //assertTextPresent( "User Name is required" );
65 assertTextPresent( "This field is required." );
68 @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
69 public void testWithEmptyPassword()
72 setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
73 clickLinkWithLocator( "modal-login-ok", true );
74 //assertTextPresent( "You have entered an incorrect username and/or password" );
75 assertTextPresent( "This field is required." );
78 @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
79 public void testWithCorrectUsernamePassword()
82 setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
83 setFieldValue( "user-login-form-password", getProperty( "ADMIN_PASSWORD" ) );
84 clickLinkWithLocator( "modal-login-ok", true );
86 assertUserLoggedIn( getProperty( "ADMIN_USERNAME" ) );