-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ReleaseNotes22
-
Introducing support for Spring MVC unit testing using the REST Assured DSL on top of MockMvc. For example given the following Spring controller:
@Controller public class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); @RequestMapping(value = "/greeting", method = GET) public @ResponseBody Greeting greeting( @RequestParam(value="name", required=false, defaultValue="World") String name) { return new Greeting(counter.incrementAndGet(), String.format(template, name)); } }
you can test it using RestAssuredMockMvc like this:
given(). standaloneSetup(new GreetingController()). param("name", "Johan"). when(). get("/greeting"). then(). statusCode(200). body("id", equalTo(1)). body("content", equalTo("Hello, Johan!"));
i.e. it's very similar to the standard REST Assured syntax. This makes it really fast to run your tests and it's also easier to bootstrap the environment and use mocks (if needed) than standard REST Assured. Most things that you're used to in standard REST Assured works with RestAssured Mock Mvc as well. For example (certain) configuration, static specifications, logging etc etc. For more info refer to the usage guide. To use it you need to depend on the Spring Mock Mvc module:
<dependency> <groupId>com.jayway.restassured</groupId> <artifactId>spring-mock-mvc</artifactId> <version>2.2.0</version> <scope>test</scope> </dependency>
Or download it from the download page if you're not using Maven.
-
Added support for oauth2 using the Scribe framework (whcih needs to be downloaded and put it classpath separately). For example:
given().auth().oauth2("accessToken"). ..
Big thanks to Waseem Shaik for helping out with this!
- OAuth 1 authentication now uses the Scribe framework instead of SignPost since Scribe has support for both oauth 1 and 2. Please download scribe and replace the signpost dependencies that you have in classpath if you're currently using oauth 1.
See change log for more details.