Skip to content

Commit 9bd7889

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 5a9a214 + ed1cb52 commit 9bd7889

File tree

28 files changed

+2191
-1
lines changed

28 files changed

+2191
-1
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
indent_style = space
12+
indent_size = 4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Common Maven
2+
13
target/
24
pom.xml.tag
35
pom.xml.releaseBackup
@@ -7,3 +9,7 @@ release.properties
79
dependency-reduced-pom.xml
810
buildNumber.properties
911
.mvn/timing.properties
12+
13+
# IDE's
14+
.idea
15+
*.iml

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
language: java
3+
install: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -Dcoveralls.skip=true -B -V
4+
script: mvn verify -Pci
5+
jdk:
6+
- oraclejdk8
7+
cache:
8+
directories:
9+
- $HOME/.m2

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright 2016 Wave Software
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Gasper!
2+
3+
[![Build Status](https://travis-ci.org/wavesoftware/java-gasper.svg?branch=develop)](https://travis-ci.org/wavesoftware/java-gasper) [![Coverage Status](https://coveralls.io/repos/github/wavesoftware/java-gasper/badge.svg?branch=develop)](https://coveralls.io/github/wavesoftware/java-gasper?branch=develop) [![Codacy Badge](https://api.codacy.com/project/badge/grade/5c4d1180812e438ebe872f9121ec4368)](https://www.codacy.com/app/krzysztof-suszynski/java-gasper) [![SonarQube Tech Debt](https://img.shields.io/sonar/http/sonar-ro.wavesoftware.pl/pl.wavesoftware:gasper/tech_debt.svg)](https://sonar.wavesoftware.pl/dashboard/index/2858)
4+
5+
Gasper is a very simple integration testing JUnit harness for `java -jar` servers like [WildFly Swarm](http://wildfly-swarm.io/) and [Spring Boot](http://projects.spring.io/spring-boot/).
6+
7+
[![WildFly Swarm](https://avatars3.githubusercontent.com/u/11523816?v=3&s=100)](http://wildfly-swarm.io/) [![Spring Boot](https://avatars2.githubusercontent.com/u/317776?v=3&s=100)](http://projects.spring.io/spring-boot/)
8+
9+
Gasper provides a simple to use JUnit `TestRule` that can be used to build integration tests with simple apps, like REST micro-services. You can configure Gasper easily with a builder interface. Gasper will start the application before test class and stop it after tests completes.
10+
11+
Gasper supports currently only [Maven](https://maven.apache.org/). The `pom.xml` file is used to read project configuration achieving zero configuration operation.
12+
13+
## Usage
14+
15+
16+
Gasper utilize your packaged application. It It means it should be used in integration tests that run after application is being packaged by build tool (Maven). Add this code to your `pom.xml` file (if you didn't done that before):
17+
18+
```xml
19+
<build>
20+
[..]
21+
<plugins>
22+
[..]
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-failsafe-plugin</artifactId>
26+
<version>2.19.1</version>
27+
<executions>
28+
<execution>
29+
<goals>
30+
<goal>integration-test</goal>
31+
<goal>verify</goal>
32+
</goals>
33+
</execution>
34+
</executions>
35+
</plugin>
36+
[..]
37+
</plugins>
38+
[..]
39+
</build>
40+
```
41+
42+
43+
Place your integration tests in classes that ends with `*IT` or `*ITest`.
44+
45+
### WildFly Swarm configuration
46+
47+
```java
48+
@ClassRule
49+
public static Gasper gasper = Gasper.configurations()
50+
.wildflySwarm()
51+
.build();
52+
```
53+
54+
### Spring Boot configuration
55+
56+
```java
57+
@ClassRule
58+
public static Gasper gasper = Gasper.configurations()
59+
.springBoot()
60+
.build();
61+
```
62+
63+
Before running `GasperBuilder.build()` method, you can reconfigure those default configurations to your needs.
64+
65+
### Example test method (Unirest + JSONAssert)
66+
67+
Gasper is best to use with libraries like [Unirest](http://unirest.io/java.html) for fetching data and asserting HTTP/S statuses and [JSON Assert](https://github.com/marcingrzejszczak/jsonassert) to validate correctness of JSON output for REST services.
68+
69+
```java
70+
@Test
71+
public void testGetRoot() throws UnirestException {
72+
// given
73+
String address = gasper.getAddress(); // Address to deployed app, running live on random port
74+
String expectedMessage = "WildFly Swarm!";
75+
76+
// when
77+
HttpResponse<String> response = Unirest.get(address).asString();
78+
79+
// then
80+
assertThat(response.getStatus()).isEqualTo(200);
81+
assertThat(response.getBody()).field("hello").isEqualTo(expectedMessage); // JSON Assert
82+
}
83+
```
84+
85+
### Additional configuration
86+
87+
To configure Gasper use `GasperBuilder` interface, for ex.:
88+
89+
```java
90+
private final int port = 11909;
91+
private final String webContext = "/test";
92+
private final String systemPropertyForPort = "swarm.http.port";
93+
94+
@ClassRule
95+
public static Gasper gasper = Gasper.configure()
96+
.silentGasperMessages()
97+
.usingSystemPropertyForPort(systemPropertyForPort)
98+
.withSystemProperty("swarm.context.path", webContext)
99+
.withSystemProperty(systemPropertyForPort, String.valueOf(port))
100+
.withJVMOptions("-server", "-Xms1G", "-Xmx1G", "-XX:+UseConcMarkSweepGC")
101+
.withMaxStartupTime(100)
102+
.withMaxDeploymentTime(20)
103+
.withEnvironmentVariable("jdbc.password", "S3CreT!1")
104+
.withTestApplicationLoggingOnConsole()
105+
.usingPomFile(Paths.get("pom.xml"))
106+
.withArtifactPackaging("jar")
107+
.waitForWebContext(webContext)
108+
.withArtifactClassifier("swarm")
109+
.usingWebContextChecker(GasperBuilderTest::checkContext)
110+
.withPort(port)
111+
.build();
112+
```
113+
114+
## Installation
115+
116+
### Maven
117+
118+
```xml
119+
<dependency>
120+
<groupId>pl.wavesoftware</groupId>
121+
<artifactId>gasper</artifactId>
122+
<version>1.0.0</version>
123+
<scope>test</scope>
124+
</dependency>
125+
```
126+
127+
## Contributing
128+
129+
Contributions are welcome!
130+
131+
To contribute, follow the standard [git flow](http://danielkummer.github.io/git-flow-cheatsheet/) of:
132+
133+
1. Fork it
134+
1. Create your feature branch (`git checkout -b feature/my-new-feature`)
135+
1. Commit your changes (`git commit -am 'Add some feature'`)
136+
1. Push to the branch (`git push origin feature/my-new-feature`)
137+
1. Create new Pull Request
138+
139+
Even if you can't contribute code, if you have an idea for an improvement please open an [issue](https://github.com/wavesoftware/java-gasper/issues).
140+
141+
## Requirements
142+
143+
* Java 8
144+
* Maven 3
145+
146+
## Releases
147+
148+
* `1.0.0` - codename: *SkyMango*
149+
* First publicly available release

0 commit comments

Comments
 (0)