Polishing
This commit is contained in:
parent
a3163ceb88
commit
8cc0fa5ae1
|
|
@ -48,7 +48,7 @@ import org.springframework.util.ReflectionUtils;
|
|||
*/
|
||||
abstract class AbstractRecursiveAnnotationVisitor extends AnnotationVisitor {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
protected final AnnotationAttributes attributes;
|
||||
|
||||
|
|
@ -94,10 +94,10 @@ abstract class AbstractRecursiveAnnotationVisitor extends AnnotationVisitor {
|
|||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
this.logger.debug("Failed to classload enum type while reading annotation metadata", ex);
|
||||
logger.debug("Failed to classload enum type while reading annotation metadata", ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
this.logger.warn("Could not access enum value while reading annotation metadata", ex);
|
||||
logger.warn("Could not access enum value while reading annotation metadata", ex);
|
||||
}
|
||||
return valueToUse;
|
||||
}
|
||||
|
|
@ -169,7 +169,6 @@ class RecursiveAnnotationAttributesVisitor extends AbstractRecursiveAnnotationVi
|
|||
|
||||
private final String annotationType;
|
||||
|
||||
|
||||
public RecursiveAnnotationAttributesVisitor(String annotationType, AnnotationAttributes attributes,
|
||||
ClassLoader classLoader) {
|
||||
super(classLoader, attributes);
|
||||
|
|
@ -183,8 +182,8 @@ class RecursiveAnnotationAttributesVisitor extends AbstractRecursiveAnnotationVi
|
|||
doVisitEnd(annotationClass);
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
this.logger.debug("Failed to class-load type while reading annotation metadata. "
|
||||
+ "This is a non-fatal error, but certain annotation metadata may be unavailable.", ex);
|
||||
logger.debug("Failed to class-load type while reading annotation metadata. " +
|
||||
"This is a non-fatal error, but certain annotation metadata may be unavailable.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +245,6 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
|||
|
||||
private final Map<String, Set<String>> metaAnnotationMap;
|
||||
|
||||
|
||||
public AnnotationAttributesReadingVisitor(String annotationType,
|
||||
MultiValueMap<String, AnnotationAttributes> attributesMap, Map<String, Set<String>> metaAnnotationMap,
|
||||
ClassLoader classLoader) {
|
||||
|
|
@ -257,7 +255,6 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
|||
this.metaAnnotationMap = metaAnnotationMap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doVisitEnd(Class<?> annotationClass) {
|
||||
super.doVisitEnd(annotationClass);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
|
|
@ -19,8 +19,8 @@ package org.springframework.core.type.filter;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.springframework.core.type.ClassMetadata;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
|
||||
/**
|
||||
* Type filter that exposes a
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
|
|
@ -29,8 +29,8 @@ import org.aspectj.weaver.patterns.PatternParser;
|
|||
import org.aspectj.weaver.patterns.SimpleScope;
|
||||
import org.aspectj.weaver.patterns.TypePattern;
|
||||
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
|
||||
/**
|
||||
* Type filter that uses AspectJ type pattern for matching.
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
|||
|
||||
resolvers.addAll(getCustomArgumentResolvers());
|
||||
resolvers.add(new PayloadArgumentResolver(this.messageConverter,
|
||||
(this.validator != null ? this.validator : new NoopValidator())));
|
||||
(this.validator != null ? this.validator : new NoOpValidator())));
|
||||
|
||||
return resolvers;
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
|||
}
|
||||
|
||||
|
||||
private static final class NoopValidator implements Validator {
|
||||
private static final class NoOpValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
|||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
|
@ -57,11 +56,11 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
/**
|
||||
* Default builder for {@link MockHttpServletRequest} required as input to
|
||||
* perform request in {@link MockMvc}.
|
||||
* Default builder for {@link MockHttpServletRequest} required as input to perform
|
||||
* requests in {@link MockMvc}.
|
||||
*
|
||||
* <p>Application tests will typically access this builder through the static
|
||||
* factory methods in {@link MockMvcBuilders}.
|
||||
* <p>Application tests will typically access this builder through the static factory
|
||||
* methods in {@link org.springframework.test.web.servlet.setup.MockMvcBuilders}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Arjen Poutsma
|
||||
|
|
@ -70,7 +69,6 @@ import org.springframework.web.util.UriUtils;
|
|||
public class MockHttpServletRequestBuilder
|
||||
implements ConfigurableSmartRequestBuilder<MockHttpServletRequestBuilder>, Mergeable {
|
||||
|
||||
|
||||
private final HttpMethod method;
|
||||
|
||||
private final UriComponents uriComponents;
|
||||
|
|
@ -144,6 +142,7 @@ public class MockHttpServletRequestBuilder
|
|||
this.uriComponents = UriComponentsBuilder.fromUri(uri).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a request parameter to the {@link MockHttpServletRequest}.
|
||||
* If called more than once, the new values are added.
|
||||
|
|
@ -429,6 +428,7 @@ public class MockHttpServletRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @return always returns {@code true}.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
|
|
@ -18,20 +18,21 @@ package org.springframework.web.filter;
|
|||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test for {@link AbstractRequestLoggingFilter} and sub classes.
|
||||
*
|
||||
|
|
@ -41,11 +42,13 @@ public class RequestLoggingFilterTests {
|
|||
|
||||
private MyRequestLoggingFilter filter;
|
||||
|
||||
|
||||
@Before
|
||||
public void createFilter() throws Exception {
|
||||
filter = new MyRequestLoggingFilter();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void uri() throws Exception {
|
||||
final MockHttpServletRequest request = new MockHttpServletRequest("POST", "/hotels");
|
||||
|
|
@ -53,17 +56,17 @@ public class RequestLoggingFilterTests {
|
|||
|
||||
request.setQueryString("booking=42");
|
||||
|
||||
FilterChain filterChain = new NoopFilterChain();
|
||||
FilterChain filterChain = new NoOpFilterChain();
|
||||
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertNotNull(filter.beforeRequestMessage);
|
||||
assertTrue(filter.beforeRequestMessage.indexOf("uri=/hotel") != -1);
|
||||
assertFalse(filter.beforeRequestMessage.indexOf("booking=42") != -1);
|
||||
assertTrue(filter.beforeRequestMessage.contains("uri=/hotel"));
|
||||
assertFalse(filter.beforeRequestMessage.contains("booking=42"));
|
||||
|
||||
assertNotNull(filter.afterRequestMessage);
|
||||
assertTrue(filter.afterRequestMessage.indexOf("uri=/hotel") != -1);
|
||||
assertFalse(filter.afterRequestMessage.indexOf("booking=42") != -1);
|
||||
assertTrue(filter.afterRequestMessage.contains("uri=/hotel"));
|
||||
assertFalse(filter.afterRequestMessage.contains("booking=42"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -75,15 +78,15 @@ public class RequestLoggingFilterTests {
|
|||
|
||||
request.setQueryString("booking=42");
|
||||
|
||||
FilterChain filterChain = new NoopFilterChain();
|
||||
FilterChain filterChain = new NoOpFilterChain();
|
||||
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertNotNull(filter.beforeRequestMessage);
|
||||
assertTrue(filter.beforeRequestMessage.indexOf("uri=/hotels?booking=42") != -1);
|
||||
assertTrue(filter.beforeRequestMessage.contains("uri=/hotels?booking=42"));
|
||||
|
||||
assertNotNull(filter.afterRequestMessage);
|
||||
assertTrue(filter.afterRequestMessage.indexOf("uri=/hotels?booking=42") != -1);
|
||||
assertTrue(filter.afterRequestMessage.contains("uri=/hotels?booking=42"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -109,7 +112,7 @@ public class RequestLoggingFilterTests {
|
|||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertNotNull(filter.afterRequestMessage);
|
||||
assertTrue(filter.afterRequestMessage.indexOf("Hello World") != -1);
|
||||
assertTrue(filter.afterRequestMessage.contains("Hello World"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -135,7 +138,7 @@ public class RequestLoggingFilterTests {
|
|||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertNotNull(filter.afterRequestMessage);
|
||||
assertTrue(filter.afterRequestMessage.indexOf(requestBody) != -1);
|
||||
assertTrue(filter.afterRequestMessage.contains(requestBody));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -162,10 +165,11 @@ public class RequestLoggingFilterTests {
|
|||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertNotNull(filter.afterRequestMessage);
|
||||
assertTrue(filter.afterRequestMessage.indexOf("Hel") != -1);
|
||||
assertFalse(filter.afterRequestMessage.indexOf("Hello World") != -1);
|
||||
assertTrue(filter.afterRequestMessage.contains("Hel"));
|
||||
assertFalse(filter.afterRequestMessage.contains("Hello World"));
|
||||
}
|
||||
|
||||
|
||||
private static class MyRequestLoggingFilter extends AbstractRequestLoggingFilter {
|
||||
|
||||
private String beforeRequestMessage;
|
||||
|
|
@ -183,7 +187,8 @@ public class RequestLoggingFilterTests {
|
|||
}
|
||||
}
|
||||
|
||||
private static class NoopFilterChain implements FilterChain {
|
||||
|
||||
private static class NoOpFilterChain implements FilterChain {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
|
|
|
|||
Loading…
Reference in New Issue