Polish SerializationTestUtils, clean up warnings, etc.

This commit is contained in:
Sam Brannen
2020-06-20 18:17:03 +02:00
parent 9d5881e0ad
commit ab0e651547
43 changed files with 133 additions and 126 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,13 +83,12 @@ public class AspectProxyFactoryTests {
}
@Test
@SuppressWarnings("unchecked")
public void testSerializable() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
ITestBean proxy = proxyFactory.getProxy();
assertThat(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();
ITestBean tb = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
ITestBean tb = SerializationTestUtils.serializeAndDeserialize(proxy);
assertThat(tb.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();
}
@@ -108,7 +107,7 @@ public class AspectProxyFactoryTests {
ITestBean proxy = proxyFactory.getProxy();
assertThat(proxy.getAge()).isEqualTo((target.getAge() * multiple));
ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
ITestBean serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
assertThat(serializedProxy.getAge()).isEqualTo((target.getAge() * multiple));
}
@@ -120,7 +119,6 @@ public class AspectProxyFactoryTests {
}
@Test // SPR-13328
@SuppressWarnings("unchecked")
public void testProxiedVarargsWithEnumArray() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
@@ -129,7 +127,6 @@ public class AspectProxyFactoryTests {
}
@Test // SPR-13328
@SuppressWarnings("unchecked")
public void testUnproxiedVarargsWithEnumArray() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnSetter.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public class ConcurrencyThrottleInterceptorTests {
ITestBean proxy = (ITestBean) proxyFactory.getProxy();
proxy.getAge();
ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
ITestBean serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
Advised advised = (Advised) serializedProxy;
ConcurrencyThrottleInterceptor serializedCti =
(ConcurrencyThrottleInterceptor) advised.getAdvisors()[0].getAdvice();

View File

@@ -49,7 +49,7 @@ public abstract class AbstractRegexpMethodPointcutTests {
@Test
public void testSerializationWithNoPatternSupplied() throws Exception {
rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc);
rpc = SerializationTestUtils.serializeAndDeserialize(rpc);
noPatternSuppliedTests(rpc);
}
@@ -63,7 +63,7 @@ public abstract class AbstractRegexpMethodPointcutTests {
public void testExactMatch() throws Exception {
rpc.setPattern("java.lang.Object.hashCode");
exactMatchTests(rpc);
rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc);
rpc = SerializationTestUtils.serializeAndDeserialize(rpc);
exactMatchTests(rpc);
}

View File

@@ -239,7 +239,7 @@ public class DelegatingIntroductionInterceptorTests {
assertThat(p.getName()).isEqualTo(name);
assertThat(((TimeStamped) p).getTimeStamp()).isEqualTo(time);
Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
Person p1 = SerializationTestUtils.serializeAndDeserialize(p);
assertThat(p1.getName()).isEqualTo(name);
assertThat(((TimeStamped) p1).getTimeStamp()).isEqualTo(time);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@ public class NameMatchMethodPointcutTests {
public void testSerializable() throws Throwable {
testSets();
// Count is now 2
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(proxied);
Person p2 = SerializationTestUtils.serializeAndDeserialize(proxied);
NopInterceptor nop2 = (NopInterceptor) ((Advised) p2).getAdvisors()[0].getAdvice();
p2.getName();
assertThat(nop2.getCount()).isEqualTo(2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@ public class RegexpMethodPointcutAdvisorIntegrationTests {
assertThat(nop.getCount()).isEqualTo(2);
// Serialize and continue...
p = (Person) SerializationTestUtils.serializeAndDeserialize(p);
p = SerializationTestUtils.serializeAndDeserialize(p);
assertThat(p.getAge()).isEqualTo(newAge);
// Remembers count, but we need to get a new reference to nop...
nop = (SerializableNopInterceptor) ((Advised) p).getAdvisors()[0].getAdvice();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -134,7 +134,7 @@ public class HotSwappableTargetSourceTests {
hts.swap(sp2);
assertThat(p.getName()).isEqualTo(sp2.getName());
p = (Person) SerializationTestUtils.serializeAndDeserialize(p);
p = SerializationTestUtils.serializeAndDeserialize(p);
// We need to get a reference to the client-side targetsource
hts = (HotSwappableTargetSource) ((Advised) p).getTargetSource();
assertThat(p.getName()).isEqualTo(sp2.getName());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public class PrototypeBasedTargetSourceTests {
bf.registerBeanDefinition("person", bd);
TestTargetSource cpts = (TestTargetSource) bf.getBean("ts");
TargetSource serialized = (TargetSource) SerializationTestUtils.serializeAndDeserialize(cpts);
TargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts);
boolean condition = serialized instanceof SingletonTargetSource;
assertThat(condition).as("Changed to SingletonTargetSource on deserialization").isTrue();
SingletonTargetSource sts = (SingletonTargetSource) serialized;