From d4c6226aa52be67c006ed84949836a65480a2489 Mon Sep 17 00:00:00 2001 From: Gaetano Piazzolla Date: Sun, 18 Jun 2023 11:23:46 +0200 Subject: [PATCH] JAVA-22250 | bumping karate to a new version compatible with jdk 17 (#14230) * JAVA-22250 | bumping karate to a new version compatible with jdk 17 * JAVA-22180 | removed unused lib and added correct scope. --- testing-modules/rest-testing/pom.xml | 39 +++++++------------ .../rest/karate/KarateIntegrationTest.java | 13 +++---- .../com/baeldung/rest}/karate/user.feature | 0 3 files changed, 20 insertions(+), 32 deletions(-) rename testing-modules/rest-testing/src/test/{resources => java/com/baeldung/rest}/karate/user.feature (100%) diff --git a/testing-modules/rest-testing/pom.xml b/testing-modules/rest-testing/pom.xml index 323c46a5fc..f8005092ae 100644 --- a/testing-modules/rest-testing/pom.xml +++ b/testing-modules/rest-testing/pom.xml @@ -26,23 +26,6 @@ commons-lang3 ${commons-lang3.version} - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - commons-logging - commons-logging - - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - com.fasterxml.jackson.core @@ -66,6 +49,7 @@ io.cucumber cucumber-junit ${cucumber.version} + test org.jbehave @@ -73,11 +57,6 @@ ${jbehave.version} test - - com.intuit.karate - karate-apache - ${karate.version} - com.intuit.karate karate-junit4 @@ -94,6 +73,18 @@ true + + + + src/test/java + + **/*.java + + + + src/test/resources + + org.apache.maven.plugins @@ -145,9 +136,7 @@ 2.9.0 6.8.0 2.21.0 - 0.6.1 - 4.4.5 - 4.5.2 + 1.3.1 4.1 diff --git a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/KarateIntegrationTest.java b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/KarateIntegrationTest.java index 59d14e6ae0..91dbd7599e 100644 --- a/testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/KarateIntegrationTest.java +++ b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/KarateIntegrationTest.java @@ -2,17 +2,16 @@ package com.baeldung.rest.karate; import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; -import cucumber.api.CucumberOptions; +import com.intuit.karate.junit4.Karate; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.runner.RunWith; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -//We need to upgrade to latest version of Karate for JDK17 --- JAVA-22250 -//@RunWith(Karate.class) -@CucumberOptions(features = "classpath:karate") +@RunWith(Karate.class) public class KarateIntegrationTest { private static final int PORT_NUMBER = 8097; @@ -20,7 +19,7 @@ public class KarateIntegrationTest { private static final WireMockServer wireMockServer = new WireMockServer(WireMockConfiguration.options().port(PORT_NUMBER)); @BeforeClass - public static void setUp() throws Exception { + public static void setUp() { wireMockServer.start(); configureFor("localhost", PORT_NUMBER); @@ -30,7 +29,7 @@ public class KarateIntegrationTest { .withHeader("Content-Type", "application/json") .withBody("{ \"id\": \"1234\", name: \"John Smith\" }"))); stubFor(post(urlEqualTo("/user/create")) - .withHeader("content-type", equalTo("application/json")) + .withHeader("content-type", equalTo("application/json; charset=UTF-8")) .withRequestBody(containing("id")) .willReturn(aResponse() .withStatus(200) @@ -40,7 +39,7 @@ public class KarateIntegrationTest { } @AfterClass - public static void tearDown() throws Exception { + public static void tearDown() { wireMockServer.stop(); } diff --git a/testing-modules/rest-testing/src/test/resources/karate/user.feature b/testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/user.feature similarity index 100% rename from testing-modules/rest-testing/src/test/resources/karate/user.feature rename to testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/user.feature