Skip to content

Commit b9a2d0a

Browse files
committed
Polishing
1 parent 52f21bd commit b9a2d0a

File tree

13 files changed

+217
-156
lines changed

13 files changed

+217
-156
lines changed

spring-aop/src/test/java/org/springframework/tests/aop/interceptor/NopInterceptor.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.
@@ -29,9 +28,7 @@ public class NopInterceptor implements MethodInterceptor {
2928

3029
private int count;
3130

32-
/**
33-
* @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation)
34-
*/
31+
3532
@Override
3633
public Object invoke(MethodInvocation invocation) throws Throwable {
3734
increment();
@@ -46,6 +43,8 @@ protected void increment() {
4643
++count;
4744
}
4845

46+
47+
@Override
4948
public boolean equals(Object other) {
5049
if (!(other instanceof NopInterceptor)) {
5150
return false;
@@ -56,4 +55,9 @@ public boolean equals(Object other) {
5655
return this.count == ((NopInterceptor) other).count;
5756
}
5857

58+
@Override
59+
public int hashCode() {
60+
return NopInterceptor.class.hashCode();
61+
}
62+
5963
}

spring-aop/src/test/java/org/springframework/tests/sample/beans/SerializablePerson.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -29,8 +29,10 @@
2929
public class SerializablePerson implements Person, Serializable {
3030

3131
private String name;
32+
3233
private int age;
3334

35+
3436
@Override
3537
public int getAge() {
3638
return age;
@@ -59,6 +61,7 @@ public Object echo(Object o) throws Throwable {
5961
return o;
6062
}
6163

64+
6265
public boolean equals(Object other) {
6366
if (!(other instanceof SerializablePerson)) {
6467
return false;
@@ -67,4 +70,9 @@ public boolean equals(Object other) {
6770
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
6871
}
6972

73+
@Override
74+
public int hashCode() {
75+
return SerializablePerson.class.hashCode();
76+
}
77+
7078
}

spring-beans/src/test/java/org/springframework/tests/beans/CollectingReaderEventListener.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -36,21 +36,23 @@
3636
*/
3737
public class CollectingReaderEventListener implements ReaderEventListener {
3838

39-
private final List defaults = new LinkedList();
39+
private final List<DefaultsDefinition> defaults = new LinkedList<DefaultsDefinition>();
4040

41-
private final Map componentDefinitions = new LinkedHashMap<>(8);
41+
private final Map<String, ComponentDefinition> componentDefinitions =
42+
new LinkedHashMap<String, ComponentDefinition>(8);
4243

43-
private final Map aliasMap = new LinkedHashMap<>(8);
44+
private final Map<String, List<AliasDefinition>> aliasMap =
45+
new LinkedHashMap<String, List<AliasDefinition>>(8);
4446

45-
private final List imports = new LinkedList();
47+
private final List<ImportDefinition> imports = new LinkedList<ImportDefinition>();
4648

4749

4850
@Override
4951
public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
5052
this.defaults.add(defaultsDefinition);
5153
}
5254

53-
public List getDefaults() {
55+
public List<DefaultsDefinition> getDefaults() {
5456
return Collections.unmodifiableList(this.defaults);
5557
}
5658

@@ -60,35 +62,35 @@ public void componentRegistered(ComponentDefinition componentDefinition) {
6062
}
6163

6264
public ComponentDefinition getComponentDefinition(String name) {
63-
return (ComponentDefinition) this.componentDefinitions.get(name);
65+
return this.componentDefinitions.get(name);
6466
}
6567

6668
public ComponentDefinition[] getComponentDefinitions() {
67-
Collection collection = this.componentDefinitions.values();
68-
return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]);
69+
Collection<ComponentDefinition> collection = this.componentDefinitions.values();
70+
return collection.toArray(new ComponentDefinition[collection.size()]);
6971
}
7072

7173
@Override
7274
public void aliasRegistered(AliasDefinition aliasDefinition) {
73-
List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName());
74-
if(aliases == null) {
75-
aliases = new ArrayList();
75+
List<AliasDefinition> aliases = this.aliasMap.get(aliasDefinition.getBeanName());
76+
if (aliases == null) {
77+
aliases = new ArrayList<AliasDefinition>();
7678
this.aliasMap.put(aliasDefinition.getBeanName(), aliases);
7779
}
7880
aliases.add(aliasDefinition);
7981
}
8082

81-
public List getAliases(String beanName) {
82-
List aliases = (List) this.aliasMap.get(beanName);
83-
return aliases == null ? null : Collections.unmodifiableList(aliases);
83+
public List<AliasDefinition> getAliases(String beanName) {
84+
List<AliasDefinition> aliases = this.aliasMap.get(beanName);
85+
return (aliases != null ? Collections.unmodifiableList(aliases) : null);
8486
}
8587

8688
@Override
8789
public void importProcessed(ImportDefinition importDefinition) {
8890
this.imports.add(importDefinition);
8991
}
9092

91-
public List getImports() {
93+
public List<ImportDefinition> getImports() {
9294
return Collections.unmodifiableList(this.imports);
9395
}
9496

spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -76,13 +76,13 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
7676

7777
private Float myFloat = new Float(0.0);
7878

79-
private Collection<? super Object> friends = new LinkedList<>();
79+
private Collection<? super Object> friends = new LinkedList<Object>();
8080

81-
private Set<?> someSet = new HashSet<>();
81+
private Set<?> someSet = new HashSet<Object>();
8282

83-
private Map<?, ?> someMap = new HashMap<>();
83+
private Map<?, ?> someMap = new HashMap<Object, Object>();
8484

85-
private List<?> someList = new ArrayList<>();
85+
private List<?> someList = new ArrayList<Object>();
8686

8787
private Properties someProperties = new Properties();
8888

@@ -255,10 +255,12 @@ public void setStringArray(String[] stringArray) {
255255
this.stringArray = stringArray;
256256
}
257257

258+
@Override
258259
public Integer[] getSomeIntegerArray() {
259260
return someIntegerArray;
260261
}
261262

263+
@Override
262264
public void setSomeIntegerArray(Integer[] someIntegerArray) {
263265
this.someIntegerArray = someIntegerArray;
264266
}
@@ -461,6 +463,7 @@ public boolean wasDestroyed() {
461463
}
462464

463465

466+
@Override
464467
public boolean equals(Object other) {
465468
if (this == other) {
466469
return true;
@@ -472,6 +475,7 @@ public boolean equals(Object other) {
472475
return (ObjectUtils.nullSafeEquals(this.name, tb2.name) && this.age == tb2.age);
473476
}
474477

478+
@Override
475479
public int hashCode() {
476480
return this.age;
477481
}
@@ -486,6 +490,7 @@ public int compareTo(Object other) {
486490
}
487491
}
488492

493+
@Override
489494
public String toString() {
490495
return this.name;
491496
}

spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -58,6 +58,7 @@ public void asyncMethods() throws Exception {
5858
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
5959
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
6060
context.refresh();
61+
6162
AsyncMethodBean asyncTest = context.getBean("asyncTest", AsyncMethodBean.class);
6263
asyncTest.doNothing(5);
6364
asyncTest.doSomething(10);
@@ -73,6 +74,7 @@ public void asyncMethodsThroughInterface() throws Exception {
7374
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
7475
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
7576
context.refresh();
77+
7678
SimpleInterface asyncTest = context.getBean("asyncTest", SimpleInterface.class);
7779
asyncTest.doNothing(5);
7880
asyncTest.doSomething(10);
@@ -91,6 +93,7 @@ public void asyncMethodsWithQualifier() throws Exception {
9193
context.registerBeanDefinition("e1", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
9294
context.registerBeanDefinition("e2", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
9395
context.refresh();
96+
9497
AsyncMethodWithQualifierBean asyncTest = context.getBean("asyncTest", AsyncMethodWithQualifierBean.class);
9598
asyncTest.doNothing(5);
9699
asyncTest.doSomething(10);
@@ -111,6 +114,7 @@ public void asyncMethodsWithQualifierThroughInterface() throws Exception {
111114
context.registerBeanDefinition("e1", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
112115
context.registerBeanDefinition("e2", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
113116
context.refresh();
117+
114118
SimpleInterface asyncTest = context.getBean("asyncTest", SimpleInterface.class);
115119
asyncTest.doNothing(5);
116120
asyncTest.doSomething(10);
@@ -128,6 +132,7 @@ public void asyncClass() throws Exception {
128132
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
129133
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
130134
context.refresh();
135+
131136
AsyncClassBean asyncTest = context.getBean("asyncTest", AsyncClassBean.class);
132137
asyncTest.doSomething(10);
133138
Future<String> future = asyncTest.returnSomething(20);
@@ -141,6 +146,7 @@ public void asyncClassWithPostProcessor() throws Exception {
141146
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncClassBean.class));
142147
context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
143148
context.refresh();
149+
144150
AsyncClassBean asyncTest = context.getBean("asyncTest", AsyncClassBean.class);
145151
asyncTest.doSomething(10);
146152
Future<String> future = asyncTest.returnSomething(20);
@@ -155,6 +161,7 @@ public void asyncClassWithInterface() throws Exception {
155161
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
156162
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
157163
context.refresh();
164+
158165
RegularInterface asyncTest = context.getBean("asyncTest", RegularInterface.class);
159166
asyncTest.doSomething(10);
160167
Future<String> future = asyncTest.returnSomething(20);
@@ -168,6 +175,7 @@ public void asyncClassWithInterfaceAndPostProcessor() throws Exception {
168175
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncClassBeanWithInterface.class));
169176
context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
170177
context.refresh();
178+
171179
RegularInterface asyncTest = context.getBean("asyncTest", RegularInterface.class);
172180
asyncTest.doSomething(10);
173181
Future<String> future = asyncTest.returnSomething(20);
@@ -182,6 +190,7 @@ public void asyncInterface() throws Exception {
182190
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
183191
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
184192
context.refresh();
193+
185194
AsyncInterface asyncTest = context.getBean("asyncTest", AsyncInterface.class);
186195
asyncTest.doSomething(10);
187196
Future<String> future = asyncTest.returnSomething(20);
@@ -195,6 +204,7 @@ public void asyncInterfaceWithPostProcessor() throws Exception {
195204
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncInterfaceBean.class));
196205
context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
197206
context.refresh();
207+
198208
AsyncInterface asyncTest = context.getBean("asyncTest", AsyncInterface.class);
199209
asyncTest.doSomething(10);
200210
Future<String> future = asyncTest.returnSomething(20);
@@ -209,6 +219,7 @@ public void dynamicAsyncInterface() throws Exception {
209219
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
210220
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
211221
context.refresh();
222+
212223
AsyncInterface asyncTest = context.getBean("asyncTest", AsyncInterface.class);
213224
asyncTest.doSomething(10);
214225
Future<String> future = asyncTest.returnSomething(20);
@@ -222,6 +233,7 @@ public void dynamicAsyncInterfaceWithPostProcessor() throws Exception {
222233
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(DynamicAsyncInterfaceBean.class));
223234
context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
224235
context.refresh();
236+
225237
AsyncInterface asyncTest = context.getBean("asyncTest", AsyncInterface.class);
226238
asyncTest.doSomething(10);
227239
Future<String> future = asyncTest.returnSomething(20);
@@ -236,6 +248,7 @@ public void asyncMethodsInInterface() throws Exception {
236248
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
237249
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
238250
context.refresh();
251+
239252
AsyncMethodsInterface asyncTest = context.getBean("asyncTest", AsyncMethodsInterface.class);
240253
asyncTest.doNothing(5);
241254
asyncTest.doSomething(10);
@@ -250,6 +263,7 @@ public void asyncMethodsInInterfaceWithPostProcessor() throws Exception {
250263
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncMethodsInterfaceBean.class));
251264
context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
252265
context.refresh();
266+
253267
AsyncMethodsInterface asyncTest = context.getBean("asyncTest", AsyncMethodsInterface.class);
254268
asyncTest.doNothing(5);
255269
asyncTest.doSomething(10);
@@ -264,6 +278,7 @@ public void dynamicAsyncMethodsInInterfaceWithPostProcessor() throws Exception {
264278
context.registerBeanDefinition("asyncTest", new RootBeanDefinition(DynamicAsyncMethodsInterfaceBean.class));
265279
context.registerBeanDefinition("asyncProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
266280
context.refresh();
281+
267282
AsyncMethodsInterface asyncTest = context.getBean("asyncTest", AsyncMethodsInterface.class);
268283
asyncTest.doSomething(10);
269284
Future<String> future = asyncTest.returnSomething(20);
@@ -461,7 +476,7 @@ public static class DynamicAsyncInterfaceBean implements FactoryBean<AsyncInterf
461476
private final AsyncInterface proxy;
462477

463478
public DynamicAsyncInterfaceBean() {
464-
ProxyFactory pf = new ProxyFactory(new HashMap<>());
479+
ProxyFactory pf = new ProxyFactory(new HashMap<String, String>());
465480
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new MethodInterceptor() {
466481
@Override
467482
public Object invoke(MethodInvocation invocation) throws Throwable {
@@ -531,7 +546,7 @@ public static class DynamicAsyncMethodsInterfaceBean implements FactoryBean<Asyn
531546
private final AsyncMethodsInterface proxy;
532547

533548
public DynamicAsyncMethodsInterfaceBean() {
534-
ProxyFactory pf = new ProxyFactory(new HashMap<>());
549+
ProxyFactory pf = new ProxyFactory(new HashMap<String, String>());
535550
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new MethodInterceptor() {
536551
@Override
537552
public Object invoke(MethodInvocation invocation) throws Throwable {

0 commit comments

Comments
 (0)