Skip to content

Commit ab0d523

Browse files
committed
Polishing
(cherry picked from commit 1932a9d)
1 parent 1cad98d commit ab0d523

File tree

10 files changed

+66
-70
lines changed

10 files changed

+66
-70
lines changed

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

Lines changed: 10 additions & 13 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,28 +28,22 @@ 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();
3835
return invocation.proceed();
3936
}
4037

41-
public int getCount() {
42-
return this.count;
43-
}
44-
4538
protected void increment() {
46-
++count;
39+
this.count++;
4740
}
4841

49-
@Override
50-
public int hashCode() {
51-
return 0;
42+
public int getCount() {
43+
return this.count;
5244
}
5345

46+
5447
@Override
5548
public boolean equals(Object other) {
5649
if (!(other instanceof NopInterceptor)) {
@@ -62,5 +55,9 @@ public boolean equals(Object other) {
6255
return this.count == ((NopInterceptor) other).count;
6356
}
6457

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

6663
}

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

Lines changed: 15 additions & 16 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.
@@ -28,31 +28,29 @@
2828
@SuppressWarnings("serial")
2929
public class SerializablePerson implements Person, Serializable {
3030

31-
private static final long serialVersionUID = 1L;
32-
33-
3431
private String name;
3532

3633
private int age;
3734

35+
3836
@Override
39-
public int getAge() {
40-
return age;
37+
public String getName() {
38+
return name;
4139
}
4240

4341
@Override
44-
public void setAge(int age) {
45-
this.age = age;
42+
public void setName(String name) {
43+
this.name = name;
4644
}
4745

4846
@Override
49-
public String getName() {
50-
return name;
47+
public int getAge() {
48+
return age;
5149
}
5250

5351
@Override
54-
public void setName(String name) {
55-
this.name = name;
52+
public void setAge(int age) {
53+
this.age = age;
5654
}
5755

5856
@Override
@@ -63,10 +61,6 @@ public Object echo(Object o) throws Throwable {
6361
return o;
6462
}
6563

66-
@Override
67-
public int hashCode() {
68-
return 0;
69-
}
7064

7165
@Override
7266
public boolean equals(Object other) {
@@ -77,4 +71,9 @@ public boolean equals(Object other) {
7771
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
7872
}
7973

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -223,7 +223,7 @@ public void setSpouse(ITestBean spouse) {
223223

224224
@Override
225225
public ITestBean[] getSpouses() {
226-
return (spouse != null ? new ITestBean[]{spouse} : null);
226+
return (spouse != null ? new ITestBean[] {spouse} : null);
227227
}
228228

229229
public String getTouchy() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void asyncMethodsThroughInterface() throws Exception {
124124
context.registerBeanDefinition("autoProxyCreator", new RootBeanDefinition(DefaultAdvisorAutoProxyCreator.class));
125125
context.registerBeanDefinition("asyncAdvisor", new RootBeanDefinition(AsyncAnnotationAdvisor.class));
126126
context.refresh();
127+
127128
SimpleInterface asyncTest = context.getBean("asyncTest", SimpleInterface.class);
128129
asyncTest.doNothing(5);
129130
asyncTest.doSomething(10);

spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -33,7 +33,6 @@
3333
/**
3434
* @author Keith Donald
3535
*/
36-
@SuppressWarnings({ "rawtypes", "unchecked" })
3736
public class ToStringCreatorTests {
3837

3938
private SomeObject s1, s2, s3;
@@ -63,20 +62,20 @@ public String toString() {
6362

6463
@Test
6564
public void defaultStyleMap() {
66-
final Map map = getMap();
65+
final Map<String, String> map = getMap();
6766
Object stringy = new Object() {
6867
@Override
6968
public String toString() {
7069
return new ToStringCreator(this).append("familyFavoriteSport", map).toString();
7170
}
7271
};
73-
assertEquals("[ToStringCreatorTests.4@" + ObjectUtils.getIdentityHexString(stringy)
74-
+ " familyFavoriteSport = map['Keri' -> 'Softball', 'Scot' -> 'Fishing', 'Keith' -> 'Flag Football']]",
72+
assertEquals("[ToStringCreatorTests.4@" + ObjectUtils.getIdentityHexString(stringy) +
73+
" familyFavoriteSport = map['Keri' -> 'Softball', 'Scot' -> 'Fishing', 'Keith' -> 'Flag Football']]",
7574
stringy.toString());
7675
}
7776

78-
private Map getMap() {
79-
Map map = new LinkedHashMap(3);
77+
private Map<String, String> getMap() {
78+
Map<String, String> map = new LinkedHashMap<>();
8079
map.put("Keri", "Softball");
8180
map.put("Scot", "Fishing");
8281
map.put("Keith", "Flag Football");
@@ -85,22 +84,22 @@ private Map getMap() {
8584

8685
@Test
8786
public void defaultStyleArray() {
88-
SomeObject[] array = new SomeObject[] { s1, s2, s3 };
87+
SomeObject[] array = new SomeObject[] {s1, s2, s3};
8988
String str = new ToStringCreator(array).toString();
90-
assertEquals("[@" + ObjectUtils.getIdentityHexString(array)
91-
+ " array<ToStringCreatorTests.SomeObject>[A, B, C]]", str);
89+
assertEquals("[@" + ObjectUtils.getIdentityHexString(array) +
90+
" array<ToStringCreatorTests.SomeObject>[A, B, C]]", str);
9291
}
9392

9493
@Test
9594
public void primitiveArrays() {
96-
int[] integers = new int[] { 0, 1, 2, 3, 4 };
95+
int[] integers = new int[] {0, 1, 2, 3, 4};
9796
String str = new ToStringCreator(integers).toString();
9897
assertEquals("[@" + ObjectUtils.getIdentityHexString(integers) + " array<Integer>[0, 1, 2, 3, 4]]", str);
9998
}
10099

101100
@Test
102101
public void appendList() {
103-
List list = new ArrayList();
102+
List<SomeObject> list = new ArrayList<>();
104103
list.add(s1);
105104
list.add(s2);
106105
list.add(s3);
@@ -111,28 +110,26 @@ public void appendList() {
111110

112111
@Test
113112
public void appendSet() {
114-
Set set = new LinkedHashSet<>(3);
113+
Set<SomeObject> set = new LinkedHashSet<>();
115114
set.add(s1);
116115
set.add(s2);
117116
set.add(s3);
118117
String str = new ToStringCreator(this).append("myLetters", set).toString();
119-
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) + " myLetters = set[A, B, C]]",
120-
str);
118+
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) + " myLetters = set[A, B, C]]", str);
121119
}
122120

123121
@Test
124122
public void appendClass() {
125123
String str = new ToStringCreator(this).append("myClass", this.getClass()).toString();
126-
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this)
127-
+ " myClass = ToStringCreatorTests]", str);
124+
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) +
125+
" myClass = ToStringCreatorTests]", str);
128126
}
129127

130128
@Test
131129
public void appendMethod() throws Exception {
132-
String str = new ToStringCreator(this).append("myMethod", this.getClass().getMethod("appendMethod"))
133-
.toString();
134-
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this)
135-
+ " myMethod = appendMethod@ToStringCreatorTests]", str);
130+
String str = new ToStringCreator(this).append("myMethod", this.getClass().getMethod("appendMethod")).toString();
131+
assertEquals("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) +
132+
" myMethod = appendMethod@ToStringCreatorTests]", str);
136133
}
137134

138135

spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -79,7 +79,7 @@ public void stringWithMethodInvoker() throws Exception {
7979
MethodInvoker methodInvoker = new MethodInvoker();
8080
methodInvoker.setTargetObject(new Greeter());
8181
methodInvoker.setTargetMethod("greet");
82-
methodInvoker.setArguments(new Object[] { new String("no match") });
82+
methodInvoker.setArguments(new Object[] {"no match"});
8383

8484
exception.expect(NoSuchMethodException.class);
8585
methodInvoker.prepare();
@@ -199,6 +199,7 @@ public static String supertypes2(Collection<?> c, List<?> l, String s, String s2
199199
}
200200
}
201201

202+
202203
@SuppressWarnings("unused")
203204
public static class Greeter {
204205

@@ -223,13 +224,17 @@ private String greet(Regular regular) {
223224
}
224225
}
225226

227+
226228
private interface Greetable {
229+
227230
String getGreeting();
228231
}
229232

233+
230234
private interface Person extends Greetable {
231235
}
232236

237+
233238
private static class Purchaser implements Greetable {
234239

235240
@Override
@@ -238,6 +243,7 @@ public String getGreeting() {
238243
}
239244
}
240245

246+
241247
private static class Shopper extends Purchaser implements Person {
242248

243249
@Override
@@ -246,6 +252,7 @@ public String getGreeting() {
246252
}
247253
}
248254

255+
249256
private static class Salesman implements Person {
250257

251258
@Override
@@ -254,6 +261,7 @@ public String getGreeting() {
254261
}
255262
}
256263

264+
257265
private static class Customer extends Shopper {
258266

259267
@Override
@@ -262,6 +270,7 @@ public String getGreeting() {
262270
}
263271
}
264272

273+
265274
private static class Regular extends Customer {
266275

267276
private String name;
@@ -276,6 +285,7 @@ public String getGreeting() {
276285
}
277286
}
278287

288+
279289
private static class VIP extends Regular {
280290

281291
public VIP(String name) {

spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import org.junit.Before;
3030
import org.junit.Test;
3131

32-
import org.springframework.beans.factory.BeanFactory;
33-
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
3432
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
3533
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
3634
import org.springframework.core.io.ClassPathResource;
@@ -44,12 +42,12 @@
4442
* @author Thomas Risberg
4543
* @author Juergen Hoeller
4644
*/
47-
public class GenericSqlQueryTests {
45+
public class GenericSqlQueryTests {
4846

4947
private static final String SELECT_ID_FORENAME_NAMED_PARAMETERS_PARSED =
5048
"select id, forename from custmr where id = ? and country = ?";
5149

52-
private BeanFactory beanFactory;
50+
private DefaultListableBeanFactory beanFactory;
5351

5452
private Connection connection;
5553

@@ -61,7 +59,7 @@ public class GenericSqlQueryTests {
6159
@Before
6260
public void setUp() throws Exception {
6361
this.beanFactory = new DefaultListableBeanFactory();
64-
new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(
62+
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
6563
new ClassPathResource("org/springframework/jdbc/object/GenericSqlQueryTests-context.xml"));
6664
DataSource dataSource = mock(DataSource.class);
6765
this.connection = mock(Connection.class);

spring-jdbc/src/test/resources/org/springframework/jdbc/object/GenericSqlQueryTests-context.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xmlns:util="http://www.springframework.org/schema/util"
4-
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
55
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
66

77
<bean id="dataSource" class="org.springframework.jdbc.datasource.TestDataSourceWrapper"/>
@@ -47,7 +47,7 @@
4747
</bean>
4848
</list>
4949
</property>
50-
<property name="rowMapperClass" value="org.springframework.jdbc.object.CustomerMapper"/>
50+
<property name="rowMapperClass" value="org.springframework.jdbc.object.CustomerMapper"/>
5151
</bean>
5252

5353
<bean id="queryWithRowMapperBean" class="org.springframework.jdbc.object.GenericSqlQuery">

0 commit comments

Comments
 (0)