diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 5cb9e0b9e1..051d1ad0dd 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -133,14 +133,14 @@ public class MockHttpServletRequestBuilder implements RequestBuilder, Mergeable * the {@code MockHttpServletRequest} can be plugged in via * {@link #with(RequestPostProcessor)}. * @param httpMethod the HTTP method (GET, POST, etc) - * @param url the URL + * @param uri the URL * @since 4.0.3 */ - MockHttpServletRequestBuilder(HttpMethod httpMethod, URI url) { + MockHttpServletRequestBuilder(HttpMethod httpMethod, URI uri) { Assert.notNull(httpMethod, "httpMethod is required"); - Assert.notNull(url, "url is required"); + Assert.notNull(uri, "uri is required"); this.method = httpMethod; - this.uriComponents = UriComponentsBuilder.fromUri(url).build(); + this.uriComponents = UriComponentsBuilder.fromUri(uri).build(); } /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java index 3e92a7e082..9026c9f991 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -59,11 +59,11 @@ public class MockMultipartHttpServletRequestBuilder extends MockHttpServletReque *

For other ways to initialize a {@code MockMultipartHttpServletRequest}, * see {@link #with(RequestPostProcessor)} and the * {@link RequestPostProcessor} extension point. - * @param url the URL + * @param uri the URL * @since 4.0.3 */ - MockMultipartHttpServletRequestBuilder(URI url) { - super(HttpMethod.POST, url); + MockMultipartHttpServletRequestBuilder(URI uri) { + super(HttpMethod.POST, uri); super.contentType(MediaType.MULTIPART_FORM_DATA); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java index 0d680d2d52..1de81ffece 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMvcRequestBuilders.java @@ -47,6 +47,15 @@ public abstract class MockMvcRequestBuilders { return new MockHttpServletRequestBuilder(HttpMethod.GET, urlTemplate, urlVariables); } + /** + * Create a {@link MockHttpServletRequestBuilder} for a GET request. + * @param uri the URL + * @since 4.0.3 + */ + public static MockHttpServletRequestBuilder get(URI uri) { + return new MockHttpServletRequestBuilder(HttpMethod.GET, uri); + } + /** * Create a {@link MockHttpServletRequestBuilder} for a POST request. * @param urlTemplate a URL template; the resulting URL will be encoded @@ -56,6 +65,15 @@ public abstract class MockMvcRequestBuilders { return new MockHttpServletRequestBuilder(HttpMethod.POST, urlTemplate, urlVariables); } + /** + * Create a {@link MockHttpServletRequestBuilder} for a POST request. + * @param uri the URL + * @since 4.0.3 + */ + public static MockHttpServletRequestBuilder post(URI uri) { + return new MockHttpServletRequestBuilder(HttpMethod.POST, uri); + } + /** * Create a {@link MockHttpServletRequestBuilder} for a PUT request. * @param urlTemplate a URL template; the resulting URL will be encoded @@ -65,6 +83,15 @@ public abstract class MockMvcRequestBuilders { return new MockHttpServletRequestBuilder(HttpMethod.PUT, urlTemplate, urlVariables); } + /** + * Create a {@link MockHttpServletRequestBuilder} for a PUT request. + * @param uri the URL + * @since 4.0.3 + */ + public static MockHttpServletRequestBuilder put(URI uri) { + return new MockHttpServletRequestBuilder(HttpMethod.PUT, uri); + } + /** * Create a {@link MockHttpServletRequestBuilder} for a PATCH request. * @param urlTemplate a URL template; the resulting URL will be encoded @@ -74,6 +101,15 @@ public abstract class MockMvcRequestBuilders { return new MockHttpServletRequestBuilder(HttpMethod.PATCH, urlTemplate, urlVariables); } + /** + * Create a {@link MockHttpServletRequestBuilder} for a PATCH request. + * @param uri the URL + * @since 4.0.3 + */ + public static MockHttpServletRequestBuilder patch(URI uri) { + return new MockHttpServletRequestBuilder(HttpMethod.PATCH, uri); + } + /** * Create a {@link MockHttpServletRequestBuilder} for a DELETE request. * @param urlTemplate a URL template; the resulting URL will be encoded @@ -83,6 +119,15 @@ public abstract class MockMvcRequestBuilders { return new MockHttpServletRequestBuilder(HttpMethod.DELETE, urlTemplate, urlVariables); } + /** + * Create a {@link MockHttpServletRequestBuilder} for a DELETE request. + * @param uri the URL + * @since 4.0.3 + */ + public static MockHttpServletRequestBuilder delete(URI uri) { + return new MockHttpServletRequestBuilder(HttpMethod.DELETE, uri); + } + /** * Create a {@link MockHttpServletRequestBuilder} for an OPTIONS request. * @param urlTemplate a URL template; the resulting URL will be encoded @@ -92,6 +137,14 @@ public abstract class MockMvcRequestBuilders { return new MockHttpServletRequestBuilder(HttpMethod.OPTIONS, urlTemplate, urlVariables); } + /** + * Create a {@link MockHttpServletRequestBuilder} for an OPTIONS request. + * @param uri the URL + * @since 4.0.3 + */ + public static MockHttpServletRequestBuilder options(URI uri) { + return new MockHttpServletRequestBuilder(HttpMethod.OPTIONS, uri); + } /** * Create a {@link MockHttpServletRequestBuilder} for a request with the given HTTP method. @@ -104,86 +157,31 @@ public abstract class MockMvcRequestBuilders { } /** - * Create a {@link MockHttpServletRequestBuilder} for a multipart request. - * @param urlTemplate a URL template; the resulting URL will be encoded - * @param urlVariables zero or more URL variables - */ - public static MockMultipartHttpServletRequestBuilder fileUpload(String urlTemplate, Object... urlVariables) { - return new MockMultipartHttpServletRequestBuilder(urlTemplate, urlVariables); - } - - - /** - * Create a {@link MockHttpServletRequestBuilder} for a GET request. - * @param url the URL - * @since 4.0.3 - */ - public static MockHttpServletRequestBuilder get(URI url) { - return new MockHttpServletRequestBuilder(HttpMethod.GET, url); - } - - /** - * Create a {@link MockHttpServletRequestBuilder} for a POST request. - * @param url the URL - * @since 4.0.3 - */ - public static MockHttpServletRequestBuilder post(URI url) { - return new MockHttpServletRequestBuilder(HttpMethod.POST, url); - } - - /** - * Create a {@link MockHttpServletRequestBuilder} for a PUT request. - * @param url the URL - * @since 4.0.3 - */ - public static MockHttpServletRequestBuilder put(URI url) { - return new MockHttpServletRequestBuilder(HttpMethod.PUT, url); - } - - /** - * Create a {@link MockHttpServletRequestBuilder} for a PATCH request. - * @param url the URL - * @since 4.0.3 - */ - public static MockHttpServletRequestBuilder patch(URI url) { - return new MockHttpServletRequestBuilder(HttpMethod.PATCH, url); - } - - /** - * Create a {@link MockHttpServletRequestBuilder} for a DELETE request. - * @param url the URL - * @since 4.0.3 - */ - public static MockHttpServletRequestBuilder delete(URI url) { - return new MockHttpServletRequestBuilder(HttpMethod.DELETE, url); - } - - /** - * Create a {@link MockHttpServletRequestBuilder} for an OPTIONS request. - * @param url the URL + * Create a {@link MockHttpServletRequestBuilder} for a request with the given HTTP method. + * @param httpMethod the HTTP method (GET, POST, etc) + * @param uri the URL * @since 4.0.3 */ - public static MockHttpServletRequestBuilder options(URI url) { - return new MockHttpServletRequestBuilder(HttpMethod.OPTIONS, url); + public static MockHttpServletRequestBuilder request(HttpMethod httpMethod, URI uri) { + return new MockHttpServletRequestBuilder(httpMethod, uri); } /** - * Create a {@link MockHttpServletRequestBuilder} for a request with the given HTTP method. - * @param httpMethod the HTTP method (GET, POST, etc) - * @param url the URL - * @since 4.0.3 + * Create a {@link MockHttpServletRequestBuilder} for a multipart request. + * @param urlTemplate a URL template; the resulting URL will be encoded + * @param urlVariables zero or more URL variables */ - public static MockHttpServletRequestBuilder request(HttpMethod httpMethod, URI url) { - return new MockHttpServletRequestBuilder(httpMethod, url); + public static MockMultipartHttpServletRequestBuilder fileUpload(String urlTemplate, Object... urlVariables) { + return new MockMultipartHttpServletRequestBuilder(urlTemplate, urlVariables); } /** * Create a {@link MockHttpServletRequestBuilder} for a multipart request. - * @param url the URL + * @param uri the URL * @since 4.0.3 */ - public static MockMultipartHttpServletRequestBuilder fileUpload(URI url) { - return new MockMultipartHttpServletRequestBuilder(url); + public static MockMultipartHttpServletRequestBuilder fileUpload(URI uri) { + return new MockMultipartHttpServletRequestBuilder(uri); } /**