diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile
new file mode 100644
index 0000000..eb553cb
--- /dev/null
+++ b/.gitpod.Dockerfile
@@ -0,0 +1,7 @@
+FROM gitpod/workspace-full
+
+USER gitpod
+
+RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && \
+ sdk install java 17.0.9-tem && \
+ sdk default java 17.0.9-tem"
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 0000000..0c92254
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,24 @@
+# This configuration file was automatically generated by Gitpod.
+# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
+# and commit this file to your remote git repository to share the goodness with others.
+
+image:
+ file: .gitpod.Dockerfile
+
+tasks:
+ - init: mvn package -DskipTests=false
+
+vscode:
+ extensions:
+ - redhat.java
+ - vscjava.vscode-java-debug
+ - vscjava.vscode-maven
+
+# Ports to expose on workspace startup
+ports:
+ - port: 8080
+ onOpen: open-preview
+ name: Calculator API
+ description: Calculator API init
+ visibility: private
+ protocol: http
diff --git a/README.md b/README.md
index c343456..2c161bf 100644
--- a/README.md
+++ b/README.md
@@ -114,7 +114,7 @@ $ docker run --rm -p 8080:8080 myjetty
> Explain: --rm means delete the container after stopping it.
-Access the web app at http://localhost:8080/api/calculator/ping in browser.
+Access the web app at http://localhost:8080/calculator/api/calculator/ping in browser.
Press Control-C to stop and remove the container.
@@ -141,4 +141,4 @@ Run all tests in docker-compose environment:
$ docker-compose up
```
-Access the web app at http://localhost:8080/api/calculator/ping in browser.
+Access the web app at http://localhost:8080/calculator/api/calculator/ping in browser.
diff --git a/pom.xml b/pom.xml
index 5ad7dcc..bee17d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,9 +19,9 @@
17
2.2
5.8.2
- 7.0.0
+ 7.6.0
3.0.0
- 1.8.2
+ 1.9.0
4.5.13
11.0.7
3.0.3
diff --git a/src/test/java/com/geekshubs/calculator/aceptance/api/PingSteps.java b/src/test/java/com/geekshubs/calculator/aceptance/api/PingSteps.java
index a32cfc3..fcdf8a8 100644
--- a/src/test/java/com/geekshubs/calculator/aceptance/api/PingSteps.java
+++ b/src/test/java/com/geekshubs/calculator/aceptance/api/PingSteps.java
@@ -8,6 +8,8 @@
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
+import com.geekshubs.calculator.configuration.Values;
+
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -32,12 +34,12 @@ public void iShouldReceiveStatusCodeResponse(int code) {
@Then("^should receive a welcome message$")
public void shouldReceiveAWelcomeMessage() throws Exception {
- assertThat(EntityUtils.toString(response.getEntity()), containsString("Welcome to Java Maven Calculator Web App!!!"));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString("Welcome to Java Maven Calculator Web App!!!"));
}
- @Then("^should receive result (\\d+)$")
+ @Then("^should receive result (-?\\d+)$")
public void shouldReceiveResultCorrect(int result) throws Exception {
- assertThat(EntityUtils.toString(response.getEntity()), containsString(String.format("\"result\":%d", result)));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString(String.format("\"result\":%d", result)));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/geekshubs/calculator/configuration/Values.java b/src/test/java/com/geekshubs/calculator/configuration/Values.java
new file mode 100644
index 0000000..7828d97
--- /dev/null
+++ b/src/test/java/com/geekshubs/calculator/configuration/Values.java
@@ -0,0 +1,5 @@
+package com.geekshubs.calculator.configuration;
+
+public class Values {
+ public static final String ENCODING = System.getProperty("project.build.sourceEncoding", "UTF-8");
+}
\ No newline at end of file
diff --git a/src/test/java/com/geekshubs/calculator/integration/ITCalculatorAPITest.java b/src/test/java/com/geekshubs/calculator/integration/ITCalculatorAPITest.java
index 171c602..e4256c9 100644
--- a/src/test/java/com/geekshubs/calculator/integration/ITCalculatorAPITest.java
+++ b/src/test/java/com/geekshubs/calculator/integration/ITCalculatorAPITest.java
@@ -7,6 +7,8 @@
import org.apache.http.util.EntityUtils;
import org.junit.jupiter.api.Test;
+import com.geekshubs.calculator.configuration.Values;
+
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -19,7 +21,7 @@ public void testPing() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:8080/calculator/api/calculator/ping");
HttpResponse response = httpclient.execute(httpGet);
assertEquals(200, response.getStatusLine().getStatusCode());
- assertThat(EntityUtils.toString(response.getEntity()), containsString("Welcome to Java Maven Calculator Web App!!!"));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString("Welcome to Java Maven Calculator Web App!!!"));
}
@Test
@@ -28,7 +30,7 @@ public void testAdd() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:8080/calculator/api/calculator/add?x=8&y=26");
HttpResponse response = httpclient.execute(httpGet);
assertEquals(200, response.getStatusLine().getStatusCode());
- assertThat(EntityUtils.toString(response.getEntity()), containsString("\"result\":34"));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString("\"result\":34"));
}
@Test
@@ -37,7 +39,7 @@ public void testSub() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:8080/calculator/api/calculator/sub?x=12&y=8");
HttpResponse response = httpclient.execute(httpGet);
assertEquals(200, response.getStatusLine().getStatusCode());
- assertThat(EntityUtils.toString(response.getEntity()), containsString("\"result\":4"));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString("\"result\":4"));
}
@Test
@@ -46,7 +48,7 @@ public void testMul() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:8080/calculator/api/calculator/mul?x=11&y=8");
HttpResponse response = httpclient.execute(httpGet);
assertEquals(200, response.getStatusLine().getStatusCode());
- assertThat(EntityUtils.toString(response.getEntity()), containsString("\"result\":88"));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString("\"result\":88"));
}
@Test
@@ -55,6 +57,6 @@ public void testDiv() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:8080/calculator/api/calculator/div?x=12&y=12");
HttpResponse response = httpclient.execute(httpGet);
assertEquals(200, response.getStatusLine().getStatusCode());
- assertThat(EntityUtils.toString(response.getEntity()), containsString("\"result\":1"));
+ assertThat(EntityUtils.toString(response.getEntity(), Values.ENCODING), containsString("\"result\":1"));
}
}
diff --git a/src/test/resources/com/geekshubs/calculator/acceptance/api/ping.feature b/src/test/resources/com/geekshubs/calculator/acceptance/api/ping.feature
index 456cb66..d3a9898 100644
--- a/src/test/resources/com/geekshubs/calculator/acceptance/api/ping.feature
+++ b/src/test/resources/com/geekshubs/calculator/acceptance/api/ping.feature
@@ -6,7 +6,14 @@ Feature: Ping check
Then I should receive 200 response status code
And should receive a welcome message
- Scenario: Should receive a sum result
- When I make a GET call on /calculator/api/calculator/add?x=8&y=8
+ Scenario Outline: Should receive a sum result for
+ When I make a GET call on /calculator/api/calculator/add?x=&y=
Then I should receive 200 response status code
- And should receive result 16
+ And should receive result
+
+ Examples:
+ | first | second | result |
+ | -2 | 3 | 1 |
+ | 10 | 15 | 25 |
+ | 99 | -99 | 0 |
+ | -1 | -10 | -11 |
diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties
new file mode 100644
index 0000000..f9ba3c9
--- /dev/null
+++ b/src/test/resources/junit-platform.properties
@@ -0,0 +1,3 @@
+cucumber.publish.quiet=false
+cucumber.publish.enabled=true
+cucumber.plugin=pretty, html:target/cucumber-reports/Cucumber.html, json:target/cucumber-reports/Cucumber.json, junit:target/cucumber-reports/Cucumber.xml