-
-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mock-server): Setting content length == 0 causes the HTTP exchang…
…e to use chunked encoding #1828
- Loading branch information
1 parent
ec066a0
commit 3b25199
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
consumer/junit5/src/test/java/au/com/dius/pact/consumer/junit5/HeadMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package au.com.dius.pact.consumer.junit5; | ||
|
||
import au.com.dius.pact.consumer.MockServer; | ||
import au.com.dius.pact.consumer.dsl.PactBuilder; | ||
import au.com.dius.pact.core.model.V4Pact; | ||
import au.com.dius.pact.core.model.annotations.Pact; | ||
import org.apache.hc.client5.http.fluent.Request; | ||
import org.apache.hc.core5.http.ClassicHttpResponse; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
@ExtendWith(PactConsumerTestExt.class) | ||
@PactTestFor(providerName = "HeadMethodProvider") | ||
public class HeadMethodTest { | ||
@Pact(consumer = "HeadMethodConsumer") | ||
public V4Pact pact(PactBuilder builder) { | ||
return builder | ||
.expectsToReceiveHttpInteraction("HEAD request", | ||
interaction -> interaction | ||
.withRequest(request -> request.path("/v1/my/path").method("HEAD")) | ||
.willRespondWith(response -> response.status(200))) | ||
.toPact(); | ||
} | ||
|
||
@Test | ||
void testPact(MockServer mockServer) throws IOException { | ||
ClassicHttpResponse httpResponse = (ClassicHttpResponse) Request.head(mockServer.getUrl() + "/v1/my/path") | ||
.execute() | ||
.returnResponse(); | ||
assertThat(httpResponse.getCode(), is(equalTo(200))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters