Replace space indentation with tabs

Issue: SPR-10127
This commit is contained in:
Phillip Webb
2012-12-19 14:55:41 -08:00
committed by Chris Beams
parent 1762157ad1
commit 2cf45bad86
154 changed files with 1481 additions and 1476 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2012 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.
@@ -96,8 +96,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
private static final String[] DATE_FORMATS = new String[] {
"EEE, dd MMM yyyy HH:mm:ss zzz",
"EEE, dd-MMM-yy HH:mm:ss zzz",
"EEE MMM dd HH:mm:ss yyyy"
"EEE, dd-MMM-yy HH:mm:ss zzz",
"EEE MMM dd HH:mm:ss yyyy"
};
private static TimeZone GMT = TimeZone.getTimeZone("GMT");

View File

@@ -463,7 +463,7 @@ public class MediaType implements Comparable<MediaType> {
* @return a read-only map, possibly empty, never <code>null</code>
*/
public Map<String, String> getParameters() {
return parameters;
return parameters;
}
/**

View File

@@ -50,13 +50,13 @@ final class HttpComponentsClientHttpRequest extends AbstractBufferingClientHttpR
private final HttpUriRequest httpRequest;
private final HttpContext httpContext;
private final HttpContext httpContext;
public HttpComponentsClientHttpRequest(HttpClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
public HttpComponentsClientHttpRequest(HttpClient httpClient, HttpUriRequest httpRequest, HttpContext httpContext) {
this.httpClient = httpClient;
this.httpRequest = httpRequest;
this.httpContext = httpContext;
this.httpContext = httpContext;
}

View File

@@ -128,7 +128,7 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
getHttpClient().getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, timeout);
}
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
HttpUriRequest httpRequest = createHttpUriRequest(httpMethod, uri);
postProcessHttpRequest(httpRequest);
return new HttpComponentsClientHttpRequest(getHttpClient(), httpRequest, createHttpContext(httpMethod, uri));
@@ -172,16 +172,16 @@ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequest
protected void postProcessHttpRequest(HttpUriRequest request) {
}
/**
* Template methods that creates a {@link HttpContext} for the given HTTP method and URI.
* <p>The default implementation returns {@code null}.
* @param httpMethod the HTTP method
* @param uri the URI
* @return the http context
*/
protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
return null;
}
/**
* Template methods that creates a {@link HttpContext} for the given HTTP method and URI.
* <p>The default implementation returns {@code null}.
* @param httpMethod the HTTP method
* @param uri the URI
* @return the http context
*/
protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
return null;
}
/**
* Shutdown hook that closes the underlying

View File

@@ -73,38 +73,38 @@ final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest {
else {
this.connection.setChunkedStreamingMode(this.chunkSize);
}
writeHeaders(headers);
this.connection.connect();
writeHeaders(headers);
this.connection.connect();
this.body = this.connection.getOutputStream();
}
return new NonClosingOutputStream(this.body);
}
private void writeHeaders(HttpHeaders headers) {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
for (String headerValue : entry.getValue()) {
this.connection.addRequestProperty(headerName, headerValue);
}
}
}
private void writeHeaders(HttpHeaders headers) {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
for (String headerValue : entry.getValue()) {
this.connection.addRequestProperty(headerName, headerValue);
}
}
}
@Override
@Override
protected ClientHttpResponse executeInternal(HttpHeaders headers) throws IOException {
try {
if (this.body != null) {
this.body.close();
}
else {
writeHeaders(headers);
this.connection.connect();
}
}
catch (IOException ex) {
// ignore
}
return new SimpleClientHttpResponse(this.connection);
}
try {
if (this.body != null) {
this.body.close();
}
else {
writeHeaders(headers);
this.connection.connect();
}
}
catch (IOException ex) {
// ignore
}
return new SimpleClientHttpResponse(this.connection);
}
private static class NonClosingOutputStream extends FilterOutputStream {

View File

@@ -183,7 +183,7 @@ public class BurlapClientInterceptor extends UrlBasedRemoteAccessor implements M
}
else {
return new RemoteAccessException(
"Cannot access Burlap remote service at [" + getServiceUrl() + "]", ex);
"Cannot access Burlap remote service at [" + getServiceUrl() + "]", ex);
}
}

View File

@@ -264,7 +264,7 @@ public class HessianClientInterceptor extends UrlBasedRemoteAccessor implements
}
else {
return new RemoteAccessException(
"Cannot access Hessian remote service at [" + getServiceUrl() + "]", ex);
"Cannot access Hessian remote service at [" + getServiceUrl() + "]", ex);
}
}

View File

@@ -210,7 +210,7 @@ public class HttpInvokerClientInterceptor extends RemoteInvocationBasedAccessor
}
else {
throw new RemoteAccessException(
"Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex);
"Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex);
}
}

View File

@@ -185,7 +185,7 @@ public abstract class GenericFilterBean implements
}
catch (BeansException ex) {
String msg = "Failed to set bean properties on filter '" +
filterConfig.getFilterName() + "': " + ex.getMessage();
filterConfig.getFilterName() + "': " + ex.getMessage();
logger.error(msg, ex);
throw new NestedServletException(msg, ex);
}
@@ -310,9 +310,9 @@ public abstract class GenericFilterBean implements
// Fail if we are still missing properties.
if (missingProps != null && missingProps.size() > 0) {
throw new ServletException(
"Initialization from FilterConfig for filter '" + config.getFilterName() +
"' failed; the following required properties were missing: " +
StringUtils.collectionToDelimitedString(missingProps, ", "));
"Initialization from FilterConfig for filter '" + config.getFilterName() +
"' failed; the following required properties were missing: " +
StringUtils.collectionToDelimitedString(missingProps, ", "));
}
}
}

View File

@@ -76,7 +76,7 @@ public abstract class FacesContextUtils {
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
*/
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc)
throws IllegalStateException {
throws IllegalStateException {
WebApplicationContext wac = getWebApplicationContext(fc);
if (wac == null) {

View File

@@ -107,7 +107,7 @@ public class UriComponentsBuilder {
protected UriComponentsBuilder() {
}
// Factory methods
// Factory methods
/**
* Returns a new, empty builder.
@@ -253,7 +253,7 @@ public class UriComponentsBuilder {
// build methods
// build methods
/**
* Builds a {@code UriComponents} instance from the various components contained in this builder.
@@ -306,7 +306,7 @@ public class UriComponentsBuilder {
return build(false).expand(uriVariableValues);
}
// URI components methods
// URI components methods
/**
* Initializes all components of this URI builder with the components of the given URI.

View File

@@ -67,7 +67,7 @@ public class UriTemplate implements Serializable {
this.uriTemplate = uriTemplate;
this.variableNames = parser.getVariableNames();
this.matchPattern = parser.getMatchPattern();
this.uriComponents = UriComponentsBuilder.fromUriString(uriTemplate).build();
this.uriComponents = UriComponentsBuilder.fromUriString(uriTemplate).build();
}
/**
@@ -78,7 +78,7 @@ public class UriTemplate implements Serializable {
return this.variableNames;
}
// expanding
// expanding
/**
* Given the Map of variables, expands this template into a URI. The Map keys represent variable names,
@@ -98,12 +98,12 @@ public class UriTemplate implements Serializable {
* or if it does not contain values for all the variable names
*/
public URI expand(Map<String, ?> uriVariables) {
UriComponents expandedComponents = uriComponents.expand(uriVariables);
UriComponents expandedComponents = uriComponents.expand(uriVariables);
UriComponents encodedComponents = expandedComponents.encode();
return encodedComponents.toUri();
return encodedComponents.toUri();
}
/**
/**
* Given an array of variables, expand this template into a full URI. The array represent variable values.
* The order of variables is significant.
* <p>Example:
@@ -118,12 +118,12 @@ public class UriTemplate implements Serializable {
* or if it does not contain sufficient variables
*/
public URI expand(Object... uriVariableValues) {
UriComponents expandedComponents = uriComponents.expand(uriVariableValues);
UriComponents expandedComponents = uriComponents.expand(uriVariableValues);
UriComponents encodedComponents = expandedComponents.encode();
return encodedComponents.toUri();
return encodedComponents.toUri();
}
// matching
// matching
/**
* Indicate whether the given URI matches this template.

View File

@@ -142,16 +142,16 @@ public abstract class WebUtils {
String root = servletContext.getRealPath("/");
if (root == null) {
throw new IllegalStateException(
"Cannot set web app root system property when WAR file is not expanded");
"Cannot set web app root system property when WAR file is not expanded");
}
String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
String oldValue = System.getProperty(key);
if (oldValue != null && !StringUtils.pathEquals(oldValue, root)) {
throw new IllegalStateException(
"Web app root system property already set to different value: '" +
key + "' = [" + oldValue + "] instead of [" + root + "] - " +
"Choose unique values for the 'webAppRootKey' context-param in your web.xml files!");
"Web app root system property already set to different value: '" +
key + "' = [" + oldValue + "] instead of [" + root + "] - " +
"Choose unique values for the 'webAppRootKey' context-param in your web.xml files!");
}
System.setProperty(key, root);
servletContext.log("Set web app root system property: '" + key + "' = [" + root + "]");
@@ -279,7 +279,7 @@ public abstract class WebUtils {
* @throws IllegalStateException if the session attribute could not be found
*/
public static Object getRequiredSessionAttribute(HttpServletRequest request, String name)
throws IllegalStateException {
throws IllegalStateException {
Object attr = getSessionAttribute(request, name);
if (attr == null) {
@@ -330,13 +330,13 @@ public abstract class WebUtils {
}
catch (InstantiationException ex) {
throw new IllegalArgumentException(
"Could not instantiate class [" + clazz.getName() +
"] for session attribute '" + name + "': " + ex.getMessage());
"Could not instantiate class [" + clazz.getName() +
"] for session attribute '" + name + "': " + ex.getMessage());
}
catch (IllegalAccessException ex) {
throw new IllegalArgumentException(
"Could not access default constructor of class [" + clazz.getName() +
"] for session attribute '" + name + "': " + ex.getMessage());
"Could not access default constructor of class [" + clazz.getName() +
"] for session attribute '" + name + "': " + ex.getMessage());
}
session.setAttribute(name, sessionObject);
}

View File

@@ -245,8 +245,8 @@ public abstract class AbstractHttpRequestFactoryTestCase {
@SuppressWarnings("serial")
private static class EchoServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
echo(req, resp);
}

View File

@@ -31,69 +31,69 @@ import org.springframework.util.Assert;
*/
public abstract class FreePortScanner {
private static final int MIN_SAFE_PORT = 1024;
private static final int MIN_SAFE_PORT = 1024;
private static final int MAX_PORT = 65535;
private static final int MAX_PORT = 65535;
private static final Random random = new Random();
private static final Random random = new Random();
/**
* Returns the number of a free port in the default range.
*/
public static int getFreePort() {
return getFreePort(MIN_SAFE_PORT, MAX_PORT);
}
/**
* Returns the number of a free port in the default range.
*/
public static int getFreePort() {
return getFreePort(MIN_SAFE_PORT, MAX_PORT);
}
/**
* Returns the number of a free port in the given range.
*/
public static int getFreePort(int minPort, int maxPort) {
Assert.isTrue(minPort > 0, "'minPort' must be larger than 0");
Assert.isTrue(maxPort > minPort, "'maxPort' must be larger than minPort");
int portRange = maxPort - minPort;
int candidatePort;
int searchCounter = 0;
do {
if (++searchCounter > portRange) {
throw new IllegalStateException(
String.format("There were no ports available in the range %d to %d", minPort, maxPort));
}
candidatePort = getRandomPort(minPort, portRange);
}
while (!isPortAvailable(candidatePort));
/**
* Returns the number of a free port in the given range.
*/
public static int getFreePort(int minPort, int maxPort) {
Assert.isTrue(minPort > 0, "'minPort' must be larger than 0");
Assert.isTrue(maxPort > minPort, "'maxPort' must be larger than minPort");
int portRange = maxPort - minPort;
int candidatePort;
int searchCounter = 0;
do {
if (++searchCounter > portRange) {
throw new IllegalStateException(
String.format("There were no ports available in the range %d to %d", minPort, maxPort));
}
candidatePort = getRandomPort(minPort, portRange);
}
while (!isPortAvailable(candidatePort));
return candidatePort;
}
return candidatePort;
}
private static int getRandomPort(int minPort, int portRange) {
return minPort + random.nextInt(portRange);
}
private static int getRandomPort(int minPort, int portRange) {
return minPort + random.nextInt(portRange);
}
private static boolean isPortAvailable(int port) {
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket();
}
catch (IOException ex) {
throw new IllegalStateException("Unable to create ServerSocket.", ex);
}
private static boolean isPortAvailable(int port) {
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket();
}
catch (IOException ex) {
throw new IllegalStateException("Unable to create ServerSocket.", ex);
}
try {
InetSocketAddress sa = new InetSocketAddress(port);
serverSocket.bind(sa);
return true;
}
catch (IOException ex) {
return false;
}
finally {
try {
serverSocket.close();
}
catch (IOException ex) {
// ignore
}
}
}
try {
InetSocketAddress sa = new InetSocketAddress(port);
serverSocket.bind(sa);
return true;
}
catch (IOException ex) {
return false;
}
finally {
try {
serverSocket.close();
}
catch (IOException ex) {
// ignore
}
}
}
}

View File

@@ -373,13 +373,13 @@ public class CommonsMultipartResolverTests {
}
List<FileItem> fileItems = new ArrayList<FileItem>();
MockFileItem fileItem1 = new MockFileItem(
"field1", "type1", empty ? "" : "field1.txt", empty ? "" : "text1");
"field1", "type1", empty ? "" : "field1.txt", empty ? "" : "text1");
MockFileItem fileItem1x = new MockFileItem(
"field1", "type1", empty ? "" : "field1.txt", empty ? "" : "text1");
"field1", "type1", empty ? "" : "field1.txt", empty ? "" : "text1");
MockFileItem fileItem2 = new MockFileItem(
"field2", "type2", empty ? "" : "C:/field2.txt", empty ? "" : "text2");
"field2", "type2", empty ? "" : "C:/field2.txt", empty ? "" : "text2");
MockFileItem fileItem2x = new MockFileItem(
"field2x", "type2", empty ? "" : "C:\\field2x.txt", empty ? "" : "text2");
"field2x", "type2", empty ? "" : "C:\\field2x.txt", empty ? "" : "text2");
MockFileItem fileItem3 = new MockFileItem("field3", null, null, "value3");
MockFileItem fileItem4 = new MockFileItem("field4", "text/html; charset=iso-8859-1", null, "value4");
MockFileItem fileItem5 = new MockFileItem("field4", null, null, "value5");

View File

@@ -38,11 +38,11 @@ public class UriComponentsBuilderTests {
public void plain() throws URISyntaxException {
UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
UriComponents result = builder.scheme("http").host("example.com").path("foo").queryParam("bar").fragment("baz").build();
assertEquals("http", result.getScheme());
assertEquals("example.com", result.getHost());
assertEquals("foo", result.getPath());
assertEquals("bar", result.getQuery());
assertEquals("baz", result.getFragment());
assertEquals("http", result.getScheme());
assertEquals("example.com", result.getHost());
assertEquals("foo", result.getPath());
assertEquals("bar", result.getQuery());
assertEquals("baz", result.getFragment());
URI expected = new URI("http://example.com/foo?bar#baz");
assertEquals("Invalid result URI", expected, result.toUri());
@@ -51,29 +51,29 @@ public class UriComponentsBuilderTests {
@Test
public void fromPath() throws URISyntaxException {
UriComponents result = UriComponentsBuilder.fromPath("foo").queryParam("bar").fragment("baz").build();
assertEquals("foo", result.getPath());
assertEquals("bar", result.getQuery());
assertEquals("baz", result.getFragment());
assertEquals("foo", result.getPath());
assertEquals("bar", result.getQuery());
assertEquals("baz", result.getFragment());
URI expected = new URI("/foo?bar#baz");
assertEquals("Invalid result URI", expected, result.toUri());
result = UriComponentsBuilder.fromPath("/foo").build();
assertEquals("/foo", result.getPath());
assertEquals("/foo", result.getPath());
expected = new URI("/foo");
expected = new URI("/foo");
assertEquals("Invalid result URI", expected, result.toUri());
}
@Test
public void fromHierarchicalUri() throws URISyntaxException {
URI uri = new URI("http://example.com/foo?bar#baz");
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
assertEquals("http", result.getScheme());
assertEquals("example.com", result.getHost());
assertEquals("/foo", result.getPath());
assertEquals("bar", result.getQuery());
assertEquals("baz", result.getFragment());
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
assertEquals("http", result.getScheme());
assertEquals("example.com", result.getHost());
assertEquals("/foo", result.getPath());
assertEquals("bar", result.getQuery());
assertEquals("baz", result.getFragment());
assertEquals("Invalid result URI", uri, result.toUri());
}
@@ -81,24 +81,24 @@ public class UriComponentsBuilderTests {
@Test
public void fromOpaqueUri() throws URISyntaxException {
URI uri = new URI("mailto:foo@bar.com#baz");
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
assertEquals("mailto", result.getScheme());
assertEquals("foo@bar.com", result.getSchemeSpecificPart());
assertEquals("baz", result.getFragment());
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
assertEquals("mailto", result.getScheme());
assertEquals("foo@bar.com", result.getSchemeSpecificPart());
assertEquals("baz", result.getFragment());
assertEquals("Invalid result URI", uri, result.toUri());
}
// SPR-9317
@Test
public void fromUriEncodedQuery() throws URISyntaxException {
URI uri = new URI("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D");
String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0);
String fromUriString = UriComponentsBuilder.fromUriString(uri.toString()).build().getQueryParams().get("param").get(0);
@Test
public void fromUriEncodedQuery() throws URISyntaxException {
URI uri = new URI("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D");
String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0);
String fromUriString = UriComponentsBuilder.fromUriString(uri.toString()).build().getQueryParams().get("param").get(0);
assertEquals(fromUri, fromUriString);
}
assertEquals(fromUri, fromUriString);
}
@Test
public void fromUriString() {
@@ -115,42 +115,42 @@ public class UriComponentsBuilderTests {
result = UriComponentsBuilder.fromUriString(
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)")
.build();
assertEquals("http", result.getScheme());
assertEquals("arjen:foobar", result.getUserInfo());
assertEquals("java.sun.com", result.getHost());
assertEquals(80, result.getPort());
assertEquals("/javase/6/docs/api/java/util/BitSet.html", result.getPath());
assertEquals("foo=bar", result.getQuery());
assertEquals("http", result.getScheme());
assertEquals("arjen:foobar", result.getUserInfo());
assertEquals("java.sun.com", result.getHost());
assertEquals(80, result.getPort());
assertEquals("/javase/6/docs/api/java/util/BitSet.html", result.getPath());
assertEquals("foo=bar", result.getQuery());
MultiValueMap<String, String> expectedQueryParams = new LinkedMultiValueMap<String, String>(1);
expectedQueryParams.add("foo", "bar");
assertEquals(expectedQueryParams, result.getQueryParams());
assertEquals("and(java.util.BitSet)", result.getFragment());
assertEquals("and(java.util.BitSet)", result.getFragment());
result = UriComponentsBuilder.fromUriString("mailto:java-net@java.sun.com#baz").build();
assertEquals("mailto", result.getScheme());
assertNull(result.getUserInfo());
assertNull(result.getHost());
assertEquals(-1, result.getPort());
assertEquals("java-net@java.sun.com", result.getSchemeSpecificPart());
assertNull(result.getPath());
assertNull(result.getQuery());
assertEquals("baz", result.getFragment());
result = UriComponentsBuilder.fromUriString("mailto:java-net@java.sun.com#baz").build();
assertEquals("mailto", result.getScheme());
assertNull(result.getUserInfo());
assertNull(result.getHost());
assertEquals(-1, result.getPort());
assertEquals("java-net@java.sun.com", result.getSchemeSpecificPart());
assertNull(result.getPath());
assertNull(result.getQuery());
assertEquals("baz", result.getFragment());
result = UriComponentsBuilder.fromUriString("docs/guide/collections/designfaq.html#28").build();
assertNull(result.getScheme());
assertNull(result.getUserInfo());
assertNull(result.getHost());
assertEquals(-1, result.getPort());
assertEquals("docs/guide/collections/designfaq.html", result.getPath());
assertNull(result.getQuery());
assertEquals("28", result.getFragment());
result = UriComponentsBuilder.fromUriString("docs/guide/collections/designfaq.html#28").build();
assertNull(result.getScheme());
assertNull(result.getUserInfo());
assertNull(result.getHost());
assertEquals(-1, result.getPort());
assertEquals("docs/guide/collections/designfaq.html", result.getPath());
assertNull(result.getQuery());
assertEquals("28", result.getFragment());
}
// SPR-9832
@Test
public void fromUriStringQueryParamWithReservedCharInValue() throws URISyntaxException {
String uri = "http://www.google.com/ig/calculator?q=1USD=?EUR";
String uri = "http://www.google.com/ig/calculator?q=1USD=?EUR";
UriComponents result = UriComponentsBuilder.fromUriString(uri).build();
assertEquals("q=1USD=?EUR", result.getQuery());

View File

@@ -26,25 +26,25 @@ import static org.junit.Assert.*;
/** @author Arjen Poutsma */
public class UriComponentsTests {
@Test
public void encode() {
UriComponents uriComponents = UriComponentsBuilder.fromPath("/hotel list").build();
UriComponents encoded = uriComponents.encode();
assertEquals("/hotel%20list", encoded.getPath());
}
@Test
public void encode() {
UriComponents uriComponents = UriComponentsBuilder.fromPath("/hotel list").build();
UriComponents encoded = uriComponents.encode();
assertEquals("/hotel%20list", encoded.getPath());
}
@Test
public void toUriEncoded() throws URISyntaxException {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
UriComponents encoded = uriComponents.encode();
assertEquals(new URI("http://example.com/hotel%20list/Z%C3%BCrich"), encoded.toUri());
}
@Test
public void toUriEncoded() throws URISyntaxException {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
UriComponents encoded = uriComponents.encode();
assertEquals(new URI("http://example.com/hotel%20list/Z%C3%BCrich"), encoded.toUri());
}
@Test
public void toUriNotEncoded() throws URISyntaxException {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
assertEquals(new URI("http://example.com/hotel%20list/Z\u00fcrich"), uriComponents.toUri());
}
@Test
public void toUriNotEncoded() throws URISyntaxException {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://example.com/hotel list/Z\u00fcrich").build();
assertEquals(new URI("http://example.com/hotel%20list/Z\u00fcrich"), uriComponents.toUri());
}
@Test
public void expand() {

View File

@@ -53,15 +53,15 @@ public class UriTemplateTests {
template.expand("1");
}
@Test
public void expandMap() throws Exception {
Map<String, String> uriVariables = new HashMap<String, String>(2);
uriVariables.put("booking", "42");
uriVariables.put("hotel", "1");
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
URI result = template.expand(uriVariables);
assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
}
@Test
public void expandMap() throws Exception {
Map<String, String> uriVariables = new HashMap<String, String>(2);
uriVariables.put("booking", "42");
uriVariables.put("hotel", "1");
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
URI result = template.expand(uriVariables);
assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
}
@Test
public void expandMapDuplicateVariables() throws Exception {
@@ -81,13 +81,13 @@ public class UriTemplateTests {
assertEquals("Invalid expanded template", new URI("http://example.com/hotels/1/bookings/42"), result);
}
@Test
public void expandMapEncoded() throws Exception {
Map<String, String> uriVariables = Collections.singletonMap("hotel", "Z\u00fcrich");
UriTemplate template = new UriTemplate("http://example.com/hotel list/{hotel}");
URI result = template.expand(uriVariables);
assertEquals("Invalid expanded template", new URI("http://example.com/hotel%20list/Z%C3%BCrich"), result);
}
@Test
public void expandMapEncoded() throws Exception {
Map<String, String> uriVariables = Collections.singletonMap("hotel", "Z\u00fcrich");
UriTemplate template = new UriTemplate("http://example.com/hotel list/{hotel}");
URI result = template.expand(uriVariables);
assertEquals("Invalid expanded template", new URI("http://example.com/hotel%20list/Z%C3%BCrich"), result);
}
@Test(expected = IllegalArgumentException.class)
public void expandMapUnboundVariables() throws Exception {