r3452 - in trunk: pollen-ui-struts2 pollen-ui-struts2/src/main/assembly pollen-ui-struts2/src/test/java/org/chorem/pollen/ui pollen-ui-struts2/src/test/resources pollen-ui-struts2-test pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui pollen-ui-struts2-test/src/test/resources
Author: tchemit Date: 2012-06-12 15:57:39 +0200 (Tue, 12 Jun 2012) New Revision: 3452 Url: http://chorem.org/repositories/revision/pollen/3452 Log: refs #606: Add some ITs to prevent regression (use jetty, will not work with tomcat plugin :() Added: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/WebDriverResource.java trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/security/ trunk/pollen-ui-struts2-test/src/test/resources/pollendb.h2.db Removed: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/WebDriverResource.java trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/security/ trunk/pollen-ui-struts2/src/test/resources/log4j.properties trunk/pollen-ui-struts2/src/test/resources/pollen-fake.properties trunk/pollen-ui-struts2/src/test/resources/pollendb.h2.db Modified: trunk/pollen-ui-struts2-test/pom.xml trunk/pollen-ui-struts2/pom.xml trunk/pollen-ui-struts2/src/main/assembly/bin.xml Modified: trunk/pollen-ui-struts2/pom.xml =================================================================== --- trunk/pollen-ui-struts2/pom.xml 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2/pom.xml 2012-06-12 13:57:39 UTC (rev 3452) @@ -186,39 +186,6 @@ <artifactId>junit</artifactId> </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-java</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-api</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-support</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-chrome-driver</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-firefox-driver</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-htmlunit-driver</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-ie-driver</artifactId> - </dependency> - <dependency> - <groupId>org.seleniumhq.selenium</groupId> - <artifactId>selenium-safari-driver</artifactId> - </dependency> - </dependencies> <!-- ************************************************************* --> @@ -431,7 +398,7 @@ <goal>war</goal> </goals> <configuration> - <primaryArtifact>false</primaryArtifact> + <primaryArtifact>true</primaryArtifact> <webappDirectory> target/pollen-embedded-${project.version} </webappDirectory> @@ -440,7 +407,7 @@ <mainClass>org.nuiton.web.war.JettyLauncher</mainClass> </manifest> </archive> - <warName>pollen-embedded-${project.version}</warName> + <warName>pollen-${project.version}-embedded</warName> <webResources> <webResource> <directory> Modified: trunk/pollen-ui-struts2/src/main/assembly/bin.xml =================================================================== --- trunk/pollen-ui-struts2/src/main/assembly/bin.xml 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2/src/main/assembly/bin.xml 2012-06-12 13:57:39 UTC (rev 3452) @@ -33,7 +33,7 @@ <outputDirectory>/</outputDirectory> <fileMode>0755</fileMode> <includes> - <include>pollen-embedded-${project.version}.war</include> + <include>pollen-${project.version}-embedded.war</include> </includes> </fileSet> Deleted: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java 2012-06-12 13:57:39 UTC (rev 3452) @@ -1,63 +0,0 @@ -/* - * #%L - * T3 :: Web - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.ui; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Rule; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.openqa.selenium.WebDriver; - -import java.util.Collection; - -/** - * Test base class for ui tests. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -@RunWith(value = Parameterized.class) -public abstract class PollenBaseWebDriverIT { - - /** Logger. */ - protected final Log log = LogFactory.getLog(getClass()); - - @Parameterized.Parameters - public static Collection<Object[]> driverTypes() { - return WebDriverResource.driverTypes(); - } - - @Rule - public WebDriverResource seleniumServer; - - protected PollenBaseWebDriverIT(Class<? extends WebDriver> driverType) { - seleniumServer = new WebDriverResource(getClass(), driverType); - } - - public WebDriver getDriver() { - return seleniumServer.getDriver(); - } - -} Deleted: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/WebDriverResource.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/WebDriverResource.java 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/WebDriverResource.java 2012-06-12 13:57:39 UTC (rev 3452) @@ -1,154 +0,0 @@ -/* - * #%L - * T3 :: Web - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package org.chorem.pollen.ui; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.rules.ExternalResource; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.chrome.ChromeDriverService; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.htmlunit.HtmlUnitDriver; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.remote.RemoteWebDriver; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -/** - * Web driver resource. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.4 - */ -public class WebDriverResource extends ExternalResource { - - /** Logger. */ - private static final Log log = LogFactory.getLog(WebDriverResource.class); - - private static ChromeDriverService service; - - protected static final Class<? extends WebDriver>[] allDrivers = new Class[]{ -// ChromeDriver.class, -// InternetExplorerDriver.class, -// SafariDriver.class, - FirefoxDriver.class, - HtmlUnitDriver.class - }; - - protected static Collection<Object[]> safeDrivers; - - public static Collection<Object[]> driverTypes() { - if (safeDrivers == null) { - - //System.setProperty("webdriver.chrome.driver", "/usr/bin/google-chrome"); - List<Class<?>> checkedDrivers = new ArrayList<Class<?>>(); - for (Class<? extends WebDriver> driver : allDrivers) { - boolean ok = checkDriver(driver); - if (ok) { - checkedDrivers.add(driver); - } - } - //{{ChromeDriver.class}, {FirefoxDriver.class}, {HtmlUnitDriver.class}} - Object[][] data = new Object[checkedDrivers.size()][1]; - int i = 0; - for (Class<?> checkedDriver : checkedDrivers) { - data[i++][0] = checkedDriver; - } - safeDrivers = Arrays.asList(data); - } - - return safeDrivers; - } - - private static boolean checkDriver(Class<? extends WebDriver> driverType) { - - WebDriver driver = null; - boolean result = false; - try { - driver = driverType.getConstructor().newInstance(); - result = true; - } catch (Exception e) { - - // can not use this driver - if (log.isInfoEnabled()) { - log.info("Can not use driver " + driverType.getName(), e); - } - } finally { - if (driver != null) { - driver.quit(); - } - } - - return result; - } - - private final Class<?> testClass; - - private final Class<? extends WebDriver> driverType; - - protected WebDriver driver; - - public WebDriverResource(Class<?> testClass, - Class<? extends WebDriver> driverType) { - this.testClass = testClass; - this.driverType = driverType; - } - - public WebDriver getDriver() { - return driver; - } - - @Override - protected void before() throws Throwable { - if (log.isInfoEnabled()) { - log.info("Start test [" + testClass.getName() + "] with driver of type " + driverType.getName()); - } - if (ChromeDriver.class == driverType) { - - service = new ChromeDriverService.Builder() - .usingChromeDriverExecutable(new File("/usr/bin/chromium-browser")) - .usingAnyFreePort() - .build(); - service.start(); - - driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome()); - - } else { - driver = driverType.getConstructor().newInstance(); - } - } - - @Override - protected void after() { - if (ChromeDriver.class == driverType) { - service.stop(); - } - driver.quit(); - } -} Deleted: trunk/pollen-ui-struts2/src/test/resources/log4j.properties =================================================================== --- trunk/pollen-ui-struts2/src/test/resources/log4j.properties 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2/src/test/resources/log4j.properties 2012-06-12 13:57:39 UTC (rev 3452) @@ -1,32 +0,0 @@ -### -# #%L -# Pollen :: UI (struts2) -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# #L% -### -log4j.rootCategory=ERROR, console - -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d [%p] %c %m%n - -log4j.logger.org.chorem=INFO -log4j.logger.org.chorem.pollen.ui.PollenShiroIsAdministratorFilter=DEBUG -log4j.logger.org.nuiton=INFO - Deleted: trunk/pollen-ui-struts2/src/test/resources/pollen-fake.properties =================================================================== --- trunk/pollen-ui-struts2/src/test/resources/pollen-fake.properties 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2/src/test/resources/pollen-fake.properties 2012-06-12 13:57:39 UTC (rev 3452) @@ -1,39 +0,0 @@ -### -# #%L -# Pollen :: UI (struts2) -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2009 - 2012 CodeLutin -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# #L% -### - -# Db configuration -hibernate.dialect=org.hibernate.dialect.H2Dialect -hibernate.connection.username=sa -hibernate.connection.password=sa -hibernate.connection.driver_class=org.h2.Driver -hibernate.show_sql=false -hibernate.hbm2ddl.auto=update - -# Database migration configuration -topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine -topia.service.migration.callback=org.chorem.pollen.entities.migration.PollenMigrationCallback -topia.service.migration.showSql=false - -# Version de l'application -pollen.version=${project.version} -siteUrl=http://localhost:8080/pollen \ No newline at end of file Deleted: trunk/pollen-ui-struts2/src/test/resources/pollendb.h2.db =================================================================== (Binary files differ) Modified: trunk/pollen-ui-struts2-test/pom.xml =================================================================== --- trunk/pollen-ui-struts2-test/pom.xml 2012-06-12 12:07:38 UTC (rev 3451) +++ trunk/pollen-ui-struts2-test/pom.xml 2012-06-12 13:57:39 UTC (rev 3452) @@ -43,28 +43,25 @@ </dependency> <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> + <!-- Provided dependencies --> <dependency> - <groupId>javax.activation</groupId> - <artifactId>activation</artifactId> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> <scope>provided</scope> </dependency> - <!-- Provided dependencies --> <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <groupId>javax.activation</groupId> + <artifactId>activation</artifactId> <scope>provided</scope> </dependency> + <!-- Test dependencies (to valid the web.xml in your ide) --> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -116,84 +113,42 @@ <!-- *** Build Settings ****************************************** --> <!-- ************************************************************* --> - <packaging>war</packaging> - <build> - <testResources> - <testResource> - <directory>src/test/resources</directory> - <filtering>true</filtering> - <includes> - <include>**/*.properties</include> - <include>**/*.xml</include> - </includes> - </testResource> - <testResource> - <directory>src/test/resources</directory> - <filtering>false</filtering> - <excludes> - <exclude>**/*.properties</exclude> - <exclude>**/*.xml</exclude> - </excludes> - </testResource> - </testResources> - - <pluginManagement> - <plugins> - - <plugin> - <artifactId>maven-war-plugin</artifactId> - <configuration> - <overlays> - <overlay> - <groupId>${project.groupId}</groupId> - <artifactId>pollen-ui-struts2</artifactId> - <type>war</type> - </overlay> - </overlays> - </configuration> - </plugin> - - </plugins> - </pluginManagement> - <plugins> <plugin> - <groupId>org.apache.tomcat.maven</groupId> - <artifactId>tomcat7-maven-plugin</artifactId> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <configuration> + <daemon>true</daemon> + <stopKey>A</stopKey> + <stopPort>1269</stopPort> + <webAppConfig> + <contextPath>/pollen</contextPath> + </webAppConfig> + <systemProperties> + <systemProperty> + <name>siteUrl</name> + <value>http://localhost:8080/pollen</value> + </systemProperty> + <systemProperty> + <name>pollen.log.dir</name> + <value>target</value> + </systemProperty> + </systemProperties> + </configuration> <executions> <execution> - <id>start-web-server</id> - <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> - <configuration> - <fork>true</fork> - <path>/pollen</path> - <systemProperties> - <pollen.log.dir>target</pollen.log.dir> - </systemProperties> - <uriEncoding>UTF-8</uriEncoding> - </configuration> + <phase>pre-integration-test</phase> </execution> - <execution> - <id>stop-web-server</id> - <phase>post-integration-test</phase> - <goals> - <goal>shutdown</goal> - </goals> - <configuration> - - <path>/pollen</path> - </configuration> - </execution> - </executions> </plugin> + <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> @@ -209,9 +164,9 @@ </goals> <configuration> <skip>false</skip> - <!--includes> + <includes> <include>**/*SIT.java</include> - </includes--> + </includes> </configuration> </execution> </executions> Copied: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java (from rev 3449, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java) =================================================================== --- trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java (rev 0) +++ trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java 2012-06-12 13:57:39 UTC (rev 3452) @@ -0,0 +1,63 @@ +/* + * #%L + * T3 :: Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Rule; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.openqa.selenium.WebDriver; + +import java.util.Collection; + +/** + * Test base class for ui tests. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +@RunWith(value = Parameterized.class) +public abstract class PollenBaseWebDriverIT { + + /** Logger. */ + protected final Log log = LogFactory.getLog(getClass()); + + @Parameterized.Parameters + public static Collection<Object[]> driverTypes() { + return WebDriverResource.driverTypes(); + } + + @Rule + public WebDriverResource seleniumServer; + + protected PollenBaseWebDriverIT(Class<? extends WebDriver> driverType) { + seleniumServer = new WebDriverResource(getClass(), driverType); + } + + public WebDriver getDriver() { + return seleniumServer.getDriver(); + } + +} Property changes on: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/PollenBaseWebDriverIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/WebDriverResource.java (from rev 3449, trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/WebDriverResource.java) =================================================================== --- trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/WebDriverResource.java (rev 0) +++ trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/WebDriverResource.java 2012-06-12 13:57:39 UTC (rev 3452) @@ -0,0 +1,154 @@ +/* + * #%L + * T3 :: Web + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.rules.ExternalResource; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeDriverService; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.htmlunit.HtmlUnitDriver; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +/** + * Web driver resource. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class WebDriverResource extends ExternalResource { + + /** Logger. */ + private static final Log log = LogFactory.getLog(WebDriverResource.class); + + private static ChromeDriverService service; + + protected static final Class<? extends WebDriver>[] allDrivers = new Class[]{ +// ChromeDriver.class, +// InternetExplorerDriver.class, +// SafariDriver.class, + FirefoxDriver.class, + HtmlUnitDriver.class + }; + + protected static Collection<Object[]> safeDrivers; + + public static Collection<Object[]> driverTypes() { + if (safeDrivers == null) { + + //System.setProperty("webdriver.chrome.driver", "/usr/bin/google-chrome"); + List<Class<?>> checkedDrivers = new ArrayList<Class<?>>(); + for (Class<? extends WebDriver> driver : allDrivers) { + boolean ok = checkDriver(driver); + if (ok) { + checkedDrivers.add(driver); + } + } + //{{ChromeDriver.class}, {FirefoxDriver.class}, {HtmlUnitDriver.class}} + Object[][] data = new Object[checkedDrivers.size()][1]; + int i = 0; + for (Class<?> checkedDriver : checkedDrivers) { + data[i++][0] = checkedDriver; + } + safeDrivers = Arrays.asList(data); + } + + return safeDrivers; + } + + private static boolean checkDriver(Class<? extends WebDriver> driverType) { + + WebDriver driver = null; + boolean result = false; + try { + driver = driverType.getConstructor().newInstance(); + result = true; + } catch (Exception e) { + + // can not use this driver + if (log.isInfoEnabled()) { + log.info("Can not use driver " + driverType.getName(), e); + } + } finally { + if (driver != null) { + driver.quit(); + } + } + + return result; + } + + private final Class<?> testClass; + + private final Class<? extends WebDriver> driverType; + + protected WebDriver driver; + + public WebDriverResource(Class<?> testClass, + Class<? extends WebDriver> driverType) { + this.testClass = testClass; + this.driverType = driverType; + } + + public WebDriver getDriver() { + return driver; + } + + @Override + protected void before() throws Throwable { + if (log.isInfoEnabled()) { + log.info("Start test [" + testClass.getName() + "] with driver of type " + driverType.getName()); + } + if (ChromeDriver.class == driverType) { + + service = new ChromeDriverService.Builder() + .usingChromeDriverExecutable(new File("/usr/bin/chromium-browser")) + .usingAnyFreePort() + .build(); + service.start(); + + driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome()); + + } else { + driver = driverType.getConstructor().newInstance(); + } + } + + @Override + protected void after() { + if (ChromeDriver.class == driverType) { + service.stop(); + } + driver.quit(); + } +} Property changes on: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/WebDriverResource.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/pollen-ui-struts2-test/src/test/resources/pollendb.h2.db (from rev 3451, trunk/pollen-ui-struts2/src/test/resources/pollendb.h2.db) =================================================================== (Binary files differ) Property changes on: trunk/pollen-ui-struts2-test/src/test/resources/pollendb.h2.db ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
tchemit@users.chorem.org