File tree 3 files changed +21
-5
lines changed
pact-jvm-consumer-junit/src
main/java/au/com/dius/pact/consumer
test/java/au/com/dius/pact/consumer
3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ public PactFragment toFragment() {
189
189
JavaConverters$ .MODULE$ .asScalaBufferConverter (existing .interactions ).asScala ());
190
190
}
191
191
192
- public PactDslRequestWithPath uponRecieving (String description ) {
192
+ public PactDslRequestWithPath uponReceiving (String description ) {
193
193
addInteraction ();
194
194
return new PactDslRequestWithPath (existing , description );
195
195
}
Original file line number Diff line number Diff line change 1
1
package au .com .dius .pact .consumer ;
2
2
3
-
4
3
import org .apache .http .client .fluent .Request ;
5
4
6
5
import java .io .IOException ;
@@ -13,6 +12,14 @@ public ConsumerClient(String url) {
13
12
}
14
13
15
14
public String get (String path ) throws IOException {
16
- return Request .Get (url + path ).execute ().returnContent ().asString ();
15
+ return Request .Get (url + path )
16
+ .addHeader ("testreqheader" , "testreqheadervalue" )
17
+ .execute ().returnContent ().asString ();
18
+ }
19
+
20
+ public int options (String path ) throws IOException {
21
+ return Request .Options (url + path )
22
+ .addHeader ("testreqheader" , "testreqheadervalue" )
23
+ .execute ().returnResponse ().getStatusLine ().getStatusCode ();
17
24
}
18
25
}
Original file line number Diff line number Diff line change @@ -19,11 +19,19 @@ protected PactFragment createFragment(ConsumerPactBuilder.PactDslWithProvider bu
19
19
.path ("/" )
20
20
.method ("GET" )
21
21
.headers (headers )
22
- .body ("{ \" test \" :true} " )
22
+ .body ("" )
23
23
.willRespondWith ()
24
24
.status (200 )
25
25
.headers (headers )
26
- .body ("{\" responsetest\" :true}" ).toFragment ();
26
+ .body ("{\" responsetest\" :true}" )
27
+ .uponReceiving ("a second test interaction" )
28
+ .method ("OPTIONS" )
29
+ .headers (headers )
30
+ .willRespondWith ()
31
+ .status (200 )
32
+ .headers (headers )
33
+ .body ("" )
34
+ .toFragment ();
27
35
}
28
36
29
37
@@ -40,6 +48,7 @@ protected String consumerName() {
40
48
@ Override
41
49
protected void runTest (String url ) {
42
50
try {
51
+ assertEquals (new ConsumerClient (url ).options ("/" ), 200 );
43
52
assertEquals (new ConsumerClient (url ).get ("/" ), "{\" responsetest\" :true}" );
44
53
} catch (Exception e ) {
45
54
throw new RuntimeException (e );
You can’t perform that action at this time.
0 commit comments