Skip to content

Commit bccd59e

Browse files
committed
Use findAnnotationAttributes() where appropriate
This commit updates code that previously used getAnnotationAttributes() in AnnotatedElementUtils to use findAnnotationAttributes(), where appropriate. Issue: SPR-12738
1 parent ebed52c commit bccd59e

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

spring-test/src/main/java/org/springframework/test/context/jdbc/MergedSqlConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ private static String getString(AnnotationAttributes attributes, String attribut
8686
Assert.notNull(testClass, "testClass must not be null");
8787

8888
// Get global attributes, if any.
89-
AnnotationAttributes attributes = AnnotatedElementUtils.getAnnotationAttributes(testClass,
89+
AnnotationAttributes attributes = AnnotatedElementUtils.findAnnotationAttributes(testClass,
9090
SqlConfig.class.getName());
9191

9292
// Override global attributes with local attributes.

spring-test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ protected long getJUnitTimeout(FrameworkMethod frameworkMethod) {
380380
* @return the timeout, or {@code 0} if none was specified
381381
*/
382382
protected long getSpringTimeout(FrameworkMethod frameworkMethod) {
383-
AnnotationAttributes annAttrs = AnnotatedElementUtils.getAnnotationAttributes(frameworkMethod.getMethod(),
383+
AnnotationAttributes annAttrs = AnnotatedElementUtils.findAnnotationAttributes(frameworkMethod.getMethod(),
384384
Timed.class.getName());
385385
if (annAttrs == null) {
386386
return 0;

spring-test/src/main/java/org/springframework/test/context/support/DirtiesContextTestExecutionListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ private void beforeOrAfterTestMethod(TestContext testContext, String phase, Meth
156156
Assert.notNull(testMethod, "The test method of the supplied TestContext must not be null");
157157

158158
final String annotationType = DirtiesContext.class.getName();
159-
AnnotationAttributes methodAnnAttrs = AnnotatedElementUtils.getAnnotationAttributes(testMethod, annotationType);
160-
AnnotationAttributes classAnnAttrs = AnnotatedElementUtils.getAnnotationAttributes(testClass, annotationType);
159+
AnnotationAttributes methodAnnAttrs = AnnotatedElementUtils.findAnnotationAttributes(testMethod, annotationType);
160+
AnnotationAttributes classAnnAttrs = AnnotatedElementUtils.findAnnotationAttributes(testClass, annotationType);
161161
boolean methodAnnotated = methodAnnAttrs != null;
162162
boolean classAnnotated = classAnnAttrs != null;
163163
MethodMode methodMode = methodAnnotated ? methodAnnAttrs.<MethodMode> getEnum("methodMode") : null;
@@ -186,7 +186,7 @@ private void beforeOrAfterTestClass(TestContext testContext, String phase, Class
186186
Assert.notNull(testClass, "The test class of the supplied TestContext must not be null");
187187

188188
final String annotationType = DirtiesContext.class.getName();
189-
AnnotationAttributes classAnnAttrs = AnnotatedElementUtils.getAnnotationAttributes(testClass, annotationType);
189+
AnnotationAttributes classAnnAttrs = AnnotatedElementUtils.findAnnotationAttributes(testClass, annotationType);
190190
boolean classAnnotated = classAnnAttrs != null;
191191
ClassMode classMode = classAnnotated ? classAnnAttrs.<ClassMode> getEnum("classMode") : null;
192192

spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -500,7 +500,7 @@ TransactionConfigurationAttributes retrieveConfigurationAttributes(TestContext t
500500
if (this.configurationAttributes == null) {
501501
Class<?> clazz = testContext.getTestClass();
502502

503-
AnnotationAttributes annAttrs = AnnotatedElementUtils.getAnnotationAttributes(clazz,
503+
AnnotationAttributes annAttrs = AnnotatedElementUtils.findAnnotationAttributes(clazz,
504504
TransactionConfiguration.class.getName());
505505
if (logger.isDebugEnabled()) {
506506
logger.debug(String.format("Retrieved @TransactionConfiguration attributes [%s] for test class [%s].",

0 commit comments

Comments
 (0)