This repository was archived by the owner on Dec 15, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +52
-65
lines changed
main/java/org/springframework/issues
java/org/springframework/issues Expand file tree Collapse file tree 6 files changed +52
-65
lines changed Original file line number Diff line number Diff line change 20
20
*/
21
21
public class DefaultFoo implements Foo {
22
22
23
- private Bar accessTokenRequest ;
23
+ private Bar bar ;
24
24
25
- public DefaultFoo (Bar accessTokenRequest ) {
26
- this .accessTokenRequest = accessTokenRequest ;
25
+ public DefaultFoo (Bar bar ) {
26
+ this .bar = bar ;
27
27
}
28
28
29
- public Bar getAccessTokenRequest () {
30
- return accessTokenRequest ;
29
+ public Bar getBar () {
30
+ return bar ;
31
31
}
32
32
33
33
}
Original file line number Diff line number Diff line change 20
20
*/
21
21
public interface Foo {
22
22
23
- Bar getAccessTokenRequest ();
23
+ Bar getBar ();
24
24
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 22
22
import org .springframework .context .i18n .LocaleContextHolder ;
23
23
import org .springframework .context .support .GenericXmlApplicationContext ;
24
24
import org .springframework .mock .web .MockHttpServletRequest ;
25
- import org .springframework .test .util .ReflectionTestUtils ;
26
25
import org .springframework .web .context .request .RequestContextHolder ;
27
26
import org .springframework .web .context .request .ServletRequestAttributes ;
28
27
@@ -48,13 +47,21 @@ public void clearScopes() {
48
47
}
49
48
50
49
@ Test
51
- public void test () {
50
+ public void testOK () {
51
+ request .setParameter ("foo" , "bar" );
52
+ GenericXmlApplicationContext context = new GenericXmlApplicationContext ("classpath:/ok-context.xml" );
53
+ Foo foo = context .getBean (Foo .class );
54
+ assertNotNull (foo );
55
+ assertEquals ("bar" , foo .getBar ().getFirst ("foo" ));
56
+ }
57
+
58
+ @ Test
59
+ public void testFails () {
52
60
request .setParameter ("foo" , "bar" );
53
61
GenericXmlApplicationContext context = new GenericXmlApplicationContext ("classpath:/test-context.xml" );
54
- HomeController controller = context .getBean (HomeController .class );
55
- Foo foo = (Foo ) ReflectionTestUtils .getField (controller , "context" );
62
+ Foo foo = context .getBean (Foo .class );
56
63
assertNotNull (foo );
57
- assertEquals ("bar" , foo .getAccessTokenRequest ().getFirst ("foo" ));
64
+ assertEquals ("bar" , foo .getBar ().getFirst ("foo" ));
58
65
}
59
66
60
67
}
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <beans xmlns =" http://www.springframework.org/schema/beans" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xmlns:aop=" http://www.springframework.org/schema/aop"
4
+ xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
5
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" >
6
+
7
+ <!-- Basic application beans. -->
8
+ <bean id =" viewResolver" class =" org.springframework.web.servlet.view.InternalResourceViewResolver" >
9
+ <property name =" prefix" value =" /WEB-INF/jsp/" />
10
+ <property name =" suffix" value =" .jsp" />
11
+ </bean >
12
+
13
+ <bean id =" foo" class =" org.springframework.issues.DefaultFoo" scope =" request" >
14
+ <aop : scoped-proxy proxy-target-class =" false" />
15
+ <constructor-arg ref =" bar" />
16
+ </bean >
17
+
18
+ <bean id =" bar" class =" org.springframework.issues.DefaultBar" scope =" request" >
19
+ <aop : scoped-proxy proxy-target-class =" false" />
20
+ <constructor-arg value =" #{request.parameterMap}" />
21
+ </bean >
22
+
23
+ <bean class =" org.springframework.beans.factory.config.CustomScopeConfigurer" >
24
+ <property name =" scopes" >
25
+ <map >
26
+ <entry key =" request" ><bean class =" org.springframework.web.context.request.RequestScope" /></entry >
27
+ <entry key =" session" ><bean class =" org.springframework.web.context.request.SessionScope" /></entry >
28
+ </map >
29
+ </property >
30
+ </bean >
31
+
32
+ </beans >
Original file line number Diff line number Diff line change 6
6
7
7
<bean id =" conversionService" class =" org.springframework.core.convert.support.DefaultConversionService" />
8
8
9
- <!-- Basic application beans. -->
10
- <bean id =" viewResolver" class =" org.springframework.web.servlet.view.InternalResourceViewResolver" >
11
- <property name =" prefix" value =" /WEB-INF/jsp/" />
12
- <property name =" suffix" value =" .jsp" />
13
- </bean >
14
-
15
- <bean class =" org.springframework.issues.HomeController" >
16
- <property name =" foo" ref =" foo" />
17
- </bean >
18
-
19
- <bean id =" foo" class =" org.springframework.issues.DefaultFoo" scope =" request" >
20
- <aop : scoped-proxy proxy-target-class =" false" />
21
- <constructor-arg ref =" tokenRequest" />
22
- </bean >
23
-
24
- <bean id =" tokenRequest" class =" org.springframework.issues.DefaultBar" scope =" request" >
25
- <aop : scoped-proxy proxy-target-class =" false" />
26
- <constructor-arg value =" #{request.parameterMap}" />
27
- </bean >
28
-
29
- <bean class =" org.springframework.beans.factory.config.CustomScopeConfigurer" >
30
- <property name =" scopes" >
31
- <map >
32
- <entry key =" request" ><bean class =" org.springframework.web.context.request.RequestScope" /></entry >
33
- <entry key =" session" ><bean class =" org.springframework.web.context.request.SessionScope" /></entry >
34
- </map >
35
- </property >
36
- </bean >
37
-
9
+ <import resource =" ok-context.xml" />
10
+
38
11
</beans >
You can’t perform that action at this time.
0 commit comments