Skip to content

Commit

Permalink
fail the build if a state change request returns a failure status code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Feb 28, 2015
1 parent 2eff45b commit a13bac9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,17 @@ class PactVerificationTask extends DefaultTask {
.reset())
} else {
ProviderClient client = new ProviderClient(provider: providerToVerify)
client.makeStateChangeRequest(url, state, consumer.stateChangeUsesBody)
def response = client.makeStateChangeRequest(url, state, consumer.stateChangeUsesBody)
try {
if (response.statusCode >= 400) {
AnsiConsole.out().println(Ansi.ansi().a(' ').fg(Ansi.Color.RED)
.a('State Change Request Failed - ')
.a(response.statusLine.toString()).reset())
return 'State Change Request Failed - ' + response.statusLine.toString()
}
} finally {
response.close()
}
}
return true
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,17 @@ class PactProviderMojo extends AbstractMojo {
stateChangeUsesBody = provider.stateChangeUsesBody
}
ProviderClient client = new ProviderClient(provider: provider)
client.makeStateChangeRequest(stateChangeUrl.toString(), state, stateChangeUsesBody)
def response = client.makeStateChangeRequest(stateChangeUrl.toString(), state, stateChangeUsesBody)
try {
if (response.statusCode >= 400) {
AnsiConsole.out().println(Ansi.ansi().a(' ').fg(Ansi.Color.RED)
.a('State Change Request Failed - ')
.a(response.statusLine.toString()).reset())
return 'State Change Request Failed - ' + response.statusLine.toString()
}
} finally {
response.close()
}
}
return true
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion pact-jvm-provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ dependencies {
"org.scalatest:scalatest_${project.scalaVersion}:2.2.1",
'commons-io:commons-io:2.4', 'org.codehaus.groovy:groovy-all:2.3.7', 'org.fusesource.jansi:jansi:1.11',
'org.codehaus.groovy.modules.http-builder:http-builder:0.7',
'org.apache.httpcomponents:httpclient:4.3.6', 'com.googlecode.java-diff-utils:diffutils:1.3.0'
'org.apache.httpcomponents:httpclient:4.4', 'com.googlecode.java-diff-utils:diffutils:1.3.0'
}

0 comments on commit a13bac9

Please sign in to comment.