diff --git a/build.gradle b/build.gradle
index b18f28f6..b675c6c2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
classpath 'io.spring.gradle:spring-io-plugin:0.0.6.RELEASE'
- classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2'
+ classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1'
}
configurations.classpath.resolutionStrategy.eachDependency {
if (it.requested.name == 'dependency-management-plugin') {
@@ -71,6 +71,7 @@ subprojects {
dependency 'javax.servlet:javax.servlet-api:3.1.0'
dependency 'javax.validation:validation-api:1.1.0.Final'
dependency 'junit:junit:4.12'
+ dependency 'io.rest-assured:rest-assured:3.0.2'
dependency 'org.asciidoctor:asciidoctorj:1.5.3.1'
dependency 'org.hamcrest:hamcrest-core:1.3'
dependency 'org.hamcrest:hamcrest-library:1.3'
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 061bb501..2809588f 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -73,7 +73,7 @@
+ value="com.jayway.restassured.RestAssured.*, io.restassured.RestAssured.*, org.junit.Assert.*, org.junit.Assume.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.springframework.restdocs.cli.CliDocumentation.*, org.springframework.restdocs.headers.HeaderDocumentation.*, org.springframework.restdocs.hypermedia.HypermediaDocumentation.*, org.springframework.restdocs.mockmvc.IterableEnumeration.*, org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*, org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*, org.springframework.restdocs.payload.PayloadDocumentation.*, org.springframework.restdocs.operation.preprocess.Preprocessors.*, org.springframework.restdocs.request.RequestDocumentation.*, org.springframework.restdocs.restassured.RestAssuredRestDocumentation.*, org.springframework.restdocs.restassured.operation.preprocess.RestAssuredPreprocessors.*, org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.*, org.springframework.restdocs.restassured3.operation.preprocess.RestAssuredPreprocessors.*, org.springframework.restdocs.snippet.Attributes.*, org.springframework.restdocs.templates.TemplateFormats.*, org.springframework.restdocs.test.SnippetMatchers.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*" />
diff --git a/docs/build.gradle b/docs/build.gradle
index a8c7706c..ce165dba 100644
--- a/docs/build.gradle
+++ b/docs/build.gradle
@@ -5,6 +5,7 @@ plugins {
dependencies {
testCompile project(':spring-restdocs-mockmvc')
testCompile project(':spring-restdocs-restassured')
+ testCompile 'io.rest-assured:rest-assured'
testCompile 'javax.validation:validation-api'
testCompile 'junit:junit'
testCompile 'org.testng:testng:6.9.10'
diff --git a/docs/src/docs/asciidoc/getting-started.adoc b/docs/src/docs/asciidoc/getting-started.adoc
index 1b72d5f0..a0413453 100644
--- a/docs/src/docs/asciidoc/getting-started.adoc
+++ b/docs/src/docs/asciidoc/getting-started.adoc
@@ -73,7 +73,8 @@ Spring REST Docs has the following minimum requirements:
Additionally, the `spring-restdocs-restassured` module has the following minimum
requirements:
-- REST Assured 2.8
+- REST Assured 2.8 (`com.jayway.restassured:restassured`) or REST Assured 3.0
+ (`io.rest-assured:rest-assured`)
[[getting-started-build-configuration]]
=== Build configuration
@@ -135,7 +136,8 @@ the configuration are described below.
----
<1> Add a dependency on `spring-restdocs-mockmvc` in the `test` scope. If you want to use
REST Assured rather than MockMvc, add a dependency on `spring-restdocs-restassured`
- instead.
+ and `com.jayway.restassured:restassured` (REST Assured 2) or
+ `io.rest-assured:rest-assured` (REST Assured 3) instead.
<2> Add the SureFire plugin and configure it to include files whose names end with
`Documentation.java`.
<3> Add the Asciidoctor plugin.
@@ -178,7 +180,8 @@ the configuration are described below.
`operation` block macro.
<3> Add a dependency on `spring-restdocs-mockmvc` in the `testCompile` configuration. If
you want to use REST Assured rather than MockMvc, add a dependency on
- `spring-restdocs-restassured` instead.
+ `spring-restdocs-restassured` and `com.jayway.restassured:restassured` (REST Assured
+ 2) or `io.rest-assured:rest-assured` (REST Assured 3) instead.
<4> Configure a property to define the output location for generated snippets.
<5> Configure the `test` task to add the snippets directory as an output.
<6> Configure the `asciidoctor` task
@@ -326,8 +329,9 @@ include::{examples-dir}/com/example/restassured/ExampleApplicationTests.java[tag
----
<1> REST Assured is configured by adding a `RestAssuredRestDocumentationConfigurer` as a
`Filter`. An instance of this class can be obtained from the static
-`documentationConfiguration()` method on
-`org.springframework.restdocs.restassured.RestAssuredRestDocumentation`.
+`documentationConfiguration()` method on `RestAssuredRestDocumentation` in the
+`org.springframework.restdocs.restassured` or `org.springframework.restdocs.restassured3`
+package depending on the version of REST Assured that you are using.
The configurer applies sensible defaults and also provides an API for customizing the
configuration. Refer to the <> for more information.
@@ -403,8 +407,9 @@ include::{examples-dir}/com/example/restassured/InvokeService.java[tags=invoke-s
<3> Document the call to the service, writing the snippets into a directory named `index`
that will be located beneath the configured output directory. The snippets are written by
a `RestDocumentationFilter`. An instance of this class can be obtained from the
-static `document` method on
-`org.springframework.restdocs.restassured.RestAssuredRestDocumentation`.
+static `document` method on `RestAssuredRestDocumentation` in the
+`org.springframework.restdocs.restassured` or `org.springframework.restdocs.restassured3`
+package depending on the version of REST Assured that you are using.
<4> Invoke the root (`/`) of the service.
<5> Assert that the service produce the expected response.
diff --git a/docs/src/docs/asciidoc/introduction.adoc b/docs/src/docs/asciidoc/introduction.adoc
index 7a6fde22..c1d36bb0 100644
--- a/docs/src/docs/asciidoc/introduction.adoc
+++ b/docs/src/docs/asciidoc/introduction.adoc
@@ -12,9 +12,9 @@ can also be configured to use Markdown.
Spring REST Docs makes use of snippets produced by tests written with
{spring-framework-docs}/#spring-mvc-test-framework[Spring MVC Test] or
-http://www.rest-assured.io[REST Assured]. This test-driven approach helps to guarantee the
-accuracy of your service's documentation. If a snippet is incorrect the test that produces
-it will fail.
+http://www.rest-assured.io[REST Assured] 2 and 3. This test-driven approach helps to
+guarantee the accuracy of your service's documentation. If a snippet is incorrect the
+test that produces it will fail.
Documenting a RESTful service is largely about describing its resources. Two key parts
of each resource's description are the details of the HTTP requests that it consumes
diff --git a/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java b/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java
index 39544db0..75180675 100644
--- a/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java
+++ b/docs/src/test/java/com/example/restassured/CustomDefaultSnippets.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,15 +16,15 @@
package com.example.restassured;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.junit.Before;
import org.junit.Rule;
import org.springframework.restdocs.JUnitRestDocumentation;
import static org.springframework.restdocs.cli.CliDocumentation.curlRequest;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class CustomDefaultSnippets {
diff --git a/docs/src/test/java/com/example/restassured/CustomEncoding.java b/docs/src/test/java/com/example/restassured/CustomEncoding.java
index caa2d623..58f9feea 100644
--- a/docs/src/test/java/com/example/restassured/CustomEncoding.java
+++ b/docs/src/test/java/com/example/restassured/CustomEncoding.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,14 +16,14 @@
package com.example.restassured;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.junit.Before;
import org.junit.Rule;
+
import org.springframework.restdocs.JUnitRestDocumentation;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
-
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class CustomEncoding {
diff --git a/docs/src/test/java/com/example/restassured/CustomFormat.java b/docs/src/test/java/com/example/restassured/CustomFormat.java
index 8f6cf4ab..db7ccce3 100644
--- a/docs/src/test/java/com/example/restassured/CustomFormat.java
+++ b/docs/src/test/java/com/example/restassured/CustomFormat.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,21 +16,21 @@
package com.example.restassured;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.junit.Before;
import org.junit.Rule;
+
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.templates.TemplateFormats;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
-
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class CustomFormat {
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
-
+
@SuppressWarnings("unused")
private RequestSpecification spec;
diff --git a/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java b/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java
index c31cf228..e280fe45 100644
--- a/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java
+++ b/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,14 +16,14 @@
package com.example.restassured;
+import io.restassured.RestAssured;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.junit.Before;
import org.junit.Rule;
-import org.springframework.restdocs.JUnitRestDocumentation;
-import org.springframework.restdocs.restassured.RestDocumentationFilter;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
+import org.springframework.restdocs.JUnitRestDocumentation;
+import org.springframework.restdocs.restassured3.RestDocumentationFilter;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
@@ -32,8 +32,8 @@ import static org.springframework.restdocs.operation.preprocess.Preprocessors.pr
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class EveryTestPreprocessing {
diff --git a/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java b/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java
index aa91cd4e..741c6b36 100644
--- a/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java
+++ b/docs/src/test/java/com/example/restassured/ExampleApplicationTestNgTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -18,14 +18,14 @@ package com.example.restassured;
import java.lang.reflect.Method;
-import org.springframework.restdocs.ManualRestDocumentation;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
+import org.springframework.restdocs.ManualRestDocumentation;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class ExampleApplicationTestNgTests {
diff --git a/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java b/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java
index 7133906c..86d2576b 100644
--- a/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java
+++ b/docs/src/test/java/com/example/restassured/ExampleApplicationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,14 +16,14 @@
package com.example.restassured;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.junit.Before;
import org.junit.Rule;
+
import org.springframework.restdocs.JUnitRestDocumentation;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
-
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class ExampleApplicationTests {
diff --git a/docs/src/test/java/com/example/restassured/HttpHeaders.java b/docs/src/test/java/com/example/restassured/HttpHeaders.java
index 2556be02..91c56b2d 100644
--- a/docs/src/test/java/com/example/restassured/HttpHeaders.java
+++ b/docs/src/test/java/com/example/restassured/HttpHeaders.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,14 +16,14 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders;
import static org.springframework.restdocs.headers.HeaderDocumentation.responseHeaders;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class HttpHeaders {
diff --git a/docs/src/test/java/com/example/restassured/Hypermedia.java b/docs/src/test/java/com/example/restassured/Hypermedia.java
index 2922377d..de1face1 100644
--- a/docs/src/test/java/com/example/restassured/Hypermedia.java
+++ b/docs/src/test/java/com/example/restassured/Hypermedia.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,14 +16,14 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.halLinks;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class Hypermedia {
diff --git a/docs/src/test/java/com/example/restassured/InvokeService.java b/docs/src/test/java/com/example/restassured/InvokeService.java
index 347c368e..ebb0073d 100644
--- a/docs/src/test/java/com/example/restassured/InvokeService.java
+++ b/docs/src/test/java/com/example/restassured/InvokeService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,11 +16,11 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class InvokeService {
diff --git a/docs/src/test/java/com/example/restassured/ParameterizedOutput.java b/docs/src/test/java/com/example/restassured/ParameterizedOutput.java
index e5f2ce47..d0f85503 100644
--- a/docs/src/test/java/com/example/restassured/ParameterizedOutput.java
+++ b/docs/src/test/java/com/example/restassured/ParameterizedOutput.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,15 +16,15 @@
package com.example.restassured;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
import org.junit.Before;
import org.junit.Rule;
+
import org.springframework.restdocs.JUnitRestDocumentation;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
-
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
public class ParameterizedOutput {
diff --git a/docs/src/test/java/com/example/restassured/PathParameters.java b/docs/src/test/java/com/example/restassured/PathParameters.java
index 81c7cc3e..18b36965 100644
--- a/docs/src/test/java/com/example/restassured/PathParameters.java
+++ b/docs/src/test/java/com/example/restassured/PathParameters.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,13 +16,13 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class PathParameters {
diff --git a/docs/src/test/java/com/example/restassured/Payload.java b/docs/src/test/java/com/example/restassured/Payload.java
index b538acbb..35e8d58b 100644
--- a/docs/src/test/java/com/example/restassured/Payload.java
+++ b/docs/src/test/java/com/example/restassured/Payload.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,12 +16,12 @@
package com.example.restassured;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
+
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
-
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
@@ -29,7 +29,7 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.requestF
import static org.springframework.restdocs.payload.PayloadDocumentation.responseBody;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
import static org.springframework.restdocs.snippet.Attributes.attributes;
import static org.springframework.restdocs.snippet.Attributes.key;
diff --git a/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java b/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java
index 69f4936e..dcb7c91a 100644
--- a/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java
+++ b/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,16 +16,15 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
-
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.removeHeaders;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class PerTestPreprocessing {
@@ -38,7 +37,7 @@ public class PerTestPreprocessing {
preprocessResponse(prettyPrint()))) // <2>
.when().get("/")
.then().assertThat().statusCode(is(200));
- // end::preprocessing[]
+ // end::preprocessing[]
}
}
diff --git a/docs/src/test/java/com/example/restassured/RequestParameters.java b/docs/src/test/java/com/example/restassured/RequestParameters.java
index 86f40c4b..19333fb9 100644
--- a/docs/src/test/java/com/example/restassured/RequestParameters.java
+++ b/docs/src/test/java/com/example/restassured/RequestParameters.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,13 +16,13 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class RequestParameters {
diff --git a/docs/src/test/java/com/example/restassured/RequestPartPayload.java b/docs/src/test/java/com/example/restassured/RequestPartPayload.java
index ec83908e..d3e3db60 100644
--- a/docs/src/test/java/com/example/restassured/RequestPartPayload.java
+++ b/docs/src/test/java/com/example/restassured/RequestPartPayload.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -20,14 +20,14 @@ import java.io.File;
import java.util.HashMap;
import java.util.Map;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartBody;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestPartFields;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class RequestPartPayload {
diff --git a/docs/src/test/java/com/example/restassured/RequestParts.java b/docs/src/test/java/com/example/restassured/RequestParts.java
index c6a3f8c1..37808103 100644
--- a/docs/src/test/java/com/example/restassured/RequestParts.java
+++ b/docs/src/test/java/com/example/restassured/RequestParts.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -16,13 +16,13 @@
package com.example.restassured;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.request.RequestDocumentation.partWithName;
import static org.springframework.restdocs.request.RequestDocumentation.requestParts;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class RequestParts {
diff --git a/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java b/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java
index 770ed482..3ba16b19 100644
--- a/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java
+++ b/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -17,13 +17,12 @@
package com.example.restassured;
import com.example.SnippetReuse;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.specification.RequestSpecification;
-
+import io.restassured.RestAssured;
+import io.restassured.specification.RequestSpecification;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
public class RestAssuredSnippetReuse extends SnippetReuse {
diff --git a/samples/rest-assured/build.gradle b/samples/rest-assured/build.gradle
index a55dd6b1..73041777 100644
--- a/samples/rest-assured/build.gradle
+++ b/samples/rest-assured/build.gradle
@@ -34,6 +34,7 @@ ext['spring-restdocs.version'] = '1.2.0.BUILD-SNAPSHOT'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
+ testCompile 'io.rest-assured:rest-assured:3.0.2'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.springframework.restdocs:spring-restdocs-restassured'
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${project.ext['spring-restdocs.version']}"
diff --git a/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java b/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java
index c1c4de79..654ab82b 100644
--- a/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java
+++ b/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java
@@ -16,12 +16,12 @@
package com.example.restassured;
-import static com.jayway.restassured.RestAssured.given;
+import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document;
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration;
-import static org.springframework.restdocs.restassured.operation.preprocess.RestAssuredPreprocessors.modifyUris;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration;
+import static org.springframework.restdocs.restassured3.operation.preprocess.RestAssuredPreprocessors.modifyUris;
import org.junit.Before;
import org.junit.Rule;
@@ -33,8 +33,8 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.jayway.restassured.builder.RequestSpecBuilder;
-import com.jayway.restassured.specification.RequestSpecification;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.specification.RequestSpecification;
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
@RunWith(SpringJUnit4ClassRunner.class)
diff --git a/samples/rest-notes-grails/build.gradle b/samples/rest-notes-grails/build.gradle
index c0bce855..fc3d95ec 100644
--- a/samples/rest-notes-grails/build.gradle
+++ b/samples/rest-notes-grails/build.gradle
@@ -73,6 +73,7 @@ dependencies {
runtime "com.h2database:h2"
+ testCompile "io.rest-assured:rest-assured:3.0.2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-datastore-rest-client"
diff --git a/samples/rest-notes-grails/src/integration-test/groovy/com/example/ApiDocumentationSpec.groovy b/samples/rest-notes-grails/src/integration-test/groovy/com/example/ApiDocumentationSpec.groovy
index 2e15d73b..b29d51b3 100644
--- a/samples/rest-notes-grails/src/integration-test/groovy/com/example/ApiDocumentationSpec.groovy
+++ b/samples/rest-notes-grails/src/integration-test/groovy/com/example/ApiDocumentationSpec.groovy
@@ -18,7 +18,7 @@ package com.example
import org.springframework.restdocs.payload.JsonFieldType
-import static com.jayway.restassured.RestAssured.given
+import static io.restassured.RestAssured.given
import static org.hamcrest.CoreMatchers.is
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse
@@ -27,12 +27,12 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWit
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath
-import static org.springframework.restdocs.restassured.operation.preprocess.RestAssuredPreprocessors.modifyUris
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.document
-import static org.springframework.restdocs.restassured.RestAssuredRestDocumentation.documentationConfiguration
+import static org.springframework.restdocs.restassured3.operation.preprocess.RestAssuredPreprocessors.modifyUris
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document
+import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.documentationConfiguration
-import com.jayway.restassured.builder.RequestSpecBuilder
-import com.jayway.restassured.specification.RequestSpecification
+import io.restassured.builder.RequestSpecBuilder
+import io.restassured.specification.RequestSpecification
import grails.test.mixin.integration.Integration
import grails.transaction.Rollback
import org.junit.Rule
diff --git a/spring-restdocs-restassured/build.gradle b/spring-restdocs-restassured/build.gradle
index 558bdb21..68beb38f 100644
--- a/spring-restdocs-restassured/build.gradle
+++ b/spring-restdocs-restassured/build.gradle
@@ -2,8 +2,11 @@ description = 'Spring REST Docs REST Assured'
dependencies {
compile project(':spring-restdocs-core')
- compile 'com.jayway.restassured:rest-assured'
+ compileOnly 'com.jayway.restassured:rest-assured'
+ compileOnly 'io.rest-assured:rest-assured'
+ testCompile 'com.jayway.restassured:rest-assured'
+ testCompile 'io.rest-assured:rest-assured'
testCompile 'org.apache.tomcat.embed:tomcat-embed-core:8.5.11'
testCompile 'org.mockito:mockito-core'
testCompile 'org.hamcrest:hamcrest-library'
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java
index 2cb6b4fa..f9c62eb6 100644
--- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -27,7 +27,10 @@ import org.springframework.restdocs.snippet.Snippet;
*
* @author Andy Wilkinson
* @since 1.1.0
+ * @deprecated Since 1.2.0 in favor of
+ * {@link org.springframework.restdocs.restassured3.RestAssuredRestDocumentation}
*/
+@Deprecated
public abstract class RestAssuredRestDocumentation {
private static final RestAssuredRequestConverter REQUEST_CONVERTER = new RestAssuredRequestConverter();
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurer.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurer.java
index 6e64aa6f..bd14e394 100644
--- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurer.java
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredRestDocumentationConfigurer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -34,7 +34,10 @@ import org.springframework.restdocs.config.RestDocumentationConfigurer;
*
* @author Andy Wilkinson
* @since 1.1.0
+ * @deprecated since 1.2.0 in favor of
+ * {@link org.springframework.restdocs.restassured3.RestAssuredRestDocumentationConfigurer}
*/
+@Deprecated
public final class RestAssuredRestDocumentationConfigurer extends
RestDocumentationConfigurer
implements Filter {
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredSnippetConfigurer.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredSnippetConfigurer.java
index 3e1f5dee..ed850bd9 100644
--- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredSnippetConfigurer.java
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestAssuredSnippetConfigurer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -30,7 +30,10 @@ import org.springframework.restdocs.config.SnippetConfigurer;
*
* @author Andy Wilkinson
* @since 1.1.0
+ * @deprecated since 1.2.0 in favor of
+ * {@link org.springframework.restdocs.restassured3.RestAssuredSnippetConfigurer}
*/
+@Deprecated
public final class RestAssuredSnippetConfigurer extends
SnippetConfigurer
implements Filter {
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java
index 97387058..f46f76de 100644
--- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/RestDocumentationFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -35,7 +35,10 @@ import org.springframework.util.Assert;
*
* @author Andy Wilkinson
* @since 1.1.0
+ * @deprecated since 1.2.0 in favor of
+ * {@link org.springframework.restdocs.restassured3.RestDocumentationFilter}
*/
+@Deprecated
public class RestDocumentationFilter implements Filter {
static final String CONTEXT_KEY_CONFIGURATION = "org.springframework.restdocs.configuration";
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java
index b124544c..6689333c 100644
--- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/RestAssuredPreprocessors.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -29,7 +29,10 @@ import org.springframework.restdocs.operation.OperationResponse;
*
* @author Andy Wilkinson
* @since 1.1.0
+ * @deprecated since 1.2.0 in favor of
+ * {@link org.springframework.restdocs.restassured3.operation.preprocess.RestAssuredPreprocessors}
*/
+@Deprecated
public abstract class RestAssuredPreprocessors {
private RestAssuredPreprocessors() {
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java
index 60972943..6819fcf8 100644
--- a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured/operation/preprocess/UriModifyingOperationPreprocessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -55,7 +55,10 @@ import org.springframework.web.util.UriComponentsBuilder;
*
* @author Andy Wilkinson
* @since 1.1.0
+ * @deprecated since 1.2.0 in favor of
+ * {@link org.springframework.restdocs.restassured3.operation.preprocess.UriModifyingOperationPreprocessor}
*/
+@Deprecated
public final class UriModifyingOperationPreprocessor implements OperationPreprocessor {
private final UriModifyingContentModifier contentModifier = new UriModifyingContentModifier();
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java
new file mode 100644
index 00000000..f44dabbf
--- /dev/null
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRequestConverter.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2014-2017 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
+ *
+ * http://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.
+ */
+
+package org.springframework.restdocs.restassured3;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map.Entry;
+
+import io.restassured.http.Cookie;
+import io.restassured.http.Header;
+import io.restassured.specification.FilterableRequestSpecification;
+import io.restassured.specification.MultiPartSpecification;
+
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.restdocs.operation.OperationRequest;
+import org.springframework.restdocs.operation.OperationRequestFactory;
+import org.springframework.restdocs.operation.OperationRequestPart;
+import org.springframework.restdocs.operation.OperationRequestPartFactory;
+import org.springframework.restdocs.operation.Parameters;
+import org.springframework.restdocs.operation.RequestConverter;
+import org.springframework.restdocs.operation.RequestCookie;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.util.StreamUtils;
+
+/**
+ * A converter for creating an {@link OperationRequest} from a REST Assured
+ * {@link FilterableRequestSpecification}.
+ *
+ * @author Andy Wilkinson
+ */
+class RestAssuredRequestConverter
+ implements RequestConverter {
+
+ @Override
+ public OperationRequest convert(FilterableRequestSpecification requestSpec) {
+ return new OperationRequestFactory().create(URI.create(requestSpec.getURI()),
+ HttpMethod.valueOf(requestSpec.getMethod()), extractContent(requestSpec),
+ extractHeaders(requestSpec), extractParameters(requestSpec),
+ extractParts(requestSpec), extractCookies(requestSpec));
+ }
+
+ private Collection extractCookies(
+ FilterableRequestSpecification requestSpec) {
+ Collection cookies = new ArrayList<>();
+ for (Cookie cookie : requestSpec.getCookies()) {
+ cookies.add(new RequestCookie(cookie.getName(), cookie.getValue()));
+ }
+ return cookies;
+ }
+
+ private byte[] extractContent(FilterableRequestSpecification requestSpec) {
+ return convertContent(requestSpec.getBody());
+ }
+
+ private byte[] convertContent(Object content) {
+ if (content instanceof String) {
+ return ((String) content).getBytes();
+ }
+ else if (content instanceof byte[]) {
+ return (byte[]) content;
+ }
+ else if (content instanceof File) {
+ return copyToByteArray((File) content);
+ }
+ else if (content instanceof InputStream) {
+ return copyToByteArray((InputStream) content);
+ }
+ else if (content == null) {
+ return new byte[0];
+ }
+ else {
+ throw new IllegalStateException(
+ "Unsupported request content: " + content.getClass().getName());
+ }
+ }
+
+ private byte[] copyToByteArray(File file) {
+ try {
+ return FileCopyUtils.copyToByteArray(file);
+ }
+ catch (IOException ex) {
+ throw new IllegalStateException("Failed to read content from file " + file,
+ ex);
+ }
+ }
+
+ private byte[] copyToByteArray(InputStream inputStream) {
+ try {
+ inputStream.reset();
+ }
+ catch (IOException ex) {
+ throw new IllegalStateException("Cannot read content from input stream "
+ + inputStream + " due to reset() failure");
+ }
+ try {
+ return StreamUtils.copyToByteArray(inputStream);
+ }
+ catch (IOException ex) {
+ throw new IllegalStateException(
+ "Failed to read content from input stream " + inputStream, ex);
+ }
+ }
+
+ private HttpHeaders extractHeaders(FilterableRequestSpecification requestSpec) {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ for (Header header : requestSpec.getHeaders()) {
+ httpHeaders.add(header.getName(), header.getValue());
+ }
+ return httpHeaders;
+ }
+
+ private Parameters extractParameters(FilterableRequestSpecification requestSpec) {
+ Parameters parameters = new Parameters();
+ for (Entry entry : requestSpec.getQueryParams().entrySet()) {
+ parameters.add(entry.getKey(), entry.getValue().toString());
+ }
+ for (Entry entry : requestSpec.getRequestParams().entrySet()) {
+ parameters.add(entry.getKey(), entry.getValue().toString());
+ }
+ for (Entry entry : requestSpec.getFormParams().entrySet()) {
+ parameters.add(entry.getKey(), entry.getValue().toString());
+ }
+ return parameters;
+ }
+
+ private Collection extractParts(
+ FilterableRequestSpecification requestSpec) {
+ List parts = new ArrayList<>();
+ for (MultiPartSpecification multiPartSpec : requestSpec.getMultiPartParams()) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(
+ multiPartSpec.getMimeType() == null ? MediaType.TEXT_PLAIN
+ : MediaType.parseMediaType(multiPartSpec.getMimeType()));
+ parts.add(new OperationRequestPartFactory().create(
+ multiPartSpec.getControlName(), multiPartSpec.getFileName(),
+ convertContent(multiPartSpec.getContent()), headers));
+ }
+ return parts;
+ }
+}
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredResponseConverter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredResponseConverter.java
new file mode 100644
index 00000000..e93263d9
--- /dev/null
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredResponseConverter.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2014-2017 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
+ *
+ * http://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.
+ */
+
+package org.springframework.restdocs.restassured3;
+
+import io.restassured.http.Header;
+import io.restassured.response.Response;
+
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.restdocs.operation.OperationResponse;
+import org.springframework.restdocs.operation.OperationResponseFactory;
+import org.springframework.restdocs.operation.ResponseConverter;
+
+/**
+ * A converter for creating an {@link OperationResponse} from a REST Assured
+ * {@link Response}.
+ *
+ * @author Andy Wilkinson
+ */
+class RestAssuredResponseConverter implements ResponseConverter {
+
+ @Override
+ public OperationResponse convert(Response response) {
+ return new OperationResponseFactory().create(
+ HttpStatus.valueOf(response.getStatusCode()), extractHeaders(response),
+ extractContent(response));
+ }
+
+ private HttpHeaders extractHeaders(Response response) {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ for (Header header : response.getHeaders()) {
+ httpHeaders.add(header.getName(), header.getValue());
+ }
+ return httpHeaders;
+ }
+
+ private byte[] extractContent(Response response) {
+ return response.getBody().asByteArray();
+ }
+
+}
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.java
new file mode 100644
index 00000000..65beb5a4
--- /dev/null
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentation.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2014-2017 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
+ *
+ * http://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.
+ */
+
+package org.springframework.restdocs.restassured3;
+
+import org.springframework.restdocs.RestDocumentationContextProvider;
+import org.springframework.restdocs.generate.RestDocumentationGenerator;
+import org.springframework.restdocs.operation.preprocess.OperationRequestPreprocessor;
+import org.springframework.restdocs.operation.preprocess.OperationResponsePreprocessor;
+import org.springframework.restdocs.snippet.Snippet;
+
+/**
+ * Static factory methods for documenting RESTful APIs using REST Assured 3.
+ *
+ * @author Andy Wilkinson
+ * @since 1.2.0
+ */
+public abstract class RestAssuredRestDocumentation {
+
+ private static final RestAssuredRequestConverter REQUEST_CONVERTER = new RestAssuredRequestConverter();
+
+ private static final RestAssuredResponseConverter RESPONSE_CONVERTER = new RestAssuredResponseConverter();
+
+ private RestAssuredRestDocumentation() {
+
+ }
+
+ /**
+ * Documents the API call with the given {@code identifier} using the given
+ * {@code snippets}.
+ *
+ * @param identifier an identifier for the API call that is being documented
+ * @param snippets the snippets that will document the API call
+ * @return a {@link RestDocumentationFilter} that will produce the documentation
+ */
+ public static RestDocumentationFilter document(String identifier,
+ Snippet... snippets) {
+ return new RestDocumentationFilter(new RestDocumentationGenerator<>(identifier,
+ REQUEST_CONVERTER, RESPONSE_CONVERTER, snippets));
+ }
+
+ /**
+ * Documents the API call with the given {@code identifier} using the given
+ * {@code snippets} in addition to any default snippets. The given
+ * {@code requestPreprocessor} is applied to the request before it is documented.
+ *
+ * @param identifier an identifier for the API call that is being documented
+ * @param requestPreprocessor the request preprocessor
+ * @param snippets the snippets
+ * @return a {@link RestDocumentationFilter} that will produce the documentation
+ */
+ public static RestDocumentationFilter document(String identifier,
+ OperationRequestPreprocessor requestPreprocessor, Snippet... snippets) {
+ return new RestDocumentationFilter(new RestDocumentationGenerator<>(identifier,
+ REQUEST_CONVERTER, RESPONSE_CONVERTER, requestPreprocessor, snippets));
+ }
+
+ /**
+ * Documents the API call with the given {@code identifier} using the given
+ * {@code snippets} in addition to any default snippets. The given
+ * {@code responsePreprocessor} is applied to the request before it is documented.
+ *
+ * @param identifier an identifier for the API call that is being documented
+ * @param responsePreprocessor the response preprocessor
+ * @param snippets the snippets
+ * @return a {@link RestDocumentationFilter} that will produce the documentation
+ */
+ public static RestDocumentationFilter document(String identifier,
+ OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) {
+ return new RestDocumentationFilter(new RestDocumentationGenerator<>(identifier,
+ REQUEST_CONVERTER, RESPONSE_CONVERTER, responsePreprocessor, snippets));
+ }
+
+ /**
+ * Documents the API call with the given {@code identifier} using the given
+ * {@code snippets} in addition to any default snippets. The given
+ * {@code requestPreprocessor} and {@code responsePreprocessor} are applied to the
+ * request and response respectively before they are documented.
+ *
+ * @param identifier an identifier for the API call that is being documented
+ * @param requestPreprocessor the request preprocessor
+ * @param responsePreprocessor the response preprocessor
+ * @param snippets the snippets
+ * @return a {@link RestDocumentationFilter} that will produce the documentation
+ */
+ public static RestDocumentationFilter document(String identifier,
+ OperationRequestPreprocessor requestPreprocessor,
+ OperationResponsePreprocessor responsePreprocessor, Snippet... snippets) {
+ return new RestDocumentationFilter(new RestDocumentationGenerator<>(identifier,
+ REQUEST_CONVERTER, RESPONSE_CONVERTER, requestPreprocessor,
+ responsePreprocessor, snippets));
+ }
+
+ /**
+ * Provides access to a {@link RestAssuredRestDocumentationConfigurer} that can be
+ * used to configure Spring REST Docs using the given {@code contextProvider}.
+ *
+ * @param contextProvider the context provider
+ * @return the configurer
+ */
+ public static RestAssuredRestDocumentationConfigurer documentationConfiguration(
+ RestDocumentationContextProvider contextProvider) {
+ return new RestAssuredRestDocumentationConfigurer(contextProvider);
+ }
+
+}
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationConfigurer.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationConfigurer.java
new file mode 100644
index 00000000..66713b64
--- /dev/null
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationConfigurer.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2014-2017 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
+ *
+ * http://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.
+ */
+
+package org.springframework.restdocs.restassured3;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.restassured.filter.Filter;
+import io.restassured.filter.FilterContext;
+import io.restassured.response.Response;
+import io.restassured.specification.FilterableRequestSpecification;
+import io.restassured.specification.FilterableResponseSpecification;
+
+import org.springframework.restdocs.RestDocumentationContext;
+import org.springframework.restdocs.RestDocumentationContextProvider;
+import org.springframework.restdocs.config.RestDocumentationConfigurer;
+
+/**
+ * A REST Assured 3-specific {@link RestDocumentationConfigurer}.
+ *
+ * @author Andy Wilkinson
+ * @since 1.2.0
+ */
+public final class RestAssuredRestDocumentationConfigurer extends
+ RestDocumentationConfigurer
+ implements Filter {
+
+ private final RestAssuredSnippetConfigurer snippetConfigurer = new RestAssuredSnippetConfigurer(
+ this);
+
+ private final RestDocumentationContextProvider contextProvider;
+
+ RestAssuredRestDocumentationConfigurer(
+ RestDocumentationContextProvider contextProvider) {
+ this.contextProvider = contextProvider;
+ }
+
+ @Override
+ public RestAssuredSnippetConfigurer snippets() {
+ return this.snippetConfigurer;
+ }
+
+ @Override
+ public Response filter(FilterableRequestSpecification requestSpec,
+ FilterableResponseSpecification responseSpec, FilterContext filterContext) {
+ RestDocumentationContext context = this.contextProvider.beforeOperation();
+ filterContext.setValue(RestDocumentationContext.class.getName(), context);
+ Map configuration = new HashMap<>();
+ filterContext.setValue(RestDocumentationFilter.CONTEXT_KEY_CONFIGURATION,
+ configuration);
+ apply(configuration, context);
+ return filterContext.next(requestSpec, responseSpec);
+ }
+}
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredSnippetConfigurer.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredSnippetConfigurer.java
new file mode 100644
index 00000000..a4b12b3e
--- /dev/null
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestAssuredSnippetConfigurer.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2014-2017 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
+ *
+ * http://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.
+ */
+
+package org.springframework.restdocs.restassured3;
+
+import io.restassured.filter.Filter;
+import io.restassured.filter.FilterContext;
+import io.restassured.response.Response;
+import io.restassured.specification.FilterableRequestSpecification;
+import io.restassured.specification.FilterableResponseSpecification;
+
+import org.springframework.restdocs.config.SnippetConfigurer;
+
+/**
+ * A configurer that can be used to configure the generated documentation snippets when
+ * using REST Assured 3.
+ *
+ * @author Andy Wilkinson
+ * @since 1.2.0
+ */
+public final class RestAssuredSnippetConfigurer extends
+ SnippetConfigurer
+ implements Filter {
+
+ RestAssuredSnippetConfigurer(RestAssuredRestDocumentationConfigurer parent) {
+ super(parent);
+ }
+
+ @Override
+ public Response filter(FilterableRequestSpecification requestSpec,
+ FilterableResponseSpecification responseSpec, FilterContext context) {
+ return and().filter(requestSpec, responseSpec, context);
+ }
+
+}
diff --git a/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.java b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.java
new file mode 100644
index 00000000..b91b06f0
--- /dev/null
+++ b/spring-restdocs-restassured/src/main/java/org/springframework/restdocs/restassured3/RestDocumentationFilter.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2014-2017 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
+ *
+ * http://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.
+ */
+
+package org.springframework.restdocs.restassured3;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.restassured.filter.Filter;
+import io.restassured.filter.FilterContext;
+import io.restassured.response.Response;
+import io.restassured.specification.FilterableRequestSpecification;
+import io.restassured.specification.FilterableResponseSpecification;
+
+import org.springframework.restdocs.RestDocumentationContext;
+import org.springframework.restdocs.generate.RestDocumentationGenerator;
+import org.springframework.restdocs.snippet.Snippet;
+import org.springframework.util.Assert;
+
+/**
+ * A REST Assured 3 {@link Filter} for documenting RESTful APIs.
+ *
+ * @author Andy Wilkinson
+ * @since 1.2.0
+ */
+public class RestDocumentationFilter implements Filter {
+
+ static final String CONTEXT_KEY_CONFIGURATION = "org.springframework.restdocs.configuration";
+
+ private final RestDocumentationGenerator delegate;
+
+ RestDocumentationFilter(
+ RestDocumentationGenerator delegate) {
+ Assert.notNull(delegate, "delegate must be non-null");
+ this.delegate = delegate;
+ }
+
+ @Override
+ public final Response filter(FilterableRequestSpecification requestSpec,
+ FilterableResponseSpecification responseSpec, FilterContext context) {
+ Response response = context.next(requestSpec, responseSpec);
+
+ Map configuration = getConfiguration(requestSpec, context);
+
+ this.delegate.handle(requestSpec, response, configuration);
+
+ return response;
+ }
+
+ /**
+ * Returns the configuration that should be used when calling the delgate. The
+ * configuration is derived from the given {@code requestSpec} and {@code context}.
+ *
+ * @param requestSpec the request specification
+ * @param context the filter context
+ * @return the configuration
+ */
+ protected Map getConfiguration(
+ FilterableRequestSpecification requestSpec, FilterContext context) {
+ Map configuration = new HashMap<>(
+ context.