Split project to modules
This commit is contained in:
parent
1bbaf72084
commit
73b3630e2f
26 changed files with 145 additions and 34 deletions
|
@ -0,0 +1,39 @@
|
|||
package pl.touk.mockserver.client
|
||||
|
||||
import groovy.json.JsonSlurper
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.TypeChecked
|
||||
import groovy.util.slurpersupport.GPathResult
|
||||
import org.apache.http.HttpEntity
|
||||
import org.apache.http.client.methods.CloseableHttpResponse
|
||||
import org.apache.http.util.EntityUtils
|
||||
|
||||
@CompileStatic
|
||||
@TypeChecked
|
||||
class Util {
|
||||
static GPathResult extractXmlResponse(CloseableHttpResponse response) {
|
||||
HttpEntity entity = response.entity
|
||||
|
||||
GPathResult xml = new XmlSlurper().parseText(EntityUtils.toString(entity))
|
||||
EntityUtils.consumeQuietly(entity)
|
||||
return xml
|
||||
}
|
||||
|
||||
static String soap(String request) {
|
||||
return """<?xml version='1.0' encoding='UTF-8'?>
|
||||
<soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/' xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
|
||||
<soap-env:Body>$request</soap-env:Body>
|
||||
</soap-env:Envelope>"""
|
||||
}
|
||||
|
||||
static Object extractJsonResponse(CloseableHttpResponse response) {
|
||||
HttpEntity entity = response.entity
|
||||
Object json = new JsonSlurper().parseText(EntityUtils.toString(entity))
|
||||
EntityUtils.consumeQuietly(entity)
|
||||
return json
|
||||
}
|
||||
|
||||
static void consumeResponse(CloseableHttpResponse response) {
|
||||
EntityUtils.consumeQuietly(response.entity)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue