Revision 991672a1
Added by Andreas Kohlbecker about 12 years ago
.gitattributes | ||
---|---|---|
256 | 256 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/SystemUtils.java -text |
257 | 257 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java -text |
258 | 258 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java -text |
259 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java -text |
|
259 | 260 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties -text |
260 | 261 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/log4j.properties -text |
261 | 262 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalSeleniumRCTestBase.java -text |
... | ... | |
263 | 264 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java -text |
264 | 265 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CichorieaeSearchTest.java -text |
265 | 266 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java -text |
267 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java -text |
|
266 | 268 |
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 |
267 | 269 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firebug-1.6.2.xpi -text |
270 |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firexpath-0.9.6.1-fx.xpi -text |
|
268 | 271 |
modules/cdm_dataportal/test/phpUnit/TestUtils.php -text |
269 | 272 |
modules/cdm_dataportal/test/phpUnit/bootstrap.php -text |
270 | 273 |
modules/cdm_dataportal/test/phpUnit/phpUnit.conf.xml -text |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalContext.java | ||
---|---|---|
3 | 3 |
* Copyright (C) 2009 EDIT |
4 | 4 |
* European Distributed Institute of Taxonomy |
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.dataportal; |
11 | 11 |
|
12 | 12 |
import java.net.URI; |
13 |
import java.net.URISyntaxException; |
|
14 | 13 |
import java.util.UUID; |
15 | 14 |
|
16 | 15 |
import org.apache.log4j.Logger; |
... | ... | |
20 | 19 |
* TODO 2. let constructor read from a dataPortalTestContext.properties located in the jar (/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties) |
21 | 20 |
* TODO 3. DataPortalTest.properties should allow setting the defalut eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase.SYSTEM_PROPERTY_NAME_BROWSER |
22 | 21 |
* TODO 4. DataPortalTest.properties should allow setting webdriver.firefox.bin etc in order to circumven the need to set it by -Dwebdriver.firefox.bin |
23 |
*
|
|
22 |
* |
|
24 | 23 |
* @author a.kohlbecker |
25 | 24 |
* |
26 | 25 |
*/ |
27 | 26 |
public enum DataPortalContext { |
28 | 27 |
|
29 |
cichorieae(""), |
|
30 |
palmae(""), |
|
31 |
cyprus(""); |
|
28 |
cichorieae, |
|
29 |
palmae, |
|
30 |
cyprus, |
|
31 |
floramalesiana; |
|
32 | 32 |
|
33 | 33 |
URI baseUri; |
34 | 34 |
URI cdmServerUri; |
... | ... | |
37 | 37 |
|
38 | 38 |
public final Logger logger = Logger.getLogger(DataPortalContext.class); |
39 | 39 |
|
40 |
private DataPortalContext(String dummy) { |
|
41 |
|
|
40 |
private DataPortalContext() { |
|
42 | 41 |
this.baseUri = TestConfiguration.getProperty(composePropertyKey("baseUri"), URI.class); |
43 | 42 |
this.cdmServerUri = TestConfiguration.getProperty(composePropertyKey("cdmServerUri"), URI.class); |
44 | 43 |
this.classificationUUID = TestConfiguration.getProperty(composePropertyKey("classificationUUID"), UUID.class); |
45 |
|
|
46 | 44 |
} |
47 | 45 |
|
48 | 46 |
private String composePropertyKey(String fieldName) { |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.dataportal; |
5 | 5 |
|
... | ... | |
20 | 20 |
|
21 | 21 |
/** |
22 | 22 |
* @author a.kohlbecker |
23 |
*
|
|
23 |
* |
|
24 | 24 |
*/ |
25 | 25 |
public class TestConfiguration { |
26 | 26 |
|
27 | 27 |
/** |
28 |
*
|
|
28 |
* |
|
29 | 29 |
*/ |
30 | 30 |
private static final String DATA_PORTAL_TEST_PROPERTIES_FILE = "DataPortalTest.properties"; |
31 | 31 |
|
... | ... | |
72 | 72 |
} |
73 | 73 |
|
74 | 74 |
/** |
75 |
*
|
|
75 |
* |
|
76 | 76 |
*/ |
77 | 77 |
private void updateSystemProperties(boolean doOverride) { |
78 | 78 |
for(Object o : properties.keySet()){ |
... | ... | |
98 | 98 |
testConfiguration = new TestConfiguration(); |
99 | 99 |
} |
100 | 100 |
String value = testConfiguration.getProperties().getProperty(key); |
101 |
if(URI.class.isAssignableFrom(type)){ |
|
102 |
try { |
|
103 |
return (T) new URI(value); |
|
104 |
} catch (URISyntaxException e) { |
|
105 |
logger.error("Invalid URI " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString()); |
|
106 |
} |
|
107 |
} else if(UUID.class.isAssignableFrom(type)){ |
|
108 |
try { |
|
109 |
return (T) UUID.fromString(value); |
|
110 |
} catch (IllegalArgumentException e) { |
|
111 |
logger.error("Invalid UUID " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString()); |
|
101 |
|
|
102 |
if(value != null){ |
|
103 |
if(URI.class.isAssignableFrom(type)){ |
|
104 |
try { |
|
105 |
return (T) new URI(value); |
|
106 |
} catch (URISyntaxException e) { |
|
107 |
logger.error("Invalid URI " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString()); |
|
108 |
} |
|
109 |
} else if(UUID.class.isAssignableFrom(type)){ |
|
110 |
try { |
|
111 |
return (T) UUID.fromString(value); |
|
112 |
} catch (IllegalArgumentException e) { |
|
113 |
logger.error("Invalid UUID " + value + " in property " + key + " of " + testConfiguration.propertySourceUri.toString()); |
|
114 |
} |
|
115 |
} else if(String.class.isAssignableFrom(type)){ |
|
116 |
return (T) value; |
|
117 |
} else { |
|
118 |
throw new RuntimeException("Unsupported type " + type.toString()); |
|
112 | 119 |
} |
113 |
} else if(String.class.isAssignableFrom(type)){ |
|
114 |
return (T) value; |
|
115 |
} else { |
|
116 |
throw new RuntimeException("Unsupported type " + type.toString()); |
|
117 | 120 |
} |
121 |
|
|
118 | 122 |
return null; |
119 | 123 |
} |
120 | 124 |
|
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java | ||
---|---|---|
31 | 31 |
public class DataPortalContextSuite extends Suite{ |
32 | 32 |
|
33 | 33 |
/** |
34 |
* Only to be used for test calsses which extend {@link CdmDataPortalTestBase}
|
|
34 |
* Only to be used for test classes which extend {@link CdmDataPortalTestBase}
|
|
35 | 35 |
* |
36 | 36 |
* @author a.kohlbecker |
37 | 37 |
*/ |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.dataportal.testutils; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import org.junit.Assert; |
|
10 |
import org.openqa.selenium.By; |
|
11 |
import org.openqa.selenium.WebElement; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author a.kohlbecker |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class PolytomousKeyTestTool { |
|
18 |
|
|
19 |
Map<Integer, KeyLineData> linesUnderTest; // = new HashMap<Integer, KeyLineData>(); |
|
20 |
List<WebElement> keyTableRows; |
|
21 |
|
|
22 |
public PolytomousKeyTestTool(List<WebElement> keyTableRows, Map<Integer, KeyLineData> linesUnderTest){ |
|
23 |
this.linesUnderTest = linesUnderTest; |
|
24 |
this.keyTableRows = keyTableRows; |
|
25 |
} |
|
26 |
|
|
27 |
public void runTest(){ |
|
28 |
for(Integer key : linesUnderTest.keySet()){ |
|
29 |
testPolytomousKeyLine(keyTableRows.get(key), linesUnderTest.get(key)); |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
public static class KeyLineData{ |
|
34 |
|
|
35 |
String nodeNumber = null; |
|
36 |
String edgeText = null; |
|
37 |
LinkClass linkClass = null; |
|
38 |
String linkText = null; |
|
39 |
|
|
40 |
public KeyLineData(String nodeNumber, String edgeText, LinkClass linkClass, String linkText) { |
|
41 |
this.nodeNumber = nodeNumber; |
|
42 |
this.edgeText = edgeText; |
|
43 |
this.linkClass = linkClass; |
|
44 |
this.linkText = linkText; |
|
45 |
} |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
public enum LinkClass { |
|
50 |
nodeLinkToNode, |
|
51 |
nodeLinkToTaxon; |
|
52 |
} |
|
53 |
|
|
54 |
public void testPolytomousKeyLine(WebElement keyEntry, KeyLineData data) { |
|
55 |
Assert.assertEquals("node number", data.nodeNumber, keyEntry.findElement(By.className("nodeNumber")).getText()); |
|
56 |
Assert.assertEquals("edge text", data.edgeText + data.linkText, keyEntry.findElement(By.className("edge")).getText()); |
|
57 |
WebElement link = keyEntry.findElement(By.className(data.linkClass.name())); |
|
58 |
Assert.assertEquals("link text", data.linkText, link.findElement(By.tagName("a")).getText()); |
|
59 |
} |
|
60 |
|
|
61 |
} |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties | ||
---|---|---|
16 | 16 |
dataPortalContext.cyprus.classificationUUID=0c2b5d25-7b15-4401-8b51-dd4be0ee5cab |
17 | 17 |
dataPortalContext.cyprus.themeName= |
18 | 18 |
|
19 |
dataPortalContext.floramalesiana.baseUri=http://160.45.63.201/dataportal/preview/flora-malesiana/ |
|
20 |
dataPortalContext.floramalesiana.cdmServerUri=http://160.45.63.201:8080/flora-malesiana/ |
|
21 |
dataPortalContext.floramalesiana.classificationUUID=ca4e4bcb-a1d1-4124-a358-a3d3c41dd450 |
|
22 |
dataPortalContext.floramalesiana.themeName= |
|
23 |
|
|
19 | 24 |
# |
20 | 25 |
# The browser to be used for testing (defaults to firefox) |
21 | 26 |
# |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java | ||
---|---|---|
32 | 32 |
public static final String SYSTEM_PROPERTY_NAME_BROWSER = "browser"; |
33 | 33 |
|
34 | 34 |
private static final String FIREBUG_VERSION = "1.6.2"; |
35 |
private static final String FIREXPATH_VERSION = "0.9.6.1"; |
|
35 | 36 |
|
36 | 37 |
protected static WebDriver driver; |
37 | 38 |
|
... | ... | |
103 | 104 |
firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firebug-" + FIREBUG_VERSION + ".xpi"); |
104 | 105 |
firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION); // avoid displaying firt run page |
105 | 106 |
|
107 |
firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firexpath-" + FIREXPATH_VERSION + "-fx.xpi"); |
|
108 |
|
|
106 | 109 |
// --- allow enabling incompatible addons |
107 | 110 |
// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi"); |
108 | 111 |
// firefoxProfile.setPreference("extensions.acr.firstrun", false); |
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java | ||
---|---|---|
13 | 13 |
import org.junit.Test; |
14 | 14 |
import org.openqa.selenium.By; |
15 | 15 |
import org.openqa.selenium.RenderedWebElement; |
16 |
import org.openqa.selenium.WebElement; |
|
16 | 17 |
|
17 | 18 |
import eu.etaxonomy.dataportal.DataPortalContext; |
18 | 19 |
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts; |
... | ... | |
32 | 33 |
@Test |
33 | 34 |
public void searchResultsWithoutAnnotationFootnotes(){ |
34 | 35 |
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"); |
35 |
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']")); |
|
36 |
|
|
37 |
// --- This variant is slower in FF that using the full xpath |
|
38 |
// WebElement container = driver.findElement(By.id("squeeze")); |
|
39 |
// RenderedWebElement element = (RenderedWebElement)container.findElement(By.xpath("div/div/ul/li/span[contains(@class, 'footnote-key')]")); |
|
40 |
|
|
41 |
// --- using the full xpath |
|
42 |
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')]")); |
|
36 | 43 |
Assert.assertNull("result set entries must not have footnote keys", element); |
37 | 44 |
} |
38 | 45 |
|
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2009 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.dataportal.selenium.tests; |
|
11 |
|
|
12 |
import java.util.HashMap; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
|
|
16 |
import org.junit.Assert; |
|
17 |
import org.junit.Test; |
|
18 |
import org.openqa.selenium.By; |
|
19 |
import org.openqa.selenium.RenderedWebElement; |
|
20 |
import org.openqa.selenium.WebElement; |
|
21 |
|
|
22 |
import eu.etaxonomy.dataportal.DataPortalContext; |
|
23 |
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts; |
|
24 |
import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase; |
|
25 |
import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool; |
|
26 |
import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool.KeyLineData; |
|
27 |
import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool.LinkClass; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author a.kohlbecker |
|
31 |
* |
|
32 |
*/ |
|
33 |
|
|
34 |
@DataPortalContexts( { DataPortalContext.floramalesiana }) |
|
35 |
public class FloraMalesianaPolytomousKeyTest extends CdmDataPortalTestBase{ |
|
36 |
|
|
37 |
/** |
|
38 |
* see http://dev.e-taxonomy.eu/trac/ticket/2350 |
|
39 |
*/ |
|
40 |
@Test |
|
41 |
public void key_to_Malaysian_Sapindaceae_Genera(){ |
|
42 |
driver.get(getBaseUrl() + "?q=cdm_dataportal/polytomousKey/40cf3253-ce7a-4ad6-9a32-27695c36eb5d"); |
|
43 |
|
|
44 |
// Page title |
|
45 |
RenderedWebElement element = (RenderedWebElement)driver.findElement(By.xpath(".//*[@id='squeeze']/div/div/h2")); |
|
46 |
Assert.assertEquals("Key to Malaysian Sapindaceae Genera (based on vegetative and flower characters)", element.getText()); |
|
47 |
|
|
48 |
List<WebElement> keyTableList = driver.findElements(By.className("polytomousKey")); |
|
49 |
Assert.assertEquals("Only one polytomousKey table expected", 1, keyTableList.size()); |
|
50 |
WebElement keyTable = keyTableList.get(0); |
|
51 |
|
|
52 |
List<WebElement> tableRows = keyTable.findElements(By.xpath("tbody/tr")); |
|
53 |
|
|
54 |
Map<Integer, PolytomousKeyTestTool.KeyLineData> keyLineDataMap = new HashMap<Integer, PolytomousKeyTestTool.KeyLineData>(); |
|
55 |
|
|
56 |
keyLineDataMap.put(0, new KeyLineData( |
|
57 |
"0", |
|
58 |
"Trees or shrubs, exceptionally lianas. Leaves simple, unifoliolate, (bi)pinnate or digitate. Inflorescences without basal tendrils", |
|
59 |
LinkClass.nodeLinkToNode, |
|
60 |
"1")); |
|
61 |
|
|
62 |
keyLineDataMap.put(1, new KeyLineData("0'", |
|
63 |
"Herbaceous or woody climbers. Leaves biternate. Inflorescences with basal tendrils", |
|
64 |
LinkClass.nodeLinkToTaxon, |
|
65 |
"Cardiospermum")); |
|
66 |
|
|
67 |
keyLineDataMap.put(2, new KeyLineData("1", |
|
68 |
"Leaves simple, unifoliolate, (im)paripinnate or digitate", |
|
69 |
LinkClass.nodeLinkToNode, |
|
70 |
"2")); |
|
71 |
|
|
72 |
keyLineDataMap.put(3, new KeyLineData("1'", |
|
73 |
"Leaves bipinnate", |
|
74 |
LinkClass.nodeLinkToTaxon, |
|
75 |
"Tristiropsis")); |
|
76 |
|
|
77 |
keyLineDataMap.put(126, new KeyLineData("116", |
|
78 |
"Leaflets entire or crenulate, lower surface without small glands. Inflorescences axillary, sometimes together pseudoterminal; cymes dense, many-flowered", |
|
79 |
LinkClass.nodeLinkToTaxon, |
|
80 |
"Synima cordierorum")); |
|
81 |
|
|
82 |
keyLineDataMap.put(127, new KeyLineData("116'", |
|
83 |
"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", |
|
84 |
LinkClass.nodeLinkToTaxon, |
|
85 |
"Trigonachras")); |
|
86 |
|
|
87 |
PolytomousKeyTestTool tester = new PolytomousKeyTestTool(tableRows, keyLineDataMap); |
|
88 |
tester.runTest(); |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
} |
Also available in: Unified diff
more tests + firepath plugin