Skip to content

Commit

Permalink
Merge pull request #185 from ArcBees/spg_integration_tests_basic
Browse files Browse the repository at this point in the history
Integration Tests groundwork
  • Loading branch information
Simon-Pierre Gingras committed Jan 29, 2015
2 parents 39b4bc8 + 83fd71d commit 7db7120
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 18 deletions.
109 changes: 109 additions & 0 deletions integration-test/pom.xml
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>
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@
* the License.
*/

package com.arcbees.chosen.client;
package com.arcbees.chosen.integrationtest.client;

import com.google.gwt.junit.client.GWTTestCase;

public class CompileGwtTest extends GWTTestCase {
@Override
public String getModuleName() {
return "com.arcbees.chosen.Chosen";
}

public void testSandbox() {
assertTrue(true);
}
public enum CarBrand {
TOYOTA,
HONDA,
MERCEDES,
FORD,
HYUNDAI,
FERRARI,
BMW,
TESLA,
AUDI,
BENTLEY,
CADILLAC,
CHEVROLET,
CHRYSLER,
DODGE,
MITSUBISHI,
JAGUAR,
JEEP
}
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);
}
}
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>
9 changes: 9 additions & 0 deletions integration-test/src/main/webapp/WEB-INF/web.xml
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>
14 changes: 14 additions & 0 deletions integration-test/src/main/webapp/index.html
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>
73 changes: 73 additions & 0 deletions integration-test/src/test/java/SampleIT.java
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();
}
}
39 changes: 33 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@
<maven.compiler.target>1.6</maven.compiler.target>
<maven-javadoc-plugin.version>2.9</maven-javadoc-plugin.version>
<maven-surefire-plugin.version>2.12</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.17</maven-failsafe-plugin.version>
<jetty-maven-plugin.version>9.3.0.M1</jetty-maven-plugin.version>

<!-- testing -->
<junit.version>4.11</junit.version>
<selenium-java.version>2.41.0</selenium-java.version>
<assertj-core.version>1.7.0</assertj-core.version>

<!-- GitHub Sites -->
<github.version>0.9</github.version>
Expand All @@ -93,6 +100,7 @@

<modules>
<module>plugin</module>
<module>integration-test</module>
<module>sample</module>
</modules>

Expand Down Expand Up @@ -189,21 +197,40 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.arcbees</groupId>
<artifactId>gwtchosen</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.arcbees.gss</groupId>
<artifactId>gsss</artifactId>
<version>${gsss.version}</version>
</dependency>

<!-- Test deps -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium-java.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

0 comments on commit 7db7120

Please sign in to comment.