-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from ArcBees/spg_integration_tests_basic
Integration Tests groundwork
- Loading branch information
Showing
9 changed files
with
314 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>gwtchosen-project</artifactId> | ||
<groupId>com.arcbees</groupId> | ||
<version>2.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<packaging>war</packaging> | ||
|
||
<artifactId>integration-test</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.arcbees</groupId> | ||
<artifactId>gwtchosen</artifactId> | ||
</dependency> | ||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>integration-test</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${maven-failsafe-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>gwt-maven-plugin</artifactId> | ||
<version>${gwt.version}</version> | ||
<executions> | ||
<execution> | ||
<configuration> | ||
<module>com.arcbees.chosen.integrationtest.ChosenIntegrationTests</module> | ||
</configuration> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>${jetty-maven-plugin.version}</version> | ||
|
||
<configuration> | ||
<webAppSourceDirectory> | ||
${project.build.directory}/${project.build.finalName} | ||
</webAppSourceDirectory> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>start-jetty</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
<configuration> | ||
<scanIntervalSeconds>0</scanIntervalSeconds> | ||
<daemon>true</daemon> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>stop-jetty</id> | ||
<phase>post-integration-test</phase> | ||
<goals> | ||
<goal>stop</goal> | ||
</goals> | ||
<configuration> | ||
<stopPort>9966</stopPort> | ||
<stopKey>jetty-stop</stopKey> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...src/main/java/com/arcbees/chosen/integrationtest/client/ChosenSampleIntegrationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright 2014 ArcBees Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.arcbees.chosen.integrationtest.client; | ||
|
||
import java.util.EnumSet; | ||
|
||
import com.arcbees.chosen.client.gwt.ChosenValueListBox; | ||
import com.google.common.base.CaseFormat; | ||
import com.google.gwt.core.client.EntryPoint; | ||
import com.google.gwt.text.shared.AbstractRenderer; | ||
import com.google.gwt.user.client.ui.RootPanel; | ||
|
||
public class ChosenSampleIntegrationTests implements EntryPoint { | ||
@Override | ||
public void onModuleLoad() { | ||
RootPanel rootPanel = RootPanel.get(); | ||
ChosenValueListBox<CarBrand> listBox = new ChosenValueListBox<CarBrand>(new AbstractRenderer<CarBrand>() { | ||
@Override | ||
public String render(CarBrand object) { | ||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, object.name()); | ||
} | ||
}); | ||
|
||
listBox.setAcceptableValues(EnumSet.allOf(CarBrand.class)); | ||
listBox.setValue(CarBrand.AUDI); | ||
|
||
rootPanel.add(listBox); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...test/src/main/resources/com/arcbees/chosen/integrationtest/ChosenIntegrationTests.gwt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN" | ||
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd"> | ||
<module rename-to='ChosenIntegrationTests'> | ||
<inherits name="com.arcbees.chosen.Chosen"/> | ||
|
||
<set-property name="user.agent" value="safari"/> | ||
|
||
<entry-point class="com.arcbees.chosen.integrationtest.client.ChosenSampleIntegrationTests"/> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://java.sun.com/xml/ns/javaee" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
version="2.5"> | ||
<welcome-file-list> | ||
<welcome-file>index.html</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | ||
<title>Chosen Integration Tests</title> | ||
<script type="text/javascript" src="ChosenIntegrationTests/ChosenIntegrationTests.nocache.js"></script> | ||
</head> | ||
<body> | ||
|
||
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' | ||
style="position: absolute; width: 0;height: 0; border: 0;"></iframe> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright 2014 ArcBees Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import org.junit.After; | ||
import org.junit.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class SampleIT { | ||
private static final String ROOT = "http://localhost:8080"; | ||
|
||
private final WebDriver webDriver = new ChromeDriver(); | ||
private static final int TIME_OUT_IN_SECONDS = 20; | ||
|
||
@Test | ||
public void sampleTest() throws Throwable { | ||
webDriver.get(ROOT); | ||
|
||
clickElementWithDisplayString("Ford"); | ||
|
||
assertThat(getSelectedValueText()).isEqualTo("Ford"); | ||
} | ||
|
||
@After | ||
public void after() { | ||
webDriver.quit(); | ||
} | ||
|
||
private WebDriverWait webDriverWait() { | ||
return new WebDriverWait(webDriver, TIME_OUT_IN_SECONDS); | ||
} | ||
|
||
private void clickElementWithDisplayString(String displayString) { | ||
openDropDown(); | ||
|
||
WebElement li = webDriverWait().until(ExpectedConditions.presenceOfElementLocated( | ||
By.xpath(String.format("//li[text()='%s']", displayString)))); | ||
li.click(); | ||
} | ||
|
||
private void openDropDown() { | ||
WebElement btn = webDriverWait().until(ExpectedConditions.elementToBeClickable(By.xpath | ||
("//div[@id='chozen_container__0_chzn']/a"))); | ||
|
||
btn.click(); | ||
} | ||
|
||
private String getSelectedValueText() { | ||
WebElement span = webDriverWait().until(ExpectedConditions.visibilityOfElementLocated(By.xpath | ||
("//div[@id='chozen_container__0_chzn']/a/span"))); | ||
|
||
return span.getText(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters