Return-Path: Delivered-To: apmail-continuum-commits-archive@www.apache.org Received: (qmail 91123 invoked from network); 10 Jul 2009 02:47:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Jul 2009 02:47:38 -0000 Received: (qmail 78481 invoked by uid 500); 10 Jul 2009 02:47:48 -0000 Delivered-To: apmail-continuum-commits-archive@continuum.apache.org Received: (qmail 78426 invoked by uid 500); 10 Jul 2009 02:47:48 -0000 Mailing-List: contact commits-help@continuum.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@continuum.apache.org Delivered-To: mailing list commits@continuum.apache.org Received: (qmail 78417 invoked by uid 99); 10 Jul 2009 02:47:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jul 2009 02:47:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jul 2009 02:47:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3E976238887A; Fri, 10 Jul 2009 02:47:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r792789 - in /continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test: AboutTest.java SetupSelenium.java parent/AbstractSeleniumTest.java Date: Fri, 10 Jul 2009 02:47:26 -0000 To: commits@continuum.apache.org From: carlos@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090710024726.3E976238887A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: carlos Date: Fri Jul 10 02:47:25 2009 New Revision: 792789 URL: http://svn.apache.org/viewvc?rev=792789&view=rev Log: Split the AboutTest into SetupSelenium test Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java (with props) Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractSeleniumTest.java Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java?rev=792789&r1=792788&r2=792789&view=diff ============================================================================== --- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java (original) +++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java Fri Jul 10 02:47:25 2009 @@ -20,7 +20,6 @@ */ import org.apache.continuum.web.test.parent.AbstractContinuumTest; -import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; /** @@ -33,44 +32,6 @@ public class AboutTest extends AbstractContinuumTest { - @BeforeSuite - public void initializeContinuum() - throws Exception - { - getSelenium().open( baseUrl ); - String title = getSelenium().getTitle(); - if ( title.equals( "Create Admin User" ) ) - { - assertCreateAdmin(); - String fullname = getProperty( "ADMIN_FULLNAME" ); - String username = getProperty( "ADMIN_USERNAME" ); - String mail = getProperty( "ADMIN_MAIL" ); - String password = getProperty( "ADMIN_PASSWORD" ); - submitAdminData( fullname, mail, password ); - assertAutenticatedPage( username ); - assertEditConfigurationPage(); - postAdminUserCreation(); - clickLinkWithText( "Logout" ); - } - } - - private void postAdminUserCreation() - { - if ( getTitle().endsWith( "Continuum - Configuration" ) ) - { - String workingDir = getFieldValue( "configuration_workingDirectory" ); - String buildOutputDir = getFieldValue( "configuration_buildOutputDirectory" ); - String releaseOutputDir = getFieldValue( "configuration_releaseOutputDirectory" ); - String locationDir = "target/data"; - String data = "data"; - setFieldValue( "workingDirectory", workingDir.replaceFirst( data, locationDir ) ); - setFieldValue( "buildOutputDirectory", buildOutputDir.replaceFirst( data, locationDir ) ); - setFieldValue( "releaseOutputDirectory", releaseOutputDir.replaceFirst( data, locationDir ) ); - setFieldValue( "baseUrl", baseUrl ); - submit(); - } - } - public void displayAboutPage() { goToAboutPage(); Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java?rev=792789&view=auto ============================================================================== --- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java (added) +++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java Fri Jul 10 02:47:25 2009 @@ -0,0 +1,104 @@ +package org.apache.continuum.web.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.continuum.web.test.parent.AbstractContinuumTest; +import org.testng.Assert; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +/** + * Based on SetupSelenium of Wendy Smoak test. + * + * @author José Morales Martínez + * @version $Id$ + */ +@Test( groups = { "setup" }, alwaysRun = true ) +public class SetupSelenium + extends AbstractContinuumTest +{ + @Override + @AfterSuite + public void close() + throws Exception + { + super.close(); + } + + @Override + @BeforeSuite + public void open() + throws Exception + { + super.open(); + } + + @BeforeTest + @Parameters( { "browser" } ) + public void initializeContinuum( String browser ) + throws Exception + { + System.out.println( this.getClass().getName() + " initializeContinuum" ); + + super.open( browser ); + Assert.assertNotNull( getSelenium(), "Selenium is not initialized" ); + getSelenium().open( baseUrl ); + String title = getSelenium().getTitle(); + if ( title.equals( "Create Admin User" ) ) + { + assertCreateAdmin(); + String fullname = getProperty( "ADMIN_FULLNAME" ); + String username = getProperty( "ADMIN_USERNAME" ); + String mail = getProperty( "ADMIN_MAIL" ); + String password = getProperty( "ADMIN_PASSWORD" ); + submitAdminData( fullname, mail, password ); + assertAutenticatedPage( username ); + assertEditConfigurationPage(); + postAdminUserCreation(); + clickLinkWithText( "Logout" ); + } + } + + private void postAdminUserCreation() + { + if ( getTitle().endsWith( "Continuum - Configuration" ) ) + { + String workingDir = getFieldValue( "configuration_workingDirectory" ); + String buildOutputDir = getFieldValue( "configuration_buildOutputDirectory" ); + String releaseOutputDir = getFieldValue( "configuration_releaseOutputDirectory" ); + String locationDir = "target/data"; + String data = "data"; + setFieldValue( "workingDirectory", workingDir.replaceFirst( data, locationDir ) ); + setFieldValue( "buildOutputDirectory", buildOutputDir.replaceFirst( data, locationDir ) ); + setFieldValue( "releaseOutputDirectory", releaseOutputDir.replaceFirst( data, locationDir ) ); + setFieldValue( "baseUrl", baseUrl ); + submit(); + } + } + + public void displayAboutPage() + { + goToAboutPage(); + } + +} \ No newline at end of file Propchange: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Propchange: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SetupSelenium.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractSeleniumTest.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractSeleniumTest.java?rev=792789&r1=792788&r2=792789&view=diff ============================================================================== --- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractSeleniumTest.java (original) +++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractSeleniumTest.java Fri Jul 10 02:47:25 2009 @@ -30,10 +30,7 @@ import java.util.Map.Entry; import org.apache.commons.io.IOUtils; -import org.codehaus.plexus.util.StringUtils; import org.testng.Assert; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium; @@ -54,15 +51,19 @@ private static Properties p; + private static String seleniumHost; + + private static int seleniumPort; + private final static String PROPERTIES_SEPARATOR = "="; /** - * Initialize selenium an others properties. This method is called from BeforeSuite method of sub-class. + * Initialize properties. */ - @BeforeSuite( alwaysRun = true ) public void open() throws Exception { + System.out.println( this.getClass().getName() + " open" ); InputStream input = this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ); p = new Properties(); p.load( input ); @@ -70,30 +71,34 @@ baseUrl = getProperty( "BASE_URL" ); maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" ); - String seleniumHost = getProperty( "SELENIUM_HOST" ); - int seleniumPort = Integer.parseInt( ( getProperty( "SELENIUM_PORT" ) ) ); - - String seleniumBrowser = System.getProperty( "browser" ); - if ( StringUtils.isEmpty( seleniumBrowser ) ) - { - seleniumBrowser = getProperty( "SELENIUM_BROWSER" ); - } + seleniumHost = getProperty( "SELENIUM_HOST" ); + seleniumPort = Integer.parseInt( ( getProperty( "SELENIUM_PORT" ) ) ); + } - final Selenium s = new DefaultSelenium( seleniumHost, seleniumPort, seleniumBrowser, baseUrl ); - selenium = new ThreadLocal() + /** + * Initialize selenium + */ + public void open( String browser ) + throws Exception + { + if ( getSelenium() == null ) { - @Override - protected Selenium initialValue() + final Selenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl ); + selenium = new ThreadLocal() { - return s; - } - }; - getSelenium().start(); + @Override + protected Selenium initialValue() + { + return s; + } + }; + getSelenium().start(); + } } public static Selenium getSelenium() { - return selenium.get(); + return selenium == null ? null : selenium.get(); } protected String getProperty( String key ) @@ -129,11 +134,15 @@ /** * Close selenium session. Called from AfterSuite method of sub-class */ - @AfterSuite( alwaysRun = true ) public void close() throws Exception { - getSelenium().stop(); + System.out.println(this.getClass().getName() + " close"); + + if ( getSelenium() != null ) + { + getSelenium().stop(); + } } // *******************************************************