This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # HTTP URLs that Could Not Be Fixed These URLs were unable to be fixed. Please review them to see if they can be manually resolved. * [ ] http://aopalliance.sourceforge.net (200) with 3 occurrences could not be migrated: ([https](https://aopalliance.sourceforge.net) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/ (200) with 5 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_blocks.html (200) with 1 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_blocks.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_coding.html (200) with 3 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_coding.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_design.html (200) with 1 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_design.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_javadoc.html (200) with 4 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_javadoc.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_misc.html (200) with 1 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_misc.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_naming.html (200) with 1 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_naming.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_sizes.html (200) with 2 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_sizes.html) result AnnotatedConnectException). * [ ] http://checkstyle.sourceforge.net/config_whitespace.html (200) with 2 occurrences could not be migrated: ([https](https://checkstyle.sourceforge.net/config_whitespace.html) result AnnotatedConnectException). * [ ] http://codearte.io (200) with 16 occurrences could not be migrated: ([https](https://codearte.io) result SSLHandshakeException). * [ ] http://docbkx-tools.sourceforge.net/docbkx-maven-plugin/ (200) with 1 occurrences could not be migrated: ([https](https://docbkx-tools.sourceforge.net/docbkx-maven-plugin/) result AnnotatedConnectException). * [ ] http://erik.eae.net/archives/2007/07/27/18.54.15/ (200) with 1 occurrences could not be migrated: ([https](https://erik.eae.net/archives/2007/07/27/18.54.15/) result SSLHandshakeException). * [ ] http://findbugs.sourceforge.net/ (200) with 3 occurrences could not be migrated: ([https](https://findbugs.sourceforge.net/) result AnnotatedConnectException). * [ ] http://groovy-lang.org (200) with 31 occurrences could not be migrated: ([https](https://groovy-lang.org) result SSLProtocolException). * [ ] http://groovy-lang.org/json.html (200) with 46 occurrences could not be migrated: ([https](https://groovy-lang.org/json.html) result SSLProtocolException). * [ ] http://hsqldb.org (200) with 1 occurrences could not be migrated: ([https](https://hsqldb.org) result SSLHandshakeException). * [ ] http://hsqldb.org/web/hsqlLicense.html (200) with 1 occurrences could not be migrated: ([https](https://hsqldb.org/web/hsqlLicense.html) result SSLHandshakeException). * [ ] http://htmlunit.sourceforge.net (200) with 1 occurrences could not be migrated: ([https](https://htmlunit.sourceforge.net) result AnnotatedConnectException). * [ ] http://javascript.nwbox.com/IEContentLoaded/ (200) with 1 occurrences could not be migrated: ([https](https://javascript.nwbox.com/IEContentLoaded/) result SSLHandshakeException). * [ ] http://jtds.sourceforge.net (200) with 1 occurrences could not be migrated: ([https](https://jtds.sourceforge.net) result AnnotatedConnectException). * [ ] http://nekohtml.sourceforge.net/ (200) with 1 occurrences could not be migrated: ([https](https://nekohtml.sourceforge.net/) result AnnotatedConnectException). * [ ] http://objenesis.org (200) with 1 occurrences could not be migrated: ([https](https://objenesis.org) result SSLHandshakeException). * [ ] http://partners.com (200) with 54 occurrences could not be migrated: ([https](https://partners.com) result SSLHandshakeException). * [ ] http://planet.apache.org/ (200) with 6 occurrences could not be migrated: ([https](https://planet.apache.org/) result ConnectTimeoutException). * [ ] http://rest-assured.io/ (200) with 16 occurrences could not be migrated: ([https](https://rest-assured.io/) result SSLHandshakeException). * [ ] http://spockframework.org (200) with 2 occurrences could not be migrated: ([https](https://spockframework.org) result SSLHandshakeException). * [ ] http://spockframework.org/ (200) with 3 occurrences could not be migrated: ([https](https://spockframework.org/) result SSLHandshakeException). * [ ] http://toomuchcoding.com/blog/categories/accurest/ (200) with 16 occurrences could not be migrated: ([https](https://toomuchcoding.com/blog/categories/accurest/) result SSLHandshakeException). * [ ] http://toomuchcoding.com/blog/categories/spring-cloud-contract/ (200) with 16 occurrences could not be migrated: ([https](https://toomuchcoding.com/blog/categories/spring-cloud-contract/) result SSLHandshakeException). * [ ] http://wiremock.org (200) with 24 occurrences could not be migrated: ([https](https://wiremock.org) result SSLHandshakeException). * [ ] http://wiremock.org/docs/stateful-behaviour/ (200) with 10 occurrences could not be migrated: ([https](https://wiremock.org/docs/stateful-behaviour/) result SSLHandshakeException). * [ ] http://wiremock.org/docs/stubbing/ (200) with 7 occurrences could not be migrated: ([https](https://wiremock.org/docs/stubbing/) result SSLHandshakeException). * [ ] http://wiremock.org/stateful-behaviour.html (200) with 22 occurrences could not be migrated: ([https](https://wiremock.org/stateful-behaviour.html) result SSLHandshakeException). * [ ] http://wiremock.org/stubbing.html (200) with 16 occurrences could not be migrated: ([https](https://wiremock.org/stubbing.html) result SSLHandshakeException). * [ ] http://www.jdom.org (200) with 1 occurrences could not be migrated: ([https](https://www.jdom.org) result AnnotatedConnectException). * [ ] http://www.saxproject.org/copying.html (200) with 1 occurrences could not be migrated: ([https](https://www.saxproject.org/copying.html) result AnnotatedConnectException). * [ ] http://blindsignals.com/index.php/2009/07/jquery-delay/ (301) with 1 occurrences could not be migrated: ([https](https://blindsignals.com/index.php/2009/07/jquery-delay/) result SSLHandshakeException). * [ ] http://192.168.0.100:8081/artifactory/libs-release-local (403) with 14 occurrences could not be migrated: ([https](https://192.168.0.100:8081/artifactory/libs-release-local) result ConnectTimeoutException). * [ ] http://takari.io/takari-lifecycle/takari-lifecycle-plugin (404) with 9 occurrences could not be migrated: ([https](https://takari.io/takari-lifecycle/takari-lifecycle-plugin) result ConnectTimeoutException). * [ ] http://takari.io/takari-plugin-testing-project/takari-plugin-integration-testing (404) with 3 occurrences could not be migrated: ([https](https://takari.io/takari-plugin-testing-project/takari-plugin-integration-testing) result ConnectTimeoutException). * [ ] http://takari.io/takari-plugin-testing-project/takari-plugin-testing (404) with 3 occurrences could not be migrated: ([https](https://takari.io/takari-plugin-testing-project/takari-plugin-testing) result ConnectTimeoutException). * [ ] http://toomuchcoding.com/blog/2015/09/27/microservice-deployment/ (404) with 2 occurrences could not be migrated: ([https](https://toomuchcoding.com/blog/2015/09/27/microservice-deployment/) result SSLHandshakeException). * [ ] http://www.seamframework.org/Weld/cdi-api (404) with 3 occurrences could not be migrated: ([https](https://www.seamframework.org/Weld/cdi-api) result SSLHandshakeException). * [ ] http://xstream.codehaus.com/license.html (404) with 1 occurrences could not be migrated: ([https](https://xstream.codehaus.com/license.html) result ConnectTimeoutException). # Fixed URLs ## Fixed But Review Recommended These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended. * [ ] http://fontawesome.io (301) with 4 occurrences migrated to: https://fontawesome.com?from=io ([https](https://fontawesome.io) result AnnotatedConnectException). * [ ] http://freemarker.org/ (301) with 1 occurrences migrated to: https://freemarker.apache.org/ ([https](https://freemarker.org/) result ConnectTimeoutException). * [ ] http://www.ultraq.net.nz/programming/thymeleaf-layout-dialect/ (302) with 1 occurrences migrated to: https://github.com/ultraq/thymeleaf-layout-dialect/ ([https](https://www.ultraq.net.nz/programming/thymeleaf-layout-dialect/) result ConnectTimeoutException). * [ ] http://jsperf.com/getall-vs-sizzle/2 (301) with 1 occurrences migrated to: https://jsperf.com/getall-vs-sizzle/2 ([https](https://jsperf.com/getall-vs-sizzle/2) result ReadTimeoutException). * [ ] http://webjars.org (301) with 5 occurrences migrated to: https://www.webjars.org ([https](https://webjars.org) result SSLHandshakeException). * [ ] http://zenorocha.mit-license.org (301) with 1 occurrences migrated to: https://zenorocha.mit-license.org/ ([https](https://zenorocha.mit-license.org) result NullPointerException). * [ ] http://wiki.ecmascript.org/doku.php?id=harmony:egal (ConnectTimeoutException) with 1 occurrences migrated to: https://wiki.ecmascript.org/doku.php?id=harmony:egal ([https](https://wiki.ecmascript.org/doku.php?id=harmony:egal) result ConnectTimeoutException). * [ ] http://www.w3.org/TR/html4/loose.dtd (ReadTimeoutException) with 1 occurrences migrated to: https://www.w3.org/TR/html4/loose.dtd ([https](https://www.w3.org/TR/html4/loose.dtd) result ReadTimeoutException). * [ ] http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd (ReadTimeoutException) with 24 occurrences migrated to: https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ([https](https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd) result ReadTimeoutException). * [ ] http://codehaus.org/xstream-parent/xstream/ (UnknownHostException) with 1 occurrences migrated to: https://codehaus.org/xstream-parent/xstream/ ([https](https://codehaus.org/xstream-parent/xstream/) result UnknownHostException). * [ ] http://dist.codehaus.org/janino/new_bsd_license.txt (UnknownHostException) with 1 occurrences migrated to: https://dist.codehaus.org/janino/new_bsd_license.txt ([https](https://dist.codehaus.org/janino/new_bsd_license.txt) result UnknownHostException). * [ ] http://docs.codehaus.org/display/BTM/Home/btm (UnknownHostException) with 1 occurrences migrated to: https://docs.codehaus.org/display/BTM/Home/btm ([https](https://docs.codehaus.org/display/BTM/Home/btm) result UnknownHostException). * [ ] http://docs.codehaus.org/display/JANINO/Home/janino (UnknownHostException) with 1 occurrences migrated to: https://docs.codehaus.org/display/JANINO/Home/janino ([https](https://docs.codehaus.org/display/JANINO/Home/janino) result UnknownHostException). * [ ] http://foo.bar (UnknownHostException) with 14 occurrences migrated to: https://foo.bar ([https](https://foo.bar) result UnknownHostException). * [ ] http://forge.sonatype.com/spice-parent/plexus-build-api/ (UnknownHostException) with 3 occurrences migrated to: https://forge.sonatype.com/spice-parent/plexus-build-api/ ([https](https://forge.sonatype.com/spice-parent/plexus-build-api/) result UnknownHostException). * [ ] http://jaxen.codehaus.org/ (UnknownHostException) with 1 occurrences migrated to: https://jaxen.codehaus.org/ ([https](https://jaxen.codehaus.org/) result UnknownHostException). * [ ] http://jaxen.codehaus.org/license.html (UnknownHostException) with 1 occurrences migrated to: https://jaxen.codehaus.org/license.html ([https](https://jaxen.codehaus.org/license.html) result UnknownHostException). * [ ] http://metrics.codahale.com/metrics-core/ (UnknownHostException) with 1 occurrences migrated to: https://metrics.codahale.com/metrics-core/ ([https](https://metrics.codahale.com/metrics-core/) result UnknownHostException). * [ ] http://metrics.codahale.com/metrics-ganglia/ (UnknownHostException) with 1 occurrences migrated to: https://metrics.codahale.com/metrics-ganglia/ ([https](https://metrics.codahale.com/metrics-ganglia/) result UnknownHostException). * [ ] http://metrics.codahale.com/metrics-graphite/ (UnknownHostException) with 1 occurrences migrated to: https://metrics.codahale.com/metrics-graphite/ ([https](https://metrics.codahale.com/metrics-graphite/) result UnknownHostException). * [ ] http://metrics.codahale.com/metrics-servlets/ (UnknownHostException) with 1 occurrences migrated to: https://metrics.codahale.com/metrics-servlets/ ([https](https://metrics.codahale.com/metrics-servlets/) result UnknownHostException). * [ ] http://mojo.codehaus.org/animal-sniffer-parent/animal-sniffer-maven-plugin (UnknownHostException) with 2 occurrences migrated to: https://mojo.codehaus.org/animal-sniffer-parent/animal-sniffer-maven-plugin ([https](https://mojo.codehaus.org/animal-sniffer-parent/animal-sniffer-maven-plugin) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-archiver/ (UnknownHostException) with 3 occurrences migrated to: https://plexus.codehaus.org/plexus-archiver/ ([https](https://plexus.codehaus.org/plexus-archiver/) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-classworlds/ (UnknownHostException) with 3 occurrences migrated to: https://plexus.codehaus.org/plexus-classworlds/ ([https](https://plexus.codehaus.org/plexus-classworlds/) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-components/plexus-interpolation (UnknownHostException) with 3 occurrences migrated to: https://plexus.codehaus.org/plexus-components/plexus-interpolation ([https](https://plexus.codehaus.org/plexus-components/plexus-interpolation) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-containers/plexus-component-annotations/ (UnknownHostException) with 3 occurrences migrated to: https://plexus.codehaus.org/plexus-containers/plexus-component-annotations/ ([https](https://plexus.codehaus.org/plexus-containers/plexus-component-annotations/) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-containers/plexus-component-metadata/ (UnknownHostException) with 8 occurrences migrated to: https://plexus.codehaus.org/plexus-containers/plexus-component-metadata/ ([https](https://plexus.codehaus.org/plexus-containers/plexus-component-metadata/) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-io/ (UnknownHostException) with 3 occurrences migrated to: https://plexus.codehaus.org/plexus-io/ ([https](https://plexus.codehaus.org/plexus-io/) result UnknownHostException). * [ ] http://plexus.codehaus.org/plexus-utils (UnknownHostException) with 3 occurrences migrated to: https://plexus.codehaus.org/plexus-utils ([https](https://plexus.codehaus.org/plexus-utils) result UnknownHostException). * [ ] http://spice.sonatype.org/plexus-cipher (UnknownHostException) with 3 occurrences migrated to: https://spice.sonatype.org/plexus-cipher ([https](https://spice.sonatype.org/plexus-cipher) result UnknownHostException). * [ ] http://spice.sonatype.org/plexus-sec-dispatcher (UnknownHostException) with 3 occurrences migrated to: https://spice.sonatype.org/plexus-sec-dispatcher ([https](https://spice.sonatype.org/plexus-sec-dispatcher) result UnknownHostException). * [ ] http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html (UnknownHostException) with 1 occurrences migrated to: https://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html ([https](https://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html) result UnknownHostException). * [ ] http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding (UnknownHostException) with 1 occurrences migrated to: https://wiki.fasterxml.com/JacksonExtensionXmlDataBinding ([https](https://wiki.fasterxml.com/JacksonExtensionXmlDataBinding) result UnknownHostException). * [ ] http://wiki.fasterxml.com/JacksonModuleJSR310 (UnknownHostException) with 1 occurrences migrated to: https://wiki.fasterxml.com/JacksonModuleJSR310 ([https](https://wiki.fasterxml.com/JacksonModuleJSR310) result UnknownHostException). * [ ] http://wiki.fasterxml.com/JacksonModuleJoda (UnknownHostException) with 1 occurrences migrated to: https://wiki.fasterxml.com/JacksonModuleJoda ([https](https://wiki.fasterxml.com/JacksonModuleJoda) result UnknownHostException). * [ ] http://www.aspectj.org (UnknownHostException) with 3 occurrences migrated to: https://www.aspectj.org ([https](https://www.aspectj.org) result UnknownHostException). * [ ] http://www.blog.project13.pl (UnknownHostException) with 5 occurrences migrated to: https://www.blog.project13.pl ([https](https://www.blog.project13.pl) result UnknownHostException). * [ ] http://www.mockito.org (UnknownHostException) with 1 occurrences migrated to: https://www.mockito.org ([https](https://www.mockito.org) result UnknownHostException). * [ ] http://activemq.apache.org/activemq-amqp (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-amqp ([https](https://activemq.apache.org/activemq-amqp) result 404). * [ ] http://activemq.apache.org/activemq-blueprint (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-blueprint ([https](https://activemq.apache.org/activemq-blueprint) result 404). * [ ] http://activemq.apache.org/activemq-broker (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-broker ([https](https://activemq.apache.org/activemq-broker) result 404). * [ ] http://activemq.apache.org/activemq-camel (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-camel ([https](https://activemq.apache.org/activemq-camel) result 404). * [ ] http://activemq.apache.org/activemq-client (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-client ([https](https://activemq.apache.org/activemq-client) result 404). * [ ] http://activemq.apache.org/activemq-console (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-console ([https](https://activemq.apache.org/activemq-console) result 404). * [ ] http://activemq.apache.org/activemq-http (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-http ([https](https://activemq.apache.org/activemq-http) result 404). * [ ] http://activemq.apache.org/activemq-jaas (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-jaas ([https](https://activemq.apache.org/activemq-jaas) result 404). * [ ] http://activemq.apache.org/activemq-jdbc-store (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-jdbc-store ([https](https://activemq.apache.org/activemq-jdbc-store) result 404). * [ ] http://activemq.apache.org/activemq-jms-pool (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-jms-pool ([https](https://activemq.apache.org/activemq-jms-pool) result 404). * [ ] http://activemq.apache.org/activemq-kahadb-store (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-kahadb-store ([https](https://activemq.apache.org/activemq-kahadb-store) result 404). * [ ] http://activemq.apache.org/activemq-karaf (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-karaf ([https](https://activemq.apache.org/activemq-karaf) result 404). * [ ] http://activemq.apache.org/activemq-leveldb-store (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-leveldb-store ([https](https://activemq.apache.org/activemq-leveldb-store) result 404). * [ ] http://activemq.apache.org/activemq-log4j-appender (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-log4j-appender ([https](https://activemq.apache.org/activemq-log4j-appender) result 404). * [ ] http://activemq.apache.org/activemq-mqtt (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-mqtt ([https](https://activemq.apache.org/activemq-mqtt) result 404). * [ ] http://activemq.apache.org/activemq-openwire-generator (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-openwire-generator ([https](https://activemq.apache.org/activemq-openwire-generator) result 404). * [ ] http://activemq.apache.org/activemq-openwire-legacy (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-openwire-legacy ([https](https://activemq.apache.org/activemq-openwire-legacy) result 404). * [ ] http://activemq.apache.org/activemq-osgi (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-osgi ([https](https://activemq.apache.org/activemq-osgi) result 404). * [ ] http://activemq.apache.org/activemq-partition (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-partition ([https](https://activemq.apache.org/activemq-partition) result 404). * [ ] http://activemq.apache.org/activemq-pool (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-pool ([https](https://activemq.apache.org/activemq-pool) result 404). * [ ] http://activemq.apache.org/activemq-ra (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-ra ([https](https://activemq.apache.org/activemq-ra) result 404). * [ ] http://activemq.apache.org/activemq-run (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-run ([https](https://activemq.apache.org/activemq-run) result 404). * [ ] http://activemq.apache.org/activemq-runtime-config (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-runtime-config ([https](https://activemq.apache.org/activemq-runtime-config) result 404). * [ ] http://activemq.apache.org/activemq-shiro (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-shiro ([https](https://activemq.apache.org/activemq-shiro) result 404). * [ ] http://activemq.apache.org/activemq-spring (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-spring ([https](https://activemq.apache.org/activemq-spring) result 404). * [ ] http://activemq.apache.org/activemq-stomp (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-stomp ([https](https://activemq.apache.org/activemq-stomp) result 404). * [ ] http://activemq.apache.org/activemq-web (404) with 1 occurrences migrated to: https://activemq.apache.org/activemq-web ([https](https://activemq.apache.org/activemq-web) result 404). * [ ] http://apache.org/activemq/artemis-commons (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-commons ([https](https://apache.org/activemq/artemis-commons) result 404). * [ ] http://apache.org/activemq/artemis-core-client (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-core-client ([https](https://apache.org/activemq/artemis-core-client) result 404). * [ ] http://apache.org/activemq/artemis-jms-client (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-jms-client ([https](https://apache.org/activemq/artemis-jms-client) result 404). * [ ] http://apache.org/activemq/artemis-jms-server (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-jms-server ([https](https://apache.org/activemq/artemis-jms-server) result 404). * [ ] http://apache.org/activemq/artemis-journal (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-journal ([https](https://apache.org/activemq/artemis-journal) result 404). * [ ] http://apache.org/activemq/artemis-native (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-native ([https](https://apache.org/activemq/artemis-native) result 404). * [ ] http://apache.org/activemq/artemis-protocols/artemis-amqp-protocol (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-protocols/artemis-amqp-protocol ([https](https://apache.org/activemq/artemis-protocols/artemis-amqp-protocol) result 404). * [ ] http://apache.org/activemq/artemis-selector (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-selector ([https](https://apache.org/activemq/artemis-selector) result 404). * [ ] http://apache.org/activemq/artemis-server (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-server ([https](https://apache.org/activemq/artemis-server) result 404). * [ ] http://apache.org/activemq/artemis-service-extensions (404) with 1 occurrences migrated to: https://apache.org/activemq/artemis-service-extensions ([https](https://apache.org/activemq/artemis-service-extensions) result 404). * [ ] http://camel.apache.org/camel-parent/components/camel-jackson (404) with 1 occurrences migrated to: https://camel.apache.org/camel-parent/components/camel-jackson ([https](https://camel.apache.org/camel-parent/components/camel-jackson) result 404). * [ ] http://camel.apache.org/camel-parent/components/camel-jms (404) with 1 occurrences migrated to: https://camel.apache.org/camel-parent/components/camel-jms ([https](https://camel.apache.org/camel-parent/components/camel-jms) result 404). * [ ] http://camel.apache.org/camel-parent/components/camel-spring (404) with 1 occurrences migrated to: https://camel.apache.org/camel-parent/components/camel-spring ([https](https://camel.apache.org/camel-parent/components/camel-spring) result 404). * [ ] http://camel.apache.org/camel-parent/components/camel-spring-boot-starter (404) with 1 occurrences migrated to: https://camel.apache.org/camel-parent/components/camel-spring-boot-starter ([https](https://camel.apache.org/camel-parent/components/camel-spring-boot-starter) result 404). * [ ] http://code.google.com/appengine/appengine-api-1.0-sdk/ (404) with 1 occurrences migrated to: https://code.google.com/appengine/appengine-api-1.0-sdk/ ([https](https://code.google.com/appengine/appengine-api-1.0-sdk/) result 404). * [ ] http://db.apache.org/derby/derby/ (404) with 1 occurrences migrated to: https://db.apache.org/derby/derby/ ([https](https://db.apache.org/derby/derby/) result 404). * [ ] http://download.eclipse.org/aether/aether-core/0.9.0/apidocs/org/eclipse/aether/util/version/GenericVersionScheme.html (404) with 9 occurrences migrated to: https://download.eclipse.org/aether/aether-core/0.9.0/apidocs/org/eclipse/aether/util/version/GenericVersionScheme.html ([https](https://download.eclipse.org/aether/aether-core/0.9.0/apidocs/org/eclipse/aether/util/version/GenericVersionScheme.html) result 404). * [ ] http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ (301) with 1 occurrences migrated to: https://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ ([https](https://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/) result 404). * [ ] http://flywaydb.org/flyway-core (301) with 1 occurrences migrated to: https://flywaydb.org/flyway-core ([https](https://flywaydb.org/flyway-core) result 404). * [ ] http://github.com/FasterXML/jackson-jaxrs-providers/jackson-datatype-jaxrs (301) with 1 occurrences migrated to: https://github.com/FasterXML/jackson-jaxrs-providers/jackson-datatype-jaxrs ([https](https://github.com/FasterXML/jackson-jaxrs-providers/jackson-datatype-jaxrs) result 404). * [ ] http://github.com/FasterXML/jackson-jaxrs-providers/jackson-jaxrs-base (301) with 1 occurrences migrated to: https://github.com/FasterXML/jackson-jaxrs-providers/jackson-jaxrs-base ([https](https://github.com/FasterXML/jackson-jaxrs-providers/jackson-jaxrs-base) result 404). * [ ] http://github.com/FasterXML/jackson-jaxrs-providers/jackson-jaxrs-json-provider (301) with 1 occurrences migrated to: https://github.com/FasterXML/jackson-jaxrs-providers/jackson-jaxrs-json-provider ([https](https://github.com/FasterXML/jackson-jaxrs-providers/jackson-jaxrs-json-provider) result 404). * [ ] http://github.com/neo4j/neo4j-ogm/neo4j-ogm-api/ (301) with 1 occurrences migrated to: https://github.com/neo4j/neo4j-ogm/neo4j-ogm-api/ ([https](https://github.com/neo4j/neo4j-ogm/neo4j-ogm-api/) result 404). * [ ] http://github.com/neo4j/neo4j-ogm/neo4j-ogm-compiler/ (301) with 1 occurrences migrated to: https://github.com/neo4j/neo4j-ogm/neo4j-ogm-compiler/ ([https](https://github.com/neo4j/neo4j-ogm/neo4j-ogm-compiler/) result 404). * [ ] http://github.com/neo4j/neo4j-ogm/neo4j-ogm-core/ (301) with 1 occurrences migrated to: https://github.com/neo4j/neo4j-ogm/neo4j-ogm-core/ ([https](https://github.com/neo4j/neo4j-ogm/neo4j-ogm-core/) result 404). * [ ] http://github.com/neo4j/neo4j-ogm/neo4j-ogm-http-driver/ (301) with 1 occurrences migrated to: https://github.com/neo4j/neo4j-ogm/neo4j-ogm-http-driver/ ([https](https://github.com/neo4j/neo4j-ogm/neo4j-ogm-http-driver/) result 404). * [ ] http://github.com/sprinframework (301) with 4 occurrences migrated to: https://github.com/sprinframework ([https](https://github.com/sprinframework) result 404). * [ ] http://github.com/spring_hadoop (301) with 4 occurrences migrated to: https://github.com/spring_hadoop ([https](https://github.com/spring_hadoop) result 404). * [ ] http://google-code-prettify.googlecode.com/svn/trunk/README.html (404) with 1 occurrences migrated to: https://google-code-prettify.googlecode.com/svn/trunk/README.html ([https](https://google-code-prettify.googlecode.com/svn/trunk/README.html) result 404). * [ ] http://hc.apache.org/httpcomponents-asyncclient (404) with 1 occurrences migrated to: https://hc.apache.org/httpcomponents-asyncclient ([https](https://hc.apache.org/httpcomponents-asyncclient) result 404). * [ ] http://hc.apache.org/httpcomponents-client (404) with 5 occurrences migrated to: https://hc.apache.org/httpcomponents-client ([https](https://hc.apache.org/httpcomponents-client) result 404). * [ ] http://hibernate.org/validator/hibernate-validator (404) with 1 occurrences migrated to: https://hibernate.org/validator/hibernate-validator ([https](https://hibernate.org/validator/hibernate-validator) result 404). * [ ] http://hibernate.org/validator/hibernate-validator-annotation-processor (404) with 1 occurrences migrated to: https://hibernate.org/validator/hibernate-validator-annotation-processor ([https](https://hibernate.org/validator/hibernate-validator-annotation-processor) result 404). * [ ] http://hornetq.org/hornetq-jms-client (301) with 1 occurrences migrated to: https://hornetq.jboss.org/hornetq-jms-client ([https](https://hornetq.org/hornetq-jms-client) result 404). * [ ] http://hornetq.org/hornetq-jms-server (301) with 1 occurrences migrated to: https://hornetq.jboss.org/hornetq-jms-server ([https](https://hornetq.org/hornetq-jms-server) result 404). * [ ] http://www.infinispan.org/infinispan-jcache-parent/infinispan-jcache (301) with 1 occurrences migrated to: https://infinispan.org/infinispan-jcache-parent/infinispan-jcache ([https](https://www.infinispan.org/infinispan-jcache-parent/infinispan-jcache) result 404). * [ ] http://www.infinispan.org/infinispan-spring4-parent/infinispan-spring4-common (301) with 1 occurrences migrated to: https://infinispan.org/infinispan-spring4-parent/infinispan-spring4-common ([https](https://www.infinispan.org/infinispan-spring4-parent/infinispan-spring4-common) result 404). * [ ] http://www.infinispan.org/infinispan-spring4-parent/infinispan-spring4-embedded (301) with 1 occurrences migrated to: https://infinispan.org/infinispan-spring4-parent/infinispan-spring4-embedded ([https](https://www.infinispan.org/infinispan-spring4-parent/infinispan-spring4-embedded) result 404). * [ ] http://json.org/json2.js (404) with 1 occurrences migrated to: https://json.org/json2.js ([https](https://json.org/json2.js) result 404). * [ ] http://logback.qos.ch/logback-access (302) with 1 occurrences migrated to: https://logback.qos.ch/logback-access ([https](https://logback.qos.ch/logback-access) result 404). * [ ] http://logback.qos.ch/logback-classic (302) with 1 occurrences migrated to: https://logback.qos.ch/logback-classic ([https](https://logback.qos.ch/logback-classic) result 404). * [ ] http://logback.qos.ch/logback-core (302) with 4 occurrences migrated to: https://logback.qos.ch/logback-core ([https](https://logback.qos.ch/logback-core) result 404). * [ ] http://lucene.apache.org/solr-parent/solr-solrj (404) with 1 occurrences migrated to: https://lucene.apache.org/solr-parent/solr-solrj ([https](https://lucene.apache.org/solr-parent/solr-solrj) result 404). * [ ] http://pivotal.github.com/jasmine (404) with 1 occurrences migrated to: https://pivotal.github.com/jasmine ([https](https://pivotal.github.com/jasmine) result 404). * [ ] http://projects.spring.io/spring-boot/spring-boot-actuator-docs/ (404) with 1 occurrences migrated to: https://projects.spring.io/spring-boot/spring-boot-actuator-docs/ ([https](https://projects.spring.io/spring-boot/spring-boot-actuator-docs/) result 404). * [ ] http://projects.spring.io/spring-cloud/spring-cloud-commons/ (404) with 1 occurrences migrated to: https://projects.spring.io/spring-cloud/spring-cloud-commons/ ([https](https://projects.spring.io/spring-cloud/spring-cloud-commons/) result 404). * [ ] http://projects.spring.io/spring-cloud/spring-cloud-config-monitor/ (404) with 1 occurrences migrated to: https://projects.spring.io/spring-cloud/spring-cloud-config-monitor/ ([https](https://projects.spring.io/spring-cloud/spring-cloud-config-monitor/) result 404). * [ ] http://projects.spring.io/spring-cloud/spring-cloud-config-server/ (404) with 1 occurrences migrated to: https://projects.spring.io/spring-cloud/spring-cloud-config-server/ ([https](https://projects.spring.io/spring-cloud/spring-cloud-config-server/) result 404). * [ ] http://projects.spring.io/spring-cloud/spring-cloud-context/ (404) with 1 occurrences migrated to: https://projects.spring.io/spring-cloud/spring-cloud-context/ ([https](https://projects.spring.io/spring-cloud/spring-cloud-context/) result 404). * [ ] http://projects.spring.io/spring-data-mongodb/spring-data-mongodb (404) with 1 occurrences migrated to: https://projects.spring.io/spring-data-mongodb/spring-data-mongodb ([https](https://projects.spring.io/spring-data-mongodb/spring-data-mongodb) result 404). * [ ] http://projects.spring.io/spring-data-mongodb/spring-data-mongodb-cross-store (404) with 1 occurrences migrated to: https://projects.spring.io/spring-data-mongodb/spring-data-mongodb-cross-store ([https](https://projects.spring.io/spring-data-mongodb/spring-data-mongodb-cross-store) result 404). * [ ] http://projects.spring.io/spring-data-mongodb/spring-data-mongodb-log4j (404) with 1 occurrences migrated to: https://projects.spring.io/spring-data-mongodb/spring-data-mongodb-log4j ([https](https://projects.spring.io/spring-data-mongodb/spring-data-mongodb-log4j) result 404). * [ ] http://repo.spring.io/snapshots (404) with 13 occurrences migrated to: https://repo.spring.io/snapshots ([https](https://repo.spring.io/snapshots) result 404). * [ ] http://www.apache.org/license/LICENSE-2.0.txt (404) with 3 occurrences migrated to: https://www.apache.org/license/LICENSE-2.0.txt ([https](https://www.apache.org/license/LICENSE-2.0.txt) result 404). * [ ] http://www.atomikos.com/ate/transactions-jdbc/ (301) with 1 occurrences migrated to: https://www.atomikos.com/ate/transactions-jdbc/ ([https](https://www.atomikos.com/ate/transactions-jdbc/) result 404). * [ ] http://www.atomikos.com/ate/transactions-jms/ (301) with 1 occurrences migrated to: https://www.atomikos.com/ate/transactions-jms/ ([https](https://www.atomikos.com/ate/transactions-jms/) result 404). * [ ] http://www.atomikos.com/ate/transactions-jta/ (301) with 1 occurrences migrated to: https://www.atomikos.com/ate/transactions-jta/ ([https](https://www.atomikos.com/ate/transactions-jta/) result 404). * [ ] http://www.crashub.org/crash.cli/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.cli/ ([https](https://www.crashub.org/crash.cli/) result 404). * [ ] http://www.crashub.org/crash.connectors/crash.connectors.ssh/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.connectors/crash.connectors.ssh/ ([https](https://www.crashub.org/crash.connectors/crash.connectors.ssh/) result 404). * [ ] http://www.crashub.org/crash.connectors/crash.connectors.telnet/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.connectors/crash.connectors.telnet/ ([https](https://www.crashub.org/crash.connectors/crash.connectors.telnet/) result 404). * [ ] http://www.crashub.org/crash.embed/crash.embed.spring/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.embed/crash.embed.spring/ ([https](https://www.crashub.org/crash.embed/crash.embed.spring/) result 404). * [ ] http://www.crashub.org/crash.plugins/crash.plugins.cron/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.plugins/crash.plugins.cron/ ([https](https://www.crashub.org/crash.plugins/crash.plugins.cron/) result 404). * [ ] http://www.crashub.org/crash.plugins/crash.plugins.mail/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.plugins/crash.plugins.mail/ ([https](https://www.crashub.org/crash.plugins/crash.plugins.mail/) result 404). * [ ] http://www.crashub.org/crash.shell/ (404) with 1 occurrences migrated to: https://www.crashub.org/crash.shell/ ([https](https://www.crashub.org/crash.shell/) result 404). * [ ] http://www.eclipse.org/jetty/javax-websocket-server-impl (404) with 1 occurrences migrated to: https://www.eclipse.org/jetty/javax-websocket-server-impl ([https](https://www.eclipse.org/jetty/javax-websocket-server-impl) result 404). * [ ] http://www.eclipse.org/jetty/websocket-client (404) with 1 occurrences migrated to: https://www.eclipse.org/jetty/websocket-client ([https](https://www.eclipse.org/jetty/websocket-client) result 404). * [ ] http://www.eclipse.org/jetty/websocket-server (404) with 1 occurrences migrated to: https://www.eclipse.org/jetty/websocket-server ([https](https://www.eclipse.org/jetty/websocket-server) result 404). * [ ] http://www.eclipse.org/sisu/org.eclipse.sisu.inject/ (404) with 3 occurrences migrated to: https://www.eclipse.org/sisu/org.eclipse.sisu.inject/ ([https](https://www.eclipse.org/sisu/org.eclipse.sisu.inject/) result 404). * [ ] http://www.eclipse.org/sisu/org.eclipse.sisu.plexus/ (404) with 3 occurrences migrated to: https://www.eclipse.org/sisu/org.eclipse.sisu.plexus/ ([https](https://www.eclipse.org/sisu/org.eclipse.sisu.plexus/) result 404). * [ ] http://www.jboss.org/undertow-parent/undertow-core (404) with 1 occurrences migrated to: https://www.jboss.org/undertow-parent/undertow-core ([https](https://www.jboss.org/undertow-parent/undertow-core) result 404). * [ ] http://www.jboss.org/undertow-parent/undertow-servlet (404) with 1 occurrences migrated to: https://www.jboss.org/undertow-parent/undertow-servlet ([https](https://www.jboss.org/undertow-parent/undertow-servlet) result 404). * [ ] http://www.jboss.org/undertow-parent/undertow-websockets-jsr (404) with 1 occurrences migrated to: https://www.jboss.org/undertow-parent/undertow-websockets-jsr ([https](https://www.jboss.org/undertow-parent/undertow-websockets-jsr) result 404). * [ ] http://www.jooq.org/jooq (404) with 1 occurrences migrated to: https://www.jooq.org/jooq ([https](https://www.jooq.org/jooq) result 404). * [ ] http://www.jooq.org/jooq-codegen (404) with 1 occurrences migrated to: https://www.jooq.org/jooq-codegen ([https](https://www.jooq.org/jooq-codegen) result 404). * [ ] http://www.jooq.org/jooq-meta (404) with 1 occurrences migrated to: https://www.jooq.org/jooq-meta ([https](https://www.jooq.org/jooq-meta) result 404). * [ ] http://www.liquibase.org/liquibase-core (404) with 1 occurrences migrated to: https://www.liquibase.org/liquibase-core ([https](https://www.liquibase.org/liquibase-core) result 404). * [ ] http://www.seleniumhq.org/selenium-api/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-api/ ([https](https://www.seleniumhq.org/selenium-api/) result 404). * [ ] http://www.seleniumhq.org/selenium-chrome-driver/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-chrome-driver/ ([https](https://www.seleniumhq.org/selenium-chrome-driver/) result 404). * [ ] http://www.seleniumhq.org/selenium-firefox-driver/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-firefox-driver/ ([https](https://www.seleniumhq.org/selenium-firefox-driver/) result 404). * [ ] http://www.seleniumhq.org/selenium-ie-driver/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-ie-driver/ ([https](https://www.seleniumhq.org/selenium-ie-driver/) result 404). * [ ] http://www.seleniumhq.org/selenium-java/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-java/ ([https](https://www.seleniumhq.org/selenium-java/) result 404). * [ ] http://www.seleniumhq.org/selenium-remote-driver/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-remote-driver/ ([https](https://www.seleniumhq.org/selenium-remote-driver/) result 404). * [ ] http://www.seleniumhq.org/selenium-safari-driver/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-safari-driver/ ([https](https://www.seleniumhq.org/selenium-safari-driver/) result 404). * [ ] http://www.seleniumhq.org/selenium-support/ (302) with 1 occurrences migrated to: https://www.seleniumhq.org/selenium-support/ ([https](https://www.seleniumhq.org/selenium-support/) result 404). * [ ] http://api.twitter.com/1/geo/id/01fbe706f872cb32.json (403) with 15 occurrences migrated to: https://api.twitter.com/1/geo/id/01fbe706f872cb32.json ([https](https://api.twitter.com/1/geo/id/01fbe706f872cb32.json) result 410). ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * [ ] http://apache.org/foundation/contributing.html with 6 occurrences migrated to: https://apache.org/foundation/contributing.html ([https](https://apache.org/foundation/contributing.html) result 200). * [ ] http://args4j.kohsuke.org/args4j/ with 4 occurrences migrated to: https://args4j.kohsuke.org/args4j/ ([https](https://args4j.kohsuke.org/args4j/) result 200). * [ ] http://asciidoctor.org with 2 occurrences migrated to: https://asciidoctor.org ([https](https://asciidoctor.org) result 200). * [ ] http://backbonejs.org with 1 occurrences migrated to: https://backbonejs.org ([https](https://backbonejs.org) result 200). * [ ] http://www.snakeyaml.org (302) with 1 occurrences migrated to: https://bitbucket.org/asomov/snakeyaml ([https](https://www.snakeyaml.org) result 200). * [ ] http://bugs.jquery.com/ticket/12282 with 1 occurrences migrated to: https://bugs.jquery.com/ticket/12282 ([https](https://bugs.jquery.com/ticket/12282) result 200). * [ ] http://bugs.jquery.com/ticket/12359 with 1 occurrences migrated to: https://bugs.jquery.com/ticket/12359 ([https](https://bugs.jquery.com/ticket/12359) result 200). * [ ] http://bugs.jquery.com/ticket/13378 with 1 occurrences migrated to: https://bugs.jquery.com/ticket/13378 ([https](https://bugs.jquery.com/ticket/13378) result 200). * [ ] http://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js with 11 occurrences migrated to: https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js ([https](https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js) result 200). * [ ] http://codehaus-plexus.github.io/plexus-containers/plexus-component-metadata/ with 1 occurrences migrated to: https://codehaus-plexus.github.io/plexus-containers/plexus-component-metadata/ ([https](https://codehaus-plexus.github.io/plexus-containers/plexus-component-metadata/) result 200). * [ ] http://commons.apache.org/proper/commons-beanutils/ with 1 occurrences migrated to: https://commons.apache.org/proper/commons-beanutils/ ([https](https://commons.apache.org/proper/commons-beanutils/) result 200). * [ ] http://commons.apache.org/proper/commons-codec/ with 4 occurrences migrated to: https://commons.apache.org/proper/commons-codec/ ([https](https://commons.apache.org/proper/commons-codec/) result 200). * [ ] http://commons.apache.org/proper/commons-collections/ with 3 occurrences migrated to: https://commons.apache.org/proper/commons-collections/ ([https](https://commons.apache.org/proper/commons-collections/) result 200). * [ ] http://commons.apache.org/proper/commons-compress/ with 3 occurrences migrated to: https://commons.apache.org/proper/commons-compress/ ([https](https://commons.apache.org/proper/commons-compress/) result 200). * [ ] http://commons.apache.org/proper/commons-exec/ with 3 occurrences migrated to: https://commons.apache.org/proper/commons-exec/ ([https](https://commons.apache.org/proper/commons-exec/) result 200). * [ ] http://commons.apache.org/proper/commons-lang/ with 3 occurrences migrated to: https://commons.apache.org/proper/commons-lang/ ([https](https://commons.apache.org/proper/commons-lang/) result 200). * [ ] http://commons.apache.org/proper/commons-pool/ with 1 occurrences migrated to: https://commons.apache.org/proper/commons-pool/ ([https](https://commons.apache.org/proper/commons-pool/) result 200). * [ ] http://community.apache.org/ with 12 occurrences migrated to: https://community.apache.org/ ([https](https://community.apache.org/) result 200). * [ ] http://community.apache.org/gsoc.html with 6 occurrences migrated to: https://community.apache.org/gsoc.html ([https](https://community.apache.org/gsoc.html) result 200). * [ ] http://community.apache.org/newbiefaq.html with 6 occurrences migrated to: https://community.apache.org/newbiefaq.html ([https](https://community.apache.org/newbiefaq.html) result 200). * [ ] http://community.apache.org/newcomers/ with 6 occurrences migrated to: https://community.apache.org/newcomers/ ([https](https://community.apache.org/newcomers/) result 200). * [ ] http://creativecommons.org/licenses/by/3.0/ with 2 occurrences migrated to: https://creativecommons.org/licenses/by/3.0/ ([https](https://creativecommons.org/licenses/by/3.0/) result 200). * [ ] http://diveintohtml5.info/history.html with 1 occurrences migrated to: https://diveintohtml5.info/history.html ([https](https://diveintohtml5.info/history.html) result 200). * [ ] http://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/api/ with 1 occurrences migrated to: https://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/api/ ([https](https://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/api/) result 200). * [ ] http://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/ with 1 occurrences migrated to: https://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/ ([https](https://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/) result 200). * [ ] http://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/api/ with 1 occurrences migrated to: https://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/api/ ([https](https://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/api/) result 200). * [ ] http://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/reference/html/ with 1 occurrences migrated to: https://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/reference/html/ ([https](https://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/reference/html/) result 200). * [ ] http://example.org with 16 occurrences migrated to: https://example.org ([https](https://example.org) result 200). * [ ] http://example.org/ with 32 occurrences migrated to: https://example.org/ ([https](https://example.org/) result 200). * [ ] http://git-scm.com/ with 5 occurrences migrated to: https://git-scm.com/ ([https](https://git-scm.com/) result 200). * [ ] http://git-scm.com/docs/git-clone with 20 occurrences migrated to: https://git-scm.com/docs/git-clone ([https](https://git-scm.com/docs/git-clone) result 200). * [ ] http://github.com/FasterXML/jackson with 8 occurrences migrated to: https://github.com/FasterXML/jackson ([https](https://github.com/FasterXML/jackson) result 200). * [ ] http://github.com/FasterXML/jackson-dataformats-binary with 2 occurrences migrated to: https://github.com/FasterXML/jackson-dataformats-binary ([https](https://github.com/FasterXML/jackson-dataformats-binary) result 200). * [ ] http://github.com/FasterXML/jackson-datatype-jdk8/ with 1 occurrences migrated to: https://github.com/FasterXML/jackson-datatype-jdk8/ ([https](https://github.com/FasterXML/jackson-datatype-jdk8/) result 200). * [ ] http://github.com/FasterXML/jackson-datatype-json-org with 1 occurrences migrated to: https://github.com/FasterXML/jackson-datatype-json-org ([https](https://github.com/FasterXML/jackson-datatype-json-org) result 200). * [ ] http://github.com/FasterXML/jackson-module-jaxb-annotations with 1 occurrences migrated to: https://github.com/FasterXML/jackson-module-jaxb-annotations ([https](https://github.com/FasterXML/jackson-module-jaxb-annotations) result 200). * [ ] http://github.com/FasterXML/jackson-module-parameter-names/ with 1 occurrences migrated to: https://github.com/FasterXML/jackson-module-parameter-names/ ([https](https://github.com/FasterXML/jackson-module-parameter-names/) result 200). * [ ] http://github.com/dain/snappy with 3 occurrences migrated to: https://github.com/dain/snappy ([https](https://github.com/dain/snappy) result 200). * [ ] http://github.com/mockito/mockito/blob/master/LICENSE with 1 occurrences migrated to: https://github.com/mockito/mockito/blob/master/LICENSE ([https](https://github.com/mockito/mockito/blob/master/LICENSE) result 200). * [ ] http://github.com/samskivert/jmustache with 1 occurrences migrated to: https://github.com/samskivert/jmustache ([https](https://github.com/samskivert/jmustache) result 200). * [ ] http://github.com/skyscreamer/yoga with 4 occurrences migrated to: https://github.com/skyscreamer/yoga ([https](https://github.com/skyscreamer/yoga) result 200). * [ ] http://github.com/spring-cloud/spring-cloud-contract with 1 occurrences migrated to: https://github.com/spring-cloud/spring-cloud-contract ([https](https://github.com/spring-cloud/spring-cloud-contract) result 200). * [ ] http://github.com/spring-projects/gh-pages with 1 occurrences migrated to: https://github.com/spring-projects/gh-pages ([https](https://github.com/spring-projects/gh-pages) result 200). * [ ] http://github.com/spring-projects/spring-data-solr with 1 occurrences migrated to: https://github.com/spring-projects/spring-data-solr ([https](https://github.com/spring-projects/spring-data-solr) result 200). * [ ] http://github.com/spring-projects/spring-security-oauth with 2 occurrences migrated to: https://github.com/spring-projects/spring-security-oauth ([https](https://github.com/spring-projects/spring-security-oauth) result 200). * [ ] http://github.com/tim-group/java-statsd-client with 1 occurrences migrated to: https://github.com/tim-group/java-statsd-client ([https](https://github.com/tim-group/java-statsd-client) result 200). * [ ] http://grigio.org with 1 occurrences migrated to: https://grigio.org ([https](https://grigio.org) result 200). * [ ] http://groovy.github.io/GMavenPlus/ with 10 occurrences migrated to: https://groovy.github.io/GMavenPlus/ ([https](https://groovy.github.io/GMavenPlus/) result 200). * [ ] http://h2database.com/html/license.html with 1 occurrences migrated to: https://h2database.com/html/license.html ([https](https://h2database.com/html/license.html) result 200). * [ ] http://handlebarsjs.com/ with 9 occurrences migrated to: https://handlebarsjs.com/ ([https](https://handlebarsjs.com/) result 200). * [ ] http://helpwanted.apache.org/ with 6 occurrences migrated to: https://helpwanted.apache.org/ ([https](https://helpwanted.apache.org/) result 200). * [ ] http://hibernate.org with 6 occurrences migrated to: https://hibernate.org ([https](https://hibernate.org) result 200). * [ ] http://imgs.mi9.com/uploads/landscape/2101/beautiful-leaf-wallpapers_1280x960_28083.jpg with 1 occurrences migrated to: https://imgs.mi9.com/uploads/landscape/2101/beautiful-leaf-wallpapers_1280x960_28083.jpg ([https](https://imgs.mi9.com/uploads/landscape/2101/beautiful-leaf-wallpapers_1280x960_28083.jpg) result 200). * [ ] http://incubator.apache.org/ with 6 occurrences migrated to: https://incubator.apache.org/ ([https](https://incubator.apache.org/) result 200). * [ ] http://jcp.org/aboutJava/communityprocess/final/jsr250/index.html with 3 occurrences migrated to: https://jcp.org/aboutJava/communityprocess/final/jsr250/index.html ([https](https://jcp.org/aboutJava/communityprocess/final/jsr250/index.html) result 200). * [ ] http://jcp.org/en/jsr/detail?id=914 with 1 occurrences migrated to: https://jcp.org/en/jsr/detail?id=914 ([https](https://jcp.org/en/jsr/detail?id=914) result 200). * [ ] http://jekyllrb.com with 1 occurrences migrated to: https://jekyllrb.com ([https](https://jekyllrb.com) result 200). * [ ] http://jquery.com/ with 6 occurrences migrated to: https://jquery.com/ ([https](https://jquery.com/) result 200). * [ ] http://json.org/license.html with 3 occurrences migrated to: https://json.org/license.html ([https](https://json.org/license.html) result 200). * [ ] http://labs.apache.org/ with 6 occurrences migrated to: https://labs.apache.org/ ([https](https://labs.apache.org/) result 200). * [ ] http://logging.apache.org/log4j/2.x/log4j-api/ with 1 occurrences migrated to: https://logging.apache.org/log4j/2.x/log4j-api/ ([https](https://logging.apache.org/log4j/2.x/log4j-api/) result 200). * [ ] http://logging.apache.org/log4j/2.x/log4j-core/ with 1 occurrences migrated to: https://logging.apache.org/log4j/2.x/log4j-core/ ([https](https://logging.apache.org/log4j/2.x/log4j-core/) result 200). * [ ] http://logging.apache.org/log4j/2.x/log4j-slf4j-impl/ with 1 occurrences migrated to: https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/ ([https](https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/) result 200). * [ ] http://martinfowler.com/articles/consumerDrivenContracts.html with 16 occurrences migrated to: https://martinfowler.com/articles/consumerDrivenContracts.html ([https](https://martinfowler.com/articles/consumerDrivenContracts.html) result 200). * [ ] http://maven.apache.org with 11 occurrences migrated to: https://maven.apache.org ([https](https://maven.apache.org) result 200). * [ ] http://maven.apache.org/ with 134 occurrences migrated to: https://maven.apache.org/ ([https](https://maven.apache.org/) result 200). * [ ] http://maven.apache.org/download.cgi with 14 occurrences migrated to: https://maven.apache.org/download.cgi ([https](https://maven.apache.org/download.cgi) result 200). * [ ] http://maven.apache.org/guides/mini/guide-configuring-plugins.html with 5 occurrences migrated to: https://maven.apache.org/guides/mini/guide-configuring-plugins.html ([https](https://maven.apache.org/guides/mini/guide-configuring-plugins.html) result 200). * [ ] http://maven.apache.org/maven-release/maven-release-plugin/ with 1 occurrences migrated to: https://maven.apache.org/maven-release/maven-release-plugin/ ([https](https://maven.apache.org/maven-release/maven-release-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-antrun-plugin/ with 5 occurrences migrated to: https://maven.apache.org/plugins/maven-antrun-plugin/ ([https](https://maven.apache.org/plugins/maven-antrun-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-assembly-plugin/ with 5 occurrences migrated to: https://maven.apache.org/plugins/maven-assembly-plugin/ ([https](https://maven.apache.org/plugins/maven-assembly-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-checkstyle-plugin/ with 11 occurrences migrated to: https://maven.apache.org/plugins/maven-checkstyle-plugin/ ([https](https://maven.apache.org/plugins/maven-checkstyle-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-clean-plugin/ with 5 occurrences migrated to: https://maven.apache.org/plugins/maven-clean-plugin/ ([https](https://maven.apache.org/plugins/maven-clean-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-compiler-plugin/ with 7 occurrences migrated to: https://maven.apache.org/plugins/maven-compiler-plugin/ ([https](https://maven.apache.org/plugins/maven-compiler-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-dependency-plugin/ with 5 occurrences migrated to: https://maven.apache.org/plugins/maven-dependency-plugin/ ([https](https://maven.apache.org/plugins/maven-dependency-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-deploy-plugin/ with 5 occurrences migrated to: https://maven.apache.org/plugins/maven-deploy-plugin/ ([https](https://maven.apache.org/plugins/maven-deploy-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-eclipse-plugin/ with 3 occurrences migrated to: https://maven.apache.org/plugins/maven-eclipse-plugin/ ([https](https://maven.apache.org/plugins/maven-eclipse-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-install-plugin/ with 5 occurrences migrated to: https://maven.apache.org/plugins/maven-install-plugin/ ([https](https://maven.apache.org/plugins/maven-install-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-jar-plugin/ with 8 occurrences migrated to: https://maven.apache.org/plugins/maven-jar-plugin/ ([https](https://maven.apache.org/plugins/maven-jar-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-javadoc-plugin/ with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-javadoc-plugin/ ([https](https://maven.apache.org/plugins/maven-javadoc-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-project-info-reports-plugin/ with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-project-info-reports-plugin/ ([https](https://maven.apache.org/plugins/maven-project-info-reports-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-resources-plugin/ with 8 occurrences migrated to: https://maven.apache.org/plugins/maven-resources-plugin/ ([https](https://maven.apache.org/plugins/maven-resources-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-shade-plugin/ with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-shade-plugin/ ([https](https://maven.apache.org/plugins/maven-shade-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-site-plugin/ with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-site-plugin/ ([https](https://maven.apache.org/plugins/maven-site-plugin/) result 200). * [ ] http://maven.apache.org/plugins/maven-source-plugin/ with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-source-plugin/ ([https](https://maven.apache.org/plugins/maven-source-plugin/) result 200). * [ ] http://maven.apache.org/ref/3.3.9/maven-aether-provider/ with 4 occurrences migrated to: https://maven.apache.org/ref/3.3.9/maven-aether-provider/ ([https](https://maven.apache.org/ref/3.3.9/maven-aether-provider/) result 200). * [ ] http://maven.apache.org/shared/maven-archiver/ with 3 occurrences migrated to: https://maven.apache.org/shared/maven-archiver/ ([https](https://maven.apache.org/shared/maven-archiver/) result 200). * [ ] http://maven.apache.org/shared/maven-filtering/ with 3 occurrences migrated to: https://maven.apache.org/shared/maven-filtering/ ([https](https://maven.apache.org/shared/maven-filtering/) result 200). * [ ] http://maven.apache.org/shared/maven-shared-utils/ with 3 occurrences migrated to: https://maven.apache.org/shared/maven-shared-utils/ ([https](https://maven.apache.org/shared/maven-shared-utils/) result 200). * [ ] http://maven.apache.org/surefire/maven-failsafe-plugin/ with 8 occurrences migrated to: https://maven.apache.org/surefire/maven-failsafe-plugin/ ([https](https://maven.apache.org/surefire/maven-failsafe-plugin/) result 200). * [ ] http://maven.apache.org/surefire/maven-surefire-plugin/ with 6 occurrences migrated to: https://maven.apache.org/surefire/maven-surefire-plugin/ ([https](https://maven.apache.org/surefire/maven-surefire-plugin/) result 200). * [ ] http://maven.apache.org/xsd/assembly-1.1.3.xsd with 34 occurrences migrated to: https://maven.apache.org/xsd/assembly-1.1.3.xsd ([https](https://maven.apache.org/xsd/assembly-1.1.3.xsd) result 200). * [ ] http://maven.apache.org/xsd/maven-4.0.0.xsd with 20 occurrences migrated to: https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200). * [ ] http://nn.mit-license.org/ with 1 occurrences migrated to: https://nn.mit-license.org/ ([https](https://nn.mit-license.org/) result 200). * [ ] http://opensource.org/licenses/BSD-3-Clause with 1 occurrences migrated to: https://opensource.org/licenses/BSD-3-Clause ([https](https://opensource.org/licenses/BSD-3-Clause) result 200). * [ ] http://opensource.org/licenses/MIT with 2 occurrences migrated to: https://opensource.org/licenses/MIT ([https](https://opensource.org/licenses/MIT) result 200). * [ ] http://opensource.org/licenses/mit-license.html with 2 occurrences migrated to: https://opensource.org/licenses/mit-license.html ([https](https://opensource.org/licenses/mit-license.html) result 200). * [ ] http://pages.github.com/ with 1 occurrences migrated to: https://pages.github.com/ ([https](https://pages.github.com/) result 200). * [ ] http://people.apache.org/ with 6 occurrences migrated to: https://people.apache.org/ ([https](https://people.apache.org/) result 200). * [ ] http://people.apache.org/committer-index.html with 6 occurrences migrated to: https://people.apache.org/committer-index.html ([https](https://people.apache.org/committer-index.html) result 200). * [ ] http://projects.spring.io/spring-batch/ with 4 occurrences migrated to: https://projects.spring.io/spring-batch/ ([https](https://projects.spring.io/spring-batch/) result 200). * [ ] http://projects.spring.io/spring-boot/ with 79 occurrences migrated to: https://projects.spring.io/spring-boot/ ([https](https://projects.spring.io/spring-boot/) result 200). * [ ] http://projects.spring.io/spring-cloud/ with 4 occurrences migrated to: https://projects.spring.io/spring-cloud/ ([https](https://projects.spring.io/spring-cloud/) result 200). * [ ] http://repository.jboss.org/licenses/apache-2.0.txt with 3 occurrences migrated to: https://repository.jboss.org/licenses/apache-2.0.txt ([https](https://repository.jboss.org/licenses/apache-2.0.txt) result 200). * [ ] http://rubygems.org with 1 occurrences migrated to: https://rubygems.org ([https](https://rubygems.org) result 200). * [ ] http://rubygems.org/ with 1 occurrences migrated to: https://rubygems.org/ ([https](https://rubygems.org/) result 200). * [ ] http://silviomoreto.github.io/bootstrap-select/ with 2 occurrences migrated to: https://silviomoreto.github.io/bootstrap-select/ ([https](https://silviomoreto.github.io/bootstrap-select/) result 200). * [ ] http://sizzlejs.com/ with 12 occurrences migrated to: https://sizzlejs.com/ ([https](https://sizzlejs.com/) result 200). * [ ] http://spring.io with 1 occurrences migrated to: https://spring.io ([https](https://spring.io) result 200). * [ ] http://spring.io/ with 4 occurrences migrated to: https://spring.io/ ([https](https://spring.io/) result 200). * [ ] http://spring.io/guides/gs/gradle/ with 1 occurrences migrated to: https://spring.io/guides/gs/gradle/ ([https](https://spring.io/guides/gs/gradle/) result 200). * [ ] http://spring.io/guides/gs/maven/ with 1 occurrences migrated to: https://spring.io/guides/gs/maven/ ([https](https://spring.io/guides/gs/maven/) result 200). * [ ] http://spring.io/projects/spring-cloud-contract with 4 occurrences migrated to: https://spring.io/projects/spring-cloud-contract ([https](https://spring.io/projects/spring-cloud-contract) result 200). * [ ] http://stackoverflow.com/questions/tagged/spring-cloud with 1 occurrences migrated to: https://stackoverflow.com/questions/tagged/spring-cloud ([https](https://stackoverflow.com/questions/tagged/spring-cloud) result 200). * [ ] http://stackoverflow.com/questions/tagged/spring-data-jpa with 1 occurrences migrated to: https://stackoverflow.com/questions/tagged/spring-data-jpa ([https](https://stackoverflow.com/questions/tagged/spring-data-jpa) result 200). * [ ] http://status.apache.org with 6 occurrences migrated to: https://status.apache.org ([https](https://status.apache.org) result 200). * [ ] http://subversion.apache.org/style/site.css with 6 occurrences migrated to: https://subversion.apache.org/style/site.css ([https](https://subversion.apache.org/style/site.css) result 200). * [ ] http://tomcat.apache.org/ with 6 occurrences migrated to: https://tomcat.apache.org/ ([https](https://tomcat.apache.org/) result 200). * [ ] http://tomcat.apache.org/taglibs/standard/ with 1 occurrences migrated to: https://tomcat.apache.org/taglibs/standard/ ([https](https://tomcat.apache.org/taglibs/standard/) result 200). * [ ] http://twitter.com/byscuits with 2 occurrences migrated to: https://twitter.com/byscuits ([https](https://twitter.com/byscuits) result 200). * [ ] http://twitter.com/fontawesome with 2 occurrences migrated to: https://twitter.com/fontawesome ([https](https://twitter.com/fontawesome) result 200). * [ ] http://underscorejs.org with 1 occurrences migrated to: https://underscorejs.org ([https](https://underscorejs.org) result 200). * [ ] http://velocity.apache.org/engine/devel/ with 1 occurrences migrated to: https://velocity.apache.org/engine/devel/ ([https](https://velocity.apache.org/engine/devel/) result 200). * [ ] http://velocity.apache.org/tools/devel/ with 1 occurrences migrated to: https://velocity.apache.org/tools/devel/ ([https](https://velocity.apache.org/tools/devel/) result 200). * [ ] http://www.JSON.org/ with 1 occurrences migrated to: https://www.JSON.org/ ([https](https://www.JSON.org/) result 200). * [ ] http://www.antlr.org/ with 1 occurrences migrated to: https://www.antlr.org/ ([https](https://www.antlr.org/) result 200). * [ ] http://www.antlr.org/license.html with 1 occurrences migrated to: https://www.antlr.org/license.html ([https](https://www.antlr.org/license.html) result 200). * [ ] http://www.apachecon.com/ with 6 occurrences migrated to: https://www.apachecon.com/ ([https](https://www.apachecon.com/) result 200). * [ ] http://www.atomikos.com/Main/WhichLicenseApplies with 3 occurrences migrated to: https://www.atomikos.com/Main/WhichLicenseApplies ([https](https://www.atomikos.com/Main/WhichLicenseApplies) result 200). * [ ] http://www.minidev.net/ (301) with 3 occurrences migrated to: https://www.bahis41.com/ ([https](https://www.minidev.net/) result 200). * [ ] http://www.brics.dk/automaton/ with 3 occurrences migrated to: https://www.brics.dk/automaton/ ([https](https://www.brics.dk/automaton/) result 200). * [ ] http://www.eclipse.org/legal/epl-v10.html with 41 occurrences migrated to: https://www.eclipse.org/legal/epl-v10.html ([https](https://www.eclipse.org/legal/epl-v10.html) result 200). * [ ] http://www.eclipse.org/org/documents/epl-v10.php with 21 occurrences migrated to: https://www.eclipse.org/org/documents/epl-v10.php ([https](https://www.eclipse.org/org/documents/epl-v10.php) result 200). * [ ] http://ehcache.org (301) with 4 occurrences migrated to: https://www.ehcache.org/ ([https](https://ehcache.org) result 200). * [ ] http://www.firebirdsql.org/en/devel-jdbc-driver/ with 3 occurrences migrated to: https://www.firebirdsql.org/en/devel-jdbc-driver/ ([https](https://www.firebirdsql.org/en/devel-jdbc-driver/) result 200). * [ ] http://www.gnu.org/copyleft/lesser.html with 5 occurrences migrated to: https://www.gnu.org/copyleft/lesser.html ([https](https://www.gnu.org/copyleft/lesser.html) result 200). * [ ] http://www.gnu.org/licenses/lgpl-2.1.html with 11 occurrences migrated to: https://www.gnu.org/licenses/lgpl-2.1.html ([https](https://www.gnu.org/licenses/lgpl-2.1.html) result 200). * [ ] http://www.gnu.org/licenses/licenses.html with 1 occurrences migrated to: https://www.gnu.org/licenses/licenses.html ([https](https://www.gnu.org/licenses/licenses.html) result 200). * [ ] http://www.gnu.org/licenses/old-licenses/gpl-2.0.html with 1 occurrences migrated to: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html ([https](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) result 200). * [ ] http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html with 5 occurrences migrated to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html ([https](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) result 200). * [ ] http://www.gravatar.com/avatar/035ae18f5f948ab3c8a5cbf40bbea383?d=mm&s=60 with 5 occurrences migrated to: https://www.gravatar.com/avatar/035ae18f5f948ab3c8a5cbf40bbea383?d=mm&s=60 ([https](https://www.gravatar.com/avatar/035ae18f5f948ab3c8a5cbf40bbea383?d=mm&s=60) result 200). * [ ] http://www.gravatar.com/avatar/b7639ec84d2cddb7acb11672403edac5?d=mm&s=60 with 5 occurrences migrated to: https://www.gravatar.com/avatar/b7639ec84d2cddb7acb11672403edac5?d=mm&s=60 ([https](https://www.gravatar.com/avatar/b7639ec84d2cddb7acb11672403edac5?d=mm&s=60) result 200). * [ ] http://www.gravatar.com/avatar/cbbca82404e50c3e504384568456197a?d=mm&s=60 with 5 occurrences migrated to: https://www.gravatar.com/avatar/cbbca82404e50c3e504384568456197a?d=mm&s=60 ([https](https://www.gravatar.com/avatar/cbbca82404e50c3e504384568456197a?d=mm&s=60) result 200). * [ ] http://www.h2database.com with 1 occurrences migrated to: https://www.h2database.com ([https](https://www.h2database.com) result 200). * [ ] http://www.javassist.org/ with 1 occurrences migrated to: https://www.javassist.org/ ([https](https://www.javassist.org/) result 200). * [ ] http://www.jboss.org with 2 occurrences migrated to: https://www.jboss.org ([https](https://www.jboss.org) result 200). * [ ] http://www.joda.org/joda-time/ with 1 occurrences migrated to: https://www.joda.org/joda-time/ ([https](https://www.joda.org/joda-time/) result 200). * [ ] http://www.jooq.org/inc/LICENSE.txt with 3 occurrences migrated to: https://www.jooq.org/inc/LICENSE.txt ([https](https://www.jooq.org/inc/LICENSE.txt) result 200). * [ ] http://kyruus.com (301) with 2 occurrences migrated to: https://www.kyruus.com/ ([https](https://kyruus.com) result 200). * [ ] http://www.postgresql.org/about/licence/ with 1 occurrences migrated to: https://www.postgresql.org/about/licence/ ([https](https://www.postgresql.org/about/licence/) result 200). * [ ] http://www.slf4j.org with 16 occurrences migrated to: https://www.slf4j.org ([https](https://www.slf4j.org) result 200). * [ ] http://www.slideshare.net/MarcinGrzejszczak/stick-to-the-rules-consumer-driven-contracts-201507-confitura with 16 occurrences migrated to: https://www.slideshare.net/MarcinGrzejszczak/stick-to-the-rules-consumer-driven-contracts-201507-confitura ([https](https://www.slideshare.net/MarcinGrzejszczak/stick-to-the-rules-consumer-driven-contracts-201507-confitura) result 200). * [ ] http://www.springframework.org/schema/beans/spring-beans.xsd with 18 occurrences migrated to: https://www.springframework.org/schema/beans/spring-beans.xsd ([https](https://www.springframework.org/schema/beans/spring-beans.xsd) result 200). * [ ] http://www.springframework.org/schema/integration/spring-integration.xsd with 18 occurrences migrated to: https://www.springframework.org/schema/integration/spring-integration.xsd ([https](https://www.springframework.org/schema/integration/spring-integration.xsd) result 200). * [ ] http://www.thymeleaf.org with 5 occurrences migrated to: https://www.thymeleaf.org ([https](https://www.thymeleaf.org) result 200). * [ ] http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html with 1 occurrences migrated to: https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html ([https](https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html) result 200). * [ ] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/java-binding.zip with 1 occurrences migrated to: https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/java-binding.zip ([https](https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/java-binding.zip) result 200). * [ ] http://www.w3.org/TR/2011/REC-css3-selectors-20110929/ with 2 occurrences migrated to: https://www.w3.org/TR/2011/REC-css3-selectors-20110929/ ([https](https://www.w3.org/TR/2011/REC-css3-selectors-20110929/) result 200). * [ ] http://www.w3.org/TR/CSS21/syndata.html with 2 occurrences migrated to: https://www.w3.org/TR/CSS21/syndata.html ([https](https://www.w3.org/TR/CSS21/syndata.html) result 200). * [ ] http://www.w3.org/TR/selectors/ with 4 occurrences migrated to: https://www.w3.org/TR/selectors/ ([https](https://www.w3.org/TR/selectors/) result 200). * [ ] http://www.xmlunit.org/ with 6 occurrences migrated to: https://www.xmlunit.org/ ([https](https://www.xmlunit.org/) result 200). * [ ] http://asm.objectweb.org/asm/ (301) with 3 occurrences migrated to: https://asm.ow2.org/asm/ ([https](https://asm.objectweb.org/asm/) result 301). * [ ] http://asm.objectweb.org/license.html (301) with 2 occurrences migrated to: https://asm.ow2.org/license.html ([https](https://asm.objectweb.org/license.html) result 301). * [ ] http://cloud.spring.io/spring-cloud-cli with 14 occurrences migrated to: https://cloud.spring.io/spring-cloud-cli ([https](https://cloud.spring.io/spring-cloud-cli) result 301). * [ ] http://code.google.com/appengine/terms.html with 1 occurrences migrated to: https://code.google.com/appengine/terms.html ([https](https://code.google.com/appengine/terms.html) result 301). * [ ] http://code.google.com/p/atinject/ with 4 occurrences migrated to: https://code.google.com/p/atinject/ ([https](https://code.google.com/p/atinject/) result 301). * [ ] http://code.google.com/p/guava-libraries/guava with 4 occurrences migrated to: https://code.google.com/p/guava-libraries/guava ([https](https://code.google.com/p/guava-libraries/guava) result 301). * [ ] http://code.google.com/p/json-simple/ with 1 occurrences migrated to: https://code.google.com/p/json-simple/ ([https](https://code.google.com/p/json-simple/) result 301). * [ ] http://codearte.github.io/accurest with 2 occurrences migrated to: https://codearte.github.io/accurest ([https](https://codearte.github.io/accurest) result 301). * [ ] http://couchbase.com with 1 occurrences migrated to: https://couchbase.com ([https](https://couchbase.com) result 301). * [ ] http://curator.apache.org/curator-framework with 1 occurrences migrated to: https://curator.apache.org/curator-framework ([https](https://curator.apache.org/curator-framework) result 301). * [ ] http://curator.apache.org/curator-recipes with 1 occurrences migrated to: https://curator.apache.org/curator-recipes ([https](https://curator.apache.org/curator-recipes) result 301). * [ ] http://curator.apache.org/curator-test with 1 occurrences migrated to: https://curator.apache.org/curator-test ([https](https://curator.apache.org/curator-test) result 301). * [ ] http://curator.apache.org/curator-x-discovery with 1 occurrences migrated to: https://curator.apache.org/curator-x-discovery ([https](https://curator.apache.org/curator-x-discovery) result 301). * [ ] http://dev.w3.org/csswg/cssom/ with 1 occurrences migrated to: https://dev.w3.org/csswg/cssom/ ([https](https://dev.w3.org/csswg/cssom/) result 301). * [ ] http://docs.python.org/library/functions.html with 1 occurrences migrated to: https://docs.python.org/library/functions.html ([https](https://docs.python.org/library/functions.html) result 301). * [ ] http://static.springframework.org/spring-security/oauth/spring-security-oauth (301) with 1 occurrences migrated to: https://docs.spring.io/spring-security/oauth/spring-security-oauth ([https](https://static.springframework.org/spring-security/oauth/spring-security-oauth) result 301). * [ ] http://static.springframework.org/spring-security/oauth/spring-security-oauth2 (301) with 1 occurrences migrated to: https://docs.spring.io/spring-security/oauth/spring-security-oauth2 ([https](https://static.springframework.org/spring-security/oauth/spring-security-oauth2) result 301). * [ ] http://dom4j.org with 1 occurrences migrated to: https://dom4j.org ([https](https://dom4j.org) result 301). * [ ] http://el-spec.java.net with 1 occurrences migrated to: https://el-spec.java.net ([https](https://el-spec.java.net) result 301). * [ ] http://forum.spring.io/forum/spring-projects/data with 1 occurrences migrated to: https://forum.spring.io/forum/spring-projects/data ([https](https://forum.spring.io/forum/spring-projects/data) result 301). * [ ] http://git-scm.com/documentation with 10 occurrences migrated to: https://git-scm.com/documentation ([https](https://git-scm.com/documentation) result 301). * [ ] http://github.com/SpringSource/spring-data-envers with 1 occurrences migrated to: https://github.com/SpringSource/spring-data-envers ([https](https://github.com/SpringSource/spring-data-envers) result 301). * [ ] http://github.com/SpringSource/spring-data-jpa with 1 occurrences migrated to: https://github.com/SpringSource/spring-data-jpa ([https](https://github.com/SpringSource/spring-data-jpa) result 301). * [ ] http://github.com/SpringSource/spring-hateoas with 1 occurrences migrated to: https://github.com/SpringSource/spring-hateoas ([https](https://github.com/SpringSource/spring-hateoas) result 301). * [ ] http://github.com/cowtowncoder/java-classmate with 1 occurrences migrated to: https://github.com/cowtowncoder/java-classmate ([https](https://github.com/cowtowncoder/java-classmate) result 301). * [ ] http://github.com/flapdoodle-oss/embedmongo.flapdoodle.de with 1 occurrences migrated to: https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de ([https](https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de) result 301). * [ ] http://github.com/pivotal/jasmine-ajax with 1 occurrences migrated to: https://github.com/pivotal/jasmine-ajax ([https](https://github.com/pivotal/jasmine-ajax) result 301). * [ ] http://glassfish.java.net/public/CDDL+GPL_1_1.html with 16 occurrences migrated to: https://glassfish.java.net/public/CDDL+GPL_1_1.html ([https](https://glassfish.java.net/public/CDDL+GPL_1_1.html) result 301). * [ ] http://hc.apache.org/httpcomponents-core-ga with 4 occurrences migrated to: https://hc.apache.org/httpcomponents-core-ga ([https](https://hc.apache.org/httpcomponents-core-ga) result 301). * [ ] http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_ with 1 occurrences migrated to: https://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_ ([https](https://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_) result 301). * [ ] http://javamail.java.net/javax.mail with 1 occurrences migrated to: https://javamail.java.net/javax.mail ([https](https://javamail.java.net/javax.mail) result 301). * [ ] http://javamail.java.net/javax.mail-api with 1 occurrences migrated to: https://javamail.java.net/javax.mail-api ([https](https://javamail.java.net/javax.mail-api) result 301). * [ ] http://jira.springsource.org/browse/DATAJPA with 1 occurrences migrated to: https://jira.springsource.org/browse/DATAJPA ([https](https://jira.springsource.org/browse/DATAJPA) result 301). * [ ] http://jquery.org/license with 12 occurrences migrated to: https://jquery.org/license ([https](https://jquery.org/license) result 301). * [ ] http://jta-spec.java.net with 1 occurrences migrated to: https://jta-spec.java.net ([https](https://jta-spec.java.net) result 301). * [ ] http://junit.org with 4 occurrences migrated to: https://junit.org ([https](https://junit.org) result 301). * [ ] http://maven.apache.org/enforcer/maven-enforcer-plugin with 4 occurrences migrated to: https://maven.apache.org/enforcer/maven-enforcer-plugin ([https](https://maven.apache.org/enforcer/maven-enforcer-plugin) result 301). * [ ] http://maven.apache.org/plugin-tools/maven-plugin-annotations with 3 occurrences migrated to: https://maven.apache.org/plugin-tools/maven-plugin-annotations ([https](https://maven.apache.org/plugin-tools/maven-plugin-annotations) result 301). * [ ] http://maven.apache.org/plugin-tools/maven-plugin-plugin with 14 occurrences migrated to: https://maven.apache.org/plugin-tools/maven-plugin-plugin ([https](https://maven.apache.org/plugin-tools/maven-plugin-plugin) result 301). * [ ] http://maven.apache.org/plugins/maven-release-plugin/ with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-release-plugin/ ([https](https://maven.apache.org/plugins/maven-release-plugin/) result 301). * [ ] http://maven.apache.org/plugins/maven-scm-publish-plugin with 4 occurrences migrated to: https://maven.apache.org/plugins/maven-scm-publish-plugin ([https](https://maven.apache.org/plugins/maven-scm-publish-plugin) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-artifact with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-artifact ([https](https://maven.apache.org/ref/3.2.5/maven-artifact) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-compat with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-compat ([https](https://maven.apache.org/ref/3.2.5/maven-compat) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-core with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-core ([https](https://maven.apache.org/ref/3.2.5/maven-core) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-model with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-model ([https](https://maven.apache.org/ref/3.2.5/maven-model) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-model-builder with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-model-builder ([https](https://maven.apache.org/ref/3.2.5/maven-model-builder) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-plugin-api with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-plugin-api ([https](https://maven.apache.org/ref/3.2.5/maven-plugin-api) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-repository-metadata with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-repository-metadata ([https](https://maven.apache.org/ref/3.2.5/maven-repository-metadata) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-settings with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-settings ([https](https://maven.apache.org/ref/3.2.5/maven-settings) result 301). * [ ] http://maven.apache.org/ref/3.2.5/maven-settings-builder with 3 occurrences migrated to: https://maven.apache.org/ref/3.2.5/maven-settings-builder ([https](https://maven.apache.org/ref/3.2.5/maven-settings-builder) result 301). * [ ] http://maven.apache.org/surefire/maven-surefire-plugin with 2 occurrences migrated to: https://maven.apache.org/surefire/maven-surefire-plugin ([https](https://maven.apache.org/surefire/maven-surefire-plugin) result 301). * [ ] http://maven.apache.org/wagon/wagon-provider-api with 3 occurrences migrated to: https://maven.apache.org/wagon/wagon-provider-api ([https](https://maven.apache.org/wagon/wagon-provider-api) result 301). * [ ] http://pact.io/ with 5 occurrences migrated to: https://pact.io/ ([https](https://pact.io/) result 301). * [ ] http://projects.spring.io/spring-cloud with 26 occurrences migrated to: https://projects.spring.io/spring-cloud ([https](https://projects.spring.io/spring-cloud) result 301). * [ ] http://projects.spring.io/spring-data-jpa with 2 occurrences migrated to: https://projects.spring.io/spring-data-jpa ([https](https://projects.spring.io/spring-data-jpa) result 301). * [ ] http://projects.spring.io/spring-ws with 4 occurrences migrated to: https://projects.spring.io/spring-ws ([https](https://projects.spring.io/spring-ws) result 301). * [ ] http://servlet-spec.java.net with 1 occurrences migrated to: https://servlet-spec.java.net ([https](https://servlet-spec.java.net) result 301). * [ ] http://sf.net/projects/wsdl4j with 1 occurrences migrated to: https://sf.net/projects/wsdl4j ([https](https://sf.net/projects/wsdl4j) result 301). * [ ] http://spockframework.github.io/ with 16 occurrences migrated to: https://spockframework.github.io/ ([https](https://spockframework.github.io/) result 301). * [ ] http://spring-projects.github.io/ with 1 occurrences migrated to: https://spring-projects.github.io/ ([https](https://spring-projects.github.io/) result 301). * [ ] http://stackoverflow.com/questions/136443/why-doesnt-ie7- with 1 occurrences migrated to: https://stackoverflow.com/questions/136443/why-doesnt-ie7- ([https](https://stackoverflow.com/questions/136443/why-doesnt-ie7-) result 301). * [ ] http://twitter.github.com/bootstrap/javascript.html with 13 occurrences migrated to: https://twitter.github.com/bootstrap/javascript.html ([https](https://twitter.github.com/bootstrap/javascript.html) result 301). * [ ] http://www.eclemma.org/jacoco with 24 occurrences migrated to: https://www.eclemma.org/jacoco ([https](https://www.eclemma.org/jacoco) result 301). * [ ] http://www.eclipse.org/jetty with 16 occurrences migrated to: https://www.eclipse.org/jetty ([https](https://www.eclipse.org/jetty) result 301). * [ ] http://www.eclipse.org/jetty/jetty-orbit/javax.servlet.jsp with 1 occurrences migrated to: https://www.eclipse.org/jetty/jetty-orbit/javax.servlet.jsp ([https](https://www.eclipse.org/jetty/jetty-orbit/javax.servlet.jsp) result 301). * [ ] http://www.hazelcast.com/hazelcast-hibernate/hazelcast-hibernate4/ with 1 occurrences migrated to: https://www.hazelcast.com/hazelcast-hibernate/hazelcast-hibernate4/ ([https](https://www.hazelcast.com/hazelcast-hibernate/hazelcast-hibernate4/) result 301). * [ ] http://www.hazelcast.com/hazelcast-spring/ with 1 occurrences migrated to: https://www.hazelcast.com/hazelcast-spring/ ([https](https://www.hazelcast.com/hazelcast-spring/) result 301). * [ ] http://www.hazelcast.com/hazelcast/ with 1 occurrences migrated to: https://www.hazelcast.com/hazelcast/ ([https](https://www.hazelcast.com/hazelcast/) result 301). * [ ] http://www.jolokia.org/jolokia-agent-parent/jolokia-core/ with 1 occurrences migrated to: https://www.jolokia.org/jolokia-agent-parent/jolokia-core/ ([https](https://www.jolokia.org/jolokia-agent-parent/jolokia-core/) result 301). * [ ] http://www.modernizr.com/ with 1 occurrences migrated to: https://www.modernizr.com/ ([https](https://www.modernizr.com/) result 301). * [ ] http://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin with 1 occurrences migrated to: https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin ([https](https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin) result 301). * [ ] http://www.mojohaus.org/exec-maven-plugin with 5 occurrences migrated to: https://www.mojohaus.org/exec-maven-plugin ([https](https://www.mojohaus.org/exec-maven-plugin) result 301). * [ ] http://www.mongodb.org with 2 occurrences migrated to: https://www.mongodb.org ([https](https://www.mongodb.org) result 301). * [ ] http://www.mozilla.org/MPL/MPL-1.1.html with 1 occurrences migrated to: https://www.mozilla.org/MPL/MPL-1.1.html ([https](https://www.mozilla.org/MPL/MPL-1.1.html) result 301). * [ ] http://www.mozilla.org/js/language/js20/rationale/syntax.html with 1 occurrences migrated to: https://www.mozilla.org/js/language/js20/rationale/syntax.html ([https](https://www.mozilla.org/js/language/js20/rationale/syntax.html) result 301). * [ ] http://www.opensource.org/licenses/BSD-3-Clause with 3 occurrences migrated to: https://www.opensource.org/licenses/BSD-3-Clause ([https](https://www.opensource.org/licenses/BSD-3-Clause) result 301). * [ ] http://www.opensource.org/licenses/bsd-license.php with 8 occurrences migrated to: https://www.opensource.org/licenses/bsd-license.php ([https](https://www.opensource.org/licenses/bsd-license.php) result 301). * [ ] http://www.opensource.org/licenses/cpl1.0.txt with 1 occurrences migrated to: https://www.opensource.org/licenses/cpl1.0.txt ([https](https://www.opensource.org/licenses/cpl1.0.txt) result 301). * [ ] http://www.opensource.org/licenses/lgpl-license.php with 7 occurrences migrated to: https://www.opensource.org/licenses/lgpl-license.php ([https](https://www.opensource.org/licenses/lgpl-license.php) result 301). * [ ] http://www.opensource.org/licenses/mit-license.php with 15 occurrences migrated to: https://www.opensource.org/licenses/mit-license.php ([https](https://www.opensource.org/licenses/mit-license.php) result 301). * [ ] http://www.sonatype.org/nexus/ with 7 occurrences migrated to: https://www.sonatype.org/nexus/ ([https](https://www.sonatype.org/nexus/) result 301). * [ ] http://nexus.sonatype.org/oss-repository-hosting.html/sqlite-jdbc (301) with 1 occurrences migrated to: https://www.sonatype.org/nexus/ ([https](https://nexus.sonatype.org/oss-repository-hosting.html/sqlite-jdbc) result 301). * [ ] http://nexus.sonatype.org/oss-repository-hosting.html/parent/elasticsearch (301) with 1 occurrences migrated to: https://www.sonatype.org/nexus/ ([https](https://nexus.sonatype.org/oss-repository-hosting.html/parent/elasticsearch) result 301). * [ ] http://www.spring.io with 8 occurrences migrated to: https://www.spring.io ([https](https://www.spring.io) result 301). * [ ] http://www.spring.io/spring-data/spring-data-commons with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-commons ([https](https://www.spring.io/spring-data/spring-data-commons) result 301). * [ ] http://www.spring.io/spring-data/spring-data-gemfire with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-gemfire ([https](https://www.spring.io/spring-data/spring-data-gemfire) result 301). * [ ] http://www.spring.io/spring-data/spring-data-keyvalue with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-keyvalue ([https](https://www.spring.io/spring-data/spring-data-keyvalue) result 301). * [ ] http://www.spring.io/spring-data/spring-data-neo4j-parent/spring-data-neo4j with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-neo4j-parent/spring-data-neo4j ([https](https://www.spring.io/spring-data/spring-data-neo4j-parent/spring-data-neo4j) result 301). * [ ] http://www.spring.io/spring-data/spring-data-redis with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-redis ([https](https://www.spring.io/spring-data/spring-data-redis) result 301). * [ ] http://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-core with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-core ([https](https://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-core) result 301). * [ ] http://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-hal-browser with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-hal-browser ([https](https://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-hal-browser) result 301). * [ ] http://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-webmvc with 1 occurrences migrated to: https://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-webmvc ([https](https://www.spring.io/spring-data/spring-data-rest-parent/spring-data-rest-webmvc) result 301). * [ ] http://www.springsource.org with 1 occurrences migrated to: https://www.springsource.org ([https](https://www.springsource.org) result 301). * [ ] http://www.svnkit.com/ with 1 occurrences migrated to: https://www.svnkit.com/ ([https](https://www.svnkit.com/) result 301). * [ ] http://www.svnkit.com/license.html with 1 occurrences migrated to: https://www.svnkit.com/license.html ([https](https://www.svnkit.com/license.html) result 301). * [ ] http://www.w3.org/TR/css3-selectors/ with 2 occurrences migrated to: https://www.w3.org/TR/css3-selectors/ ([https](https://www.w3.org/TR/css3-selectors/) result 301). * [ ] http://www.w3.org/TR/css3-syntax/ with 1 occurrences migrated to: https://www.w3.org/TR/css3-syntax/ ([https](https://www.w3.org/TR/css3-syntax/) result 301). * [ ] http://xml.apache.org/commons/components/external/ with 1 occurrences migrated to: https://xml.apache.org/commons/components/external/ ([https](https://xml.apache.org/commons/components/external/) result 301). * [ ] http://assertj.org/assertj-core (302) with 4 occurrences migrated to: https://c.clickprotects.com/c?pid=11165151-assertjorg&c=b25a569aad684a3b19b4ddb1957a8597-wFUeFFewseuf%09XIjEvtaDIvv0%2FfeueSeXpVphrp%09wSSFSuukS3S3f%09ukf%09UwU%09w4%09tijv2I%092vvRN%3A%2F%2FatYIaeIAj0eEtQ%2FatYIa%2FwF%2Ff%2Fw3%2F9Iji6ajQI%2F9Iji6ajQIeEQR%3FAQ%3DkwF%265p6g9%3D3UF3s%26jtL%3D%25Spw%26mIaE2jLvg9%3DSw3F3k%26EajniIa_qo%3DSw3F3k%26oIjigo%3DGLSyb8PsMmzmpfT7CcGAMz%25F9%25F9%26Wai%3D2vvR%25Fh%25s6%25s6EiqEHNIaYIeojavNIjaE2eLIv%25s6iqLH%25s6EiqEH%25F6iqo%25F93s4fffkfuw3fss3Ff%25sUoN_N_Hnzqo%25F9Su4fffffk3Fw3fuUF%25sUoN_N_qLYILvta0_OIIo_qo%25F9344fffffffwffsf4s%25sUoN_I_RatoWEv_qo%25F9mlF3sVV%25s6h%25sUEq_EWNvtQIa_qo%25F9wffws3s%25sUEq_ENI_qo%25F9wffk%25sUEq_OIIo_qo%25F9wffkS3w%25sUoN_I_RatoWEv_QIaE2jLv_qo%25F9wF4u4uk%25sUoN_I_RatoWEv_EtWLva0%25F9Gr%25sUoN_I_RatoWEv_ijLzWjzI%25F9IL%25sUoN_I_RatoWEv_E2jLLIi%25F9tLiqLI%25sUoN_Wai_Y%25F9s%25sUoN_oINv_Wai%25F92vvRN%25Fh%25s6%25s6nnneYIaq.tLnqaIiINNeEtQ%25s6NQjavR2tLIN%25s6jRRiI-qR2tLI-ba%25s6%25sSF6NHW%25sSF9NHWFw3fsSf%25sSsUEQR%25sSF9ENI-r2tRRqLz-mlF3sVV%25s6h%25sSsUEQR%25sSF97rp-7-BZ-DTD-X-h7-DTDp-DTDp-s7fcyf-cy-p5hJ-mlF3sVV%25s6h%25sSsUEYtNaE%25sSF9ENIep5hJemlF3sVV%25s6h%25sSsUEYt_Eaqo%25sSF9%25sS45EjQRjqzL%25sS49%25sU2vvRN%25Fh%25s6%25s6veQ0YqNWjiqMeLIv%25s6EiqEH_RqbIi%25F6Iv%25F9E%25sUjzt%25F9sws%25sUjt%25F9uSU%25sUjEj%25F9%25S5*7jQRjqzLg9*%25S9%25sUNq%25F9-s%25sUEq%25F9-s%25sURq%25F9-s%25sUjo%25F9%25S5*hozatWRg9*%25S9%25sUNYw%25F9%25S5*lajEHIag9*%25S9%25sUjoYv%25F9-s%25sUE2Li%25F9-s%25sUYLoa%25F9ww3S%25sUN.%25F9USUw%25sUaIo%25F9%26iqLHqL_qo%3Duwwsu3f%26gNNov%3Dw3fFsUfksfS3%26NIjaE2g9%3DRsSeF4wEwOFFEwksAOkIOkwO%269IjiDjQI%3DhRRiI%257s%25hp%2Bqc2tLI%257s%25hp%2ByX%2Bwsu85%2BqL%2BJIiitn%26oiRaE%3D433e33%26hX%3Ds%26D8%3Dw%26D9c%3Dsf%26cD%3Dw%26rl%3D4%266cl%3D9rc%26D9r%3D%26Dmr%3D%26mXr%3D%26c9%3D%26AaLgo%3Dwk4UF%26gN6va%3Df%26gNrQjav%3Df%26tR%3D%267m%3D%26XX%3Ds%26gNVRN%3Df%26EtoI%3D%26jEtoI%3DkFU%26EjvIzta0%3D%26BjNVqLH%3D%26D9%3D%26mD%3D%268X%3D%26iLHgo%3D%26rdG%3DmlF3sVV%25s6h%26tR%3D%24%21%7BEiqEH9jvjeEiqEHgo%7D%09%5BLWii%5D%09fefF%09feUs%09%5BLWii%5D%09OjiNI%09uFk%09Sw3F3k%2F3UF3s%2Fuwwsu3f%09rphX7B%09%5BLWii%5D%09%5BLWii%5D%09f%09w3sewUuewffewsu%09%5BLWii%5D%09%5BLWii%5D%09f%7Ef%093wUEkjFj-3EAs-kUAA-uokO-SoA3IjuIjE33%09jNNIav1%09%5BLWii%5D%09jNNIav1%09%5BLWii%5D%09%5BLWii%5D%09%5BLWii%5D%09f%09f%09%5BLWii%5D%09f%09f%09%5BLWii%5D%09GLSyb8PsMmzmpfT7CcGAMz%3D%3D%09%5BLWii%5D%09uFk-Sw3F3k%2F3UF3s%2Fuwwsu3f%09f%09%5BLWii%5D%09%5BLWii%5D%09UUfUs%09jNNIav1taz%09%5BLWii%5D%09%5BLWii%5D%09&r=1&ptt= ([https](https://assertj.org/assertj-core) result 302). * [ ] http://commons.apache.org/collections/ with 1 occurrences migrated to: https://commons.apache.org/collections/ ([https](https://commons.apache.org/collections/) result 302). * [ ] http://commons.apache.org/configuration/ with 1 occurrences migrated to: https://commons.apache.org/configuration/ ([https](https://commons.apache.org/configuration/) result 302). * [ ] http://commons.apache.org/dbcp/ with 2 occurrences migrated to: https://commons.apache.org/dbcp/ ([https](https://commons.apache.org/dbcp/) result 302). * [ ] http://commons.apache.org/digester/ with 1 occurrences migrated to: https://commons.apache.org/digester/ ([https](https://commons.apache.org/digester/) result 302). * [ ] http://commons.apache.org/io/ with 3 occurrences migrated to: https://commons.apache.org/io/ ([https](https://commons.apache.org/io/) result 302). * [ ] http://commons.apache.org/pool/ with 1 occurrences migrated to: https://commons.apache.org/pool/ ([https](https://commons.apache.org/pool/) result 302). * [ ] http://dev.mysql.com/doc/connector-j/en/ with 1 occurrences migrated to: https://dev.mysql.com/doc/connector-j/en/ ([https](https://dev.mysql.com/doc/connector-j/en/) result 302). * [ ] http://github.com/xetorthio/jedis/raw/master/LICENSE.txt with 1 occurrences migrated to: https://github.com/xetorthio/jedis/raw/master/LICENSE.txt ([https](https://github.com/xetorthio/jedis/raw/master/LICENSE.txt) result 302). * [ ] http://maven.apache.org/ref/current/maven-core/lifecycles.html with 15 occurrences migrated to: https://maven.apache.org/ref/current/maven-core/lifecycles.html ([https](https://maven.apache.org/ref/current/maven-core/lifecycles.html) result 302). * [ ] http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx with 2 occurrences migrated to: https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx ([https](https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx) result 302). * [ ] http://repo.spring.io/libs-snapshot with 16 occurrences migrated to: https://repo.spring.io/libs-snapshot ([https](https://repo.spring.io/libs-snapshot) result 302). * [ ] http://repo.spring.io/milestone with 31 occurrences migrated to: https://repo.spring.io/milestone ([https](https://repo.spring.io/milestone) result 302). * [ ] http://repo.spring.io/release with 27 occurrences migrated to: https://repo.spring.io/release ([https](https://repo.spring.io/release) result 302). * [ ] http://repo.spring.io/snapshot with 27 occurrences migrated to: https://repo.spring.io/snapshot ([https](https://repo.spring.io/snapshot) result 302). * [ ] http://scripts.sil.org/OFL with 2 occurrences migrated to: https://scripts.sil.org/OFL ([https](https://scripts.sil.org/OFL) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-core with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-core ([https](https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-core) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client ([https](https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-hystrix-stream with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-hystrix-stream ([https](https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-hystrix-stream) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-spectator with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-spectator ([https](https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-spectator) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-turbine-stream with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-turbine-stream ([https](https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-turbine-stream) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream ([https](https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-codec with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-codec ([https](https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-codec) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-rxjava with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-rxjava ([https](https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-rxjava) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-test-support with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-test-support ([https](https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-test-support) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-test-support-internal with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-test-support-internal ([https](https://spring.io/spring-cloud/spring-cloud-stream-parent/spring-cloud-stream-test-support-internal) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-config with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-config ([https](https://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-config) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-core with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-core ([https](https://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-core) result 302). * [ ] http://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-discovery with 1 occurrences migrated to: https://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-discovery ([https](https://spring.io/spring-cloud/spring-cloud-zookeeper/spring-cloud-zookeeper-discovery) result 302). * [ ] http://spring.io/spring-security with 14 occurrences migrated to: https://spring.io/spring-security ([https](https://spring.io/spring-security) result 302). * [ ] http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context with 1 occurrences migrated to: https://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context ([https](https://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context) result 302). * [ ] http://www.eclipse.org/aether/aether-api/ with 4 occurrences migrated to: https://www.eclipse.org/aether/aether-api/ ([https](https://www.eclipse.org/aether/aether-api/) result 302). * [ ] http://www.eclipse.org/aether/aether-connector-basic/ with 4 occurrences migrated to: https://www.eclipse.org/aether/aether-connector-basic/ ([https](https://www.eclipse.org/aether/aether-connector-basic/) result 302). * [ ] http://www.eclipse.org/aether/aether-impl/ with 4 occurrences migrated to: https://www.eclipse.org/aether/aether-impl/ ([https](https://www.eclipse.org/aether/aether-impl/) result 302). * [ ] http://www.eclipse.org/aether/aether-spi/ with 3 occurrences migrated to: https://www.eclipse.org/aether/aether-spi/ ([https](https://www.eclipse.org/aether/aether-spi/) result 302). * [ ] http://www.eclipse.org/aether/aether-transport-file/ with 4 occurrences migrated to: https://www.eclipse.org/aether/aether-transport-file/ ([https](https://www.eclipse.org/aether/aether-transport-file/) result 302). * [ ] http://www.eclipse.org/aether/aether-transport-http/ with 4 occurrences migrated to: https://www.eclipse.org/aether/aether-transport-http/ ([https](https://www.eclipse.org/aether/aether-transport-http/) result 302). * [ ] http://www.eclipse.org/aether/aether-util/ with 3 occurrences migrated to: https://www.eclipse.org/aether/aether-util/ ([https](https://www.eclipse.org/aether/aether-util/) result 302). * [ ] http://www.jboss.org/jbosstm/narayana-jta-all/jdbc/ with 1 occurrences migrated to: https://www.jboss.org/jbosstm/narayana-jta-all/jdbc/ ([https](https://www.jboss.org/jbosstm/narayana-jta-all/jdbc/) result 302). * [ ] http://www.jboss.org/jbosstm/narayana-jta-all/jms/ with 1 occurrences migrated to: https://www.jboss.org/jbosstm/narayana-jta-all/jms/ ([https](https://www.jboss.org/jbosstm/narayana-jta-all/jms/) result 302). * [ ] http://www.jboss.org/jbosstm/narayana-jta-all/jta/ with 1 occurrences migrated to: https://www.jboss.org/jbosstm/narayana-jta-all/jta/ ([https](https://www.jboss.org/jbosstm/narayana-jta-all/jta/) result 302). * [ ] http://www.jboss.org/jbosstm/narayana-jts-all/narayana-jts-integration/ with 1 occurrences migrated to: https://www.jboss.org/jbosstm/narayana-jts-all/narayana-jts-integration/ ([https](https://www.jboss.org/jbosstm/narayana-jts-all/narayana-jts-integration/) result 302). # Ignored These URLs were intentionally ignored. * http://accessors-smart/ with 3 occurrences * http://docbook.org/ns/docbook with 48053 occurrences * http://jacoco-maven-plugin with 5 occurrences * http://link/to/your/nexus/or/artifactory/or/sth with 47 occurrences * http://link/to/your/nexus/or/artifactory/or/sth</contractsRepositoryUrl> with 3 occurrences * http://loanIssuance/name with 16 occurrences * http://localhost with 71 occurrences * http://localhost:12345 with 16 occurrences * http://localhost:12346 with 16 occurrences * http://localhost:4000/spring-xyz/ with 1 occurrences * http://localhost:8080/foo with 1 occurrences * http://localhost:8081/artifactory/libs-release-local with 28 occurrences * http://localhost:8081/artifactory/libs-release-local/com/example/bookstore/0.0.1.RELEASE/ with 14 occurrences * http://localhost:8081/artifactory/libs-release-local/com/example/bookstore/0.0.1.RELEASE/bookstore-0.0.1.RELEASE-stubs.jar with 14 occurrences * http://localhost:8085 with 19 occurrences * http://localhost:8085</contractsRepositoryUrl> with 1 occurrences * http://localhost:8888/users with 18 occurrences * http://localhost:9876/api/books with 2 occurrences * http://maven.apache.org/POM/4.0.0 with 56 occurrences * http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 with 76 occurrences * http://someNameThatShouldMapFraudDetectionServer/name with 16 occurrences * http://some_url with 11 occurrences * http://www with 1 occurrences * http://www.springframework.org/schema/beans with 36 occurrences * http://www.springframework.org/schema/integration with 36 occurrences * http://www.w3.org/1999/xhtml with 160 occurrences * http://www.w3.org/1999/xlink with 1 occurrences * http://www.w3.org/2000/svg with 1 occurrences * http://www.w3.org/2001/XMLSchema-instance with 84 occurrences
2208 lines
205 KiB
HTML
2208 lines
205 KiB
HTML
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>8. Contract DSL</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="multi_spring-cloud-contract.html" title="Spring Cloud Contract"><link rel="up" href="multi_spring-cloud-contract.html" title="Spring Cloud Contract"><link rel="prev" href="multi_stub-runner-for-messaging.html" title="7. Stub Runner for Messaging"><link rel="next" href="multi__customization.html" title="9. Customization"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">8. Contract DSL</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi_stub-runner-for-messaging.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__customization.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="contract-dsl" href="#contract-dsl"></a>8. Contract DSL</h1></div></div></div><p>Spring Cloud Contract supports out of the box 2 types of DSL. One written in
|
|
<code class="literal">Groovy</code> and one written in <code class="literal">YAML</code>.</p><p>If you decide to write the contract in Groovy, do not be alarmed if you have not used Groovy
|
|
before. Knowledge of the language is not really needed, as the Contract DSL uses only a
|
|
tiny subset of it (only literals, method calls and closures). Also, the DSL is statically
|
|
typed, to make it programmer-readable without any knowledge of the DSL itself.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>Remember that, inside the Groovy contract file, you have to provide the fully
|
|
qualified name to the <code class="literal">Contract</code> class and <code class="literal">make</code> static imports, such as
|
|
<code class="literal">org.springframework.cloud.spec.Contract.make { …​ }</code>. You can also provide an import to
|
|
the <code class="literal">Contract</code> class: <code class="literal">import org.springframework.cloud.spec.Contract</code> and then call
|
|
<code class="literal">Contract.make { …​ }</code>.</p></td></tr></table></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Spring Cloud Contract supports defining multiple contracts in a single file.</p></td></tr></table></div><p>The following is a complete example of a Groovy contract definition:</p><pre class="programlisting"></pre><p>The following is a complete example of a YAML contract definition:</p><pre class="programlisting">description: Some description
|
|
name: some name
|
|
priority: 8
|
|
ignored: true
|
|
request:
|
|
url: /foo
|
|
queryParameters:
|
|
a: b
|
|
b: c
|
|
method: PUT
|
|
headers:
|
|
foo: bar
|
|
fooReq: baz
|
|
body:
|
|
foo: bar
|
|
matchers:
|
|
body:
|
|
- path: $.foo
|
|
type: by_regex
|
|
value: bar
|
|
headers:
|
|
- key: foo
|
|
regex: bar
|
|
response:
|
|
status: 200
|
|
headers:
|
|
foo2: bar
|
|
foo3: foo33
|
|
fooRes: baz
|
|
body:
|
|
foo2: bar
|
|
foo3: baz
|
|
nullValue: null
|
|
matchers:
|
|
body:
|
|
- path: $.foo2
|
|
type: by_regex
|
|
value: bar
|
|
- path: $.foo3
|
|
type: by_command
|
|
value: executeMe($it)
|
|
- path: $.nullValue
|
|
type: by_null
|
|
value: null
|
|
headers:
|
|
- key: foo2
|
|
regex: bar
|
|
- key: foo3
|
|
command: andMeToo($it)</pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>You can compile contracts to stubs mapping using standalone maven command:
|
|
<code class="literal">mvn org.springframework.cloud:spring-cloud-contract-maven-plugin:convert</code></p></td></tr></table></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_limitations" href="#_limitations"></a>8.1 Limitations</h2></div></div></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Spring Cloud Contract Verifier does not properly support XML. Please use JSON or
|
|
help us implement this feature.</p></td></tr></table></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>The support for verifying the size of JSON arrays is experimental. If you want
|
|
to turn it on, please set the value of the following system property to <code class="literal">true</code>:
|
|
<code class="literal">spring.cloud.contract.verifier.assert.size</code>. By default, this feature is set to <code class="literal">false</code>.
|
|
You can also provide the <code class="literal">assertJsonSize</code> property in the plugin configuration.</p></td></tr></table></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>Because JSON structure can have any form, it can be impossible to parse it
|
|
properly when using the Groovy DSL and the <code class="literal">value(consumer(…​), producer(…​))</code> notation in <code class="literal">GString</code>. That
|
|
is why you should use the Groovy Map notation.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_common_top_level_elements" href="#_common_top_level_elements"></a>8.2 Common Top-Level elements</h2></div></div></div><p>The following sections describe the most common top-level elements:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-description" title="8.2.1 Description">Section 8.2.1, “Description”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-name" title="8.2.2 Name">Section 8.2.2, “Name”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-ignoring-contracts" title="8.2.3 Ignoring Contracts">Section 8.2.3, “Ignoring Contracts”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-passing-values-from-files" title="8.2.4 Passing Values from Files">Section 8.2.4, “Passing Values from Files”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-http-top-level-elements" title="8.2.5 HTTP Top-Level Elements">Section 8.2.5, “HTTP Top-Level Elements”</a></li></ul></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-description" href="#contract-dsl-description"></a>8.2.1 Description</h3></div></div></div><p>You can add a <code class="literal">description</code> to your contract. The description is arbitrary text. The
|
|
following code shows an example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting"> org.springframework.cloud.contract.spec.Contract.make {
|
|
description(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'
|
|
</span>given:
|
|
An input
|
|
when:
|
|
Sth happens
|
|
then:
|
|
Output
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">')
|
|
</span> }</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">description: Some description
|
|
name: some name
|
|
priority: 8
|
|
ignored: true
|
|
request:
|
|
url: /foo
|
|
queryParameters:
|
|
a: b
|
|
b: c
|
|
method: PUT
|
|
headers:
|
|
foo: bar
|
|
fooReq: baz
|
|
body:
|
|
foo: bar
|
|
matchers:
|
|
body:
|
|
- path: $.foo
|
|
type: by_regex
|
|
value: bar
|
|
headers:
|
|
- key: foo
|
|
regex: bar
|
|
response:
|
|
status: 200
|
|
headers:
|
|
foo2: bar
|
|
foo3: foo33
|
|
fooRes: baz
|
|
body:
|
|
foo2: bar
|
|
foo3: baz
|
|
nullValue: null
|
|
matchers:
|
|
body:
|
|
- path: $.foo2
|
|
type: by_regex
|
|
value: bar
|
|
- path: $.foo3
|
|
type: by_command
|
|
value: executeMe($it)
|
|
- path: $.nullValue
|
|
type: by_null
|
|
value: null
|
|
headers:
|
|
- key: foo2
|
|
regex: bar
|
|
- key: foo3
|
|
command: andMeToo($it)</pre><p>
|
|
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-name" href="#contract-dsl-name"></a>8.2.2 Name</h3></div></div></div><p>You can provide a name for your contract. Assume that you provided the following name:
|
|
<code class="literal">should register a user</code>. If you do so, the name of the autogenerated test is
|
|
<code class="literal">validate_should_register_a_user</code>. Also, the name of the stub in a WireMock stub is
|
|
<code class="literal">should_register_a_user.json</code>.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>You must ensure that the name does not contain any characters that make the
|
|
generated test not compile. Also, remember that, if you provide the same name for
|
|
multiple contracts, your autogenerated tests fail to compile and your generated stubs
|
|
override each other.</p></td></tr></table></div><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
name(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"some_special_name"</span>)
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">name: some name</pre><p>
|
|
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-ignoring-contracts" href="#contract-dsl-ignoring-contracts"></a>8.2.3 Ignoring Contracts</h3></div></div></div><p>If you want to ignore a contract, you can either set a value of ignored contracts in the
|
|
plugin configuration or set the <code class="literal">ignored</code> property on the contract itself:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
ignored()
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">ignored: true</pre><p>
|
|
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-passing-values-from-files" href="#contract-dsl-passing-values-from-files"></a>8.2.4 Passing Values from Files</h3></div></div></div><p>Starting with version <code class="literal">1.2.0</code>, you can pass values from files. Assume that you have the
|
|
following resources in our project.</p><pre class="programlisting">└── src
|
|
└── <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">test</span>
|
|
└── resources
|
|
└── contracts
|
|
├── readFromFile.groovy
|
|
├── request.json
|
|
└── response.json</pre><p>Further assume that your contract is as follows:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">/*
|
|
* Copyright 2013-2019 the original author or authors.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.cloud.contract.spec.Contract
|
|
|
|
Contract.make {
|
|
request {
|
|
method(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'PUT'</span>)
|
|
headers {
|
|
contentType(applicationJson())
|
|
}
|
|
body(file(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"request.json"</span>))
|
|
url(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/1"</span>)
|
|
}
|
|
response {
|
|
status OK()
|
|
body(file(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response.json"</span>))
|
|
headers {
|
|
contentType(applicationJson())
|
|
}
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
method: GET
|
|
url: /foo
|
|
bodyFromFile: request.json
|
|
response:
|
|
status: 200
|
|
bodyFromFile: response.json</pre><p>
|
|
</p><p>Further assume that the JSON files is as follows:</p><p><span class="strong"><strong>request.json</strong></span></p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"status"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"REQUEST"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span></pre><p><span class="strong"><strong>response.json</strong></span></p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"status"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"RESPONSE"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span></pre><p>When test or stub generation takes place, the contents of the file is passed to the body
|
|
of a request or a response. The name of the file needs to be a file with location
|
|
relative to the folder in which the contract lays.</p><p>If you need to pass the contents of a file in a binary form
|
|
it’s enough for you to use the <code class="literal">fileAsBytes</code> method in Groovy DSL or <code class="literal">bodyFromFileAsBytes</code> field in YAML.</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.cloud.contract.spec.Contract
|
|
|
|
Contract.make {
|
|
request {
|
|
url(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/1"</span>)
|
|
method(PUT())
|
|
headers {
|
|
contentType(applicationOctetStream())
|
|
}
|
|
body(fileAsBytes(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"request.pdf"</span>))
|
|
}
|
|
response {
|
|
status <span class="hl-number">200</span>
|
|
body(fileAsBytes(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response.pdf"</span>))
|
|
headers {
|
|
contentType(applicationOctetStream())
|
|
}
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
url: /1
|
|
method: PUT
|
|
headers:
|
|
Content-Type: application/octet-stream
|
|
bodyFromFileAsBytes: request.pdf
|
|
response:
|
|
status: 200
|
|
bodyFromFileAsBytes: response.pdf
|
|
headers:
|
|
Content-Type: application/octet-stream</pre><p>
|
|
</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>You should use this approach whenever you want to work with binary payloads both for HTTP and messaging.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-http-top-level-elements" href="#contract-dsl-http-top-level-elements"></a>8.2.5 HTTP Top-Level Elements</h3></div></div></div><p>The following methods can be called in the top-level closure of a contract definition.
|
|
<code class="literal">request</code> and <code class="literal">response</code> are mandatory. <code class="literal">priority</code> is optional.</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Definition of HTTP request part of the contract</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// (this can be a valid request or invalid depending</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// on type of contract being specified).</span>
|
|
request {
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foo"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Definition of HTTP response part of the contract</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// (a service implementing this contract should respond</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// with following response after receiving request</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// specified in "request" part above).</span>
|
|
response {
|
|
status <span class="hl-number">200</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Contract priority, which can be used for overriding</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// contracts (1 is highest). Priority is optional.</span>
|
|
priority <span class="hl-number">1</span>
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">priority: 8
|
|
request:
|
|
...
|
|
response:
|
|
...</pre><p>
|
|
</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>If you want to make your contract have a <span class="strong"><strong>higher</strong></span> value of priority
|
|
you need to pass a <span class="strong"><strong>lower</strong></span> number to the <code class="literal">priority</code> tag / method. E.g. <code class="literal">priority</code> with
|
|
value <code class="literal">5</code> has <span class="strong"><strong>higher</strong></span> priority than <code class="literal">priority</code> with value <code class="literal">10</code>.</p></td></tr></table></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_request" href="#_request"></a>8.3 Request</h2></div></div></div><p>The HTTP protocol requires only <span class="strong"><strong>method and url</strong></span> to be specified in a request. The
|
|
same information is mandatory in request definition of the Contract.</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// HTTP request method (GET/POST/PUT/DELETE).</span>
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Path component of request URL is specified as follows.</span>
|
|
urlPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/users'</span>)
|
|
}
|
|
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
status <span class="hl-number">200</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">method: PUT
|
|
url: /foo</pre><p>
|
|
</p><p>It is possible to specify an absolute rather than relative <code class="literal">url</code>, but using <code class="literal">urlPath</code> is
|
|
the recommended way, as doing so makes the tests <span class="strong"><strong>host-independent</strong></span>.</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Specifying `url` and `urlPath` in one contract is illegal.</span>
|
|
url(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'http://localhost:8888/users'</span>)
|
|
}
|
|
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
status <span class="hl-number">200</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
method: PUT
|
|
urlPath: /foo</pre><p>
|
|
</p><p><code class="literal">request</code> may contain <span class="strong"><strong>query parameters</strong></span>.</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
method GET()
|
|
|
|
urlPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/users'</span>) {
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Each parameter is specified in form</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// `'paramName' : paramValue` where parameter value</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// may be a simple literal or one of matcher functions,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// all of which are used in this example.</span>
|
|
queryParameters {
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// If a simple literal is used as value</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// default matcher function is used (equalTo)</span>
|
|
parameter <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'limit'</span>: <span class="hl-number">100</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// `equalTo` function simply compares passed value</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// using identity operator (==).</span>
|
|
parameter <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'filter'</span>: equalTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"email"</span>)
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// `containing` function matches strings</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// that contains passed substring.</span>
|
|
parameter <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'gender'</span>: value(consumer(containing(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[mf]"</span>)), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'mf'</span>))
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// `matching` function tests parameter</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// against passed regular expression.</span>
|
|
parameter <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'offset'</span>: value(consumer(matching(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[0-9]+"</span>)), producer(<span class="hl-number">123</span>))
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// `notMatching` functions tests if parameter</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// does not match passed regular expression.</span>
|
|
parameter <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'loginStartsWith'</span>: value(consumer(notMatching(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">".{0,2}"</span>)), producer(<span class="hl-number">3</span>))
|
|
}
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
}
|
|
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
status <span class="hl-number">200</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
...
|
|
queryParameters:
|
|
a: b
|
|
b: c
|
|
headers:
|
|
foo: bar
|
|
fooReq: baz
|
|
cookies:
|
|
foo: bar
|
|
fooReq: baz
|
|
body:
|
|
foo: bar
|
|
matchers:
|
|
body:
|
|
- path: $.foo
|
|
type: by_regex
|
|
value: bar
|
|
headers:
|
|
- key: foo
|
|
regex: bar
|
|
response:
|
|
status: 200
|
|
fixedDelayMilliseconds: 1000
|
|
headers:
|
|
foo2: bar
|
|
foo3: foo33
|
|
fooRes: baz
|
|
body:
|
|
foo2: bar
|
|
foo3: baz
|
|
nullValue: null
|
|
matchers:
|
|
body:
|
|
- path: $.foo2
|
|
type: by_regex
|
|
value: bar
|
|
- path: $.foo3
|
|
type: by_command
|
|
value: executeMe($it)
|
|
- path: $.nullValue
|
|
type: by_null
|
|
value: null
|
|
headers:
|
|
- key: foo2
|
|
regex: bar
|
|
- key: foo3
|
|
command: andMeToo($it)
|
|
cookies:
|
|
- key: foo2
|
|
regex: bar
|
|
- key: foo3
|
|
predefined:</pre><p>
|
|
</p><p><code class="literal">request</code> may contain additional <span class="strong"><strong>request headers</strong></span>, as shown in the following example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foo"</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Each header is added in form `'Header-Name' : 'Header-Value'`.</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// there are also some helper methods</span>
|
|
headers {
|
|
header <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'key'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'value'</span>
|
|
contentType(applicationJson())
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
}
|
|
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
status <span class="hl-number">200</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
...
|
|
headers:
|
|
foo: bar
|
|
fooReq: baz</pre><p>
|
|
</p><p><code class="literal">request</code> may contain additional <span class="strong"><strong>request cookies</strong></span>, as shown in the following example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foo"</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Each Cookies is added in form `'Cookie-Key' : 'Cookie-Value'`.</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// there are also some helper methods</span>
|
|
cookies {
|
|
cookie <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'key'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'value'</span>
|
|
cookie(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'another_key'</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'another_value'</span>)
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
}
|
|
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
status <span class="hl-number">200</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
...
|
|
cookies:
|
|
foo: bar
|
|
fooReq: baz</pre><p>
|
|
</p><p><code class="literal">request</code> may contain a <span class="strong"><strong>request body</strong></span>:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foo"</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Currently only JSON format of request body is supported.</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Format will be determined from a header or body's content.</span>
|
|
body <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'{ "login" : "john", "name": "John The Contract" }'</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span>
|
|
}
|
|
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
status <span class="hl-number">200</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
...
|
|
body:
|
|
foo: bar</pre><p>
|
|
</p><p><code class="literal">request</code> may contain <span class="strong"><strong>multipart</strong></span> elements. To include multipart elements, use the
|
|
<code class="literal">multipart</code> method/section, as shown in the following examples</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting"></pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
method: PUT
|
|
url: /multipart
|
|
headers:
|
|
Content-Type: multipart/form-data;boundary=AaB03x
|
|
multipart:
|
|
params:
|
|
# key (parameter name), value (parameter value) pair
|
|
formParameter: '"formParameterValue"'
|
|
someBooleanParameter: true
|
|
named:
|
|
- paramName: file
|
|
fileName: filename.csv
|
|
fileContent: file content
|
|
matchers:
|
|
multipart:
|
|
params:
|
|
- key: formParameter
|
|
regex: ".+"
|
|
- key: someBooleanParameter
|
|
predefined: any_boolean
|
|
named:
|
|
- paramName: file
|
|
fileName:
|
|
predefined: non_empty
|
|
fileContent:
|
|
predefined: non_empty
|
|
response:
|
|
status: 200</pre><p>
|
|
</p><p>In the preceding example, we define parameters in either of two ways:</p><div class="itemizedlist"><p class="title"><b>Groovy DSL</b></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Directly, by using the map notation, where the value can be a dynamic property (such as
|
|
<code class="literal">formParameter: $(consumer(…​), producer(…​))</code>).</li><li class="listitem">By using the <code class="literal">named(…​)</code> method that lets you set a named parameter. A named parameter
|
|
can set a <code class="literal">name</code> and <code class="literal">content</code>. You can call it either via a method with two arguments,
|
|
such as <code class="literal">named("fileName", "fileContent")</code>, or via a map notation, such as
|
|
<code class="literal">named(name: "fileName", content: "fileContent")</code>.</li></ul></div><div class="itemizedlist"><p class="title"><b>YAML</b></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">The multipart parameters are set via <code class="literal">multipart.params</code> section</li><li class="listitem">The named parameters (the <code class="literal">fileName</code> and <code class="literal">fileContent</code> for a given parameter name)
|
|
can be set via the <code class="literal">multipart.named</code> section. That section contains
|
|
the <code class="literal">paramName</code> (name of the parameter), <code class="literal">fileName</code> (name of the file),
|
|
<code class="literal">fileContent</code> (content of the file) fields</li><li class="listitem"><p class="simpara">The dynamic bits can be set via the <code class="literal">matchers.multipart</code> section</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">for parameters use the <code class="literal">params</code> section that can accept
|
|
<code class="literal">regex</code> or a <code class="literal">predefined</code> regular expression</li><li class="listitem">for named params use the <code class="literal">named</code> section where first you
|
|
define the parameter name via <code class="literal">paramName</code> and then you can pass the
|
|
parametrization of either <code class="literal">fileName</code> or <code class="literal">fileContent</code> via
|
|
<code class="literal">regex</code> or a <code class="literal">predefined</code> regular expression</li></ul></div></li></ul></div><p>From this contract, the generated test is as follows:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given()
|
|
.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"multipart/form-data;boundary=AaB03x"</span>)
|
|
.param(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"formParameter"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\"formParameterValue\""</span>)
|
|
.param(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"someBooleanParameter"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"true"</span>)
|
|
.multiPart(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"file"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"filename.csv"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"file content"</span>.getBytes());
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request)
|
|
.put(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/multipart"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);</pre><p>The WireMock stub is as follows:</p><pre class="programlisting"> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'
|
|
</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"request"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"url"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/multipart"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"method"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"PUT"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matches"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"multipart/form-data;boundary=AaB03x.*"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bodyPatterns"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matches"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"</span>formParameter\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\\r\\n(Content-Type: .*\\r\\n)?(Content-Transfer-Encoding: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n\\"</span>.+\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\\r\\n--\\\\1.*"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matches"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"</span>someBooleanParameter\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\\r\\n(Content-Type: .*\\r\\n)?(Content-Transfer-Encoding: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n(true|false)\\r\\n--\\\\1.*"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matches"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">".*--(.*)\\r\\nContent-Disposition: form-data; name=\\"</span>file\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"; filename=\\"</span>[\\\\S\\\\s]+\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\\r\\n(Content-Type: .*\\r\\n)?(Content-Transfer-Encoding: .*\\r\\n)?(Content-Length: \\\\d+\\r\\n)?\\r\\n[\\\\S\\\\s]+\\r\\n--\\\\1.*"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"status"</span> : <span class="hl-number">200</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"transformers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response-template"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo-transformer"</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'</span></pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_response" href="#_response"></a>8.4 Response</h2></div></div></div><p>The response must contain an <span class="strong"><strong>HTTP status code</strong></span> and may contain other information. The
|
|
following code shows an example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">//...</span>
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foo"</span>
|
|
}
|
|
response {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Status code sent by the server</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// in response to request specified above.</span>
|
|
status OK()
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">response:
|
|
...
|
|
status: 200</pre><p>
|
|
</p><p>Besides status, the response may contain <span class="strong"><strong>headers</strong></span>, <span class="strong"><strong>cookies</strong></span> and a <span class="strong"><strong>body</strong></span>, both of which are
|
|
specified the same way as in the request (see the previous paragraph).</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>Via the Groovy DSL you can reference the <code class="literal">org.springframework.cloud.contract.spec.internal.HttpStatus</code>
|
|
methods to provide a meaningful status instead of a digit. E.g. you can call
|
|
<code class="literal">OK()</code> for a status <code class="literal">200</code> or <code class="literal">BAD_REQUEST()</code> for <code class="literal">400</code>.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_dynamic_properties" href="#_dynamic_properties"></a>8.5 Dynamic properties</h2></div></div></div><p>The contract can contain some dynamic properties: timestamps, IDs, and so on. You do not
|
|
want to force the consumers to stub their clocks to always return the same value of time
|
|
so that it gets matched by the stub.</p><p>For Groovy DSL you can provide the dynamic parts in your contracts
|
|
in two ways: pass them directly in the body or set them in a separate section called
|
|
<code class="literal">bodyMatchers</code>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Before 2.0.0 these were set using <code class="literal">testMatchers</code> and <code class="literal">stubMatchers</code>,
|
|
check out the <a class="link" href="https://github.com/spring-cloud/spring-cloud-contract/wiki/Spring-Cloud-Contract-2.0-Migration-Guide" target="_top">migration guide</a> for more information.</p></td></tr></table></div><p>For YAML you can only use the <code class="literal">matchers</code> section.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_dynamic_properties_inside_the_body" href="#_dynamic_properties_inside_the_body"></a>8.5.1 Dynamic properties inside the body</h3></div></div></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>This section is valid only for Groovy DSL. Check out the
|
|
<a class="xref" href="multi_contract-dsl.html#contract-matchers" title="8.5.7 Dynamic Properties in the Matchers Sections">Section 8.5.7, “Dynamic Properties in the Matchers Sections”</a> section for YAML examples of a similar feature.</p></td></tr></table></div><p>You can set the properties inside the body either with the <code class="literal">value</code> method or, if you use
|
|
the Groovy map notation, with <code class="literal">$()</code>. The following example shows how to set dynamic
|
|
properties with the value method:</p><pre class="programlisting">value(consumer(...), producer(...))
|
|
value(c(...), p(...))
|
|
value(stub(...), test(...))
|
|
value(client(...), server(...))</pre><p>The following example shows how to set dynamic properties with <code class="literal">$()</code>:</p><pre class="programlisting">$(consumer(...), producer(...))
|
|
$(c(...), p(...))
|
|
$(stub(...), test(...))
|
|
$(client(...), server(...))</pre><p>Both approaches work equally well. <code class="literal">stub</code> and <code class="literal">client</code> methods are aliases over the <code class="literal">consumer</code>
|
|
method. Subsequent sections take a closer look at what you can do with those values.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_regular_expressions" href="#_regular_expressions"></a>8.5.2 Regular expressions</h3></div></div></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>This section is valid only for Groovy DSL. Check out the
|
|
<a class="xref" href="multi_contract-dsl.html#contract-matchers" title="8.5.7 Dynamic Properties in the Matchers Sections">Section 8.5.7, “Dynamic Properties in the Matchers Sections”</a> section for YAML examples of a similar feature.</p></td></tr></table></div><p>You can use regular expressions to write your requests in Contract DSL. Doing so is
|
|
particularly useful when you want to indicate that a given response should be provided
|
|
for requests that follow a given pattern. Also, you can use regular expressions when you
|
|
need to use patterns and not exact values both for your test and your server side tests.</p><p>The following example shows how to use regular expressions to write a request:</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>)
|
|
url $(consumer(~/\/[<span class="hl-number">0</span>-<span class="hl-number">9</span>]{<span class="hl-number">2</span>}/), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/12'</span>))
|
|
}
|
|
response {
|
|
status OK()
|
|
body(
|
|
id: $(anyNumber()),
|
|
surname: $(
|
|
consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Kowalsky'</span>),
|
|
producer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-zA-Z]+'</span>))
|
|
),
|
|
name: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Jan'</span>,
|
|
created: $(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'2014-02-02 12:23:43'</span>), producer(execute(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'currentDate(it)'</span>))),
|
|
correlationId: value(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'5d1f9fef-e0dc-4f3d-a7e4-72d2220dd827'</span>),
|
|
producer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'</span>))
|
|
)
|
|
)
|
|
headers {
|
|
header <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Content-Type'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'text/plain'</span>
|
|
}
|
|
}
|
|
}</pre><p>You can also provide only one side of the communication with a regular expression. If you
|
|
do so, then the contract engine automatically provides the generated string that matches
|
|
the provided regular expression. The following code shows an example:</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'PUT'</span>
|
|
url value(consumer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/foo/[0-9]{5}'</span>)))
|
|
body([
|
|
requestElement: $(consumer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[0-9]{5}'</span>)))
|
|
])
|
|
headers {
|
|
header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'header'</span>, $(consumer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'application\\/vnd\\.fraud\\.v1\\+json;.*'</span>))))
|
|
}
|
|
}
|
|
response {
|
|
status OK()
|
|
body([
|
|
responseElement: $(producer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[0-9]{7}'</span>)))
|
|
])
|
|
headers {
|
|
contentType(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/vnd.fraud.v1+json"</span>)
|
|
}
|
|
}
|
|
}</pre><p>In the preceding example, the opposite side of the communication has the respective data
|
|
generated for request and response.</p><p>Spring Cloud Contract comes with a series of predefined regular expressions that you can
|
|
use in your contracts, as shown in the following example:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern TRUE_OR_FALSE = Pattern.compile(/(true|false)/)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern ALPHA_NUMERIC = Pattern.compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-zA-Z0-9]+'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern ONLY_ALPHA_UNICODE = Pattern.compile(/[\p{L}]*/)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern NUMBER = Pattern.compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'-?(\\d*\\.\\d+|\\d+)'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern INTEGER = Pattern.compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'-?(\\d+)'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern POSITIVE_INT = Pattern.compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'([1-9]\\d*)'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern DOUBLE = Pattern.compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'-?(\\d*\\.\\d+)'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern HEX = Pattern.compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-fA-F0-9]+'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern IP_ADDRESS = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern HOSTNAME_PATTERN = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'((http[s]?|ftp):/)/?([^:/\\s]+)(:[0-9]{1,5})?'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern EMAIL = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern URL = UrlHelper.URL
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern HTTPS_URL = UrlHelper.HTTPS_URL
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern UUID = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern ANY_DATE = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern ANY_DATE_TIME = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern ANY_TIME = Pattern.
|
|
compile(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern NON_EMPTY = Pattern.compile(/[\S\s]+/)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern NON_BLANK = Pattern.compile(/^\s*\S[\S\s]*/)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> Pattern ISO8601_WITH_OFFSET = Pattern.
|
|
compile(/([<span class="hl-number">0</span>-<span class="hl-number">9</span>]{<span class="hl-number">4</span>})-(<span class="hl-number">1</span>[<span class="hl-number">0</span>-<span class="hl-number">2</span>]|<span class="hl-number">0</span>[<span class="hl-number">1</span>-<span class="hl-number">9</span>])-(<span class="hl-number">3</span>[<span class="hl-number">01</span>]|<span class="hl-number">0</span>[<span class="hl-number">1</span>-<span class="hl-number">9</span>]|[<span class="hl-number">12</span>][<span class="hl-number">0</span>-<span class="hl-number">9</span>])T(<span class="hl-number">2</span>[<span class="hl-number">0</span>-<span class="hl-number">3</span>]|[<span class="hl-number">01</span>][<span class="hl-number">0</span>-<span class="hl-number">9</span>]):([<span class="hl-number">0</span>-<span class="hl-number">5</span>][<span class="hl-number">0</span>-<span class="hl-number">9</span>]):([<span class="hl-number">0</span>-<span class="hl-number">5</span>][<span class="hl-number">0</span>-<span class="hl-number">9</span>])(\.\d{<span class="hl-number">3</span>})?(Z|[+-][<span class="hl-number">01</span>]\d:[<span class="hl-number">0</span>-<span class="hl-number">5</span>]\d)/)
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> Pattern anyOf(String... values) {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> Pattern.compile(values.collect({ <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"^$it\$"</span> }).join(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"|"</span>))
|
|
}
|
|
|
|
RegexProperty onlyAlphaUnicode() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(ONLY_ALPHA_UNICODE).asString()
|
|
}
|
|
|
|
RegexProperty alphaNumeric() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(ALPHA_NUMERIC).asString()
|
|
}
|
|
|
|
RegexProperty number() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(NUMBER).asDouble()
|
|
}
|
|
|
|
RegexProperty positiveInt() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(POSITIVE_INT).asInteger()
|
|
}
|
|
|
|
RegexProperty anyBoolean() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(TRUE_OR_FALSE).asBooleanType()
|
|
}
|
|
|
|
RegexProperty anInteger() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(INTEGER).asInteger()
|
|
}
|
|
|
|
RegexProperty aDouble() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(DOUBLE).asDouble()
|
|
}
|
|
|
|
RegexProperty ipAddress() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(IP_ADDRESS).asString()
|
|
}
|
|
|
|
RegexProperty hostname() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(HOSTNAME_PATTERN).asString()
|
|
}
|
|
|
|
RegexProperty email() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(EMAIL).asString()
|
|
}
|
|
|
|
RegexProperty url() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(URL).asString()
|
|
}
|
|
|
|
RegexProperty httpsUrl() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(HTTPS_URL).asString()
|
|
}
|
|
|
|
RegexProperty uuid() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(UUID).asString()
|
|
}
|
|
|
|
RegexProperty isoDate() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(ANY_DATE).asString()
|
|
}
|
|
|
|
RegexProperty isoDateTime() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(ANY_DATE_TIME).asString()
|
|
}
|
|
|
|
RegexProperty isoTime() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(ANY_TIME).asString()
|
|
}
|
|
|
|
RegexProperty iso8601WithOffset() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(ISO8601_WITH_OFFSET).asString()
|
|
}
|
|
|
|
RegexProperty nonEmpty() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(NON_EMPTY).asString()
|
|
}
|
|
|
|
RegexProperty nonBlank() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> RegexProperty(NON_BLANK).asString()
|
|
}</pre><p>In your contract, you can use it as shown in the following example:</p><pre class="programlisting">Contract dslWithOptionalsInString = Contract.make {
|
|
priority <span class="hl-number">1</span>
|
|
request {
|
|
method POST()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/users/password'</span>
|
|
headers {
|
|
contentType(applicationJson())
|
|
}
|
|
body(
|
|
email: $(consumer(optional(regex(email()))), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'abc@abc.com'</span>)),
|
|
callback_url: $(consumer(regex(hostname())), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'http://partners.com'</span>))
|
|
)
|
|
}
|
|
response {
|
|
status <span class="hl-number">404</span>
|
|
headers {
|
|
contentType(applicationJson())
|
|
}
|
|
body(
|
|
code: value(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"123123"</span>), producer(optional(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"123123"</span>))),
|
|
message: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"User not found by email = [${value(producer(regex(email())), consumer('not.existing@user.com'))}]"</span>
|
|
)
|
|
}
|
|
}</pre><p>To make matters even simpler you can use a set of predefined objects that will automatically assume that you want a regular expression to be passed.
|
|
All of those methods start with <code class="literal">any</code> prefix:</p><pre class="programlisting">T anyAlphaUnicode()
|
|
|
|
T anyAlphaNumeric()
|
|
|
|
T anyNumber()
|
|
|
|
T anyInteger()
|
|
|
|
T anyPositiveInt()
|
|
|
|
T anyDouble()
|
|
|
|
T anyHex()
|
|
|
|
T aBoolean()
|
|
|
|
T anyIpAddress()
|
|
|
|
T anyHostname()
|
|
|
|
T anyEmail()
|
|
|
|
T anyUrl()
|
|
|
|
T anyHttpsUrl()
|
|
|
|
T anyUuid()
|
|
|
|
T anyDate()
|
|
|
|
T anyDateTime()
|
|
|
|
T anyTime()
|
|
|
|
T anyIso8601WithOffset()
|
|
|
|
T anyNonBlankString()
|
|
|
|
T anyNonEmptyString()
|
|
|
|
T anyOf(String... values)</pre><p>and this is an example of how you can reference those methods:</p><pre class="programlisting">Contract contractDsl = Contract.make {
|
|
label <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'trigger_event'</span>
|
|
input {
|
|
triggeredBy(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'toString()'</span>)
|
|
}
|
|
outputMessage {
|
|
sentTo <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'topic.rateablequote'</span>
|
|
body([
|
|
alpha : $(anyAlphaUnicode()),
|
|
number : $(anyNumber()),
|
|
anInteger : $(anyInteger()),
|
|
positiveInt : $(anyPositiveInt()),
|
|
aDouble : $(anyDouble()),
|
|
aBoolean : $(aBoolean()),
|
|
ip : $(anyIpAddress()),
|
|
hostname : $(anyHostname()),
|
|
email : $(anyEmail()),
|
|
url : $(anyUrl()),
|
|
httpsUrl : $(anyHttpsUrl()),
|
|
uuid : $(anyUuid()),
|
|
date : $(anyDate()),
|
|
dateTime : $(anyDateTime()),
|
|
time : $(anyTime()),
|
|
iso8601WithOffset: $(anyIso8601WithOffset()),
|
|
nonBlankString : $(anyNonBlankString()),
|
|
nonEmptyString : $(anyNonEmptyString()),
|
|
anyOf : $(anyOf(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'bar'</span>))
|
|
])
|
|
}
|
|
}</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_passing_optional_parameters" href="#_passing_optional_parameters"></a>8.5.3 Passing Optional Parameters</h3></div></div></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>This section is valid only for Groovy DSL. Check out the
|
|
<a class="xref" href="multi_contract-dsl.html#contract-matchers" title="8.5.7 Dynamic Properties in the Matchers Sections">Section 8.5.7, “Dynamic Properties in the Matchers Sections”</a> section for YAML examples of a similar feature.</p></td></tr></table></div><p>It is possible to provide optional parameters in your contract. However, you can provide
|
|
optional parameters only for the following:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><span class="emphasis"><em>STUB</em></span> side of the Request</li><li class="listitem"><span class="emphasis"><em>TEST</em></span> side of the Response</li></ul></div><p>The following example shows how to provide optional parameters:</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
priority <span class="hl-number">1</span>
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'POST'</span>
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/users/password'</span>
|
|
headers {
|
|
contentType(applicationJson())
|
|
}
|
|
body(
|
|
email: $(consumer(optional(regex(email()))), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'abc@abc.com'</span>)),
|
|
callback_url: $(consumer(regex(hostname())), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'http://partners.com'</span>))
|
|
)
|
|
}
|
|
response {
|
|
status <span class="hl-number">404</span>
|
|
headers {
|
|
header <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Content-Type'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'application/json'</span>
|
|
}
|
|
body(
|
|
code: value(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"123123"</span>), producer(optional(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"123123"</span>)))
|
|
)
|
|
}
|
|
}</pre><p>By wrapping a part of the body with the <code class="literal">optional()</code> method, you create a regular
|
|
expression that must be present 0 or more times.</p><p>If you use Spock for, the following test would be generated from the previous example:</p><pre class="programlisting"> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">""</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"
|
|
</span> given:
|
|
def request = given()
|
|
.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json"</span>)
|
|
.body(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'{"email":"abc@abc.com","callback_url":"http://partners.com"}'</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span>)
|
|
|
|
when:
|
|
def response = given().spec(request)
|
|
.post(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/users/password"</span>)
|
|
|
|
then:
|
|
response.statusCode == <span class="hl-number">404</span>
|
|
response.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Content-Type'</span>) == <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'application/json'</span>
|
|
and:
|
|
DocumentContext parsedJson = JsonPath.parse(response.body.asString())
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['code']"</span>).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"(123123)?"</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">""</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"</span></pre><p>The following stub would also be generated:</p><pre class="programlisting"> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'
|
|
</span>{
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"request"</span> : {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"url"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/users/password"</span>,
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"method"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"POST"</span>,
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bodyPatterns"</span> : [ {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.['email'] =~ /([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,6})?/)]"</span>
|
|
}, {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.['callback_url'] =~ /((http[s]?|ftp):\\\\/)\\\\/?([^:\\\\/\\\\s]+)(:[0-9]{1,5})?/)]"</span>
|
|
} ],
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span> : {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"equalTo"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json"</span>
|
|
}
|
|
}
|
|
},
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response"</span> : {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"status"</span> : <span class="hl-number">404</span>,
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"body"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\\"</span>code\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span><span class="hl-number">123123</span>\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">",\\"</span>message\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span>User not found by email == [not.existing<em><span class="hl-annotation" style="color: gray">@user.com]\\"}",</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json"</span>
|
|
}
|
|
},
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"priority"</span> : <span class="hl-number">1</span>
|
|
}
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'</span></pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_executing_custom_methods_on_the_server_side" href="#_executing_custom_methods_on_the_server_side"></a>8.5.4 Executing Custom Methods on the Server Side</h3></div></div></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>This section is valid only for Groovy DSL. Check out the
|
|
<a class="xref" href="multi_contract-dsl.html#contract-matchers" title="8.5.7 Dynamic Properties in the Matchers Sections">Section 8.5.7, “Dynamic Properties in the Matchers Sections”</a> section for YAML examples of a similar feature.</p></td></tr></table></div><p>You can define a method call that executes on the server side during the test. Such a
|
|
method can be added to the class defined as "baseClassForTests" in the configuration. The
|
|
following code shows an example of the contract portion of the test case:</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'PUT'</span>
|
|
url $(consumer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'^/api/[0-9]{2}$'</span>)), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/api/12'</span>))
|
|
headers {
|
|
header <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Content-Type'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'application/json'</span>
|
|
}
|
|
body <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'\
|
|
</span> [{
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"text"</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Gonna see you at Warsaw"</span>
|
|
}]
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'
|
|
</span> }
|
|
response {
|
|
body(
|
|
path: $(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/api/12'</span>), producer(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'^/api/[0-9]{2}$'</span>))),
|
|
correlationId: $(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'1223456'</span>), producer(execute(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'isProperCorrelationId($it)'</span>)))
|
|
)
|
|
status OK()
|
|
}
|
|
}</pre><p>The following code shows the base class portion of the test case:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">abstract</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> BaseMockMvcSpec <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">extends</span> Specification {
|
|
|
|
def setup() {
|
|
RestAssuredMockMvc.standaloneSetup(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> PairIdController())
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> isProperCorrelationId(Integer correlationId) {
|
|
assert correlationId == <span class="hl-number">123456</span>
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> isEmpty(String value) {
|
|
assert value == null
|
|
}
|
|
|
|
}</pre><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>You cannot use both a String and <code class="literal">execute</code> to perform concatenation. For
|
|
example, calling <code class="literal">header('Authorization', 'Bearer ' + execute('authToken()'))</code> leads to
|
|
improper results. Instead, call <code class="literal">header('Authorization', execute('authToken()'))</code> and
|
|
ensure that the <code class="literal">authToken()</code> method returns everything you need.</p></td></tr></table></div><p>The type of the object read from the JSON can be one of the following, depending on the
|
|
JSON path:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">String</code>: If you point to a <code class="literal">String</code> value in the JSON.</li><li class="listitem"><code class="literal">JSONArray</code>: If you point to a <code class="literal">List</code> in the JSON.</li><li class="listitem"><code class="literal">Map</code>: If you point to a <code class="literal">Map</code> in the JSON.</li><li class="listitem"><code class="literal">Number</code>: If you point to <code class="literal">Integer</code>, <code class="literal">Double</code> etc. in the JSON.</li><li class="listitem"><code class="literal">Boolean</code>: If you point to a <code class="literal">Boolean</code> in the JSON.</li></ul></div><p>In the request part of the contract, you can specify that the <code class="literal">body</code> should be taken from
|
|
a method.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>You must provide both the consumer and the producer side. The <code class="literal">execute</code> part
|
|
is applied for the whole body - not for parts of it.</p></td></tr></table></div><p>The following example shows how to read an object from JSON:</p><pre class="programlisting">Contract contractDsl = Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/something'</span>
|
|
body(
|
|
$(c(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>), p(execute(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'hashCode()'</span>)))
|
|
)
|
|
}
|
|
response {
|
|
status OK()
|
|
}
|
|
}</pre><p>The preceding example results in calling the <code class="literal">hashCode()</code> method in the request body.
|
|
It should resemble the following code:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given()
|
|
.body(hashCode());
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request)
|
|
.get(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/something"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_referencing_the_request_from_the_response" href="#_referencing_the_request_from_the_response"></a>8.5.5 Referencing the Request from the Response</h3></div></div></div><p>The best situation is to provide fixed values, but sometimes you need to reference a
|
|
request in your response.</p><p>If you’re writing contracts using Groovy DSL, you can use the <code class="literal">fromRequest()</code> method, which lets
|
|
you reference a bunch of elements from the HTTP request. You can use the following
|
|
options:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">fromRequest().url()</code>: Returns the request URL and query parameters.</li><li class="listitem"><code class="literal">fromRequest().query(String key)</code>: Returns the first query parameter with a given name.</li><li class="listitem"><code class="literal">fromRequest().query(String key, int index)</code>: Returns the nth query parameter with a
|
|
given name.</li><li class="listitem"><code class="literal">fromRequest().path()</code>: Returns the full path.</li><li class="listitem"><code class="literal">fromRequest().path(int index)</code>: Returns the nth path element.</li><li class="listitem"><code class="literal">fromRequest().header(String key)</code>: Returns the first header with a given name.</li><li class="listitem"><code class="literal">fromRequest().header(String key, int index)</code>: Returns the nth header with a given name.</li><li class="listitem"><code class="literal">fromRequest().body()</code>: Returns the full request body.</li><li class="listitem"><code class="literal">fromRequest().body(String jsonPath)</code>: Returns the element from the request that
|
|
matches the JSON Path.</li></ul></div><p>If you’re using the YAML contract definition you have to use the
|
|
<a class="link" href="https://handlebarsjs.com/" target="_top">Handlebars</a> <code class="literal">{{{ }}}</code> notation with custom, Spring Cloud Contract
|
|
functions to achieve this.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">{{{ request.url }}}</code>: Returns the request URL and query parameters.</li><li class="listitem"><code class="literal">{{{ request.query.key.[index] }}}</code>: Returns the nth query parameter with a given name.
|
|
E.g. for key <code class="literal">foo</code>, first entry <code class="literal">{{{ request.query.foo.[0] }}}</code></li><li class="listitem"><code class="literal">{{{ request.path }}}</code>: Returns the full path.</li><li class="listitem"><code class="literal">{{{ request.path.[index] }}}</code>: Returns the nth path element. E.g.
|
|
for first entry <code class="literal">`</code>{{{ request.path.[0] }}}</li><li class="listitem"><code class="literal">{{{ request.headers.key }}}</code>: Returns the first header with a given name.</li><li class="listitem"><code class="literal">{{{ request.headers.key.[index] }}}</code>: Returns the nth header with a given name.</li><li class="listitem"><code class="literal">{{{ request.body }}}</code>: Returns the full request body.</li><li class="listitem"><code class="literal">{{{ jsonpath this 'your.json.path' }}}</code>: Returns the element from the request that
|
|
matches the JSON Path. E.g. for json path <code class="literal">$.foo</code> - <code class="literal">{{{ jsonpath this '$.foo' }}}</code></li></ul></div><p>Consider the following contract:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting"></pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
method: GET
|
|
url: /api/v1/xxxx
|
|
queryParameters:
|
|
foo:
|
|
- bar
|
|
- bar2
|
|
headers:
|
|
Authorization:
|
|
- secret
|
|
- secret2
|
|
body:
|
|
foo: bar
|
|
baz: 5
|
|
response:
|
|
status: 200
|
|
headers:
|
|
Authorization: "foo {{{ request.headers.Authorization.0 }}} bar"
|
|
body:
|
|
url: "{{{ request.url }}}"
|
|
path: "{{{ request.path }}}"
|
|
pathIndex: "{{{ request.path.1 }}}"
|
|
param: "{{{ request.query.foo }}}"
|
|
paramIndex: "{{{ request.query.foo.1 }}}"
|
|
authorization: "{{{ request.headers.Authorization.0 }}}"
|
|
authorization2: "{{{ request.headers.Authorization.1 }}"
|
|
fullBody: "{{{ request.body }}}"
|
|
responseFoo: "{{{ jsonpath this '$.foo' }}}"
|
|
responseBaz: "{{{ jsonpath this '$.baz' }}}"
|
|
responseBaz2: "Bla bla {{{ jsonpath this '$.foo' }}} bla bla"</pre><p>
|
|
</p><p>Running a JUnit test generation leads to a test that resembles the following example:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given()
|
|
.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Authorization"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret"</span>)
|
|
.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Authorization"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret2"</span>)
|
|
.body(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\"foo\":\"bar\",\"baz\":5}"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo"</span>,<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo"</span>,<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar2"</span>)
|
|
.get(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/api/v1/xxxx"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);
|
|
assertThat(response.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Authorization"</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo secret bar"</span>);
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and:</span>
|
|
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['fullBody']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\"foo\":\"bar\",\"baz\":5}"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['authorization']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['authorization2']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret2"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['path']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/api/v1/xxxx"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['param']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['paramIndex']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar2"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['pathIndex']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"v1"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['responseBaz']"</span>).isEqualTo(<span class="hl-number">5</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['responseFoo']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['url']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/api/v1/xxxx?foo=bar&foo=bar2"</span>);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['responseBaz2']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Bla bla bar bla bla"</span>);</pre><p>As you can see, elements from the request have been properly referenced in the response.</p><p>The generated WireMock stub should resemble the following example:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"request"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"urlPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/api/v1/xxxx"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"method"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"POST"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Authorization"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"equalTo"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret2"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"queryParameters"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"equalTo"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar2"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bodyPatterns"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.['baz'] == 5)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.['foo'] == 'bar')]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"status"</span> : <span class="hl-number">200</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"body"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\"authorization\":\"{{{request.headers.Authorization.[0]}}}\",\"path\":\"{{{request.path}}}\",\"responseBaz\":{{{jsonpath this '$.baz'}}} ,\"param\":\"{{{request.query.foo.[0]}}}\",\"pathIndex\":\"{{{request.path.[1]}}}\",\"responseBaz2\":\"Bla bla {{{jsonpath this '$.foo'}}} bla bla\",\"responseFoo\":\"{{{jsonpath this '$.foo'}}}\",\"authorization2\":\"{{{request.headers.Authorization.[1]}}}\",\"fullBody\":\"{{{escapejsonbody}}}\",\"url\":\"{{{request.url}}}\",\"paramIndex\":\"{{{request.query.foo.[1]}}}\"}"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Authorization"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{{{request.headers.Authorization.[0]}}};foo"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"transformers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response-template"</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span></pre><p>Sending a request such as the one presented in the <code class="literal">request</code> part of the contract results
|
|
in sending the following response body:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"url"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/api/v1/xxxx?foo=bar&foo=bar2"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"path"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/api/v1/xxxx"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"pathIndex"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"v1"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"param"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"paramIndex"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar2"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"authorization"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"authorization2"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret2"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"fullBody"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\"foo\":\"bar\",\"baz\":5}"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"responseFoo"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bar"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"responseBaz"</span> : <span class="hl-number">5</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"responseBaz2"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Bla bla bar bla bla"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span></pre><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>This feature works only with WireMock having a version greater than or equal
|
|
to 2.5.1. The Spring Cloud Contract Verifier uses WireMock’s
|
|
<code class="literal">response-template</code> response transformer. It uses Handlebars to convert the Mustache <code class="literal">{{{ }}}</code> templates into
|
|
proper values. Additionally, it registers two helper functions:</p></td></tr></table></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">escapejsonbody</code>: Escapes the request body in a format that can be embedded in a JSON.</li><li class="listitem"><code class="literal">jsonpath</code>: For a given parameter, find an object in the request body.</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_registering_your_own_wiremock_extension" href="#_registering_your_own_wiremock_extension"></a>8.5.6 Registering Your Own WireMock Extension</h3></div></div></div><p>WireMock lets you register custom extensions. By default, Spring Cloud Contract registers
|
|
the transformer, which lets you reference a request from a response. If you want to
|
|
provide your own extensions, you can register an implementation of the
|
|
<code class="literal">org.springframework.cloud.contract.verifier.dsl.wiremock.WireMockExtensions</code> interface.
|
|
Since we use the spring.factories extension approach, you can create an entry in
|
|
<code class="literal">META-INF/spring.factories</code> file similar to the following:</p><pre class="programlisting">org.springframework.cloud.contract.verifier.dsl.wiremock.WireMockExtensions=\
|
|
org.springframework.cloud.contract.stubrunner.provider.wiremock.TestWireMockExtensions
|
|
org.springframework.cloud.contract.spec.ContractConverter=\
|
|
org.springframework.cloud.contract.stubrunner.TestCustomYamlContractConverter</pre><p>The following is an example of a custom extension:</p><p><b>TestWireMockExtensions.groovy. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">/*
|
|
* Copyright 2013-2019 the original author or authors.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">package</span> org.springframework.cloud.contract.verifier.dsl.wiremock
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> com.github.tomakehurst.wiremock.extension.Extension
|
|
|
|
<strong class="hl-tag" style="color: blue">/**
|
|
* Extension that registers the default transformer and the custom one
|
|
*/</strong>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> TestWireMockExtensions <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">implements</span> WireMockExtensions {
|
|
<em><span class="hl-annotation" style="color: gray">@Override</span></em>
|
|
List<Extension> extensions() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> [
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> DefaultResponseTransformer(),
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> CustomExtension()
|
|
]
|
|
}
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> CustomExtension <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">implements</span> Extension {
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Override</span></em>
|
|
String getName() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo-transformer"</span>
|
|
}
|
|
}</pre><p>
|
|
</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>Remember to override the <code class="literal">applyGlobally()</code> method and set it to <code class="literal">false</code> if you
|
|
want the transformation to be applied only for a mapping that explicitly requires it.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-matchers" href="#contract-matchers"></a>8.5.7 Dynamic Properties in the Matchers Sections</h3></div></div></div><p>If you work with <a class="link" href="https://docs.pact.io/" target="_top">Pact</a>, the following discussion may seem familiar.
|
|
Quite a few users are used to having a separation between the body and setting the
|
|
dynamic parts of a contract.</p><p>You can use the <code class="literal">bodyMatchers</code> section for two reasons:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Define the dynamic values that should end up in a stub.
|
|
You can set it in the <code class="literal">request</code> or <code class="literal">inputMessage</code> part of your contract.</li><li class="listitem">Verify the result of your test.
|
|
This section is present in the <code class="literal">response</code> or <code class="literal">outputMessage</code> side of the
|
|
contract.</li></ul></div><p>Currently, Spring Cloud Contract Verifier supports only JSON Path-based matchers with the
|
|
following matching possibilities:</p><div class="itemizedlist"><p class="title"><b>Groovy DSL</b></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">For the stubs(in tests on the Consumer’s side):</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><code class="literal">byEquality()</code>: The value taken from the consumer’s request via the provided JSON Path must be
|
|
equal to the value provided in the contract.</li><li class="listitem"><code class="literal">byRegex(…​)</code>: The value taken from the consumer’s request via the provided JSON Path must
|
|
match the regex. You can also pass the type of the expected matched value (e.g. <code class="literal">asString()</code>, <code class="literal">asLong()</code> etc.)</li><li class="listitem"><code class="literal">byDate()</code>: The value taken from the consumer’s request via the provided JSON Path must
|
|
match the regex for an ISO Date value.</li><li class="listitem"><code class="literal">byTimestamp()</code>: The value taken from the consumer’s request via the provided JSON Path must
|
|
match the regex for an ISO DateTime value.</li><li class="listitem"><code class="literal">byTime()</code>: The value taken from the consumer’s request via the provided JSON Path must
|
|
match the regex for an ISO Time value.</li></ul></div></li><li class="listitem"><p class="simpara">For the verification(in generated tests on the Producer’s side):</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><code class="literal">byEquality()</code>: The value taken from the producer’s response via the provided JSON Path must be
|
|
equal to the provided value in the contract.</li><li class="listitem"><code class="literal">byRegex(…​)</code>: The value taken from the producer’s response via the provided JSON Path must
|
|
match the regex.</li><li class="listitem"><code class="literal">byDate()</code>: The value taken from the producer’s response via the provided JSON Path must match
|
|
the regex for an ISO Date value.</li><li class="listitem"><code class="literal">byTimestamp()</code>: The value taken from the producer’s response via the provided JSON Path must
|
|
match the regex for an ISO DateTime value.</li><li class="listitem"><code class="literal">byTime()</code>: The value taken from the producer’s response via the provided JSON Path must match
|
|
the regex for an ISO Time value.</li><li class="listitem"><code class="literal">byType()</code>: The value taken from the producer’s response via the provided JSON Path needs to be
|
|
of the same type as the type defined in the body of the response in the contract.
|
|
<code class="literal">byType</code> can take a closure, in which you can set <code class="literal">minOccurrence</code> and <code class="literal">maxOccurrence</code>. For the request side, you should use the closure to assert size of the collection.
|
|
That way, you can assert the size of the flattened collection. To check the size of an
|
|
unflattened collection, use a custom method with the <code class="literal">byCommand(…​)</code> testMatcher.</li><li class="listitem"><p class="simpara"><code class="literal">byCommand(…​)</code>: The value taken from the producer’s response via the provided JSON Path is
|
|
passed as an input to the custom method that you provide. For example,
|
|
<code class="literal">byCommand('foo($it)')</code> results in calling a <code class="literal">foo</code> method to which the value matching the
|
|
JSON Path gets passed. The type of the object read from the JSON can be one of the
|
|
following, depending on the JSON path:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: square; "><li class="listitem"><code class="literal">String</code>: If you point to a <code class="literal">String</code> value.</li><li class="listitem"><code class="literal">JSONArray</code>: If you point to a <code class="literal">List</code>.</li><li class="listitem"><code class="literal">Map</code>: If you point to a <code class="literal">Map</code>.</li><li class="listitem"><code class="literal">Number</code>: If you point to <code class="literal">Integer</code>, <code class="literal">Double</code>, or other kind of number.</li><li class="listitem"><code class="literal">Boolean</code>: If you point to a <code class="literal">Boolean</code>.</li></ul></div></li><li class="listitem"><code class="literal">byNull()</code>: The value taken from the response via the provided JSON Path must be null</li></ul></div></li></ul></div><p><b>YAML. </b><span class="emphasis"><em>Please read the Groovy section for detailed explanation of
|
|
what the types mean</em></span></p><p>For YAML the structure of a matcher looks like this</p><pre class="programlisting">- path: $.foo
|
|
type: by_regex
|
|
value: bar
|
|
regexType: as_string</pre><p>Or if you want to use one of the predefined regular expressions
|
|
<code class="literal">[only_alpha_unicode, number, any_boolean, ip_address, hostname,
|
|
email, url, uuid, iso_date, iso_date_time, iso_time, iso_8601_with_offset, non_empty, non_blank]</code>:</p><pre class="programlisting">- path: $.foo
|
|
type: by_regex
|
|
predefined: only_alpha_unicode</pre><p>Below you can find the allowed list of `type`s.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p class="simpara">For <code class="literal">stubMatchers</code>:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><code class="literal">by_equality</code></li><li class="listitem"><code class="literal">by_regex</code></li><li class="listitem"><code class="literal">by_date</code></li><li class="listitem"><code class="literal">by_timestamp</code></li><li class="listitem"><code class="literal">by_time</code></li><li class="listitem"><p class="simpara"><code class="literal">by_type</code></p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: square; "><li class="listitem">there are 2 additional fields accepted: <code class="literal">minOccurrence</code> and <code class="literal">maxOccurrence</code>.</li></ul></div></li></ul></div></li><li class="listitem"><p class="simpara">For <code class="literal">testMatchers</code>:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><code class="literal">by_equality</code></li><li class="listitem"><code class="literal">by_regex</code></li><li class="listitem"><code class="literal">by_date</code></li><li class="listitem"><code class="literal">by_timestamp</code></li><li class="listitem"><code class="literal">by_time</code></li><li class="listitem"><p class="simpara"><code class="literal">by_type</code></p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: square; "><li class="listitem">there are 2 additional fields accepted: <code class="literal">minOccurrence</code> and <code class="literal">maxOccurrence</code>.</li></ul></div></li><li class="listitem"><code class="literal">by_command</code></li><li class="listitem"><code class="literal">by_null</code></li></ul></div></li></ul></div><p>You can also define which type the regular expression corresponds to via the <code class="literal">regexType</code> field. Below you can find the allowed list of regular expression types:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">as_integer</li><li class="listitem">as_double</li><li class="listitem">as_float,</li><li class="listitem">as_long</li><li class="listitem">as_short</li><li class="listitem">as_boolean</li><li class="listitem">as_string</li></ul></div><p>Consider the following example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">Contract contractDsl = Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>
|
|
urlPath <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/get'</span>
|
|
body([
|
|
duck : <span class="hl-number">123</span>,
|
|
alpha : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'abc'</span>,
|
|
number : <span class="hl-number">123</span>,
|
|
aBoolean : true,
|
|
date : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'2017-01-01'</span>,
|
|
dateTime : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'2017-01-01T01:23:45'</span>,
|
|
time : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'01:02:34'</span>,
|
|
valueWithoutAMatcher: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>,
|
|
valueWithTypeMatch : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'string'</span>,
|
|
key : [
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'complex.key'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>
|
|
]
|
|
])
|
|
bodyMatchers {
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.duck'</span>, byRegex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[0-9]{3}"</span>).asInteger())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.duck'</span>, byEquality())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.alpha'</span>, byRegex(onlyAlphaUnicode()).asString())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.alpha'</span>, byEquality())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.number'</span>, byRegex(number()).asInteger())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.aBoolean'</span>, byRegex(anyBoolean()).asBooleanType())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.date'</span>, byDate())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.dateTime'</span>, byTimestamp())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.time'</span>, byTime())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\$.['key'].['complex.key']"</span>, byEquality())
|
|
}
|
|
headers {
|
|
contentType(applicationJson())
|
|
}
|
|
}
|
|
response {
|
|
status OK()
|
|
body([
|
|
duck : <span class="hl-number">123</span>,
|
|
alpha : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'abc'</span>,
|
|
number : <span class="hl-number">123</span>,
|
|
positiveInteger : <span class="hl-number">1234567890</span>,
|
|
negativeInteger : -<span class="hl-number">1234567890</span>,
|
|
positiveDecimalNumber: <span class="hl-number">123.4567890</span>,
|
|
negativeDecimalNumber: -<span class="hl-number">123.4567890</span>,
|
|
aBoolean : true,
|
|
date : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'2017-01-01'</span>,
|
|
dateTime : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'2017-01-01T01:23:45'</span>,
|
|
time : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"01:02:34"</span>,
|
|
valueWithoutAMatcher : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>,
|
|
valueWithTypeMatch : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'string'</span>,
|
|
valueWithMin : [
|
|
<span class="hl-number">1</span>, <span class="hl-number">2</span>, <span class="hl-number">3</span>
|
|
],
|
|
valueWithMax : [
|
|
<span class="hl-number">1</span>, <span class="hl-number">2</span>, <span class="hl-number">3</span>
|
|
],
|
|
valueWithMinMax : [
|
|
<span class="hl-number">1</span>, <span class="hl-number">2</span>, <span class="hl-number">3</span>
|
|
],
|
|
valueWithMinEmpty : [],
|
|
valueWithMaxEmpty : [],
|
|
key : [
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'complex.key'</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>
|
|
],
|
|
nullValue : null
|
|
])
|
|
bodyMatchers {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// asserts the jsonpath value against manual regex</span>
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.duck'</span>, byRegex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[0-9]{3}"</span>).asInteger())
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// asserts the jsonpath value against the provided value</span>
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.duck'</span>, byEquality())
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// asserts the jsonpath value against some default regex</span>
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.alpha'</span>, byRegex(onlyAlphaUnicode()).asString())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.alpha'</span>, byEquality())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.number'</span>, byRegex(number()).asInteger())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.positiveInteger'</span>, byRegex(anInteger()).asInteger())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.negativeInteger'</span>, byRegex(anInteger()).asInteger())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.positiveDecimalNumber'</span>, byRegex(aDouble()).asDouble())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.negativeDecimalNumber'</span>, byRegex(aDouble()).asDouble())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.aBoolean'</span>, byRegex(anyBoolean()).asBooleanType())
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// asserts vs inbuilt time related regex</span>
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.date'</span>, byDate())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.dateTime'</span>, byTimestamp())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.time'</span>, byTime())
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// asserts that the resulting type is the same as in response body</span>
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.valueWithTypeMatch'</span>, byType())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.valueWithMin'</span>, byType {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// results in verification of size of array (min 1)</span>
|
|
minOccurrence(<span class="hl-number">1</span>)
|
|
})
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.valueWithMax'</span>, byType {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// results in verification of size of array (max 3)</span>
|
|
maxOccurrence(<span class="hl-number">3</span>)
|
|
})
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.valueWithMinMax'</span>, byType {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// results in verification of size of array (min 1 & max 3)</span>
|
|
minOccurrence(<span class="hl-number">1</span>)
|
|
maxOccurrence(<span class="hl-number">3</span>)
|
|
})
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.valueWithMinEmpty'</span>, byType {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// results in verification of size of array (min 0)</span>
|
|
minOccurrence(<span class="hl-number">0</span>)
|
|
})
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.valueWithMaxEmpty'</span>, byType {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// results in verification of size of array (max 0)</span>
|
|
maxOccurrence(<span class="hl-number">0</span>)
|
|
})
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// will execute a method `assertThatValueIsANumber`</span>
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.duck'</span>, byCommand(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'assertThatValueIsANumber($it)'</span>))
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\$.['key'].['complex.key']"</span>, byEquality())
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.nullValue'</span>, byNull())
|
|
}
|
|
headers {
|
|
contentType(applicationJson())
|
|
header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Some-Header'</span>, $(c(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'someValue'</span>), p(regex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'[a-zA-Z]{9}'</span>))))
|
|
}
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">request:
|
|
method: GET
|
|
urlPath: /get/1
|
|
headers:
|
|
Content-Type: application/json
|
|
cookies:
|
|
foo: 2
|
|
bar: 3
|
|
queryParameters:
|
|
limit: 10
|
|
offset: 20
|
|
filter: 'email'
|
|
sort: name
|
|
search: 55
|
|
age: 99
|
|
name: John.Doe
|
|
email: 'bob@email.com'
|
|
body:
|
|
duck: 123
|
|
alpha: "abc"
|
|
number: 123
|
|
aBoolean: true
|
|
date: "2017-01-01"
|
|
dateTime: "2017-01-01T01:23:45"
|
|
time: "01:02:34"
|
|
valueWithoutAMatcher: "foo"
|
|
valueWithTypeMatch: "string"
|
|
key:
|
|
"complex.key": 'foo'
|
|
nullValue: null
|
|
valueWithMin:
|
|
- 1
|
|
- 2
|
|
- 3
|
|
valueWithMax:
|
|
- 1
|
|
- 2
|
|
- 3
|
|
valueWithMinMax:
|
|
- 1
|
|
- 2
|
|
- 3
|
|
valueWithMinEmpty: []
|
|
valueWithMaxEmpty: []
|
|
matchers:
|
|
url:
|
|
regex: /get/[0-9]
|
|
# predefined:
|
|
# execute a method
|
|
#command: 'equals($it)'
|
|
queryParameters:
|
|
- key: limit
|
|
type: equal_to
|
|
value: 20
|
|
- key: offset
|
|
type: containing
|
|
value: 20
|
|
- key: sort
|
|
type: equal_to
|
|
value: name
|
|
- key: search
|
|
type: not_matching
|
|
value: '^[0-9]{2}$'
|
|
- key: age
|
|
type: not_matching
|
|
value: '^\\w*$'
|
|
- key: name
|
|
type: matching
|
|
value: 'John.*'
|
|
- key: hello
|
|
type: absent
|
|
cookies:
|
|
- key: foo
|
|
regex: '[0-9]'
|
|
- key: bar
|
|
command: 'equals($it)'
|
|
headers:
|
|
- key: Content-Type
|
|
regex: "application/json.*"
|
|
body:
|
|
- path: $.duck
|
|
type: by_regex
|
|
value: "[0-9]{3}"
|
|
- path: $.duck
|
|
type: by_equality
|
|
- path: $.alpha
|
|
type: by_regex
|
|
predefined: only_alpha_unicode
|
|
- path: $.alpha
|
|
type: by_equality
|
|
- path: $.number
|
|
type: by_regex
|
|
predefined: number
|
|
- path: $.aBoolean
|
|
type: by_regex
|
|
predefined: any_boolean
|
|
- path: $.date
|
|
type: by_date
|
|
- path: $.dateTime
|
|
type: by_timestamp
|
|
- path: $.time
|
|
type: by_time
|
|
- path: "$.['key'].['complex.key']"
|
|
type: by_equality
|
|
- path: $.nullvalue
|
|
type: by_null
|
|
- path: $.valueWithMin
|
|
type: by_type
|
|
minOccurrence: 1
|
|
- path: $.valueWithMax
|
|
type: by_type
|
|
maxOccurrence: 3
|
|
- path: $.valueWithMinMax
|
|
type: by_type
|
|
minOccurrence: 1
|
|
maxOccurrence: 3
|
|
response:
|
|
status: 200
|
|
cookies:
|
|
foo: 1
|
|
bar: 2
|
|
body:
|
|
duck: 123
|
|
alpha: "abc"
|
|
number: 123
|
|
aBoolean: true
|
|
date: "2017-01-01"
|
|
dateTime: "2017-01-01T01:23:45"
|
|
time: "01:02:34"
|
|
valueWithoutAMatcher: "foo"
|
|
valueWithTypeMatch: "string"
|
|
valueWithMin:
|
|
- 1
|
|
- 2
|
|
- 3
|
|
valueWithMax:
|
|
- 1
|
|
- 2
|
|
- 3
|
|
valueWithMinMax:
|
|
- 1
|
|
- 2
|
|
- 3
|
|
valueWithMinEmpty: []
|
|
valueWithMaxEmpty: []
|
|
key:
|
|
'complex.key': 'foo'
|
|
nulValue: null
|
|
matchers:
|
|
headers:
|
|
- key: Content-Type
|
|
regex: "application/json.*"
|
|
cookies:
|
|
- key: foo
|
|
regex: '[0-9]'
|
|
- key: bar
|
|
command: 'equals($it)'
|
|
body:
|
|
- path: $.duck
|
|
type: by_regex
|
|
value: "[0-9]{3}"
|
|
- path: $.duck
|
|
type: by_equality
|
|
- path: $.alpha
|
|
type: by_regex
|
|
predefined: only_alpha_unicode
|
|
- path: $.alpha
|
|
type: by_equality
|
|
- path: $.number
|
|
type: by_regex
|
|
predefined: number
|
|
- path: $.aBoolean
|
|
type: by_regex
|
|
predefined: any_boolean
|
|
- path: $.date
|
|
type: by_date
|
|
- path: $.dateTime
|
|
type: by_timestamp
|
|
- path: $.time
|
|
type: by_time
|
|
- path: $.valueWithTypeMatch
|
|
type: by_type
|
|
- path: $.valueWithMin
|
|
type: by_type
|
|
minOccurrence: 1
|
|
- path: $.valueWithMax
|
|
type: by_type
|
|
maxOccurrence: 3
|
|
- path: $.valueWithMinMax
|
|
type: by_type
|
|
minOccurrence: 1
|
|
maxOccurrence: 3
|
|
- path: $.valueWithMinEmpty
|
|
type: by_type
|
|
minOccurrence: 0
|
|
- path: $.valueWithMaxEmpty
|
|
type: by_type
|
|
maxOccurrence: 0
|
|
- path: $.duck
|
|
type: by_command
|
|
value: assertThatValueIsANumber($it)
|
|
- path: $.nullValue
|
|
type: by_null
|
|
value: null
|
|
headers:
|
|
Content-Type: application/json</pre><p>
|
|
</p><p>In the preceding example, you can see the dynamic portions of the contract in the
|
|
<code class="literal">matchers</code> sections. For the request part, you can see that, for all fields but
|
|
<code class="literal">valueWithoutAMatcher</code>, the values of the regular expressions that the stub should
|
|
contain are explicitly set. For the <code class="literal">valueWithoutAMatcher</code>, the verification takes place
|
|
in the same way as without the use of matchers. In that case, the test performs an
|
|
equality check.</p><p>For the response side in the <code class="literal">bodyMatchers</code> section, we define the dynamic parts in a
|
|
similar manner. The only difference is that the <code class="literal">byType</code> matchers are also present. The
|
|
verifier engine checks four fields to verify whether the response from the test
|
|
has a value for which the JSON path matches the given field, is of the same type as the one
|
|
defined in the response body, and passes the following check (based on the method being called):</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">For <code class="literal">$.valueWithTypeMatch</code>, the engine checks whether the type is the same.</li><li class="listitem">For <code class="literal">$.valueWithMin</code>, the engine check the type and asserts whether the size is greater
|
|
than or equal to the minimum occurrence.</li><li class="listitem">For <code class="literal">$.valueWithMax</code>, the engine checks the type and asserts whether the size is
|
|
smaller than or equal to the maximum occurrence.</li><li class="listitem">For <code class="literal">$.valueWithMinMax</code>, the engine checks the type and asserts whether the size is
|
|
between the min and maximum occurrence.</li></ul></div><p>The resulting test would resemble the following example (note that an <code class="literal">and</code> section
|
|
separates the autogenerated assertions and the assertion from matchers):</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given()
|
|
.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json"</span>)
|
|
.body(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\"duck\":123,\"alpha\":\"abc\",\"number\":123,\"aBoolean\":true,\"date\":\"2017-01-01\",\"dateTime\":\"2017-01-01T01:23:45\",\"time\":\"01:02:34\",\"valueWithoutAMatcher\":\"foo\",\"valueWithTypeMatch\":\"string\",\"key\":{\"complex.key\":\"foo\"}}"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request)
|
|
.get(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/get"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);
|
|
assertThat(response.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json.*"</span>);
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and:</span>
|
|
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['valueWithoutAMatcher']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo"</span>);
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and:</span>
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.duck"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[0-9]{3}"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.duck"</span>, Integer.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).isEqualTo(<span class="hl-number">123</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.alpha"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[\\p{L}]*"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.alpha"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"abc"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.number"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"-?(\\d*\\.\\d+|\\d+)"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.aBoolean"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"(true|false)"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.date"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.dateTime"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])"</span>);
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.time"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])"</span>);
|
|
assertThat((Object) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithTypeMatch"</span>)).isInstanceOf(java.lang.String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
assertThat((Object) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMin"</span>)).isInstanceOf(java.util.List.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
assertThat((java.lang.Iterable) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMin"</span>, java.util.Collection.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).as(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMin"</span>).hasSizeGreaterThanOrEqualTo(<span class="hl-number">1</span>);
|
|
assertThat((Object) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMax"</span>)).isInstanceOf(java.util.List.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
assertThat((java.lang.Iterable) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMax"</span>, java.util.Collection.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).as(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMax"</span>).hasSizeLessThanOrEqualTo(<span class="hl-number">3</span>);
|
|
assertThat((Object) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMinMax"</span>)).isInstanceOf(java.util.List.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
assertThat((java.lang.Iterable) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMinMax"</span>, java.util.Collection.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).as(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMinMax"</span>).hasSizeBetween(<span class="hl-number">1</span>, <span class="hl-number">3</span>);
|
|
assertThat((Object) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMinEmpty"</span>)).isInstanceOf(java.util.List.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
assertThat((java.lang.Iterable) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMinEmpty"</span>, java.util.Collection.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).as(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMinEmpty"</span>).hasSizeGreaterThanOrEqualTo(<span class="hl-number">0</span>);
|
|
assertThat((Object) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMaxEmpty"</span>)).isInstanceOf(java.util.List.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
assertThat((java.lang.Iterable) parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMaxEmpty"</span>, java.util.Collection.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).as(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.valueWithMaxEmpty"</span>).hasSizeLessThanOrEqualTo(<span class="hl-number">0</span>);
|
|
assertThatValueIsANumber(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.duck"</span>));
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.['key'].['complex.key']"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo"</span>);</pre><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>Notice that, for the <code class="literal">byCommand</code> method, the example calls the
|
|
<code class="literal">assertThatValueIsANumber</code>. This method must be defined in the test base class or be
|
|
statically imported to your tests. Notice that the <code class="literal">byCommand</code> call was converted to
|
|
<code class="literal">assertThatValueIsANumber(parsedJson.read("$.duck"));</code>. That means that the engine took
|
|
the method name and passed the proper JSON path as a parameter to it.</p></td></tr></table></div><p>The resulting WireMock stub is in the following example:</p><pre class="programlisting"> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'
|
|
</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"request"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"urlPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/get"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"method"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"POST"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matches"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json.*"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bodyPatterns"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.['list'].['some'].['nested'][?(@.['anothervalue'] == 4)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.['valueWithoutAMatcher'] == 'foo')]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.['valueWithTypeMatch'] == 'string')]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.['list'].['someother'].['nested'][?(@.['json'] == 'with value')]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.['list'].['someother'].['nested'][?(@.['anothervalue'] == 4)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.duck =~ /([0-9]{3})/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.duck == 123)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.alpha =~ /([\\\\p{L}]*)/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.alpha == 'abc')]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.number =~ /(-?(\\\\d*\\\\.\\\\d+|\\\\d+))/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.aBoolean =~ /((true|false))/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.date =~ /((\\\\d\\\\d\\\\d\\\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.dateTime =~ /(([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]))/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.time =~ /((2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9]))/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$.list.some.nested[?(@.json =~ /(.*)/)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.valueWithMin.size() >= 1)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.valueWithMax.size() <= 3)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.valueWithMinMax.size() >= 1 && @.valueWithMinMax.size() <= 3)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"matchesJsonPath"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"$[?(@.valueWithOccurrence.size() >= 4 && @.valueWithOccurrence.size() <= 4)]"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"status"</span> : <span class="hl-number">200</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"body"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"{\\"</span>date\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span><span class="hl-number">2017</span>-<span class="hl-number">01</span>-<span class="hl-number">01</span>\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">",\\"</span>dateTime\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span><span class="hl-number">2017</span>-<span class="hl-number">01</span>-<span class="hl-number">01</span>T01:<span class="hl-number">23</span>:<span class="hl-number">45</span>\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">",\\"</span>aBoolean\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":true,\\"</span>valueWithMax\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":[1,2,3],\\"</span>valueWithOccurrence\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":[1,2,3,4],\\"</span>number\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":123,\\"</span>duck\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":123,\\"</span>alpha\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span>abc\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">",\\"</span>valueWithMin\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":[1,2,3],\\"</span>time\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span><span class="hl-number">01</span>:<span class="hl-number">02</span>:<span class="hl-number">34</span>\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">",\\"</span>valueWithTypeMatch\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span>string\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">",\\"</span>valueWithMinMax\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":[1,2,3],\\"</span>valueWithoutAMatcher\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">":\\"</span>foo\\<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"}"</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">,</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"headers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">{</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/json"</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">},</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"transformers"</span> : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">[</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"response-template"</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">]</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'</span></pre><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>If you use a <code class="literal">matcher</code>, then the part of the request and response that the
|
|
<code class="literal">matcher</code> addresses with the JSON Path gets removed from the assertion. In the case of
|
|
verifying a collection, you must create matchers for <span class="strong"><strong>all</strong></span> the elements of the
|
|
collection.</p></td></tr></table></div><p>Consider the following example:</p><pre class="programlisting">Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>
|
|
url(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/foo"</span>)
|
|
}
|
|
response {
|
|
status OK()
|
|
body(events: [[
|
|
operation : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'EXPORT'</span>,
|
|
eventId : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'16f1ed75-0bcc-4f0d-a04d-3121798faf99'</span>,
|
|
status : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'OK'</span>
|
|
], [
|
|
operation : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'INPUT_PROCESSING'</span>,
|
|
eventId : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'3bb4ac82-6652-462f-b6d1-75e424a0024a'</span>,
|
|
status : <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'OK'</span>
|
|
]
|
|
]
|
|
)
|
|
bodyMatchers {
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.events[0].operation'</span>, byRegex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'.+'</span>))
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.events[0].eventId'</span>, byRegex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$'</span>))
|
|
jsonPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'$.events[0].status'</span>, byRegex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'.+'</span>))
|
|
}
|
|
}
|
|
}</pre><p>The preceding code leads to creating the following test (the code block shows only the assertion section):</p><pre class="programlisting">and:
|
|
DocumentContext parsedJson = JsonPath.parse(response.body.asString())
|
|
assertThatJson(parsedJson).array(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['events']"</span>).contains(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['eventId']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"16f1ed75-0bcc-4f0d-a04d-3121798faf99"</span>)
|
|
assertThatJson(parsedJson).array(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['events']"</span>).contains(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['operation']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"EXPORT"</span>)
|
|
assertThatJson(parsedJson).array(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['events']"</span>).contains(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['operation']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"INPUT_PROCESSING"</span>)
|
|
assertThatJson(parsedJson).array(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['events']"</span>).contains(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['eventId']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"3bb4ac82-6652-462f-b6d1-75e424a0024a"</span>)
|
|
assertThatJson(parsedJson).array(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['events']"</span>).contains(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['status']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"OK"</span>)
|
|
and:
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\$.events[0].operation"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">".+"</span>)
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\$.events[0].eventId"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})\$"</span>)
|
|
assertThat(parsedJson.read(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"\$.events[0].status"</span>, String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">".+"</span>)</pre><p>As you can see, the assertion is malformed. Only the first element of the array got
|
|
asserted. In order to fix this, you should apply the assertion to the whole <code class="literal">$.events</code>
|
|
collection and assert it with the <code class="literal">byCommand(…​)</code> method.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_jax_rs_support" href="#_jax_rs_support"></a>8.6 JAX-RS Support</h2></div></div></div><p>The Spring Cloud Contract Verifier supports the JAX-RS 2 Client API. The base class needs
|
|
to define <code class="literal">protected WebTarget webTarget</code> and server initialization. The only option for
|
|
testing JAX-RS API is to start a web server. Also, a request with a body needs to have a
|
|
content type set. Otherwise, the default of <code class="literal">application/octet-stream</code> gets used.</p><p>In order to use JAX-RS mode, use the following settings:</p><pre class="programlisting">testMode == <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'JAXRSCLIENT'</span></pre><p>The following example shows a generated test API:</p><pre class="programlisting"> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'
|
|
</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
Response response = webTarget
|
|
.path(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/users"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"limit"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"10"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"offset"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"20"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"filter"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"email"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"sort"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"name"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"search"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"55"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"age"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"99"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"name"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Denis.Stepanov"</span>)
|
|
.queryParam(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"email"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"bob@email.com"</span>)
|
|
.request()
|
|
.method(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"GET"</span>);
|
|
|
|
String responseAsString = response.readEntity(String.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.getStatus()).isEqualTo(<span class="hl-number">200</span>);
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and:</span>
|
|
DocumentContext parsedJson = JsonPath.parse(responseAsString);
|
|
assertThatJson(parsedJson).field(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"['property1']"</span>).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"a"</span>);
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'</span></pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_async_support" href="#_async_support"></a>8.7 Async Support</h2></div></div></div><p>If you’re using asynchronous communication on the server side (your controllers are
|
|
returning <code class="literal">Callable</code>, <code class="literal">DeferredResult</code>, and so on), then, inside your contract, you must
|
|
provide an <code class="literal">async()</code> method in the <code class="literal">response</code> section. The following code shows an example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/get'</span>
|
|
}
|
|
response {
|
|
status OK()
|
|
body <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Passed'</span>
|
|
async()
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">response:
|
|
async: true</pre><p>
|
|
</p><p>You can also use the <code class="literal">fixedDelayMilliseconds</code> method / property to add delay to your stubs.</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method GET()
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/get'</span>
|
|
}
|
|
response {
|
|
status <span class="hl-number">200</span>
|
|
body <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Passed'</span>
|
|
fixedDelayMilliseconds <span class="hl-number">1000</span>
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">response:
|
|
fixedDelayMilliseconds: 1000</pre><p>
|
|
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_working_with_context_paths" href="#_working_with_context_paths"></a>8.8 Working with Context Paths</h2></div></div></div><p>Spring Cloud Contract supports context paths.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>The only change needed to fully support context paths is the switch on the
|
|
<span class="strong"><strong>PRODUCER</strong></span> side. Also, the autogenerated tests must use <span class="strong"><strong>EXPLICIT</strong></span> mode. The consumer
|
|
side remains untouched. In order for the generated test to pass, you must use <span class="strong"><strong>EXPLICIT</strong></span>
|
|
mode.</p></td></tr></table></div><p class="primary"><b>Maven. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><plugin></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.cloud<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-cloud-contract-maven-plugin<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><version></span>${spring-cloud-contract.version}<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></version></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><extensions></span>true<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></extensions></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><configuration></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><testMode></span>EXPLICIT<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></testMode></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></configuration></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></plugin></span></pre><p class="primary">
|
|
</p><p class="secondary"><b>Gradle. </b>
|
|
</p><pre class="programlisting">contracts {
|
|
testMode = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'EXPLICIT'</span>
|
|
}</pre><p class="secondary">
|
|
</p><p>That way, you generate a test that <span class="strong"><strong>DOES NOT</strong></span> use MockMvc. It means that you generate
|
|
real requests and you need to setup your generated test’s base class to work on a real
|
|
socket.</p><p>Consider the following contract:</p><pre class="programlisting">org.springframework.cloud.contract.spec.Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'GET'</span>
|
|
url <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/my-context-path/url'</span>
|
|
}
|
|
response {
|
|
status OK()
|
|
}
|
|
}</pre><p>The following example shows how to set up a base class and Rest Assured:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> io.restassured.RestAssured;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Before;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.boot.web.server.LocalServerPort;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@SpringBootTest(classes = ContextPathTestingBaseClass.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> ContextPathTestingBaseClass {
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@LocalServerPort</span></em> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">int</span> port;
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Before</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> setup() {
|
|
RestAssured.baseURI = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http://localhost"</span>;
|
|
RestAssured.port = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">this</span>.port;
|
|
}
|
|
}</pre><p>If you do it this way:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">All of your requests in the autogenerated tests are sent to the real endpoint with your
|
|
context path included (for example, <code class="literal">/my-context-path/url</code>).</li><li class="listitem">Your contracts reflect that you have a context path. Your generated stubs also have
|
|
that information (for example, in the stubs, you have to call <code class="literal">/my-context-path/url</code>).</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_working_with_webflux" href="#_working_with_webflux"></a>8.9 Working with WebFlux</h2></div></div></div><p>Spring Cloud Contract offers two ways of working with WebFlux.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_webflux_with_webtestclient" href="#_webflux_with_webtestclient"></a>8.9.1 WebFlux with WebTestClient</h3></div></div></div><p>One of them is via the <code class="literal">WebTestClient</code> mode.</p><p class="primary"><b>Maven. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><plugin></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.cloud<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-cloud-contract-maven-plugin<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><version></span>${spring-cloud-contract.version}<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></version></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><extensions></span>true<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></extensions></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><configuration></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><testMode></span>WEBTESTCLIENT<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></testMode></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></configuration></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></plugin></span></pre><p class="primary">
|
|
</p><p class="secondary"><b>Gradle. </b>
|
|
</p><pre class="programlisting">contracts {
|
|
testMode = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'WEBTESTCLIENT'</span>
|
|
}</pre><p class="secondary">
|
|
</p><p>The following example shows how to set up a <code class="literal">WebTestClient</code> base class and <code class="literal">RestAssured</code>
|
|
for WebFlux:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> io.restassured.module.webtestclient.RestAssuredWebTestClient;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Before;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">abstract</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> BeerRestBase {
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Before</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> setup() {
|
|
RestAssuredWebTestClient.standaloneSetup(
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> ProducerController(personToCheck -> personToCheck.age >= <span class="hl-number">20</span>));
|
|
}
|
|
}
|
|
}</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_webflux_with_explicit_mode" href="#_webflux_with_explicit_mode"></a>8.9.2 WebFlux with Explicit mode</h3></div></div></div><p>Another way is with the <code class="literal">EXPLICIT</code> mode in your generated tests
|
|
to work with WebFlux.</p><p class="primary"><b>Maven. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><plugin></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.cloud<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-cloud-contract-maven-plugin<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><version></span>${spring-cloud-contract.version}<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></version></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><extensions></span>true<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></extensions></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><configuration></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><testMode></span>EXPLICIT<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></testMode></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></configuration></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></plugin></span></pre><p class="primary">
|
|
</p><p class="secondary"><b>Gradle. </b>
|
|
</p><pre class="programlisting">contracts {
|
|
testMode = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'EXPLICIT'</span>
|
|
}</pre><p class="secondary">
|
|
</p><p>The following example shows how to set up a base class and Rest Assured for Web Flux:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@RunWith(SpringRunner.class)</span></em>
|
|
<em><span class="hl-annotation" style="color: gray">@SpringBootTest(classes = BeerRestBase.Config.class,
|
|
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
|
properties = "server.port=0")</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">abstract</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> BeerRestBase {
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// your tests go here</span>
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// in this config class you define all controllers and mocked services</span>
|
|
<em><span class="hl-annotation" style="color: gray">@Configuration</span></em>
|
|
<em><span class="hl-annotation" style="color: gray">@EnableAutoConfiguration</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> Config {
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
|
|
PersonCheckingService personCheckingService() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> personToCheck -> personToCheck.age >= <span class="hl-number">20</span>;
|
|
}
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Bean</span></em>
|
|
ProducerController producerController() {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">return</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> ProducerController(personCheckingService());
|
|
}
|
|
}
|
|
|
|
}</pre></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_xml_support_for_rest" href="#_xml_support_for_rest"></a>8.10 XML Support for REST</h2></div></div></div><p>For REST contracts, we also support XML request and response body.
|
|
The XML body has to be passed within the <code class="literal">body</code> element
|
|
as a <code class="literal">String</code> or <code class="literal">GString</code>. Also body matchers can be provided for
|
|
both request and response. In place of the <code class="literal">jsonPath(…​)</code> method, the <code class="literal">org.springframework.cloud.contract.spec.internal.BodyMatchers.xPath</code>
|
|
method should be used, with the desired <code class="literal">xPath</code> provided as the first argument
|
|
and the appropriate <code class="literal">MatchingType</code> as second. All the body matchers apart from <code class="literal">byType()</code> are supported.</p><p>Here is an example of a Groovy DSL contract with XML response body:</p><pre class="programlisting"> Contract.make {
|
|
request {
|
|
method GET()
|
|
urlPath <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/get'</span>
|
|
headers {
|
|
contentType(applicationXml())
|
|
}
|
|
}
|
|
response {
|
|
status(OK())
|
|
headers {
|
|
contentType(applicationXml())
|
|
}
|
|
body <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">""</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"
|
|
</span><test>
|
|
<duck type=<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'xtype'</span>><span class="hl-number">123</span></duck>
|
|
<alpha>abc</alpha>
|
|
<list>
|
|
<elem>abc</elem>
|
|
<elem>def</elem>
|
|
<elem>ghi</elem>
|
|
</list>
|
|
<number><span class="hl-number">123</span></number>
|
|
<aBoolean>true</aBoolean>
|
|
<date><span class="hl-number">2017</span>-<span class="hl-number">01</span>-<span class="hl-number">01</span></date>
|
|
<dateTime><span class="hl-number">2017</span>-<span class="hl-number">01</span>-<span class="hl-number">01</span>T01:<span class="hl-number">23</span>:<span class="hl-number">45</span></dateTime>
|
|
<time><span class="hl-number">01</span>:<span class="hl-number">02</span>:<span class="hl-number">34</span></time>
|
|
<valueWithoutAMatcher>foo</valueWithoutAMatcher>
|
|
<key><complex>foo</complex></key>
|
|
</test><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">""</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"
|
|
</span> bodyMatchers {
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/duck/text()'</span>, byRegex(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[0-9]{3}"</span>))
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/duck/text()'</span>, byCommand(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'test($it)'</span>))
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/duck/xxx'</span>, byNull())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/duck/text()'</span>, byEquality())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/alpha/text()'</span>, byRegex(onlyAlphaUnicode()))
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/alpha/text()'</span>, byEquality())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/number/text()'</span>, byRegex(number()))
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/date/text()'</span>, byDate())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/dateTime/text()'</span>, byTimestamp())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/time/text()'</span>, byTime())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/*/complex/text()'</span>, byEquality())
|
|
xPath(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/test/duck/@type'</span>, byEquality())
|
|
}
|
|
}
|
|
}</pre><p>And below is an example of a YAML contract with XML request and response bodies:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">include</span>::{verifier_core_path}/src/test/resources/yml/contract_rest_xml.yml</pre><p>Here is an example of an automatically generated test for XML response body:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Test</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> validate_xmlMatches() <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">throws</span> Exception {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given()
|
|
.header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"Content-Type"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"application/xml"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request).get(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/get"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and:</span>
|
|
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
|
|
.newDocumentBuilder();
|
|
Document parsedXml = documentBuilder.parse(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> InputSource(
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> StringReader(response.getBody().asString())));
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and:</span>
|
|
assertThat(valueFromXPath(parsedXml, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/list/elem/text()"</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"abc"</span>);
|
|
assertThat(valueFromXPath(parsedXml,<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/list/elem[2]/text()"</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"def"</span>);
|
|
assertThat(valueFromXPath(parsedXml, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/duck/text()"</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[0-9]{3}"</span>);
|
|
assertThat(nodeFromXPath(parsedXml, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/duck/xxx"</span>)).isNull();
|
|
assertThat(valueFromXPath(parsedXml, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/alpha/text()"</span>)).matches(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"[\\p{L}]*"</span>);
|
|
assertThat(valueFromXPath(parsedXml, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/*/complex/text()"</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"foo"</span>);
|
|
assertThat(valueFromXPath(parsedXml, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/test/duck/@type"</span>)).isEqualTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"xtype"</span>);
|
|
}</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_messaging_top_level_elements" href="#_messaging_top_level_elements"></a>8.11 Messaging Top-Level Elements</h2></div></div></div><p>The DSL for messaging looks a little bit different than the one that focuses on HTTP. The
|
|
following sections explain the differences:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-output-triggered-method" title="8.11.1 Output Triggered by a Method">Section 8.11.1, “Output Triggered by a Method”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-output-triggered-message" title="8.11.2 Output Triggered by a Message">Section 8.11.2, “Output Triggered by a Message”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-consumer-producer" title="8.11.3 Consumer/Producer">Section 8.11.3, “Consumer/Producer”</a></li><li class="listitem"><a class="xref" href="multi_contract-dsl.html#contract-dsl-common" title="8.11.4 Common">Section 8.11.4, “Common”</a></li></ul></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-output-triggered-method" href="#contract-dsl-output-triggered-method"></a>8.11.1 Output Triggered by a Method</h3></div></div></div><p>The output message can be triggered by calling a method (such as a <code class="literal">Scheduler</code> when a was
|
|
started and a message was sent), as shown in the following example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">def dsl = Contract.make {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Human readable description</span>
|
|
description <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Some description'</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// Label by means of which the output message can be triggered</span>
|
|
label <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'some_label'</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// input to the contract</span>
|
|
input {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// the contract will be triggered by a method</span>
|
|
triggeredBy(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'bookReturnedTriggered()'</span>)
|
|
}
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// output message of the contract</span>
|
|
outputMessage {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// destination to which the output message will be sent</span>
|
|
sentTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'output'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// the body of the output message</span>
|
|
body(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'{ "bookName" : "foo" }'</span><span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">''</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// the headers of the output message</span>
|
|
headers {
|
|
header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'BOOK-NAME'</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>)
|
|
}
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting"># Human readable description
|
|
description: Some description
|
|
# Label by means of which the output message can be triggered
|
|
label: some_label
|
|
input:
|
|
# the contract will be triggered by a method
|
|
triggeredBy: bookReturnedTriggered()
|
|
# output message of the contract
|
|
outputMessage:
|
|
# destination to which the output message will be sent
|
|
sentTo: output
|
|
# the body of the output message
|
|
body:
|
|
bookName: foo
|
|
# the headers of the output message
|
|
headers:
|
|
BOOK-NAME: foo</pre><p>
|
|
</p><p>In the previous example case, the output message is sent to <code class="literal">output</code> if a method called
|
|
<code class="literal">bookReturnedTriggered</code> is executed. On the message <span class="strong"><strong>publisher’s</strong></span> side, we generate a
|
|
test that calls that method to trigger the message. On the <span class="strong"><strong>consumer</strong></span> side, you can use
|
|
the <code class="literal">some_label</code> to trigger the message.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-output-triggered-message" href="#contract-dsl-output-triggered-message"></a>8.11.2 Output Triggered by a Message</h3></div></div></div><p>The output message can be triggered by receiving a message, as shown in the following
|
|
example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting">def dsl = Contract.make {
|
|
description <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'Some Description'</span>
|
|
label <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'some_label'</span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// input is a message</span>
|
|
input {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// the message was received from this destination</span>
|
|
messageFrom(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'input'</span>)
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// has the following body</span>
|
|
messageBody([
|
|
bookName: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>
|
|
])
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// and the following headers</span>
|
|
messageHeaders {
|
|
header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'sample'</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'header'</span>)
|
|
}
|
|
}
|
|
outputMessage {
|
|
sentTo(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'output'</span>)
|
|
body([
|
|
bookName: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>
|
|
])
|
|
headers {
|
|
header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'BOOK-NAME'</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>)
|
|
}
|
|
}
|
|
}</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting"># Human readable description
|
|
description: Some description
|
|
# Label by means of which the output message can be triggered
|
|
label: some_label
|
|
# input is a message
|
|
input:
|
|
messageFrom: input
|
|
# has the following body
|
|
messageBody:
|
|
bookName: 'foo'
|
|
# and the following headers
|
|
messageHeaders:
|
|
sample: 'header'
|
|
# output message of the contract
|
|
outputMessage:
|
|
# destination to which the output message will be sent
|
|
sentTo: output
|
|
# the body of the output message
|
|
body:
|
|
bookName: foo
|
|
# the headers of the output message
|
|
headers:
|
|
BOOK-NAME: foo</pre><p>
|
|
</p><p>In the preceding example, the output message is sent to <code class="literal">output</code> if a proper message is
|
|
received on the <code class="literal">input</code> destination. On the message <span class="strong"><strong>publisher’s</strong></span> side, the engine
|
|
generates a test that sends the input message to the defined destination. On the
|
|
<span class="strong"><strong>consumer</strong></span> side, you can either send a message to the input destination or use a label
|
|
(<code class="literal">some_label</code> in the example) to trigger the message.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-consumer-producer" href="#contract-dsl-consumer-producer"></a>8.11.3 Consumer/Producer</h3></div></div></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left">Important</th></tr><tr><td align="left" valign="top"><p>This section is valid only for Groovy DSL.</p></td></tr></table></div><p>In HTTP, you have a notion of <code class="literal">client</code>/<code class="literal">stub and `server</code>/<code class="literal">test</code> notation. You can also
|
|
use those paradigms in messaging. In addition, Spring Cloud Contract Verifier also
|
|
provides the <code class="literal">consumer</code> and <code class="literal">producer</code> methods, as presented in the following example
|
|
(note that you can use either <code class="literal">$</code> or <code class="literal">value</code> methods to provide <code class="literal">consumer</code> and <code class="literal">producer</code>
|
|
parts):</p><pre class="programlisting"> Contract.make {
|
|
label <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'some_label'</span>
|
|
input {
|
|
messageFrom value(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'jms:output'</span>), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'jms:input'</span>))
|
|
messageBody([
|
|
bookName: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>
|
|
])
|
|
messageHeaders {
|
|
header(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'sample'</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'header'</span>)
|
|
}
|
|
}
|
|
outputMessage {
|
|
sentTo $(consumer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'jms:input'</span>), producer(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'jms:output'</span>))
|
|
body([
|
|
bookName: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'foo'</span>
|
|
])
|
|
}
|
|
}</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="contract-dsl-common" href="#contract-dsl-common"></a>8.11.4 Common</h3></div></div></div><p>In the <code class="literal">input</code> or <code class="literal">outputMessage</code> section you can call <code class="literal">assertThat</code> with the name
|
|
of a <code class="literal">method</code> (e.g. <code class="literal">assertThatMessageIsOnTheQueue()</code>) that you have defined in the
|
|
base class or in a static import. Spring Cloud Contract will execute that method
|
|
in the generated test.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_multiple_contracts_in_one_file" href="#_multiple_contracts_in_one_file"></a>8.12 Multiple Contracts in One File</h2></div></div></div><p>You can define multiple contracts in one file. Such a contract might resemble the
|
|
following example:</p><p><b>Groovy DSL. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.cloud.contract.spec.Contract
|
|
|
|
[
|
|
Contract.make {
|
|
name(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"should post a user"</span>)
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'POST'</span>
|
|
url(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/users/1'</span>)
|
|
}
|
|
response {
|
|
status OK()
|
|
}
|
|
},
|
|
Contract.make {
|
|
request {
|
|
method <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'POST'</span>
|
|
url(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'/users/2'</span>)
|
|
}
|
|
response {
|
|
status OK()
|
|
}
|
|
}
|
|
]</pre><p>
|
|
</p><p><b>YAML. </b>
|
|
</p><pre class="programlisting">---
|
|
name: should post a user
|
|
request:
|
|
method: POST
|
|
url: /users/1
|
|
response:
|
|
status: 200
|
|
---
|
|
request:
|
|
method: POST
|
|
url: /users/2
|
|
response:
|
|
status: 200
|
|
---
|
|
request:
|
|
method: POST
|
|
url: /users/3
|
|
response:
|
|
status: 200</pre><p>
|
|
</p><p>In the preceding example, one contract has the <code class="literal">name</code> field and the other does not. This
|
|
leads to generation of two tests that look more or less like this:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">package</span> org.springframework.cloud.contract.verifier.tests.com.hello;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> com.example.TestBase;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> com.jayway.jsonpath.DocumentContext;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> com.jayway.jsonpath.JsonPath;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> com.jayway.restassured.module.mockmvc.specification.MockMvcRequestSpecification;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> com.jayway.restassured.response.ResponseOptions;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Test;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> org.assertj.core.api.Assertions.assertThat;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> V1Test <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">extends</span> TestBase {
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Test</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> validate_should_post_a_user() <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">throws</span> Exception {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given();
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request)
|
|
.post(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/users/1"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);
|
|
}
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Test</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> validate_withList_<span class="hl-number">1</span>() <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">throws</span> Exception {
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// given:</span>
|
|
MockMvcRequestSpecification request = given();
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// when:</span>
|
|
ResponseOptions response = given().spec(request)
|
|
.post(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"/users/2"</span>);
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// then:</span>
|
|
assertThat(response.statusCode()).isEqualTo(<span class="hl-number">200</span>);
|
|
}
|
|
|
|
}</pre><p>Notice that, for the contract that has the <code class="literal">name</code> field, the generated test method is named
|
|
<code class="literal">validate_should_post_a_user</code>. For the one that does not have the name, it is called
|
|
<code class="literal">validate_withList_1</code>. It corresponds to the name of the file <code class="literal">WithList.groovy</code> and the
|
|
index of the contract in the list.</p><p>The generated stubs is shown in the following example:</p><pre class="screen">should post a user.json
|
|
1_WithList.json</pre><p>As you can see, the first file got the <code class="literal">name</code> parameter from the contract. The second
|
|
got the name of the contract file (<code class="literal">WithList.groovy</code>) prefixed with the index (in this
|
|
case, the contract had an index of <code class="literal">1</code> in the list of contracts in the file).</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>As you can see, it is much better if you name your contracts because doing so makes
|
|
your tests far more meaningful.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_generating_spring_rest_docs_snippets_from_the_contracts" href="#_generating_spring_rest_docs_snippets_from_the_contracts"></a>8.13 Generating Spring REST Docs snippets from the contracts</h2></div></div></div><p>When you want to include the requests and responses of your API using Spring REST Docs,
|
|
you only need to make some minor changes to your setup if you are using MockMvc and RestAssuredMockMvc.
|
|
Simply include the following dependencies if you haven’t already.</p><p><b>Maven. </b>
|
|
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.cloud<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-cloud-starter-contract-verifier<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><scope></span>test<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></scope></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.restdocs<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-restdocs-mockmvc<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><optional></span>true<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></optional></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre><p>
|
|
</p><p><b>Gradle. </b>
|
|
</p><pre class="programlisting">testCompile <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'org.springframework.cloud:spring-cloud-starter-contract-verifier'</span>
|
|
testCompile <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">'org.springframework.restdocs:spring-restdocs-mockmvc'</span></pre><p>
|
|
</p><p>Next you need to make some changes to your base class like the following example.</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">package</span> com.example.fraud;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> io.restassured.module.mockmvc.RestAssuredMockMvc;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Before;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Rule;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.rules.TestName;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.runner.RunWith;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.beans.factory.annotation.Autowired;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.boot.test.context.SpringBootTest;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.restdocs.JUnitRestDocumentation;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.test.context.junit4.SpringRunner;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.web.context.WebApplicationContext;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@RunWith(SpringRunner.class)</span></em>
|
|
<em><span class="hl-annotation" style="color: gray">@SpringBootTest(classes = Application.class)</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">abstract</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> FraudBaseWithWebAppSetup {
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">private</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> String OUTPUT = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"target/generated-snippets"</span>;
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Rule</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> JUnitRestDocumentation restDocumentation = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> JUnitRestDocumentation(OUTPUT);
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Rule</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> TestName testName = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> TestName();
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Autowired</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">private</span> WebApplicationContext context;
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Before</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> setup() {
|
|
RestAssuredMockMvc.mockMvc(MockMvcBuilders.webAppContextSetup(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">this</span>.context)
|
|
.apply(documentationConfiguration(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">this</span>.restDocumentation))
|
|
.alwaysDo(document(
|
|
getClass().getSimpleName() + <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"_"</span> + testName.getMethodName()))
|
|
.build());
|
|
}
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">protected</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> assertThatRejectionReasonIsNull(Object rejectionReason) {
|
|
assert rejectionReason == null;
|
|
}
|
|
|
|
}</pre><p>In case you are using the standalone setup, you can set up RestAssuredMockMvc like this:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">package</span> com.example.fraud;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> io.restassured.module.mockmvc.RestAssuredMockMvc;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Before;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.Rule;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.junit.rules.TestName;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.restdocs.JUnitRestDocumentation;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">import</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">abstract</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> FraudBaseWithStandaloneSetup {
|
|
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">private</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">final</span> String OUTPUT = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"target/generated-snippets"</span>;
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Rule</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> JUnitRestDocumentation restDocumentation = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> JUnitRestDocumentation(OUTPUT);
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Rule</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> TestName testName = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> TestName();
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Before</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> setup() {
|
|
RestAssuredMockMvc.standaloneSetup(MockMvcBuilders
|
|
.standaloneSetup(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> FraudDetectionController())
|
|
.apply(documentationConfiguration(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">this</span>.restDocumentation))
|
|
.alwaysDo(document(
|
|
getClass().getSimpleName() + <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"_"</span> + testName.getMethodName())));
|
|
}
|
|
|
|
}</pre><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left">Tip</th></tr><tr><td align="left" valign="top"><p>You don’t need to specify the output directory for the generated snippets since version 1.2.0.RELEASE of Spring REST Docs.</p></td></tr></table></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi_stub-runner-for-messaging.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__customization.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">7. Stub Runner for Messaging </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-contract.html">Home</a></td><td width="40%" align="right" valign="top"> 9. Customization</td></tr></table></div></body></html> |