You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xi...@apache.org on 2010/07/01 09:22:43 UTC

svn commit: r959546 - in /geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport: ExtendedSelenium.java console/ConsoleTestSupport.java

Author: xiaming
Date: Thu Jul  1 07:22:42 2010
New Revision: 959546

URL: http://svn.apache.org/viewvc?rev=959546&view=rev
Log:
GERONIMO-5418 Add link to url map and link verification logic into selenium testsupport module

Modified:
    geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/ExtendedSelenium.java
    geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/console/ConsoleTestSupport.java

Modified: geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/ExtendedSelenium.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/ExtendedSelenium.java?rev=959546&r1=959545&r2=959546&view=diff
==============================================================================
--- geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/ExtendedSelenium.java (original)
+++ geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/ExtendedSelenium.java Thu Jul  1 07:22:42 2010
@@ -21,8 +21,10 @@ package org.apache.geronimo.testsupport;
 
 import com.thoughtworks.selenium.Selenium;
 import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.SeleniumException;
 
 import org.openqa.selenium.server.SeleniumServer;
+import org.apache.geronimo.testsupport.console.ConsoleTestSupport;
 
 /**
  * Provides custom extentions to Selenium.
@@ -48,4 +50,23 @@ public class ExtendedSelenium
     public void removeCookie(final String name, final String path) {
         this.getEval("selenium.removeCookie('" + name + "', '" + path + "')");
     }
+    
+    // Override click method in order to add link verification logic for geronimo console specifically.
+    @Override
+    public void click(String locator){
+    	try {
+    		super.click(locator);
+    	} catch (SeleniumException se){
+    		if (se.getMessage().lastIndexOf("not found") > 0){
+    			String linkKey = locator;
+    			if (ConsoleTestSupport.link2URL.containsKey(linkKey)) {
+    				super.open(ConsoleTestSupport.link2URL.get(linkKey).toString());
+    			} else {
+    				throw se;
+    			}
+    		} else {
+    			throw se;
+    		}
+    	}
+    }
 }

Modified: geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/console/ConsoleTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/console/ConsoleTestSupport.java?rev=959546&r1=959545&r2=959546&view=diff
==============================================================================
--- geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/console/ConsoleTestSupport.java (original)
+++ geronimo/server/branches/2.2/testsupport/testsupport-selenium/src/main/java/org/apache/geronimo/testsupport/console/ConsoleTestSupport.java Thu Jul  1 07:22:42 2010
@@ -19,6 +19,9 @@
 
 package org.apache.geronimo.testsupport.console;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.geronimo.testsupport.SeleniumTestSupport;
 
 /**
@@ -29,6 +32,54 @@ import org.apache.geronimo.testsupport.S
 public abstract class ConsoleTestSupport
     extends SeleniumTestSupport
 {
+	// Setup a link map in order to get right url when the link is not found.
+	public static final Map<String,String> link2URL;
+	static {
+		link2URL = new HashMap<String,String>();
+		link2URL.put("link=Welcome", "/console/portal/0/Welcome");
+		// under server
+		link2URL.put("link=Information", "/console/portal/1-1/Server/Information");
+		link2URL.put("link=Java System Info", "/console/portal/1-2/Server/Java System Info");
+		link2URL.put("link=Server Logs", "/console/portal/1-3/Server/Server Logs");
+		link2URL.put("link=Shutdown", "/console/portal/1-4/Server/Shutdown");
+		link2URL.put("link=Web Server", "/console/portal/1-5/Server/Web Server");
+		link2URL.put("link=Thread Pools", "/console/portal/1-6/Server/Thread Pools");
+		link2URL.put("link=Apache HTTP", "/console/portal/1-7/Server/Apache HTTP");
+		link2URL.put("link=Monitoring", "/console/portal/1-8/Server/Monitoring");
+		link2URL.put("link=JAR Aliases", "/console/portal/1-9/Server/JAR Aliases");
+		link2URL.put("link=JMS Server", "/console/portal/1-10/Server/JMS Server");
+		link2URL.put("link=EJB Server", "/console/portal/1-11/Server/EJB Server");
+		// under services
+		link2URL.put("link=Repository", "/console/portal/2-1/Services/Repository");
+		link2URL.put("link=JMS Resources", "/console/portal/2-2/Services/JMS Resources");
+		link2URL.put("link=Database Pools", "/console/portal/2-3/Services/Database Pools");
+		// under applications
+		link2URL.put("link=Web App WARs", "/console/portal/3-1/Applications/Web App WARs");
+		link2URL.put("link=System Modules", "/console/portal/3-2/Applications/System Modules");
+		link2URL.put("link=Application EARs", "/console/portal/3-3/Applications/Application EARs");
+		link2URL.put("link=EJB JARs", "/console/portal/3-4/Applications/EJB JARs");
+		link2URL.put("link=J2EE Connectors","/console/portal/3-5/Applications/J2EE Connectors");
+		link2URL.put("link=App Clients", "/console/portal/3-6/Applications/App Clients");
+		link2URL.put("link=Plan Creator", "/console/portal/3-7/Applications/Plan Creator");
+		link2URL.put("link=Deployer", "/console/portal/3-8/Applications/Deploy New");
+		link2URL.put("link=Plugins", "/console/portal/3-9/Applications/Plugins");
+		// under security
+		link2URL.put("link=Users and Groups", "/console/portal/4-1/Security/Users and Groups");
+		link2URL.put("link=Keystores", "/console/portal/4-2/Security/Keystores");
+		link2URL.put("link=Certificate Authority", "/console/portal/4-3/Security/Certificate Authority");
+		link2URL.put("link=Security Realms", "/console/portal/4-4/Security/Security Realms");
+		// under debug views
+		link2URL.put("link=JMX Viewer", "/console/portal/5-1/Debug Views/JMX Viewer");
+		link2URL.put("link=LDAP Viewer", "/console/portal/5-2/Debug Views/LDAP Viewer");
+		link2URL.put("link=ClassLoader Viewer", "/console/portal/5-3/Debug Views/ClassLoader Viewer");
+		link2URL.put("link=JNDI Viewer", "/console/portal/5-4/Debug Views/JNDI Viewer");
+		link2URL.put("link=Dependency Viewer", "/console/portal/5-5/Debug Views/Dependency Viewer");
+		// under Embedded DB
+		link2URL.put("link=DB Info", "/console/portal/6-1/Embedded DB/DB Info");
+		link2URL.put("link=DB Manager", "/console/portal/6-2/Embedded DB/DB Manager");
+		link2URL.put("link=Derby Logs", "/console/portal/6-3/Embedded DB/Derby Logs");
+		
+	}
     protected void login() throws Exception {    	
         selenium.open("/");              
         assertEquals("Apache Geronimo", selenium.getTitle());