commit 991672a12cf84a76bb3ef445462cc1faf81911fa
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Tue May 10 13:18:41 2011 +0000

    more tests + firepath plugin

diff --git a/.gitattributes b/.gitattributes
index dd9334db..46b6c200 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -256,6 +256,7 @@ modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etax
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/SystemUtils.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java -text
+modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/log4j.properties -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalSeleniumRCTestBase.java -text
@@ -263,8 +264,10 @@ modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etax
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CichorieaeSearchTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java -text
+modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firebug-1.6.2.xpi -text
+modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firexpath-0.9.6.1-fx.xpi -text
 modules/cdm_dataportal/test/phpUnit/TestUtils.php -text
 modules/cdm_dataportal/test/phpUnit/bootstrap.php -text
 modules/cdm_dataportal/test/phpUnit/phpUnit.conf.xml -text
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalContext.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalContext.java
index 3e33a89a..852cbd97 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalContext.java
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalContext.java
@@ -3,14 +3,13 @@
  * Copyright (C) 2009 EDIT
  * European Distributed Institute of Taxonomy
  * http://www.e-taxonomy.eu
- * 
+ *
  * The contents of this file are subject to the Mozilla Public License Version 1.1
  * See LICENSE.TXT at the top of this package for the full license terms.
  */
 package eu.etaxonomy.dataportal;
 
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.UUID;
 
 import org.apache.log4j.Logger;
@@ -20,15 +19,16 @@ import org.apache.log4j.Logger;
  * TODO 2. let constructor read from a dataPortalTestContext.properties located in the jar (/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties)
  * TODO 3. DataPortalTest.properties should allow setting the defalut eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase.SYSTEM_PROPERTY_NAME_BROWSER
  * TODO 4. DataPortalTest.properties should allow setting webdriver.firefox.bin etc in order to circumven the need to set it by -Dwebdriver.firefox.bin
- * 
+ *
  * @author a.kohlbecker
  *
  */
 public enum DataPortalContext {
 
-	cichorieae(""),
-	palmae(""),
-	cyprus("");
+	cichorieae,
+	palmae,
+	cyprus,
+	floramalesiana;
 
 	URI baseUri;
 	URI cdmServerUri;
@@ -37,12 +37,10 @@ public enum DataPortalContext {
 
 	public final Logger logger = Logger.getLogger(DataPortalContext.class);
 
-	private DataPortalContext(String dummy) {
-
+	private DataPortalContext() {
 		this.baseUri = TestConfiguration.getProperty(composePropertyKey("baseUri"), URI.class);
 		this.cdmServerUri = TestConfiguration.getProperty(composePropertyKey("cdmServerUri"), URI.class);
 		this.classificationUUID = TestConfiguration.getProperty(composePropertyKey("classificationUUID"), UUID.class);
-
 	}
 
 	private String composePropertyKey(String fieldName) {
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java
index 674e4af6..ab1287b5 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.dataportal;
 
@@ -20,12 +20,12 @@ import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
 
 /**
  * @author a.kohlbecker
- * 
+ *
  */
 public class TestConfiguration {
 
 	/**
-	 * 
+	 *
 	 */
 	private static final String DATA_PORTAL_TEST_PROPERTIES_FILE = "DataPortalTest.properties";
 
@@ -72,7 +72,7 @@ public class TestConfiguration {
 	}
 
 	/**
-	 * 
+	 *
 	 */
 	private void updateSystemProperties(boolean doOverride) {
 		for(Object o : properties.keySet()){
@@ -98,23 +98,27 @@ public class TestConfiguration {
 			testConfiguration = new TestConfiguration();
 		}
 		String value = testConfiguration.getProperties().getProperty(key);
-		if(URI.class.isAssignableFrom(type)){
-			try {
-				return (T) new URI(value);
-			} catch (URISyntaxException e) {
-				logger.error("Invalid URI " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString());
-			}
-		} else if(UUID.class.isAssignableFrom(type)){
-			try {
-				return (T) UUID.fromString(value);
-			} catch (IllegalArgumentException e) {
-				logger.error("Invalid UUID " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString());
+
+		if(value != null){
+			if(URI.class.isAssignableFrom(type)){
+				try {
+					return (T) new URI(value);
+				} catch (URISyntaxException e) {
+					logger.error("Invalid URI " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString());
+				}
+			} else if(UUID.class.isAssignableFrom(type)){
+				try {
+					return (T) UUID.fromString(value);
+				} catch (IllegalArgumentException e) {
+					logger.error("Invalid UUID " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString());
+				}
+			} else if(String.class.isAssignableFrom(type)){
+				return (T) value;
+			} else {
+				throw new RuntimeException("Unsupported type " + type.toString());
 			}
-		} else if(String.class.isAssignableFrom(type)){
-			return (T) value;
-		} else {
-			throw new RuntimeException("Unsupported type " + type.toString());
 		}
+
 		return null;
 	}
 
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java
index 8c99ba85..4403d098 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java
@@ -31,7 +31,7 @@ import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
 public class DataPortalContextSuite extends Suite{
 
 	/**
-	 * Only to be used for test calsses which extend {@link CdmDataPortalTestBase}
+	 * Only to be used for test classes which extend {@link CdmDataPortalTestBase}
 	 *
 	 * @author a.kohlbecker
 	 */
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java
new file mode 100644
index 00000000..79bf5909
--- /dev/null
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package eu.etaxonomy.dataportal.testutils;
+
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+/**
+ * @author a.kohlbecker
+ *
+ */
+public class PolytomousKeyTestTool {
+
+	Map<Integer, KeyLineData> linesUnderTest; //  = new HashMap<Integer, KeyLineData>();
+	List<WebElement> keyTableRows;
+
+	public PolytomousKeyTestTool(List<WebElement> keyTableRows, Map<Integer, KeyLineData> linesUnderTest){
+		this.linesUnderTest = linesUnderTest;
+		this.keyTableRows = keyTableRows;
+	}
+
+	public void runTest(){
+		for(Integer key : linesUnderTest.keySet()){
+			testPolytomousKeyLine(keyTableRows.get(key), linesUnderTest.get(key));
+		}
+	}
+
+	public static class KeyLineData{
+
+		String nodeNumber = null;
+		String edgeText = null;
+		LinkClass linkClass = null;
+		String linkText = null;
+
+		public KeyLineData(String nodeNumber, String edgeText, LinkClass linkClass, String linkText) {
+			this.nodeNumber = nodeNumber;
+			this.edgeText = edgeText;
+			this.linkClass = linkClass;
+			this.linkText = linkText;
+		}
+
+	}
+
+	public enum LinkClass {
+		nodeLinkToNode,
+		nodeLinkToTaxon;
+	}
+
+	public void testPolytomousKeyLine(WebElement keyEntry, KeyLineData data) {
+		Assert.assertEquals("node number", data.nodeNumber, keyEntry.findElement(By.className("nodeNumber")).getText());
+		Assert.assertEquals("edge text", data.edgeText + data.linkText, keyEntry.findElement(By.className("edge")).getText());
+		WebElement link = keyEntry.findElement(By.className(data.linkClass.name()));
+		Assert.assertEquals("link text", data.linkText, link.findElement(By.tagName("a")).getText());
+	}
+
+}
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties
index 3eab0f52..c680060e 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties
@@ -16,6 +16,11 @@ dataPortalContext.cyprus.cdmServerUri=http://127.0.0.1:8080
 dataPortalContext.cyprus.classificationUUID=0c2b5d25-7b15-4401-8b51-dd4be0ee5cab
 dataPortalContext.cyprus.themeName=
 
+dataPortalContext.floramalesiana.baseUri=http://160.45.63.201/dataportal/preview/flora-malesiana/
+dataPortalContext.floramalesiana.cdmServerUri=http://160.45.63.201:8080/flora-malesiana/
+dataPortalContext.floramalesiana.classificationUUID=ca4e4bcb-a1d1-4124-a358-a3d3c41dd450
+dataPortalContext.floramalesiana.themeName=
+
 #
 # The browser to be used for testing (defaults to firefox)
 #
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java
index ef5708f3..032d7593 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java
@@ -32,6 +32,7 @@ public abstract class CdmDataPortalTestBase {
 	public static final String SYSTEM_PROPERTY_NAME_BROWSER = "browser";
 
 	private static final String FIREBUG_VERSION = "1.6.2";
+	private static final String FIREXPATH_VERSION = "0.9.6.1";
 
 	protected static WebDriver driver;
 
@@ -103,6 +104,8 @@ public abstract class CdmDataPortalTestBase {
 			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firebug-" + FIREBUG_VERSION + ".xpi");
 			firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION); // avoid displaying firt run page
 
+			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firexpath-" + FIREXPATH_VERSION + "-fx.xpi");
+
 			// --- allow enabling incompatible addons
 			// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi");
 			// firefoxProfile.setPreference("extensions.acr.firstrun", false);
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java
index 0f5a6ab1..f80cadff 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java
@@ -13,6 +13,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.openqa.selenium.By;
 import org.openqa.selenium.RenderedWebElement;
+import org.openqa.selenium.WebElement;
 
 import eu.etaxonomy.dataportal.DataPortalContext;
 import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
@@ -32,7 +33,13 @@ public class CyprusSearchTest extends CdmDataPortalTestBase{
 	@Test
 	public void searchResultsWithoutAnnotationFootnotes(){
 		driver.get(getBaseUrl() + "?query=Genis*&search[tree]=0c2b5d25-7b15-4401-8b51-dd4be0ee5cab&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
-		RenderedWebElement element = (RenderedWebElement)driver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[@class='footnote-key footnote-key-1 member-of-footnotes--annotations']"));
+
+		// --- This variant is slower in FF that using the full xpath
+		//		WebElement container = driver.findElement(By.id("squeeze"));
+		//		RenderedWebElement element = (RenderedWebElement)container.findElement(By.xpath("div/div/ul/li/span[contains(@class, 'footnote-key')]"));
+
+		// --- using the full xpath
+		RenderedWebElement element = (RenderedWebElement)driver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[contains(@class, 'footnote-key')]"));
 		Assert.assertNull("result set entries must not have footnote keys", element);
 	}
 
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java
new file mode 100644
index 00000000..b142c5a8
--- /dev/null
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java
@@ -0,0 +1,92 @@
+// $Id$
+/**
+ * Copyright (C) 2009 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+package eu.etaxonomy.dataportal.selenium.tests;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.RenderedWebElement;
+import org.openqa.selenium.WebElement;
+
+import eu.etaxonomy.dataportal.DataPortalContext;
+import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
+import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
+import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool;
+import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool.KeyLineData;
+import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool.LinkClass;
+
+/**
+ * @author a.kohlbecker
+ *
+ */
+
+@DataPortalContexts( { DataPortalContext.floramalesiana })
+public class FloraMalesianaPolytomousKeyTest extends CdmDataPortalTestBase{
+
+	/**
+	 * see http://dev.e-taxonomy.eu/trac/ticket/2350
+	 */
+	@Test
+	public void key_to_Malaysian_Sapindaceae_Genera(){
+		driver.get(getBaseUrl() + "?q=cdm_dataportal/polytomousKey/40cf3253-ce7a-4ad6-9a32-27695c36eb5d");
+
+		// Page title
+		RenderedWebElement element = (RenderedWebElement)driver.findElement(By.xpath(".//*[@id='squeeze']/div/div/h2"));
+		Assert.assertEquals("Key to Malaysian Sapindaceae Genera (based on vegetative and flower characters)", element.getText());
+
+		List<WebElement> keyTableList = driver.findElements(By.className("polytomousKey"));
+		Assert.assertEquals("Only one polytomousKey table expected", 1, keyTableList.size());
+		WebElement keyTable = keyTableList.get(0);
+
+		List<WebElement> tableRows = keyTable.findElements(By.xpath("tbody/tr"));
+
+		Map<Integer, PolytomousKeyTestTool.KeyLineData> keyLineDataMap = new HashMap<Integer, PolytomousKeyTestTool.KeyLineData>();
+
+		keyLineDataMap.put(0, new KeyLineData(
+				"0",
+				"Trees or shrubs, exceptionally lianas. Leaves simple, unifoliolate, (bi)pinnate or digitate. Inflorescences without basal tendrils",
+				LinkClass.nodeLinkToNode,
+				"1"));
+
+		keyLineDataMap.put(1, new KeyLineData("0'",
+				"Herbaceous or woody climbers. Leaves biternate. Inflorescences with basal tendrils",
+				LinkClass.nodeLinkToTaxon,
+				"Cardiospermum"));
+
+		keyLineDataMap.put(2, new KeyLineData("1",
+				"Leaves simple, unifoliolate, (im)paripinnate or digitate",
+				LinkClass.nodeLinkToNode,
+				"2"));
+
+		keyLineDataMap.put(3, new KeyLineData("1'",
+				"Leaves bipinnate",
+				LinkClass.nodeLinkToTaxon,
+				"Tristiropsis"));
+
+		keyLineDataMap.put(126, new KeyLineData("116",
+				"Leaflets entire or crenulate, lower surface without small glands. Inflorescences axillary, sometimes together pseudoterminal; cymes dense, many-flowered",
+				LinkClass.nodeLinkToTaxon,
+				"Synima cordierorum"));
+
+		keyLineDataMap.put(127, new KeyLineData("116'",
+				"Leaflets entire, lower surface usually with small glands. Inflorescences axillary, together mostly pseudoterminal, by the shifting aside and suppression of the terminal bud sometimes seemingly truly terminal; cymes lax, 1- or few-flowered",
+				LinkClass.nodeLinkToTaxon,
+				"Trigonachras"));
+
+		PolytomousKeyTestTool tester = new PolytomousKeyTestTool(tableRows, keyLineDataMap);
+		tester.runTest();
+	}
+
+
+}
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firexpath-0.9.6.1-fx.xpi b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firexpath-0.9.6.1-fx.xpi
new file mode 100644
index 00000000..ac21e1b5
Binary files /dev/null and b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firexpath-0.9.6.1-fx.xpi differ
