Project

General

Profile

« Previous | Next » 

Revision 330aac83

Added by Andreas Kohlbecker almost 13 years ago

moving test base classes to main

View differences:

.gitattributes
255 255
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/DataPortalManager.java -text
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
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalSeleniumRCTestBase.java -text
259
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalTestBase.java -text
258 260
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java -text
259 261
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/testutils/PolytomousKeyTestTool.java -text
260 262
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.properties -text
261 263
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/log4j.properties -text
262
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalSeleniumRCTestBase.java -text
263
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java -text
264 264
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java -text
265 265
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CichorieaeSearchTest.java -text
266 266
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/main/java/eu/etaxonomy/dataportal/TestConfiguration.java
16 16

  
17 17
import org.apache.log4j.Logger;
18 18

  
19
import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
19
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
20 20

  
21 21
/**
22 22
 * @author a.kohlbecker
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalSeleniumRCTestBase.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.junit;
11

  
12
import org.junit.After;
13
import org.junit.AfterClass;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.openqa.selenium.WebDriverBackedSelenium;
17

  
18
import com.thoughtworks.selenium.Selenium;
19

  
20
import eu.etaxonomy.dataportal.DataPortalContext;
21
import eu.etaxonomy.dataportal.DataPortalManager;
22

  
23
/**
24
 * http://seleniumhq.org/docs/03_webdriver.html#emulating-selenium-rc
25
 *
26
 * @author a.kohlbecker
27
 * @deprecated SeleniumRCTests should only be used if you are really desperatly
28
 *             shor in time and you need to use the Selenium 1 IDE in order to
29
 *             quickly create tests.
30
 */
31
@Deprecated
32
public abstract class CdmDataPortalSeleniumRCTestBase extends CdmDataPortalTestBase {
33

  
34
	protected static Selenium selenium;
35

  
36
	@Before
37
	public void setUpSelenium() {
38
		if(selenium == null) {
39
			selenium = new WebDriverBackedSelenium(driver, getContext().getBaseUri().toString());
40
		}
41
	}
42

  
43
	@AfterClass
44
	public static void stopSelenium() {
45
		if (selenium != null) {
46
			selenium.stop();
47
			selenium = null;
48
		}
49
	}
50

  
51
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalTestBase.java
1
/**
2
 *
3
 */
4
package eu.etaxonomy.dataportal.junit;
5

  
6
import java.io.IOException;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.AfterClass;
10
import org.junit.BeforeClass;
11
import org.junit.runner.RunWith;
12
import org.openqa.selenium.WebDriver;
13
import org.openqa.selenium.chrome.ChromeDriver;
14
import org.openqa.selenium.firefox.FirefoxDriver;
15
import org.openqa.selenium.firefox.FirefoxProfile;
16
import org.openqa.selenium.ie.InternetExplorerDriver;
17

  
18
import eu.etaxonomy.dataportal.Browser;
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.SystemUtils;
21

  
22
/**
23
 * @author a.kohlbecker
24
 *
25
 */
26
@RunWith(DataPortalContextSuite.class)
27
public abstract class CdmDataPortalTestBase {
28

  
29
	public static final Logger logger = Logger.getLogger(CdmDataPortalTestBase.class);
30

  
31
	public static final String SYSTEM_PROPERTY_NAME_BROWSER = "browser";
32

  
33
	private static final String FIREBUG_VERSION = "1.6.2";
34
	private static final String FIREXPATH_VERSION = "0.9.6.1";
35

  
36
	protected static WebDriver driver;
37

  
38
	private DataPortalContext context;
39

  
40
	public DataPortalContext getContext() {
41
		return context;
42
	}
43

  
44
	public void setContext(DataPortalContext context) {
45
		this.context = context;
46

  
47
	}
48

  
49
	@BeforeClass
50
	public static void setUpDriver() {
51
		try {
52
			Browser browser = Browser.valueOf(System.getProperty(SYSTEM_PROPERTY_NAME_BROWSER, Browser.firefox.name()));
53

  
54
			logger.info("Using browser: " + browser.name());
55
			switch (browser) {
56
			case firefox:
57
				driver = initFirefoxDriver();
58
				break;
59
			case chrome:
60
				driver = initChromeDriver();
61
				break;
62
			case iexplorer:
63
				driver = initInternetExplorerDriver();
64
				break;
65
			}
66

  
67
		} catch (NullPointerException e) {
68
			SystemUtils.handleInvalidSystemProperty(SYSTEM_PROPERTY_NAME_BROWSER, e);
69
		} catch (IllegalArgumentException e) {
70
			SystemUtils.handleInvalidSystemProperty(SYSTEM_PROPERTY_NAME_BROWSER, e);
71
		}
72

  
73
	}
74

  
75
	@AfterClass
76
	public static void closeDriver() {
77
		if (driver != null) {
78
			driver.quit();
79
		}
80
	}
81

  
82
	public static WebDriver initChromeDriver() {
83
		return new ChromeDriver();
84
	}
85

  
86
	public static WebDriver initInternetExplorerDriver() {
87
		return new InternetExplorerDriver();
88
	}
89

  
90
	/**
91
	 * -Dwebdriver.firefox.bin=/usr/lib/iceweasel/firefox-bin
92
	 *
93
	 * See http://code.google.com/p/selenium/wiki/FirefoxDriverInternals
94
	 *
95
	 * @return
96
	 */
97
	public static WebDriver initFirefoxDriver() {
98
		CdmDataPortalTestBase.logger.debug(("##:" + System.getProperty("webdriver.firefox.bin")));
99

  
100
		FirefoxProfile firefoxProfile = new FirefoxProfile();
101
		try {
102

  
103
			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firebug-" + FIREBUG_VERSION + ".xpi");
104
			firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION); // avoid displaying firt run page
105

  
106
			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firexpath-" + FIREXPATH_VERSION + "-fx.xpi");
107

  
108
			// --- allow enabling incompatible addons
109
			// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi");
110
			// firefoxProfile.setPreference("extensions.acr.firstrun", false);
111
			// firefoxProfile.setPreference("extensions.enabledAddons", "fxdriver@googlecode.com,compatibility@addons.mozilla.org:0.8.3,fxdriver@googlecode.com:0.9.7376,{CAFEEFAC-0016-0000-0024-ABCDEFFEDCBA}:6.0.24,{20a82645-c095-46ed-80e3-08825760534b}:0.0.0,meetinglauncher@iconf.net:4.10.12.316,jqs@sun.com:1.0,{972ce4c6-7e08-4474-a285-3208198ce6fd}:4.0");
112
			// firefoxProfile.setPreference("extensions.checkCompatibility", false);
113
			// firefoxProfile.setPreference("extensions.checkCompatibility.4.0", false);
114
			// firefoxProfile.setPreference("extensions.checkCompatibility.4.1", false);
115

  
116
		} catch (IOException e) {
117
			CdmDataPortalTestBase.logger.error(e);
118
			System.exit(-1);
119
		}
120
		driver = new FirefoxDriver(firefoxProfile);
121

  
122
		return driver;
123
	}
124

  
125
	/**
126
	 * Return the {@link DataPortalContext#getBaseUri()} of the currently active
127
	 * context as String
128
	 *
129
	 * @return string representatoin of the DataPortal base URI
130
	 */
131
	public String getBaseUrl() {
132
		return context.getBaseUri().toString();
133
	}
134

  
135
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java
21 21
import org.junit.runners.model.Statement;
22 22

  
23 23
import eu.etaxonomy.dataportal.DataPortalContext;
24
import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
25 24

  
26 25

  
27 26
/**
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalSeleniumRCTestBase.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;
11

  
12
import org.junit.After;
13
import org.junit.AfterClass;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.openqa.selenium.WebDriverBackedSelenium;
17

  
18
import com.thoughtworks.selenium.Selenium;
19

  
20
import eu.etaxonomy.dataportal.DataPortalContext;
21
import eu.etaxonomy.dataportal.DataPortalManager;
22

  
23
/**
24
 * http://seleniumhq.org/docs/03_webdriver.html#emulating-selenium-rc
25
 *
26
 * @author a.kohlbecker
27
 * @deprecated SeleniumRCTests should only be used if you are really desperatly
28
 *             shor in time and you need to use the Selenium 1 IDE in order to
29
 *             quickly create tests.
30
 */
31
@Deprecated
32
public abstract class CdmDataPortalSeleniumRCTestBase extends CdmDataPortalTestBase {
33

  
34
	protected static Selenium selenium;
35

  
36
	@Before
37
	public void setUpSelenium() {
38
		if(selenium == null) {
39
			selenium = new WebDriverBackedSelenium(driver, getContext().getBaseUri().toString());
40
		}
41
	}
42

  
43
	@AfterClass
44
	public static void stopSelenium() {
45
		if (selenium != null) {
46
			selenium.stop();
47
			selenium = null;
48
		}
49
	}
50

  
51
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/CdmDataPortalTestBase.java
1
/**
2
 *
3
 */
4
package eu.etaxonomy.dataportal.selenium;
5

  
6
import java.io.IOException;
7

  
8
import org.apache.log4j.Logger;
9
import org.junit.AfterClass;
10
import org.junit.BeforeClass;
11
import org.junit.runner.RunWith;
12
import org.openqa.selenium.WebDriver;
13
import org.openqa.selenium.chrome.ChromeDriver;
14
import org.openqa.selenium.firefox.FirefoxDriver;
15
import org.openqa.selenium.firefox.FirefoxProfile;
16
import org.openqa.selenium.ie.InternetExplorerDriver;
17

  
18
import eu.etaxonomy.dataportal.Browser;
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.SystemUtils;
21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite;
22

  
23
/**
24
 * @author a.kohlbecker
25
 *
26
 */
27
@RunWith(DataPortalContextSuite.class)
28
public abstract class CdmDataPortalTestBase {
29

  
30
	public static final Logger logger = Logger.getLogger(CdmDataPortalTestBase.class);
31

  
32
	public static final String SYSTEM_PROPERTY_NAME_BROWSER = "browser";
33

  
34
	private static final String FIREBUG_VERSION = "1.6.2";
35
	private static final String FIREXPATH_VERSION = "0.9.6.1";
36

  
37
	protected static WebDriver driver;
38

  
39
	private DataPortalContext context;
40

  
41
	public DataPortalContext getContext() {
42
		return context;
43
	}
44

  
45
	public void setContext(DataPortalContext context) {
46
		this.context = context;
47

  
48
	}
49

  
50
	@BeforeClass
51
	public static void setUpDriver() {
52
		try {
53
			Browser browser = Browser.valueOf(System.getProperty(SYSTEM_PROPERTY_NAME_BROWSER, Browser.firefox.name()));
54

  
55
			logger.info("Using browser: " + browser.name());
56
			switch (browser) {
57
			case firefox:
58
				driver = initFirefoxDriver();
59
				break;
60
			case chrome:
61
				driver = initChromeDriver();
62
				break;
63
			case iexplorer:
64
				driver = initInternetExplorerDriver();
65
				break;
66
			}
67

  
68
		} catch (NullPointerException e) {
69
			SystemUtils.handleInvalidSystemProperty(SYSTEM_PROPERTY_NAME_BROWSER, e);
70
		} catch (IllegalArgumentException e) {
71
			SystemUtils.handleInvalidSystemProperty(SYSTEM_PROPERTY_NAME_BROWSER, e);
72
		}
73

  
74
	}
75

  
76
	@AfterClass
77
	public static void closeDriver() {
78
		if (driver != null) {
79
			driver.quit();
80
		}
81
	}
82

  
83
	public static WebDriver initChromeDriver() {
84
		return new ChromeDriver();
85
	}
86

  
87
	public static WebDriver initInternetExplorerDriver() {
88
		return new InternetExplorerDriver();
89
	}
90

  
91
	/**
92
	 * -Dwebdriver.firefox.bin=/usr/lib/iceweasel/firefox-bin
93
	 *
94
	 * See http://code.google.com/p/selenium/wiki/FirefoxDriverInternals
95
	 *
96
	 * @return
97
	 */
98
	public static WebDriver initFirefoxDriver() {
99
		CdmDataPortalTestBase.logger.debug(("##:" + System.getProperty("webdriver.firefox.bin")));
100

  
101
		FirefoxProfile firefoxProfile = new FirefoxProfile();
102
		try {
103

  
104
			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firebug-" + FIREBUG_VERSION + ".xpi");
105
			firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION); // avoid displaying firt run page
106

  
107
			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firexpath-" + FIREXPATH_VERSION + "-fx.xpi");
108

  
109
			// --- allow enabling incompatible addons
110
			// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi");
111
			// firefoxProfile.setPreference("extensions.acr.firstrun", false);
112
			// firefoxProfile.setPreference("extensions.enabledAddons", "fxdriver@googlecode.com,compatibility@addons.mozilla.org:0.8.3,fxdriver@googlecode.com:0.9.7376,{CAFEEFAC-0016-0000-0024-ABCDEFFEDCBA}:6.0.24,{20a82645-c095-46ed-80e3-08825760534b}:0.0.0,meetinglauncher@iconf.net:4.10.12.316,jqs@sun.com:1.0,{972ce4c6-7e08-4474-a285-3208198ce6fd}:4.0");
113
			// firefoxProfile.setPreference("extensions.checkCompatibility", false);
114
			// firefoxProfile.setPreference("extensions.checkCompatibility.4.0", false);
115
			// firefoxProfile.setPreference("extensions.checkCompatibility.4.1", false);
116

  
117
		} catch (IOException e) {
118
			CdmDataPortalTestBase.logger.error(e);
119
			System.exit(-1);
120
		}
121
		driver = new FirefoxDriver(firefoxProfile);
122

  
123
		return driver;
124
	}
125

  
126
	/**
127
	 * Return the {@link DataPortalContext#getBaseUri()} of the currently active
128
	 * context as String
129
	 *
130
	 * @return string representatoin of the DataPortal base URI
131
	 */
132
	public String getBaseUrl() {
133
		return context.getBaseUri().toString();
134
	}
135

  
136
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java
17 17
import org.openqa.selenium.WebElement;
18 18

  
19 19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalSeleniumRCTestBase;
20 21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
21 22

  
22 23
@SuppressWarnings("deprecation")
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CichorieaeSearchTest.java
17 17
import org.openqa.selenium.WebElement;
18 18

  
19 19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
20 21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
21
import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
22 22

  
23 23
@DataPortalContexts( { DataPortalContext.cichorieae })
24 24
public class CichorieaeSearchTest extends CdmDataPortalTestBase {
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java
16 16
import org.openqa.selenium.WebElement;
17 17

  
18 18
import eu.etaxonomy.dataportal.DataPortalContext;
19
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
19 20
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
20
import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
21 21

  
22 22
/**
23 23
 * @author a.kohlbecker
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java
20 20
import org.openqa.selenium.WebElement;
21 21

  
22 22
import eu.etaxonomy.dataportal.DataPortalContext;
23
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
23 24
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
24
import eu.etaxonomy.dataportal.selenium.CdmDataPortalTestBase;
25 25
import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool;
26 26
import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool.KeyLineData;
27 27
import eu.etaxonomy.dataportal.testutils.PolytomousKeyTestTool.LinkClass;

Also available in: Unified diff