Skip to content

Commit 56c93af

Browse files
committed
Correct Tests About Conflicting Annotations
Issue gh-9289
1 parent ffd4a0f commit 56c93af

9 files changed

+18
-58
lines changed

core/src/test/java/org/springframework/security/authorization/method/PostAuthorizeAuthorizationManagerTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
159159
@Test
160160
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
161161
Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
162-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
163-
ClassLevelAnnotations.class, "inheritedAnnotations");
162+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
163+
"inheritedAnnotations");
164164
MethodInvocationResult result = new MethodInvocationResult(methodInvocation, null);
165165
PostAuthorizeAuthorizationManager manager = new PostAuthorizeAuthorizationManager();
166166
assertThatExceptionOfType(AnnotationConfigurationException.class)

core/src/test/java/org/springframework/security/authorization/method/PostAuthorizeReactiveAuthorizationManagerTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
165165
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
166166
Mono<Authentication> authentication = Mono
167167
.just(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
168-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
169-
ClassLevelAnnotations.class, "inheritedAnnotations");
168+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
169+
"inheritedAnnotations");
170170
MethodInvocationResult result = new MethodInvocationResult(methodInvocation, null);
171171
PostAuthorizeReactiveAuthorizationManager manager = new PostAuthorizeReactiveAuthorizationManager();
172172
assertThatExceptionOfType(AnnotationConfigurationException.class)

core/src/test/java/org/springframework/security/authorization/method/PostFilterAuthorizationMethodInterceptorTests.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
120120

121121
@Test
122122
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
123-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
124-
ConflictingAnnotations.class, "inheritedAnnotations");
123+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
124+
"inheritedAnnotations");
125125
PostFilterAuthorizationMethodInterceptor advice = new PostFilterAuthorizationMethodInterceptor();
126126
assertThatExceptionOfType(AnnotationConfigurationException.class)
127127
.isThrownBy(() -> advice.invoke(methodInvocation));
@@ -230,16 +230,6 @@ public void doSomething() {
230230

231231
}
232232

233-
public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
234-
235-
@Override
236-
@PostFilter("filterObject == 'jack'")
237-
public void inheritedAnnotations() {
238-
239-
}
240-
241-
}
242-
243233
public interface InterfaceAnnotationsOne {
244234

245235
@PostFilter("filterObject == 'jim'")

core/src/test/java/org/springframework/security/authorization/method/PostFilterAuthorizationReactiveMethodInterceptorTests.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
116116

117117
@Test
118118
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
119-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
120-
ConflictingAnnotations.class, "inheritedAnnotations");
119+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
120+
"inheritedAnnotations");
121121
PostFilterAuthorizationReactiveMethodInterceptor interceptor = new PostFilterAuthorizationReactiveMethodInterceptor();
122122
assertThatExceptionOfType(AnnotationConfigurationException.class)
123123
.isThrownBy(() -> interceptor.invoke(methodInvocation));
@@ -155,16 +155,6 @@ public void doSomething() {
155155

156156
}
157157

158-
public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
159-
160-
@Override
161-
@PostFilter("filterObject == 'jack'")
162-
public void inheritedAnnotations() {
163-
164-
}
165-
166-
}
167-
168158
public interface InterfaceAnnotationsOne {
169159

170160
@PostFilter("filterObject == 'jim'")

core/src/test/java/org/springframework/security/authorization/method/PreAuthorizeAuthorizationManagerTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
127127
@Test
128128
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
129129
Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
130-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
131-
ClassLevelAnnotations.class, "inheritedAnnotations");
130+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
131+
"inheritedAnnotations");
132132
PreAuthorizeAuthorizationManager manager = new PreAuthorizeAuthorizationManager();
133133
assertThatExceptionOfType(AnnotationConfigurationException.class)
134134
.isThrownBy(() -> manager.check(authentication, methodInvocation));

core/src/test/java/org/springframework/security/authorization/method/PreAuthorizeReactiveAuthorizationManagerTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
138138
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
139139
Mono<Authentication> authentication = Mono
140140
.just(new TestingAuthenticationToken("user", "password", "ROLE_USER"));
141-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
142-
ClassLevelAnnotations.class, "inheritedAnnotations");
141+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
142+
"inheritedAnnotations");
143143
PreAuthorizeReactiveAuthorizationManager manager = new PreAuthorizeReactiveAuthorizationManager();
144144
assertThatExceptionOfType(AnnotationConfigurationException.class)
145145
.isThrownBy(() -> manager.check(authentication, methodInvocation));

core/src/test/java/org/springframework/security/authorization/method/PreFilterAuthorizationMethodInterceptorTests.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
180180

181181
@Test
182182
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
183-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
184-
ConflictingAnnotations.class, "inheritedAnnotations");
183+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
184+
"inheritedAnnotations");
185185
PreFilterAuthorizationMethodInterceptor advice = new PreFilterAuthorizationMethodInterceptor();
186186
assertThatExceptionOfType(AnnotationConfigurationException.class)
187187
.isThrownBy(() -> advice.invoke(methodInvocation));
@@ -297,16 +297,6 @@ public void doSomething() {
297297

298298
}
299299

300-
public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
301-
302-
@Override
303-
@PreFilter("filterObject == 'jack'")
304-
public void inheritedAnnotations() {
305-
306-
}
307-
308-
}
309-
310300
public interface InterfaceAnnotationsOne {
311301

312302
@PreFilter("filterObject == 'jim'")

core/src/test/java/org/springframework/security/authorization/method/PreFilterAuthorizationReactiveMethodInterceptorTests.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
151151

152152
@Test
153153
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
154-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ConflictingAnnotations(),
155-
ConflictingAnnotations.class, "inheritedAnnotations");
154+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
155+
"inheritedAnnotations");
156156
PreFilterAuthorizationReactiveMethodInterceptor interceptor = new PreFilterAuthorizationReactiveMethodInterceptor();
157157
assertThatExceptionOfType(AnnotationConfigurationException.class)
158158
.isThrownBy(() -> interceptor.invoke(methodInvocation));
@@ -200,16 +200,6 @@ public void doSomething() {
200200

201201
}
202202

203-
public static class ConflictingAnnotations implements InterfaceAnnotationsThree {
204-
205-
@Override
206-
@PreFilter("filterObject == 'jack'")
207-
public void inheritedAnnotations() {
208-
209-
}
210-
211-
}
212-
213203
public interface InterfaceAnnotationsOne {
214204

215205
@PreFilter("filterObject == 'jim'")

core/src/test/java/org/springframework/security/authorization/method/SecuredAuthorizationManagerTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public void checkInheritedAnnotationsWhenDuplicatedThenAnnotationConfigurationEx
147147
@Test
148148
public void checkInheritedAnnotationsWhenConflictingThenAnnotationConfigurationException() throws Exception {
149149
Supplier<Authentication> authentication = () -> new TestingAuthenticationToken("user", "password", "ROLE_USER");
150-
MockMethodInvocation methodInvocation = new MockMethodInvocation(new ClassLevelAnnotations(),
151-
ClassLevelAnnotations.class, "inheritedAnnotations");
150+
MockMethodInvocation methodInvocation = new MockMethodInvocation(new TestClass(), TestClass.class,
151+
"inheritedAnnotations");
152152
SecuredAuthorizationManager manager = new SecuredAuthorizationManager();
153153
assertThatExceptionOfType(AnnotationConfigurationException.class)
154154
.isThrownBy(() -> manager.check(authentication, methodInvocation));

0 commit comments

Comments
 (0)