Browse Source

Polishing

pull/1929/head
Sam Brannen 7 years ago
parent
commit
1b54d2119d
  1. 10
      spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/RequestContextHolderTests.java

10
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/RequestContextHolderTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2018 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.
@ -36,13 +36,14 @@ import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.annotation.RequestScope; import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -71,7 +72,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
* @author Sam Brannen * @author Sam Brannen
* @see CustomRequestAttributesRequestContextHolderTests * @see CustomRequestAttributesRequestContextHolderTests
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringRunner.class)
@WebAppConfiguration @WebAppConfiguration
@ContextConfiguration @ContextConfiguration
@DirtiesContext @DirtiesContext
@ -163,7 +164,6 @@ public class RequestContextHolderTests {
@Bean @Bean
@RequestScope @RequestScope
@Scope(scopeName = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public RequestScopedService requestScopedService() { public RequestScopedService requestScopedService() {
return new RequestScopedService(); return new RequestScopedService();
} }
@ -174,7 +174,7 @@ public class RequestContextHolderTests {
} }
@Bean @Bean
@Scope(scopeName = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) @SessionScope
public SessionScopedService sessionScopedService() { public SessionScopedService sessionScopedService() {
return new SessionScopedService(); return new SessionScopedService();
} }

Loading…
Cancel
Save