geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r439765 - in /geronimo/server/trunk/testsuite: ./ console-testsuite/ console-testsuite/basic/ console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/
Date Sun, 03 Sep 2006 11:56:52 GMT
Author: jdillon
Date: Sun Sep  3 04:56:51 2006
New Revision: 439765

URL: http://svn.apache.org/viewvc?rev=439765&view=rev
Log:
Adding TestNG-based tests

Added:
    geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
  (with props)
    geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
  (with props)
    geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
  (with props)
    geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
  (with props)
Modified:
    geronimo/server/trunk/testsuite/console-testsuite/basic/pom.xml
    geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SimpleLoginTest.java
    geronimo/server/trunk/testsuite/console-testsuite/pom.xml
    geronimo/server/trunk/testsuite/pom.xml

Modified: geronimo/server/trunk/testsuite/console-testsuite/basic/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/basic/pom.xml?rev=439765&r1=439764&r2=439765&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/basic/pom.xml (original)
+++ geronimo/server/trunk/testsuite/console-testsuite/basic/pom.xml Sun Sep  3 04:56:51 2006
@@ -45,6 +45,13 @@
     
     <dependencies>
         <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <classifier>jdk14</classifier>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
             <groupId>org.openqa.selenium.client-drivers</groupId>
             <artifactId>selenium-java-client-driver</artifactId>
             <scope>test</scope>

Added: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java?rev=439765&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
(added)
+++ geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
Sun Sep  3 04:56:51 2006
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.testsuite.console;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ConsoleTestSupport
+    extends SeleniumTestSupport
+{
+    protected void login() throws Exception {
+        selenium.open("/");
+        selenium.waitForPageToLoad("30000");
+        assertEquals("Apache Geronimo", selenium.getTitle());
+        
+        selenium.click("link=Console");
+        selenium.waitForPageToLoad("30000");
+        assertEquals("Geronimo Console Login", selenium.getTitle());
+        
+        selenium.type("j_username", "system");
+        selenium.type("j_password", "manager");
+        selenium.click("submit");
+        selenium.waitForPageToLoad("30000");
+        assertEquals("Geronimo Console", selenium.getTitle());
+    }
+    
+    protected void logout() throws Exception {
+        selenium.click("//a[contains(@href, '/console/logout.jsp')]");
+        selenium.waitForPageToLoad("30000");
+        assertEquals("Geronimo Console Login", selenium.getTitle());
+        
+        selenium.removeCookie("JSESSIONID", "/");
+    }
+}
+

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ConsoleTestSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java?rev=439765&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
(added)
+++ geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
Sun Sep  3 04:56:51 2006
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.testsuite.console;
+
+import com.thoughtworks.selenium.Selenium;
+import com.thoughtworks.selenium.DefaultSelenium;
+
+import org.openqa.selenium.server.SeleniumServer;
+
+/**
+ * Provides custom extentions to Selenium.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtendedSelenium
+    extends DefaultSelenium
+{
+    public ExtendedSelenium(final String serverHost, final int serverPort, final String browserStartCommand,
final String browserURL) {
+        super(serverHost, serverPort, browserStartCommand, browserURL);
+    }
+    
+    /**
+     * Remove a cookie from the browser.
+     *
+     * <p>
+     * This requires some custom hooks in <tt>user-extensions.js</tt>.  
+     * When using the <tt>selenium-maven-plugin</tt> the defaults should be merged
+     * into the <tt>user-extensions.js</tt> which is loaded by the server.
+     */
+    public void removeCookie(final String name, final String path) {
+        this.getEval("selenium.removeCookie('" + name + "', '" + path + "')");
+    }
+}

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/ExtendedSelenium.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java?rev=439765&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
(added)
+++ geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
Sun Sep  3 04:56:51 2006
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.testsuite.console;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class LinkCheckTest
+    extends ConsoleTestSupport
+{
+    /**
+     * @testng.test
+     */
+    public void testServerInfoLink() throws Exception {
+        login();
+        
+        selenium.click("link=Information");
+        selenium.waitForPageToLoad("30000");
+        assertEquals("Geronimo Console", selenium.getTitle());
+        
+        assertTrue(selenium.isTextPresent("Geronimo Version"));
+        assertTrue(selenium.isTextPresent("Geronimo Start Time"));
+        
+        assertEquals("Server Info", selenium.getText(
+            "xpath=/html/body/table[@id='rootfragment']/tbody/tr[2]/td/table/tbody/tr[2]/td[4]/table/tbody/tr[1]/td/table/tbody/tr[1]/td/div/table/tbody/tr/td[2]/table/tbody/tr/td[1]/strong"));
+        
+        logout();
+    }
+}
+

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/LinkCheckTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java?rev=439765&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
(added)
+++ geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
Sun Sep  3 04:56:51 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.testsuite.console;
+
+import org.apache.geronimo.testsupport.TestSupport;
+
+import com.thoughtworks.selenium.Selenium;
+
+import org.openqa.selenium.server.SeleniumServer;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class SeleniumTestSupport
+    extends TestSupport
+{
+    protected static ExtendedSelenium selenium;
+    
+    protected ExtendedSelenium createSeleniumClient(String url) throws Exception {
+        super.setUp();
+        
+        if (url == null) {
+            url = "http://localhost:" + SeleniumServer.DEFAULT_PORT;
+        }
+        
+        log.info("Creating Selenium client for URL: " + url);
+        
+        ExtendedSelenium selenium = new ExtendedSelenium(
+            "localhost", SeleniumServer.DEFAULT_PORT, "*firefox", url);
+        
+        return selenium;
+    }
+    
+    /**
+     * @testng.before-suite
+     */
+    protected void startSeleniumClient() throws Exception {
+        log.info("Starting Selenium client");
+        
+        selenium = createSeleniumClient("http://localhost:8080/");
+        selenium.start();
+    }
+    
+    /**
+     * @testng.after-suite
+     */
+    protected void stopSeleniumClient() throws Exception {
+        log.info("Stopping Selenium client");
+        
+        selenium.stop();
+    }
+}
+

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SeleniumTestSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SimpleLoginTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SimpleLoginTest.java?rev=439765&r1=439764&r2=439765&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SimpleLoginTest.java
(original)
+++ geronimo/server/trunk/testsuite/console-testsuite/basic/src/test/java/org/apache/geronimo/testsuite/console/SimpleLoginTest.java
Sun Sep  3 04:56:51 2006
@@ -19,89 +19,36 @@
 
 package org.apache.geronimo.testsuite.console;
 
-import junit.framework.TestCase;
-
-import com.thoughtworks.selenium.Selenium;
-import com.thoughtworks.selenium.DefaultSelenium;
-
-import org.openqa.selenium.server.SeleniumServer;
-
 /**
  * ???
  *
  * @version $Rev$ $Date$
  */
 public class SimpleLoginTest
-    extends TestCase
+    extends ConsoleTestSupport
 {
-    private Selenium selenium;
-    
-    protected void setUp(String url) throws Exception {
-        super.setUp();
-        if (url == null) {
-            url = "http://localhost:" + SeleniumServer.DEFAULT_PORT;
-        }
-        selenium = new DefaultSelenium("localhost", SeleniumServer.DEFAULT_PORT, "*firefox",
url);
-        selenium.start();
-    }
-    
-    protected void setUp() throws Exception {
-        super.setUp();
-        
-        this.setUp("http://localhost:8080/");
-    }
-    
-    protected void tearDown() throws Exception {
-        selenium.stop();
-    }
-    
+    /**
+     * @testng.test
+     */
     public void testLogin() throws Exception {
-        selenium.open("/");
-        assertEquals("Apache Geronimo", selenium.getTitle());
-        
-        selenium.click("link=Console");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console Login", selenium.getTitle());
+        login();
         
-        selenium.type("j_username", "system");
-        selenium.type("j_password", "manager");
-        selenium.click("submit");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console", selenium.getTitle());
-	}
+        selenium.removeCookie("JSESSIONID", "/");
+    }
     
+    /**
+     * @testng.test
+     */
     public void testLoginAndLogout() throws Exception {
-        selenium.open("/");
-        assertEquals("Apache Geronimo", selenium.getTitle());
-        
-        selenium.click("link=Console");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console Login", selenium.getTitle());
-        
-        selenium.type("j_username", "system");
-        selenium.type("j_password", "manager");
-        selenium.click("submit");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console", selenium.getTitle());
-        
-        selenium.click("//a[contains(@href, '/console/logout.jsp')]");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console Login", selenium.getTitle());
+        login();
+        logout();
     }
     
+    /**
+     * @testng.test
+     */
     public void testClickSomeLinks() throws Exception {
-        selenium.open("/");
-        assertEquals("Apache Geronimo", selenium.getTitle());
-        
-        selenium.click("link=Console");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console Login", selenium.getTitle());
-        
-        selenium.type("j_username", "system");
-        selenium.type("j_password", "manager");
-        selenium.click("submit");
-        selenium.waitForPageToLoad("30000");
-        assertEquals("Geronimo Console", selenium.getTitle());
+        login();
         
         selenium.click("link=Information");
         selenium.waitForPageToLoad("30000");
@@ -114,6 +61,8 @@
         selenium.click("link=DB Info");
         selenium.waitForPageToLoad("30000");
         assertEquals("Geronimo Console", selenium.getTitle());
+        
+        logout();
     }
 }
 

Modified: geronimo/server/trunk/testsuite/console-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/console-testsuite/pom.xml?rev=439765&r1=439764&r2=439765&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/console-testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/console-testsuite/pom.xml Sun Sep  3 04:56:51 2006
@@ -88,7 +88,6 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-invoker-plugin</artifactId>
-                <version>1.0-SNAPSHOT</version>
                 
                 <configuration>
                     <debug>true</debug>

Modified: geronimo/server/trunk/testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/pom.xml?rev=439765&r1=439764&r2=439765&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/pom.xml Sun Sep  3 04:56:51 2006
@@ -47,6 +47,13 @@
     <dependencyManagement>
         <dependencies>
             <dependency>
+                <groupId>org.testng</groupId>
+                <artifactId>testng</artifactId>
+                <classifier>jdk14</classifier>
+                <version>5.1</version>
+            </dependency>
+            
+            <dependency>
                 <groupId>org.openqa.selenium.client-drivers</groupId>
                 <artifactId>selenium-java-client-driver</artifactId>
                 <version>0.8.1</version>
@@ -60,6 +67,38 @@
         </dependencies>
     </dependencyManagement>
     
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.testsupport</groupId>
+            <artifactId>testsupport-common</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-invoker-plugin</artifactId>
+                    <version>1.0-SNAPSHOT</version>
+                </plugin>
+                
+                <!--
+                NOTE: Using custom maven-surefire-plugin that supports TestNG:
+                      
+                      http://testng.org/doc/maven.html
+                -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>2.8-SNAPSHOT</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+    
     <repositories>
         <repository>
             <id>openqa</id>
@@ -76,5 +115,15 @@
             </releases>
         </repository>
     </repositories>
+    
+    <!--
+    NOTE: This is the repository where maven-surefire-plugin:2.8-SNAPSHOT comes from.
+    -->
+    <pluginRepositories>
+        <pluginRepository>
+            <id>tapestry.javaforge</id>
+            <url>http://howardlewisship.com/repository</url>
+        </pluginRepository>
+    </pluginRepositories>
 
 </project>



Mime
View raw message