Went towards beta version of wiremock

This commit is contained in:
Marcin Grzejszczak
2015-08-30 19:33:21 +02:00
parent 154818c797
commit 0021a0dd70
4 changed files with 16 additions and 19 deletions

View File

@@ -25,30 +25,29 @@ class WireMockResponseStubStrategy extends BaseWireMockStubStrategy {
@PackageScope
ResponseDefinition buildClientResponseContent() {
ResponseDefinition responseDefinition = new ResponseDefinition()
responseDefinition.setStatus(response.status.clientValue as Integer)
appendHeaders(responseDefinition)
appendBody(responseDefinition)
return responseDefinition
int status = response.status.clientValue as Integer
HttpHeaders httpHeaders = getHttpHeaders()
String body = getBody()
return new ResponseDefinition(status, body as String, null, null, null, httpHeaders, null, null, null, null, null)
}
private void appendHeaders(ResponseDefinition responseDefinition) {
private HttpHeaders getHttpHeaders() {
if(!(response.headers)) {
return
return null
}
responseDefinition.setHeaders(new HttpHeaders(response.headers.entries?.collect { new HttpHeader(it.name, it.clientValue.toString()) }))
return new HttpHeaders(response.headers.entries?.collect { new HttpHeader(it.name, it.clientValue.toString()) })
}
private void appendBody(ResponseDefinition responseDefinition) {
private String getBody() {
if (!response.body) {
return
return null
}
Object body = response.body.clientValue
ContentType contentType = recognizeContentTypeFromHeader(response.headers)
if (contentType == ContentType.UNKNOWN) {
contentType = recognizeContentTypeFromContent(body)
}
responseDefinition.setBody(parseBody(body, contentType))
return parseBody(body, contentType)
}

View File

@@ -1,5 +1,4 @@
package io.codearte.accurest.plugin
import io.codearte.accurest.config.AccurestConfigProperties
import org.gradle.api.Plugin
import org.gradle.api.Project
@@ -30,11 +29,9 @@ class AccurestGradlePlugin implements Plugin<Project> {
createGenerateTestsTask(extension)
createAndConfigureGenerateWireMockClientStubsFromDslTask(extension)
deprecatedCreateAndConfigureGenerateWiremockClientStubsFromDslTask()
project.dependencies.add("testCompile", "io.codearte.accurest:accurest-core:+")
project.dependencies.add("testCompile", "com.blogspot.toomuchcoding:wiremock:0.0.1")
project.repositories { jcenter() }
project.configurations {
all {
exclude group: 'org.glassfish.jersey.jetty', module: 'jetty-server'
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.github.tomakehurst' && details.requested.name == "wiremock") {
@@ -45,7 +42,6 @@ class AccurestGradlePlugin implements Plugin<Project> {
}
}
project.afterEvaluate {
def hasIdea = project.plugins.findPlugin(IDEA_PLUGIN_CLASS)
if (hasIdea) {

View File

@@ -94,7 +94,9 @@ project(':accurest-core') {
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.5'
compile 'asm:asm:3.3.1'
compile 'com.blogspot.toomuchcoding:wiremock:0.0.1'
compile('com.github.tomakehurst:wiremock:2.0.0-beta') {
exclude group: 'org.mortbay.jetty', module: 'servlet-api'
}
testCompile 'cglib:cglib-nodep:2.2'
testCompile 'org.objenesis:objenesis:2.1'
testCompile 'org.skyscreamer:jsonassert:1.2.3'
@@ -108,7 +110,7 @@ project(':accurest-converters') {
compile 'org.apache.commons:commons-lang3:[3.0,)'
compile 'commons-io:commons-io:[2.0,)'
compile 'dk.brics.automaton:automaton:1.11-8' // needed for Xeger
testCompile 'com.blogspot.toomuchcoding:wiremock:0.0.1'
testCompile 'com.github.tomakehurst:wiremock:2.0.0-beta'
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
}

View File

@@ -12,7 +12,7 @@ task sourcesJar(type: Jar) {
}
artifacts {
archives javadocJar, sourcesJar, repackagedJar
archives javadocJar, sourcesJar
}
signing {