Polishing

This commit is contained in:
Juergen Hoeller
2016-08-09 12:59:54 +02:00
parent 6924f00f8c
commit 9520a593bd
7 changed files with 29 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -93,7 +93,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
/** Logger available to subclasses; static to optimize serialization */ /** Logger available to subclasses; static to optimize serialization */
protected final static Log logger = LogFactory.getLog(CglibAopProxy.class); protected static final Log logger = LogFactory.getLog(CglibAopProxy.class);
/** Keeps track of the Classes that we have validated for final methods */ /** Keeps track of the Classes that we have validated for final methods */
private static final Map<Class<?>, Boolean> validatedClasses = new WeakHashMap<Class<?>, Boolean>(); private static final Map<Class<?>, Boolean> validatedClasses = new WeakHashMap<Class<?>, Boolean>();
@@ -294,13 +294,13 @@ final class CglibAopProxy implements AopProxy, Serializable {
Callback targetDispatcher = isStatic ? Callback targetDispatcher = isStatic ?
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp(); new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp();
Callback[] mainCallbacks = new Callback[]{ Callback[] mainCallbacks = new Callback[] {
aopInterceptor, // for normal advice aopInterceptor, // for normal advice
targetInterceptor, // invoke target without considering advice, if optimized targetInterceptor, // invoke target without considering advice, if optimized
new SerializableNoOp(), // no override for methods mapped to this new SerializableNoOp(), // no override for methods mapped to this
targetDispatcher, this.advisedDispatcher, targetDispatcher, this.advisedDispatcher,
new EqualsInterceptor(this.advised), new EqualsInterceptor(this.advised),
new HashCodeInterceptor(this.advised) new HashCodeInterceptor(this.advised)
}; };
Callback[] callbacks; Callback[] callbacks;
@@ -678,10 +678,11 @@ final class CglibAopProxy implements AopProxy, Serializable {
private final MethodProxy methodProxy; private final MethodProxy methodProxy;
private boolean protectedMethod; private final boolean protectedMethod;
public CglibMethodInvocation(Object proxy, Object target, Method method, Object[] arguments, public CglibMethodInvocation(Object proxy, Object target, Method method, Object[] arguments,
Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers, MethodProxy methodProxy) { Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers, MethodProxy methodProxy) {
super(proxy, target, method, arguments, targetClass, interceptorsAndDynamicMethodMatchers); super(proxy, target, method, arguments, targetClass, interceptorsAndDynamicMethodMatchers);
this.methodProxy = methodProxy; this.methodProxy = methodProxy;
this.protectedMethod = Modifier.isProtected(method.getModifiers()); this.protectedMethod = Modifier.isProtected(method.getModifiers());
@@ -800,8 +801,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Method has advice and optimisations are enabled: " + method); logger.debug("Method has advice and optimisations are enabled: " + method);
} }
// We know that we are optimising so we can use the // We know that we are optimising so we can use the FixedStaticChainInterceptors.
// FixedStaticChainInterceptors.
int index = this.fixedInterceptorMap.get(key); int index = this.fixedInterceptorMap.get(key);
return (index + this.fixedInterceptorOffset); return (index + this.fixedInterceptorOffset);
} }

View File

@@ -16,8 +16,6 @@
package org.springframework.test.web.client; package org.springframework.test.web.client;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
@@ -36,6 +34,8 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
/** /**
* A {@link ClientHttpRequestFactory} for requests executed via {@link MockMvc}. * A {@link ClientHttpRequestFactory} for requests executed via {@link MockMvc}.
* *

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.client; package org.springframework.test.web.client;
import java.io.IOException; import java.io.IOException;

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.client; package org.springframework.test.web.client;
import java.io.IOException; import java.io.IOException;

View File

@@ -13,24 +13,24 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.client.match; package org.springframework.test.web.client.match;
import static org.springframework.test.util.AssertionErrors.assertEquals;
import static org.springframework.test.util.AssertionErrors.assertTrue;
import static org.springframework.test.util.MatcherAssertionErrors.assertThat;
import java.io.IOException; import java.io.IOException;
import javax.xml.transform.Source; import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.w3c.dom.Node;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequest; import org.springframework.http.client.ClientHttpRequest;
import org.springframework.mock.http.client.MockClientHttpRequest; import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.test.util.XmlExpectationsHelper; import org.springframework.test.util.XmlExpectationsHelper;
import org.springframework.test.web.client.RequestMatcher; import org.springframework.test.web.client.RequestMatcher;
import org.w3c.dom.Node;
import static org.hamcrest.MatcherAssert.*;
import static org.springframework.test.util.AssertionErrors.*;
/** /**
* Factory for request content {@code RequestMatcher}'s. An instance of this * Factory for request content {@code RequestMatcher}'s. An instance of this
@@ -185,8 +185,8 @@ public class ContentRequestMatchers {
MockClientHttpRequest mockRequest = (MockClientHttpRequest) request; MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
matchInternal(mockRequest); matchInternal(mockRequest);
} }
catch (Exception e) { catch (Exception ex) {
throw new AssertionError("Failed to parse expected or actual XML request content: " + e.getMessage()); throw new AssertionError("Failed to parse expected or actual XML request content: " + ex.getMessage());
} }
} }

View File

@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.client.match; package org.springframework.test.web.client.match;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.springframework.http.client.ClientHttpRequest; import org.springframework.http.client.ClientHttpRequest;
import org.springframework.mock.http.client.MockClientHttpRequest; import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.test.util.JsonPathExpectationsHelper; import org.springframework.test.util.JsonPathExpectationsHelper;
@@ -51,6 +53,7 @@ public class JsonPathRequestMatchers {
this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args); this.jsonPathHelper = new JsonPathExpectationsHelper(expression, args);
} }
/** /**
* Evaluate the JSONPath and assert the resulting value with the given {@code Matcher}. * Evaluate the JSONPath and assert the resulting value with the given {@code Matcher}.
*/ */

View File

@@ -13,20 +13,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.test.web.client.match; package org.springframework.test.web.client.match;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathExpressionException;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.w3c.dom.Node;
import org.springframework.http.client.ClientHttpRequest; import org.springframework.http.client.ClientHttpRequest;
import org.springframework.mock.http.client.MockClientHttpRequest; import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.test.util.XpathExpectationsHelper; import org.springframework.test.util.XpathExpectationsHelper;
import org.springframework.test.web.client.RequestMatcher; import org.springframework.test.web.client.RequestMatcher;
import org.w3c.dom.Node;
/** /**
* Factory methods for request content {@code RequestMatcher}'s using an XPath * Factory methods for request content {@code RequestMatcher}'s using an XPath
@@ -196,7 +195,6 @@ public class XpathRequestMatchers {
} }
protected abstract void matchInternal(MockClientHttpRequest request) throws Exception; protected abstract void matchInternal(MockClientHttpRequest request) throws Exception;
} }
} }