Browse Source

Polishing

pull/766/head
Juergen Hoeller 11 years ago
parent
commit
514eb4281c
  1. 16
      spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java
  2. 1
      spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java
  3. 15
      spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java
  4. 13
      spring-web/src/test/java/org/springframework/http/client/AbstractJettyServerTestCase.java

16
spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java

@ -155,17 +155,17 @@ public class EncodedResource implements InputStreamSource { @@ -155,17 +155,17 @@ public class EncodedResource implements InputStreamSource {
@Override
public boolean equals(Object obj) {
if (obj == this) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (obj instanceof EncodedResource) {
EncodedResource that = (EncodedResource) obj;
return (this.resource.equals(that.resource) &&
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
ObjectUtils.nullSafeEquals(this.encoding, that.encoding));
if (!(other instanceof EncodedResource)) {
return false;
}
return false;
EncodedResource otherResource = (EncodedResource) other;
return (this.resource.equals(otherResource.resource) &&
ObjectUtils.nullSafeEquals(this.charset, otherResource.charset) &&
ObjectUtils.nullSafeEquals(this.encoding, otherResource.encoding));
}
@Override

1
spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java

@ -41,7 +41,6 @@ import org.springframework.http.HttpMethod; @@ -41,7 +41,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.SettableListenableFuture;
/**
* {@link org.springframework.http.client.ClientHttpRequest} implementation that uses
* Netty 4 to execute requests.

15
spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@ -23,8 +23,6 @@ import java.util.Arrays; @@ -23,8 +23,6 @@ import java.util.Arrays;
import java.util.Locale;
import org.junit.After;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@ -36,12 +34,16 @@ import org.springframework.http.StreamingHttpOutputMessage; @@ -36,12 +34,16 @@ import org.springframework.http.StreamingHttpOutputMessage;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StreamUtils;
/** @author Arjen Poutsma */
public abstract class AbstractHttpRequestFactoryTestCase extends
AbstractJettyServerTestCase {
import static org.junit.Assert.*;
/**
* @author Arjen Poutsma
*/
public abstract class AbstractHttpRequestFactoryTestCase extends AbstractJettyServerTestCase {
protected ClientHttpRequestFactory factory;
@Before
public final void createFactory() throws Exception {
factory = createRequestFactory();
@ -60,6 +62,7 @@ public abstract class AbstractHttpRequestFactoryTestCase extends @@ -60,6 +62,7 @@ public abstract class AbstractHttpRequestFactoryTestCase extends
protected abstract ClientHttpRequestFactory createRequestFactory();
@Test
public void status() throws Exception {
URI uri = new URI(baseUrl + "/status/notfound");

13
spring-web/src/test/java/org/springframework/http/client/AbstractJettyServerTestCase.java

@ -38,13 +38,16 @@ import org.junit.BeforeClass; @@ -38,13 +38,16 @@ import org.junit.BeforeClass;
import org.springframework.util.SocketUtils;
import org.springframework.util.StreamUtils;
/** @author Arjen Poutsma */
/**
* @author Arjen Poutsma
*/
public abstract class AbstractJettyServerTestCase {
protected static String baseUrl;
private static Server jettyServer;
@BeforeClass
public static void startJettyServer() throws Exception {
int port = SocketUtils.findAvailableTcpPort();
@ -77,6 +80,7 @@ public abstract class AbstractJettyServerTestCase { @@ -77,6 +80,7 @@ public abstract class AbstractJettyServerTestCase {
}
}
/**
* Servlet that sets a given status code.
*/
@ -96,6 +100,7 @@ public abstract class AbstractJettyServerTestCase { @@ -96,6 +100,7 @@ public abstract class AbstractJettyServerTestCase {
}
}
@SuppressWarnings("serial")
private static class MethodServlet extends GenericServlet {
@ -114,6 +119,7 @@ public abstract class AbstractJettyServerTestCase { @@ -114,6 +119,7 @@ public abstract class AbstractJettyServerTestCase {
}
}
@SuppressWarnings("serial")
private static class PostServlet extends MethodServlet {
@ -138,6 +144,7 @@ public abstract class AbstractJettyServerTestCase { @@ -138,6 +144,7 @@ public abstract class AbstractJettyServerTestCase {
}
}
@SuppressWarnings("serial")
private static class EchoServlet extends HttpServlet {
@ -161,12 +168,12 @@ public abstract class AbstractJettyServerTestCase { @@ -161,12 +168,12 @@ public abstract class AbstractJettyServerTestCase {
}
}
@SuppressWarnings("serial")
private static class ParameterServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Map<String, String[]> parameters = req.getParameterMap();
assertEquals(2, parameters.size());

Loading…
Cancel
Save