Skip to content

Commit

Permalink
updating to newer version of velocity and wiremock. adding basic support
Browse files Browse the repository at this point in the history
for query paramters in templates.
  • Loading branch information
adamyork committed Feb 6, 2018
1 parent 72c6ab8 commit 73ae64d
Show file tree
Hide file tree
Showing 29 changed files with 1,731 additions and 1,129 deletions.
13 changes: 9 additions & 4 deletions .gitignore
Expand Up @@ -11,7 +11,12 @@
hs_err_pid*
.classpath
.project
.gradle
.settings
build
/bin/
.gradle/
gradle/
.settings/
build/
bin/
.idea/
gradlew
gradlew.bat
out/
153 changes: 82 additions & 71 deletions build.gradle
Expand Up @@ -14,7 +14,7 @@ buildscript {


plugins {
id "eu.appsatori.fatjar" version "0.3"
id "eu.appsatori.fatjar" version "0.3"
}

apply plugin: "java"
Expand All @@ -27,13 +27,13 @@ group = "com.github.adamyork"

sourceCompatibility = 1.7
targetCompatibility = 1.7
version = "1.4"
version = "1.5"

fatJar {
archiveName = "wiremock-velocity-transformer-standalone-" + fatJar.version + ".jar"
manifest {
attributes "Implementation-Title" : "wiremock-velocity-transformer-standalone",
"Implementation-Version" : version
attributes "Implementation-Title": "wiremock-velocity-transformer-standalone",
"Implementation-Version": version
}
}

Expand All @@ -42,17 +42,17 @@ task cleanFunctional(type: Delete) {
}

task copyFunctional(type: Copy) {
from "build/libs/"
include "*.jar"
exclude "*-sources.jar","*-javadoc.jar"
into "functional/"
from "build/libs/"
include "*.jar"
exclude "*-sources.jar", "*-javadoc.jar"
into "functional/"
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from "build/docs/javadoc"
}

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = "sources"
Expand All @@ -67,8 +67,8 @@ jar {
copyFunctional.shouldRunAfter jar
archiveName = "wiremock-velocity-transformer-" + jar.version + ".jar"
manifest {
attributes "Implementation-Title" : "wiremock-velocity-transformer",
"Implementation-Version" : version
attributes "Implementation-Title": "wiremock-velocity-transformer",
"Implementation-Version": version
}
}

Expand All @@ -80,91 +80,102 @@ artifacts {

repositories {
mavenCentral()
maven {
url "https://repository.apache.org/content/repositories/snapshots"
}
}

signing {
sign configurations.archives
}

dependencies {
compile group: "org.apache.velocity", name: "velocity", version: "1.7"
compile group: "org.apache.velocity", name: "velocity-tools", version: "2.0"
compile group: "com.github.tomakehurst", name: "wiremock", version: "2.1.12"
compile group: "org.eclipse.jetty", name: "jetty-server", version: "9.2.13.v20150730"
compile group: "org.eclipse.jetty", name: "jetty-servlet", version: "9.2.13.v20150730"
compile group: "org.eclipse.jetty", name: "jetty-servlets", version: "9.2.13.v20150730"
compile group: "org.eclipse.jetty", name: "jetty-webapp", version: "9.2.13.v20150730"
compile group: "com.google.guava", name: "guava", version: "18.0"
compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: "2.6.1"
compile group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: "2.6.1"
compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.6.1"
compile group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.1"
compile group: "org.xmlunit", name: "xmlunit-core", version: "2.1.1"
compile group: "org.xmlunit", name: "xmlunit-legacy", version: "2.1.1"
compile group: "com.jayway.jsonpath", name: "json-path", version: "2.2.0"
compile group: "org.slf4j", name: "slf4j-api", version: "1.7.12"
compile group: "net.sf.jopt-simple", name: "jopt-simple", version: "4.9"
compile group:"org.apache.commons", name: "commons-lang3", version: "3.3.4"
compile group:"com.flipkart.zjsonpatch", name: "zjsonpatch", version: "0.2.1"
compile ("junit:junit:4.12") {
compile group: "org.apache.velocity", name: "velocity-engine-core", version: "2.0"
compile group: "org.apache.velocity", name: "velocity-tools-generic", version: "3.0-SNAPSHOT"
compile group: "com.github.tomakehurst", name: "wiremock", version: "2.14.0"
compile group: "org.eclipse.jetty", name: "jetty-server", version: "9.2.22.v20170606"
compile group: "org.eclipse.jetty", name: "jetty-servlet", version: "9.2.22.v20170606"
compile group: "org.eclipse.jetty", name: "jetty-servlets", version: "9.2.22.v20170606"
compile group: "org.eclipse.jetty", name: "jetty-webapp", version: "9.2.22.v20170606"
compile group: "com.google.guava", name: "guava", version: "20.0"
compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: "2.8.9"
compile group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: "2.8.9"
compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.8.9"
compile group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.3"
compile group: "org.xmlunit", name: "xmlunit-core", version: "2.3.0"
compile group: "org.xmlunit", name: "xmlunit-legacy", version: "2.3.0"
compile group: "com.jayway.jsonpath", name: "json-path", version: "2.4.0"
compile group: "org.slf4j", name: "slf4j-api", version: "1.7.12"
compile group: "net.sf.jopt-simple", name: "jopt-simple", version: "5.0.3"
compile group: "org.apache.commons", name: "commons-lang3", version: "3.3.6"
compile group: "com.flipkart.zjsonpatch", name: "zjsonpatch", version: "0.3.0"
compile("junit:junit:4.12") {
exclude group: "org.hamcrest", module: "hamcrest-core"
}
testCompile group: "org.hamcrest", name:"hamcrest-all", version: "1.3"
testCompile group: "org.skyscreamer", name: "jsonassert", version: "1.2.3"
testCompile group: "net.sf.json-lib", name: "json-lib", version: "2.4", classifier: 'jdk15'
testCompile group: "com.googlecode.jarjar", name: "jarjar", version: "1.3"
testCompile group: "commons-io", name: "commons-io", version: "2.4"
testCompile ("org.jmock:jmock:2.5.1") {
exclude group: "junit", module: "junit-dep"
}
compile 'com.github.jknack:handlebars:4.0.6', {
exclude group: 'org.mozilla', module: 'rhino'
}
testCompile group: "org.hamcrest", name: "hamcrest-all", version: "1.3"
testCompile group: "org.skyscreamer", name: "jsonassert", version: "1.2.3"
testCompile group: "com.toomuchcoding.jsonassert", name: "jsonassert", version: "0.4.7"
testCompile group: "org.awaitility", name: "awaitility", version: "2.0.0"
testCompile group: "org.scala-lang", name: "scala-library", version: "2.11.12"
testCompile group: "org.littleshoot", name: "littleproxy", version: "1.1.2"
testCompile group: "org.apache.httpcomponents", name: "httpmime", version: "4.5"
testCompile group: "com.googlecode.jarjar", name: "jarjar", version: "1.3"
testCompile group: "commons-io", name: "commons-io", version: "2.4"
testCompile("org.jmock:jmock:2.5.1") {
exclude group: "junit", module: "junit-dep"
exclude group: "org.hamcrest", module: "hamcrest-core"
exclude group: "org.hamcrest", module: "hamcrest-library"
}
testCompile ("org.jmock:jmock-junit4:2.5.1") {
exclude group: "junit", module: "junit-dep"
testCompile("org.jmock:jmock-junit4:2.5.1") {
exclude group: "junit", module: "junit-dep"
exclude group: "org.hamcrest", module: "hamcrest-core"
exclude group: "org.hamcrest", module: "hamcrest-library"
}
testRuntime "org.slf4j:slf4j-log4j12:1.7.12"
}

uploadArchives {
repositories {
mavenDeployer {

beforeDeployment {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

pom.project {
name "wiremock-velocity-transformer"
packaging "jar"
description "transformer used to render velocity templates for stubbed responses."
url "https://github.com/adamyork/wiremock-velocity-transformer"
scm {
url "scm:git@github.com:adamyork/wiremock-velocity-transformer.git"
connection "scm:git@github.com:adamyork/wiremock-velocity-transformer.git"
developerConnection "scm:git@github.com:adamyork/wiremock-velocity-transformer.git"
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id "adamcyork"
name "Adam York"
}
}
}
name "wiremock-velocity-transformer"
packaging "jar"
description "transformer used to render velocity templates for stubbed responses."
url "https://github.com/adamyork/wiremock-velocity-transformer"

scm {
url "scm:git@github.com:adamyork/wiremock-velocity-transformer.git"
connection "scm:git@github.com:adamyork/wiremock-velocity-transformer.git"
developerConnection "scm:git@github.com:adamyork/wiremock-velocity-transformer.git"
}

licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}

developers {
developer {
id "adamcyork"
name "Adam York"
}
}
}
}
}
}
20 changes: 20 additions & 0 deletions functional/__files/response-test-body-for-post.vm
@@ -0,0 +1,20 @@
{
"requestAbsoluteUrl" : "$requestAbsoluteUrl",
"requestBody" : $requestBody,
"requestBodySomeKeyValue" : "$requestBody.someKey",
"requestMethod" : "$requestMethod",
"requestHeaderHost" : "$requestHeaderHost",
"requestHeaderUserAgent" : "$requestHeaderUserAgent",
"requestHeaderAcceptAccept" : "$requestHeaderAccept",
"requestHeaderAcceptLanguage" : "$requestHeaderAcceptLanguage",
"requestHeaderAcceptEncoding" : "$requestHeaderAcceptEncoding",
"requestHeaderConnection" : "$requestHeaderConnection",
#if($requestAbsoluteUrl == 'http://localhost:8089/my/resource')
"customProp" : "customValue",
"customProp2" : "customValue2",
#else
"customProp" : "customValue",
#end
"date" : "$date.getMonth()",
"math" : "$math.floor(2.5)"
}
22 changes: 22 additions & 0 deletions functional/__files/response-test-body-with-query-params.vm
@@ -0,0 +1,22 @@
{
"requestAbsoluteUrl" : "$requestAbsoluteUrl",
"requestMethod" : "$requestMethod",
"requestHeaderHost" : "$requestHeaderHost",
"requestHeaderUserAgent" : "$requestHeaderUserAgent",
"requestHeaderAcceptAccept" : "$requestHeaderAccept",
"requestHeaderAcceptLanguage" : "$requestHeaderAcceptLanguage",
"requestHeaderAcceptEncoding" : "$requestHeaderAcceptEncoding",
"requestHeaderConnection" : "$requestHeaderConnection",
#if($requestAbsoluteUrl == 'http://localhost:8089/my/resource')
"customProp" : "customValue",
"customProp2" : "customValue2",
#else
"customProp" : "customValue",
#end
"date" : "$date.getMonth()",
"math" : "$math.floor(2.5)",
"startDate1" : "$startDate1",
"endDate1" : "$endDate1",
"productCode1" : "$productcode1",
"productCode2" : "$productcode2"
}
29 changes: 13 additions & 16 deletions functional/__files/response-test-body.vm
@@ -1,21 +1,18 @@
{
"requestAbsoluteUrl" : "$requestAbsoluteUrl",
"requestBody" : "$requestBody",
"requestMethod" : "$requestMethod",
"requestHeaderHost" : "$requestHeaderHost",
"requestHeaderUserAgent" : "$requestHeaderUserAgent",
"requestHeaderAcceptAccept" : "$requestHeaderAccept",
"requestHeaderAcceptLanguage" : "$requestHeaderAcceptLanguage",
"requestHeaderAcceptEncoding" : "$requestHeaderAcceptEncoding",
"requestHeaderConnection" : "$requestHeaderConnection",
"date" : "$date",
"math": "$math.round(22.2)",
#if($requestAbsoluteUrl == 'http://localhost:8089/my/resource')
"requestAbsoluteUrl" : "$requestAbsoluteUrl",
"requestMethod" : "$requestMethod",
"requestHeaderHost" : "$requestHeaderHost",
"requestHeaderUserAgent" : "$requestHeaderUserAgent",
"requestHeaderAcceptAccept" : "$requestHeaderAccept",
"requestHeaderAcceptLanguage" : "$requestHeaderAcceptLanguage",
"requestHeaderAcceptEncoding" : "$requestHeaderAcceptEncoding",
"requestHeaderConnection" : "$requestHeaderConnection",
#if($requestAbsoluteUrl == 'http://localhost:8089/my/resource')
"customProp" : "customValue",
"customProp2" : "customValue2",
#else
#else
"customProp" : "customValue",
#end
"date" : "$date.getMonth()",
"math" : "$math.floor(2.5)"
#end
"date" : "$date.getMonth()",
"math" : "$math.floor(2.5)"
}
13 changes: 13 additions & 0 deletions functional/mappings/reponse-test-query-param-mapping.json
@@ -0,0 +1,13 @@
{
"request": {
"urlPattern": "/resource",
"method": "GET"
},
"response": {
"status": 200,
"bodyFileName": "response-test-body-for-post.vm",
"headers": {
"Content-Type": "application/json"
}
}
}
4 changes: 2 additions & 2 deletions functional/mappings/response-test-post-mapping.json
@@ -1,11 +1,11 @@
{
"request": {
"urlPattern": "/resource",
"urlPattern": "/resource?startDate=2018-02-01&endDate=2018-02-28&product-code=10&product-code=j1j1j1",
"method": "POST"
},
"response": {
"status": 200,
"bodyFileName": "response-test-body.vm",
"bodyFileName": "response-test-body-with-query-params.vm",
"headers": {
"Content-Type": "application/json"
}
Expand Down
Binary file not shown.
Binary file removed functional/wiremock-velocity-transformer-1.4.jar
Binary file not shown.
Binary file added functional/wiremock-velocity-transformer-1.5.jar
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion functional/wiremock.sh
@@ -1,2 +1,2 @@
#!/bin/bash
java -cp "wiremock-velocity-transformer-standalone-1.4.jar:wiremock-standalone-2.1.12.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --verbose --extensions com.github.adamyork.wiremock.transformer.VelocityResponseTransformer
java -cp "wiremock-standalone-2.14.0.jar:wiremock-velocity-transformer-standalone-1.5.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --verbose --extensions com.github.adamyork.wiremock.transformer.VelocityResponseTransformer

0 comments on commit 73ae64d

Please sign in to comment.