Revision d2a09415
Added by Andreas Kohlbecker over 8 years ago
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 org.apache.log4j.Logger; |
|
7 |
import org.junit.AfterClass; |
|
8 |
import org.junit.BeforeClass; |
|
9 |
import org.junit.runner.RunWith; |
|
10 |
import org.openqa.selenium.WebDriver; |
|
11 |
|
|
12 |
import eu.etaxonomy.dataportal.DataPortalContext; |
|
13 |
import eu.etaxonomy.dataportal.selenium.WebDriverFactory; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author a.kohlbecker |
|
17 |
* |
|
18 |
*/ |
|
19 |
@RunWith(DataPortalContextSuite.class) |
|
20 |
public abstract class CdmDataPortalTestBase { |
|
21 |
|
|
22 |
public static final Logger logger = Logger.getLogger(CdmDataPortalTestBase.class); |
|
23 |
|
|
24 |
protected static WebDriver driver; |
|
25 |
|
|
26 |
private DataPortalContext context; |
|
27 |
|
|
28 |
public DataPortalContext getContext() { |
|
29 |
return context; |
|
30 |
} |
|
31 |
|
|
32 |
public void setContext(DataPortalContext context) { |
|
33 |
this.context = context; |
|
34 |
|
|
35 |
} |
|
36 |
|
|
37 |
@BeforeClass |
|
38 |
public static void setUpDriver() { |
|
39 |
logger.debug("@BeforeClass: setUpDriver()"); |
|
40 |
driver = WebDriverFactory.newWebDriver(); |
|
41 |
} |
|
42 |
|
|
43 |
@AfterClass |
|
44 |
public static void closeDriver() { |
|
45 |
logger.debug("@AfterClass: closeDriver()"); |
|
46 |
if (driver != null) { |
|
47 |
driver.quit(); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Return the {@link DataPortalContext#getBaseUri()} of the currently active |
|
53 |
* context as String |
|
54 |
* |
|
55 |
* @return string representatoin of the DataPortal base URI |
|
56 |
*/ |
|
57 |
public String getBaseUrl() { |
|
58 |
return context.getBaseUri().toString(); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
} |
|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.dataportal.junit; |
|
5 |
|
|
6 |
import org.apache.log4j.Logger; |
|
7 |
import org.junit.AfterClass; |
|
8 |
import org.junit.BeforeClass; |
|
9 |
import org.junit.runner.RunWith; |
|
10 |
import org.openqa.selenium.WebDriver; |
|
11 |
|
|
12 |
import eu.etaxonomy.dataportal.DataPortalContext; |
|
13 |
import eu.etaxonomy.dataportal.selenium.WebDriverFactory; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author a.kohlbecker |
|
17 |
* |
|
18 |
*/ |
|
19 |
@RunWith(DataPortalContextSuite.class) |
|
20 |
public abstract class CdmDataPortalTestBase { |
|
21 |
|
|
22 |
public static final Logger logger = Logger.getLogger(CdmDataPortalTestBase.class); |
|
23 |
|
|
24 |
protected static WebDriver driver; |
|
25 |
|
|
26 |
private DataPortalContext context; |
|
27 |
|
|
28 |
public DataPortalContext getContext() { |
|
29 |
return context; |
|
30 |
} |
|
31 |
|
|
32 |
public void setContext(DataPortalContext context) { |
|
33 |
this.context = context; |
|
34 |
|
|
35 |
} |
|
36 |
|
|
37 |
@BeforeClass |
|
38 |
public static void setUpDriver() { |
|
39 |
logger.debug("@BeforeClass: setUpDriver()"); |
|
40 |
driver = WebDriverFactory.newWebDriver(); |
|
41 |
} |
|
42 |
|
|
43 |
@AfterClass |
|
44 |
public static void closeDriver() { |
|
45 |
logger.debug("@AfterClass: closeDriver()"); |
|
46 |
if (driver != null) { |
|
47 |
driver.quit(); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Return the {@link DataPortalContext#getBaseUri()} of the currently active |
|
53 |
* context as String |
|
54 |
* |
|
55 |
* @return string representatoin of the DataPortal base URI |
|
56 |
*/ |
|
57 |
public String getBaseUrl() { |
|
58 |
return context.getBaseUri().toString(); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
} |
Also available in: Unified diff
CRLF will be replaced by LF issues