1 package org.apache.archiva.web.test.parent;
3 import org.junit.runner.RunWith;
4 import org.junit.runners.BlockJUnit4ClassRunner;
7 import java.io.IOException;
10 * Licensed to the Apache Software Foundation (ASF) under one
11 * or more contributor license agreements. See the NOTICE file
12 * distributed with this work for additional information
13 * regarding copyright ownership. The ASF licenses this file
14 * to you under the Apache License, Version 2.0 (the
15 * "License"); you may not use this file except in compliance
16 * with the License. You may obtain a copy of the License at
18 * http://www.apache.org/licenses/LICENSE-2.0
20 * Unless required by applicable law or agreed to in writing,
21 * software distributed under the License is distributed on an
22 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 * KIND, either express or implied. See the License for the
24 * specific language governing permissions and limitations
28 @RunWith( BlockJUnit4ClassRunner.class )
29 public abstract class AbstractArchivaTest
30 extends AbstractSeleniumTest
33 protected String username;
35 protected String fullname;
37 public String getUserEmail()
39 String email = getProperty( "USERROLE_EMAIL" );
43 public String getUserRolePassword()
45 String password = getProperty( "USERROLE_PASSWORD" );
49 public String getUserRoleNewPassword()
51 String password_new = getProperty( "NEW_USERROLE_PASSWORD" );
55 public String getBasedir()
57 String basedir = System.getProperty( "basedir" );
59 if ( basedir == null )
61 basedir = new File( "" ).getAbsolutePath();
68 public void submitUserData( String username, String password, boolean rememberme, boolean success )
71 setFieldValue( "username", username );
72 setFieldValue( "password", password );
75 checkField( "rememberMe" );
81 assertUserLoggedIn( username );
91 public void createUser( String userName, String fullName, String email, String password, boolean valid )
93 createUser( userName, fullName, email, password, password, valid );
96 private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword,
100 clickLinkWithLocator( "menu-users-list-a", true );
101 clickLinkWithLocator( "users-view-tabs-li-user-edit-a", true );
103 assertCreateUserPage();
104 setFieldValue( "username", userName );
105 setFieldValue( "fullname", fullName );
106 setFieldValue( "email", emailAd );
107 setFieldValue( "password", password );
108 setFieldValue( "confirmPassword", confirmPassword );
110 clickLinkWithLocator( "user-create-form-register-button", true );
112 assertTextPresent( "User " + userName + " created." );
113 assertElementPresent( "users-grid-user-id-" + userName );
117 //String[] columnValues = { userName, fullName, emailAd };
118 //assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) );
123 assertCreateUserPage();
127 public void deleteUser( String userName, String fullName, String emailAdd )
129 deleteUser( userName, fullName, emailAdd, false, false );
132 public void deleteUser( String userName, String fullName, String emailAd, boolean validated, boolean locked )
134 clickLinkWithLocator( "menu-users-list-a", true );
135 assertTextPresent( userName );
136 assertTextPresent( fullName );
138 clickLinkWithLocator( "users-grid-delete-" + userName );
140 clickLinkWithLocator( "dialog-confirm-modal-ok" );
141 assertTextPresent( "User " + userName + " deleted." );
143 clickLinkWithLocator( "alert-message-success-close-a" );
145 assertElementNotPresent( "users-grid-user-id-" + userName );
146 assertTextNotPresent( fullName );
154 public void assertCreateUserPage()
156 assertTextPresent( "Username" );
157 assertElementPresent( "username" );
158 assertTextPresent( "Full Name" );
159 assertElementPresent( "fullname" );
160 assertTextPresent( "Email Address" );
161 assertElementPresent( "email" );
162 assertTextPresent( "Password" );
163 assertElementPresent( "password" );
164 assertTextPresent( "Confirm Password" );
165 assertElementPresent( "confirmPassword" );
166 assertButtonWithIdPresent( "user-create-form-register-button" );
170 public void goToHomePage()
172 getSelenium().open( baseUrl );
175 protected void logout()
177 clickLinkWithText( "Logout" );
178 assertTextNotPresent( "Current User:" );
179 assertLinkNotVisible( "Edit Details" );
180 assertLinkNotVisible( "Logout" );
181 assertLinkVisible( "Login" );
184 protected String getAdminUserName()
186 return getProperty( "ADMIN_FULLNAME" );