Skip to content

Commit ab0e651

Browse files
committed
Polish SerializationTestUtils, clean up warnings, etc.
1 parent 9d5881e commit ab0e651

File tree

43 files changed

+133
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+133
-126
lines changed

integration-tests/src/test/java/org/springframework/aop/config/AopNamespaceHandlerScopeIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void testSingletonScoping() throws Exception {
7070
assertThat(singletonScoped.getName()).isEqualTo(rob);
7171
singletonScoped.setName(bram);
7272
assertThat(singletonScoped.getName()).isEqualTo(bram);
73-
ITestBean deserialized = (ITestBean) SerializationTestUtils.serializeAndDeserialize(singletonScoped);
73+
ITestBean deserialized = SerializationTestUtils.serializeAndDeserialize(singletonScoped);
7474
assertThat(deserialized.getName()).isEqualTo(bram);
7575
}
7676

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -83,13 +83,12 @@ public void testWithInstanceWithNonAspect() throws Exception {
8383
}
8484

8585
@Test
86-
@SuppressWarnings("unchecked")
8786
public void testSerializable() throws Exception {
8887
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
8988
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
9089
ITestBean proxy = proxyFactory.getProxy();
9190
assertThat(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();
92-
ITestBean tb = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
91+
ITestBean tb = SerializationTestUtils.serializeAndDeserialize(proxy);
9392
assertThat(tb.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();
9493
}
9594

@@ -108,7 +107,7 @@ public void testWithInstance() throws Exception {
108107
ITestBean proxy = proxyFactory.getProxy();
109108
assertThat(proxy.getAge()).isEqualTo((target.getAge() * multiple));
110109

111-
ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
110+
ITestBean serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
112111
assertThat(serializedProxy.getAge()).isEqualTo((target.getAge() * multiple));
113112
}
114113

@@ -120,7 +119,6 @@ public void testWithNonSingletonAspectInstance() throws Exception {
120119
}
121120

122121
@Test // SPR-13328
123-
@SuppressWarnings("unchecked")
124122
public void testProxiedVarargsWithEnumArray() throws Exception {
125123
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
126124
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
@@ -129,7 +127,6 @@ public void testProxiedVarargsWithEnumArray() throws Exception {
129127
}
130128

131129
@Test // SPR-13328
132-
@SuppressWarnings("unchecked")
133130
public void testUnproxiedVarargsWithEnumArray() throws Exception {
134131
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
135132
proxyFactory.addAspect(LoggingAspectOnSetter.class);

spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -54,7 +54,7 @@ public void testSerializable() throws Exception {
5454
ITestBean proxy = (ITestBean) proxyFactory.getProxy();
5555
proxy.getAge();
5656

57-
ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
57+
ITestBean serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
5858
Advised advised = (Advised) serializedProxy;
5959
ConcurrencyThrottleInterceptor serializedCti =
6060
(ConcurrencyThrottleInterceptor) advised.getAdvisors()[0].getAdvice();

spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testNoPatternSupplied() throws Exception {
4949

5050
@Test
5151
public void testSerializationWithNoPatternSupplied() throws Exception {
52-
rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc);
52+
rpc = SerializationTestUtils.serializeAndDeserialize(rpc);
5353
noPatternSuppliedTests(rpc);
5454
}
5555

@@ -63,7 +63,7 @@ protected void noPatternSuppliedTests(AbstractRegexpMethodPointcut rpc) throws E
6363
public void testExactMatch() throws Exception {
6464
rpc.setPattern("java.lang.Object.hashCode");
6565
exactMatchTests(rpc);
66-
rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc);
66+
rpc = SerializationTestUtils.serializeAndDeserialize(rpc);
6767
exactMatchTests(rpc);
6868
}
6969

spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public void testSerializableDelegatingIntroductionInterceptorSerializable() thro
239239
assertThat(p.getName()).isEqualTo(name);
240240
assertThat(((TimeStamped) p).getTimeStamp()).isEqualTo(time);
241241

242-
Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
242+
Person p1 = SerializationTestUtils.serializeAndDeserialize(p);
243243
assertThat(p1.getName()).isEqualTo(name);
244244
assertThat(((TimeStamped) p1).getTimeStamp()).isEqualTo(time);
245245
}

spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -109,7 +109,7 @@ public void testSets() throws Throwable {
109109
public void testSerializable() throws Throwable {
110110
testSets();
111111
// Count is now 2
112-
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(proxied);
112+
Person p2 = SerializationTestUtils.serializeAndDeserialize(proxied);
113113
NopInterceptor nop2 = (NopInterceptor) ((Advised) p2).getAdvisors()[0].getAdvice();
114114
p2.getName();
115115
assertThat(nop2.getCount()).isEqualTo(2);

spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -109,7 +109,7 @@ public void testSerialization() throws Throwable {
109109
assertThat(nop.getCount()).isEqualTo(2);
110110

111111
// Serialize and continue...
112-
p = (Person) SerializationTestUtils.serializeAndDeserialize(p);
112+
p = SerializationTestUtils.serializeAndDeserialize(p);
113113
assertThat(p.getAge()).isEqualTo(newAge);
114114
// Remembers count, but we need to get a new reference to nop...
115115
nop = (SerializableNopInterceptor) ((Advised) p).getAdvisors()[0].getAdvice();

spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -134,7 +134,7 @@ public void testSerialization() throws Exception {
134134
hts.swap(sp2);
135135
assertThat(p.getName()).isEqualTo(sp2.getName());
136136

137-
p = (Person) SerializationTestUtils.serializeAndDeserialize(p);
137+
p = SerializationTestUtils.serializeAndDeserialize(p);
138138
// We need to get a reference to the client-side targetsource
139139
hts = (HotSwappableTargetSource) ((Advised) p).getTargetSource();
140140
assertThat(p.getName()).isEqualTo(sp2.getName());

spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -55,7 +55,7 @@ public void testSerializability() throws Exception {
5555
bf.registerBeanDefinition("person", bd);
5656

5757
TestTargetSource cpts = (TestTargetSource) bf.getBean("ts");
58-
TargetSource serialized = (TargetSource) SerializationTestUtils.serializeAndDeserialize(cpts);
58+
TargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts);
5959
boolean condition = serialized instanceof SingletonTargetSource;
6060
assertThat(condition).as("Changed to SingletonTargetSource on deserialization").isTrue();
6161
SingletonTargetSource sts = (SingletonTargetSource) serialized;

spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ protected String getFinalPath(AbstractNestablePropertyAccessor pa, String nested
806806
* @param propertyPath property path, which may be nested
807807
* @return a property accessor for the target bean
808808
*/
809-
@SuppressWarnings("unchecked") // avoid nested generic
810809
protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) {
811810
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
812811
// Handle nested properties recursively.

0 commit comments

Comments
 (0)