1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
39
39
* @author Juergen Hoeller
40
40
* @author Chris Beams
41
41
*/
42
- public class ScopedProxyTests {
42
+ class ScopedProxyTests {
43
43
44
44
private static final Class <?> CLASS = ScopedProxyTests .class ;
45
45
private static final String CLASSNAME = CLASS .getSimpleName ();
@@ -51,27 +51,24 @@ public class ScopedProxyTests {
51
51
52
52
53
53
@ Test // SPR-2108
54
- public void testProxyAssignable () throws Exception {
54
+ void testProxyAssignable () {
55
55
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
56
56
new XmlBeanDefinitionReader (bf ).loadBeanDefinitions (MAP_CONTEXT );
57
57
Object baseMap = bf .getBean ("singletonMap" );
58
- boolean condition = baseMap instanceof Map ;
59
- assertThat (condition ).isTrue ();
58
+ assertThat (baseMap instanceof Map ).isTrue ();
60
59
}
61
60
62
61
@ Test
63
- public void testSimpleProxy () throws Exception {
62
+ void testSimpleProxy () {
64
63
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
65
64
new XmlBeanDefinitionReader (bf ).loadBeanDefinitions (MAP_CONTEXT );
66
65
Object simpleMap = bf .getBean ("simpleMap" );
67
- boolean condition1 = simpleMap instanceof Map ;
68
- assertThat (condition1 ).isTrue ();
69
- boolean condition = simpleMap instanceof HashMap ;
70
- assertThat (condition ).isTrue ();
66
+ assertThat (simpleMap instanceof Map ).isTrue ();
67
+ assertThat (simpleMap instanceof HashMap ).isTrue ();
71
68
}
72
69
73
70
@ Test
74
- public void testScopedOverride () throws Exception {
71
+ void testScopedOverride () {
75
72
GenericApplicationContext ctx = new GenericApplicationContext ();
76
73
new XmlBeanDefinitionReader (ctx ).loadBeanDefinitions (OVERRIDE_CONTEXT );
77
74
SimpleMapScope scope = new SimpleMapScope ();
@@ -87,7 +84,7 @@ public void testScopedOverride() throws Exception {
87
84
}
88
85
89
86
@ Test
90
- public void testJdkScopedProxy () throws Exception {
87
+ void testJdkScopedProxy () throws Exception {
91
88
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
92
89
new XmlBeanDefinitionReader (bf ).loadBeanDefinitions (TESTBEAN_CONTEXT );
93
90
bf .setSerializationId ("X" );
@@ -97,8 +94,7 @@ public void testJdkScopedProxy() throws Exception {
97
94
ITestBean bean = (ITestBean ) bf .getBean ("testBean" );
98
95
assertThat (bean ).isNotNull ();
99
96
assertThat (AopUtils .isJdkDynamicProxy (bean )).isTrue ();
100
- boolean condition1 = bean instanceof ScopedObject ;
101
- assertThat (condition1 ).isTrue ();
97
+ assertThat (bean instanceof ScopedObject ).isTrue ();
102
98
ScopedObject scoped = (ScopedObject ) bean ;
103
99
assertThat (scoped .getTargetObject ().getClass ()).isEqualTo (TestBean .class );
104
100
bean .setAge (101 );
@@ -110,16 +106,15 @@ public void testJdkScopedProxy() throws Exception {
110
106
assertThat (deserialized ).isNotNull ();
111
107
assertThat (AopUtils .isJdkDynamicProxy (deserialized )).isTrue ();
112
108
assertThat (bean .getAge ()).isEqualTo (101 );
113
- boolean condition = deserialized instanceof ScopedObject ;
114
- assertThat (condition ).isTrue ();
109
+ assertThat (deserialized instanceof ScopedObject ).isTrue ();
115
110
ScopedObject scopedDeserialized = (ScopedObject ) deserialized ;
116
111
assertThat (scopedDeserialized .getTargetObject ().getClass ()).isEqualTo (TestBean .class );
117
112
118
113
bf .setSerializationId (null );
119
114
}
120
115
121
116
@ Test
122
- public void testCglibScopedProxy () throws Exception {
117
+ void testCglibScopedProxy () throws Exception {
123
118
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ();
124
119
new XmlBeanDefinitionReader (bf ).loadBeanDefinitions (LIST_CONTEXT );
125
120
bf .setSerializationId ("Y" );
@@ -128,21 +123,19 @@ public void testCglibScopedProxy() throws Exception {
128
123
129
124
TestBean tb = (TestBean ) bf .getBean ("testBean" );
130
125
assertThat (AopUtils .isCglibProxy (tb .getFriends ())).isTrue ();
131
- boolean condition1 = tb .getFriends () instanceof ScopedObject ;
132
- assertThat (condition1 ).isTrue ();
126
+ assertThat (tb .getFriends () instanceof ScopedObject ).isTrue ();
133
127
ScopedObject scoped = (ScopedObject ) tb .getFriends ();
134
128
assertThat (scoped .getTargetObject ().getClass ()).isEqualTo (ArrayList .class );
135
129
tb .getFriends ().add ("myFriend" );
136
130
137
131
assertThat (scope .getMap ().containsKey ("scopedTarget.scopedList" )).isTrue ();
138
132
assertThat (scope .getMap ().get ("scopedTarget.scopedList" ).getClass ()).isEqualTo (ArrayList .class );
139
133
140
- ArrayList <? > deserialized = (ArrayList <? >) SerializationTestUtils .serializeAndDeserialize (tb .getFriends ());
134
+ ArrayList <Object > deserialized = (ArrayList <Object >) SerializationTestUtils .serializeAndDeserialize (tb .getFriends ());
141
135
assertThat (deserialized ).isNotNull ();
142
136
assertThat (AopUtils .isCglibProxy (deserialized )).isTrue ();
143
- assertThat (deserialized .contains ("myFriend" )).isTrue ();
144
- boolean condition = deserialized instanceof ScopedObject ;
145
- assertThat (condition ).isTrue ();
137
+ assertThat (deserialized ).contains ("myFriend" );
138
+ assertThat (deserialized instanceof ScopedObject ).isTrue ();
146
139
ScopedObject scopedDeserialized = (ScopedObject ) deserialized ;
147
140
assertThat (scopedDeserialized .getTargetObject ().getClass ()).isEqualTo (ArrayList .class );
148
141
0 commit comments