parent
a78066830b
commit
020e51cb96
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -99,13 +99,14 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
|||
// accessibility in a SecurityManager environment.
|
||||
if (Modifier.isPublic(annotation.annotationType().getModifiers())) {
|
||||
String annotationName = annotation.annotationType().getName();
|
||||
this.attributesMap.add(annotationName, AnnotationUtils.getAnnotationAttributes(annotation, false, true));
|
||||
this.attributesMap.add(annotationName,
|
||||
AnnotationUtils.getAnnotationAttributes(annotation, false, true));
|
||||
}
|
||||
for (Annotation metaMetaAnnotation : annotation.annotationType().getAnnotations()) {
|
||||
recursivelyCollectMetaAnnotations(visited, metaMetaAnnotation);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to introspect meta-annotations on [" + annotation + "]: " + ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -94,7 +94,7 @@ abstract class AnnotationReadingVisitorUtils {
|
|||
}
|
||||
entry.setValue(value);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Throwable ex) {
|
||||
// Class not found - can't resolve class reference in annotation attribute.
|
||||
result.put(entry.getKey(), ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -46,7 +46,7 @@ public class RequestScopeTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setup() throws Exception {
|
||||
this.beanFactory.registerScope("request", new RequestScope());
|
||||
this.beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver());
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
|
|
@ -59,6 +59,7 @@ public class RequestScopeTests {
|
|||
RequestContextHolder.setRequestAttributes(null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getFromScope() throws Exception {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -38,17 +38,18 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class RequestScopedProxyTests {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
public void setup() {
|
||||
this.beanFactory.registerScope("request", new RequestScope());
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.loadBeanDefinitions(new ClassPathResource("requestScopedProxyTests.xml", getClass()));
|
||||
this.beanFactory.preInstantiateSingletons();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetFromScope() throws Exception {
|
||||
String name = "requestScopedObject";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
|
@ -34,6 +32,8 @@ import org.junit.runners.Parameterized.Parameters;
|
|||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Parameterized tests for ServletWebRequest
|
||||
* @author Juergen Hoeller
|
||||
|
|
@ -66,8 +66,9 @@ public class ServletWebRequestHttpMethodsTests {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
currentDate = new Date();
|
||||
dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
|
@ -76,6 +77,7 @@ public class ServletWebRequestHttpMethodsTests {
|
|||
request = new ServletWebRequest(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkNotModifiedNon2xxStatus() {
|
||||
long epochTime = currentDate.getTime();
|
||||
|
|
@ -87,8 +89,7 @@ public class ServletWebRequestHttpMethodsTests {
|
|||
assertNull(servletResponse.getHeader("Last-Modified"));
|
||||
}
|
||||
|
||||
// SPR-13516
|
||||
@Test
|
||||
@Test // SPR-13516
|
||||
public void checkNotModifiedInvalidStatus() {
|
||||
long epochTime = currentDate.getTime();
|
||||
servletRequest.addHeader("If-Modified-Since", epochTime);
|
||||
|
|
@ -97,7 +98,7 @@ public class ServletWebRequestHttpMethodsTests {
|
|||
assertFalse(request.checkNotModified(epochTime));
|
||||
}
|
||||
|
||||
@Test // SPR-14559
|
||||
@Test // SPR-14559
|
||||
public void checkNotModifiedInvalidIfNoneMatchHeader() {
|
||||
String eTag = "\"etagvalue\"";
|
||||
servletRequest.addHeader("If-None-Match", "missingquotes");
|
||||
|
|
@ -223,8 +224,7 @@ public class ServletWebRequestHttpMethodsTests {
|
|||
assertEquals(dateFormat.format(currentDate.getTime()), servletResponse.getHeader("Last-Modified"));
|
||||
}
|
||||
|
||||
// SPR-14224
|
||||
@Test
|
||||
@Test // SPR-14224
|
||||
public void checkNotModifiedETagAndModifiedTimestamp() {
|
||||
String eTag = "\"Foo\"";
|
||||
servletRequest.addHeader("If-None-Match", eTag);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -16,11 +16,8 @@
|
|||
|
||||
package org.springframework.web.context.request;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -35,6 +32,8 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
|
|||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
|
|
@ -46,13 +45,15 @@ public class ServletWebRequestTests {
|
|||
|
||||
private ServletWebRequest request;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
servletRequest = new MockHttpServletRequest();
|
||||
servletResponse = new MockHttpServletResponse();
|
||||
request = new ServletWebRequest(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void parameters() {
|
||||
servletRequest.addParameter("param1", "value1");
|
||||
|
|
@ -114,4 +115,4 @@ public class ServletWebRequestTests {
|
|||
assertNull(request.getNativeResponse(MultipartRequest.class));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -44,7 +44,7 @@ public class WebAsyncManagerTests {
|
|||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
this.servletRequest = new MockHttpServletRequest();
|
||||
this.asyncManager = WebAsyncUtils.getAsyncManager(servletRequest);
|
||||
this.asyncManager.setTaskExecutor(new SyncTaskExecutor());
|
||||
|
|
@ -54,6 +54,7 @@ public class WebAsyncManagerTests {
|
|||
reset(this.asyncWebRequest);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void startAsyncProcessingWithoutAsyncWebRequest() throws Exception {
|
||||
WebAsyncManager manager = WebAsyncUtils.getAsyncManager(new MockHttpServletRequest());
|
||||
|
|
@ -87,7 +88,7 @@ public class WebAsyncManagerTests {
|
|||
assertTrue(this.asyncManager.isConcurrentHandlingStarted());
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void setAsyncWebRequestAfterAsyncStarted() {
|
||||
this.asyncWebRequest.startAsync();
|
||||
this.asyncManager.setAsyncWebRequest(null);
|
||||
|
|
@ -233,7 +234,7 @@ public class WebAsyncManagerTests {
|
|||
given(this.asyncWebRequest.getNativeRequest(HttpServletRequest.class)).willReturn(this.servletRequest);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
WebAsyncTask<Object> asyncTask = new WebAsyncTask<Object>(1000L, executor, mock(Callable.class));
|
||||
WebAsyncTask<Object> asyncTask = new WebAsyncTask<>(1000L, executor, mock(Callable.class));
|
||||
this.asyncManager.startCallableProcessing(asyncTask);
|
||||
|
||||
verify(executor).submit((Runnable) notNull());
|
||||
|
|
@ -256,7 +257,7 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startDeferredResultProcessing() throws Exception {
|
||||
DeferredResult<String> deferredResult = new DeferredResult<String>(1000L);
|
||||
DeferredResult<String> deferredResult = new DeferredResult<>(1000L);
|
||||
String concurrentResult = "abc";
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
|
||||
|
|
@ -278,7 +279,7 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startDeferredResultProcessingBeforeConcurrentHandlingException() throws Exception {
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
Exception exception = new Exception();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
|
||||
|
|
@ -303,7 +304,7 @@ public class WebAsyncManagerTests {
|
|||
@Test
|
||||
public void startDeferredResultProcessingPreProcessException() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
Exception exception = new Exception();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
|
||||
|
|
@ -323,7 +324,7 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startDeferredResultProcessingPostProcessException() throws Exception {
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
Exception exception = new Exception();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
|
|
@ -28,12 +28,9 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
|
|||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.mock;
|
||||
import static org.mockito.BDDMockito.verify;
|
||||
import static org.springframework.web.context.request.async.CallableProcessingInterceptor.RESULT_NONE;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
import static org.springframework.web.context.request.async.CallableProcessingInterceptor.*;
|
||||
|
||||
/**
|
||||
* {@link WebAsyncManager} tests where container-triggered timeout/completion
|
||||
|
|
@ -53,8 +50,9 @@ public class WebAsyncManagerTimeoutTests {
|
|||
|
||||
private MockHttpServletResponse servletResponse;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public void setup() {
|
||||
this.servletRequest = new MockHttpServletRequest("GET", "/test");
|
||||
this.servletRequest.setAsyncSupported(true);
|
||||
this.servletResponse = new MockHttpServletResponse();
|
||||
|
|
@ -67,9 +65,9 @@ public class WebAsyncManagerTimeoutTests {
|
|||
this.asyncManager.setAsyncWebRequest(this.asyncWebRequest);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void startCallableProcessingTimeoutAndComplete() throws Exception {
|
||||
|
||||
StubCallable callable = new StubCallable();
|
||||
|
||||
CallableProcessingInterceptor interceptor = mock(CallableProcessingInterceptor.class);
|
||||
|
|
@ -92,7 +90,7 @@ public class WebAsyncManagerTimeoutTests {
|
|||
public void startCallableProcessingTimeoutAndResumeThroughCallback() throws Exception {
|
||||
|
||||
StubCallable callable = new StubCallable();
|
||||
WebAsyncTask<Object> webAsyncTask = new WebAsyncTask<Object>(callable);
|
||||
WebAsyncTask<Object> webAsyncTask = new WebAsyncTask<>(callable);
|
||||
webAsyncTask.onTimeout(new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
|
|
@ -153,7 +151,7 @@ public class WebAsyncManagerTimeoutTests {
|
|||
@Test
|
||||
public void startDeferredResultProcessingTimeoutAndComplete() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class);
|
||||
given(interceptor.handleTimeout(this.asyncWebRequest, deferredResult)).willReturn(true);
|
||||
|
|
@ -175,7 +173,7 @@ public class WebAsyncManagerTimeoutTests {
|
|||
@Test
|
||||
public void startDeferredResultProcessingTimeoutAndResumeWithDefaultResult() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>(null, 23);
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>(null, 23);
|
||||
this.asyncManager.startDeferredResultProcessing(deferredResult);
|
||||
|
||||
AsyncEvent event = null;
|
||||
|
|
@ -189,7 +187,7 @@ public class WebAsyncManagerTimeoutTests {
|
|||
@Test
|
||||
public void startDeferredResultProcessingTimeoutAndResumeThroughCallback() throws Exception {
|
||||
|
||||
final DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
final DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
deferredResult.onTimeout(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -210,7 +208,7 @@ public class WebAsyncManagerTimeoutTests {
|
|||
@Test
|
||||
public void startDeferredResultProcessingTimeoutAndResumeThroughInterceptor() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() {
|
||||
@Override
|
||||
|
|
@ -234,7 +232,7 @@ public class WebAsyncManagerTimeoutTests {
|
|||
@Test
|
||||
public void startDeferredResultProcessingAfterTimeoutException() throws Exception {
|
||||
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<Integer>();
|
||||
DeferredResult<Integer> deferredResult = new DeferredResult<>();
|
||||
final Exception exception = new Exception();
|
||||
|
||||
DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue