continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
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 GMT
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<Selenium>()
+    /**
+     * 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<Selenium>()
             {
-                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();
+        }
     }
 
     // *******************************************************



Mime
View raw message