Skip to content

Commit 6337765

Browse files
committed
BAEL-19798: Change port number for KarateIntegrationTest
1 parent f804b56 commit 6337765

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

testing-modules/rest-testing/src/test/java/com/baeldung/rest/karate/KarateIntegrationTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.baeldung.rest.karate;
22

33
import com.github.tomakehurst.wiremock.WireMockServer;
4+
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
45
import com.intuit.karate.junit4.Karate;
56
import cucumber.api.CucumberOptions;
67
import org.junit.AfterClass;
@@ -14,13 +15,15 @@
1415
@CucumberOptions(features = "classpath:karate")
1516
public class KarateIntegrationTest {
1617

17-
private static final WireMockServer wireMockServer = new WireMockServer();
18+
public static final int PORT_NUMBER = 8097;
19+
20+
private static final WireMockServer wireMockServer = new WireMockServer(WireMockConfiguration.options().port(PORT_NUMBER));
1821

1922
@BeforeClass
2023
public static void setUp() throws Exception {
2124
wireMockServer.start();
2225

23-
configureFor("localhost", 8080);
26+
configureFor("localhost", PORT_NUMBER);
2427
stubFor(get(urlEqualTo("/user/get"))
2528
.willReturn(aResponse()
2629
.withStatus(200)

testing-modules/rest-testing/src/test/resources/karate/user.feature

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
Feature: Testing a REST API with Karate
22

33
Scenario: Testing valid GET endpoint
4-
Given url 'http://localhost:8080/user/get'
4+
Given url 'http://localhost:8097/user/get'
55
When method GET
66
Then status 200
77

88
Scenario: Testing an invalid GET endpoint - 404
9-
Given url 'http://localhost:8080/user/wrong'
9+
Given url 'http://localhost:8097/user/wrong'
1010
When method GET
1111
Then status 404
1212

1313
Scenario: Testing the exact response of a GET endpoint
14-
Given url 'http://localhost:8080/user/get'
14+
Given url 'http://localhost:8097/user/get'
1515
When method GET
1616
Then status 200
1717
And match $ == {id:"1234",name:"John Smith"}
1818

1919
Scenario: Testing the exact response field value of a GET endpoint
20-
Given url 'http://localhost:8080/user/get'
20+
Given url 'http://localhost:8097/user/get'
2121
When method GET
2222
Then status 200
2323
And match $.id == "1234"
2424

2525
Scenario: Testing that GET response contains specific field
26-
Given url 'http://localhost:8080/user/get'
26+
Given url 'http://localhost:8097/user/get'
2727
When method GET
2828
Then status 200
2929
And match $ contains {id:"1234"}
3030

3131
Scenario: Test GET response using markers
32-
Given url 'http://localhost:8080/user/get'
32+
Given url 'http://localhost:8097/user/get'
3333
When method GET
3434
Then status 200
3535
And match $ == {id:"#notnull",name:"John Smith"}
3636

3737
Scenario: Testing a POST endpoint with request body
38-
Given url 'http://localhost:8080/user/create'
38+
Given url 'http://localhost:8097/user/create'
3939
And request { id: '1234' , name: 'John Smith'}
4040
When method POST
4141
Then status 200

0 commit comments

Comments
 (0)