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

@ -70,7 +70,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
assertThat(singletonScoped.getName()).isEqualTo(rob);
singletonScoped.setName(bram);
assertThat(singletonScoped.getName()).isEqualTo(bram);
ITestBean deserialized = (ITestBean) SerializationTestUtils.serializeAndDeserialize(singletonScoped);
ITestBean deserialized = SerializationTestUtils.serializeAndDeserialize(singletonScoped);
assertThat(deserialized.getName()).isEqualTo(bram);
}

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;

View File

@ -806,7 +806,6 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
* @param propertyPath property path, which may be nested
* @return a property accessor for the target bean
*/
@SuppressWarnings("unchecked") // avoid nested generic
protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) {
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
// Handle nested properties recursively.

View File

@ -228,7 +228,6 @@ public abstract class BeanUtils {
* @since 5.0
* @see <a href="https://kotlinlang.org/docs/reference/classes.html#constructors">Kotlin docs</a>
*/
@SuppressWarnings("unchecked")
@Nullable
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz) {
Assert.notNull(clazz, "Class must not be null");

View File

@ -1787,7 +1787,7 @@ class DefaultListableBeanFactoryTests {
lbf.setSerializationId("test");
ObjectProvider<ConstructorDependency> provider = lbf.getBeanProvider(ConstructorDependency.class);
ObjectProvider deserialized = (ObjectProvider) SerializationTestUtils.serializeAndDeserialize(provider);
ObjectProvider deserialized = SerializationTestUtils.serializeAndDeserialize(provider);
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(
deserialized::getObject);
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->

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.
@ -1135,7 +1135,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
ObjectFactoryFieldInjectionBean bean = (ObjectFactoryFieldInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}

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.
@ -394,7 +394,7 @@ public class InjectAnnotationBeanPostProcessorTests {
ObjectFactoryFieldInjectionBean bean = (ObjectFactoryFieldInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}
@ -406,7 +406,7 @@ public class InjectAnnotationBeanPostProcessorTests {
ObjectFactoryMethodInjectionBean bean = (ObjectFactoryMethodInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}
@ -418,7 +418,7 @@ public class InjectAnnotationBeanPostProcessorTests {
ObjectFactoryListFieldInjectionBean bean = (ObjectFactoryListFieldInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryListFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}
@ -430,7 +430,7 @@ public class InjectAnnotationBeanPostProcessorTests {
ObjectFactoryListMethodInjectionBean bean = (ObjectFactoryListMethodInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryListMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}
@ -442,7 +442,7 @@ public class InjectAnnotationBeanPostProcessorTests {
ObjectFactoryMapFieldInjectionBean bean = (ObjectFactoryMapFieldInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryMapFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}
@ -454,7 +454,7 @@ public class InjectAnnotationBeanPostProcessorTests {
ObjectFactoryMapMethodInjectionBean bean = (ObjectFactoryMapMethodInjectionBean) bf.getBean("annotatedBean");
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
bean = (ObjectFactoryMapMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
bean = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
}

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.
@ -72,12 +72,11 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
@SuppressWarnings("rawtypes")
public void testFactorySerialization() throws Exception {
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
ObjectFactory<?> objectFactory = testBean.getObjectFactory();
objectFactory = (ObjectFactory) SerializationTestUtils.serializeAndDeserialize(objectFactory);
objectFactory = SerializationTestUtils.serializeAndDeserialize(objectFactory);
Date date1 = (Date) objectFactory.getObject();
Date date2 = (Date) objectFactory.getObject();
@ -95,12 +94,11 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
@SuppressWarnings("rawtypes")
public void testProviderSerialization() throws Exception {
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
Provider<?> provider = testBean.getProvider();
provider = (Provider) SerializationTestUtils.serializeAndDeserialize(provider);
provider = SerializationTestUtils.serializeAndDeserialize(provider);
Date date1 = (Date) provider.get();
Date date2 = (Date) provider.get();

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.
@ -246,7 +246,7 @@ public abstract class AbstractAopProxyTests {
assertThat(cta.getCalls()).isEqualTo(1);
// Will throw exception if it fails
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
Person p2 = SerializationTestUtils.serializeAndDeserialize(p);
assertThat(p2).isNotSameAs(p);
assertThat(p2.getName()).isEqualTo(p.getName());
assertThat(p2.getAge()).isEqualTo(p.getAge());

View File

@ -523,7 +523,7 @@ public class ProxyFactoryBeanTests {
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializableSingleton");
assertThat(bf.getBean("serializableSingleton")).as("Should be a Singleton").isSameAs(p);
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
Person p2 = SerializationTestUtils.serializeAndDeserialize(p);
assertThat(p2).isEqualTo(p);
assertThat(p2).isNotSameAs(p);
assertThat(p2.getName()).isEqualTo("serializableSingleton");
@ -546,7 +546,7 @@ public class ProxyFactoryBeanTests {
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializablePrototype");
assertThat(bf.getBean("serializablePrototype")).as("Should not be a Singleton").isNotSameAs(p);
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
Person p2 = SerializationTestUtils.serializeAndDeserialize(p);
assertThat(p2).isEqualTo(p);
assertThat(p2).isNotSameAs(p);
assertThat(p2.getName()).isEqualTo("serializablePrototype");
@ -558,7 +558,7 @@ public class ProxyFactoryBeanTests {
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
Person p = (Person) bf.getBean("serializableSingleton");
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&serializableSingleton");
ProxyFactoryBean pfb2 = (ProxyFactoryBean) SerializationTestUtils.serializeAndDeserialize(pfb);
ProxyFactoryBean pfb2 = SerializationTestUtils.serializeAndDeserialize(pfb);
Person p2 = (Person) pfb2.getObject();
assertThat(p2).isEqualTo(p);
assertThat(p2).isNotSameAs(p);

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.
@ -106,7 +106,7 @@ public class ScopedProxyTests {
assertThat(scope.getMap().containsKey("testBeanTarget")).isTrue();
assertThat(scope.getMap().get("testBeanTarget").getClass()).isEqualTo(TestBean.class);
ITestBean deserialized = (ITestBean) SerializationTestUtils.serializeAndDeserialize(bean);
ITestBean deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(deserialized).isNotNull();
assertThat(AopUtils.isJdkDynamicProxy(deserialized)).isTrue();
assertThat(bean.getAge()).isEqualTo(101);

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.
@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Tests for pooling invoker interceptor.
*
* TODO: need to make these tests stronger: it's hard to
* make too many assumptions about a pool.
*
@ -45,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @author Stephane Nicoll
*/
public class CommonsPool2TargetSourceTests {
class CommonsPool2TargetSourceTests {
/**
* Initial count value set in bean factory XML
@ -55,7 +56,7 @@ public class CommonsPool2TargetSourceTests {
private DefaultListableBeanFactory beanFactory;
@BeforeEach
public void setUp() throws Exception {
void setUp() throws Exception {
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
@ -65,7 +66,7 @@ public class CommonsPool2TargetSourceTests {
* We must simulate container shutdown, which should clear threads.
*/
@AfterEach
public void tearDown() {
void tearDown() {
// Will call pool.close()
this.beanFactory.destroySingletons();
}
@ -84,17 +85,17 @@ public class CommonsPool2TargetSourceTests {
}
@Test
public void testFunctionality() {
void testFunctionality() {
testFunctionality("pooled");
}
@Test
public void testFunctionalityWithNoInterceptors() {
void testFunctionalityWithNoInterceptors() {
testFunctionality("pooledNoInterceptors");
}
@Test
public void testConfigMixin() {
void testConfigMixin() {
SideEffectBean pooled = (SideEffectBean) beanFactory.getBean("pooledWithMixin");
assertThat(pooled.getCount()).isEqualTo(INITIAL_COUNT);
PoolingConfig conf = (PoolingConfig) beanFactory.getBean("pooledWithMixin");
@ -109,25 +110,22 @@ public class CommonsPool2TargetSourceTests {
}
@Test
public void testTargetSourceSerializableWithoutConfigMixin() throws Exception {
void testTargetSourceSerializableWithoutConfigMixin() throws Exception {
CommonsPool2TargetSource cpts = (CommonsPool2TargetSource) beanFactory.getBean("personPoolTargetSource");
SingletonTargetSource serialized = (SingletonTargetSource) SerializationTestUtils.serializeAndDeserialize(cpts);
boolean condition = serialized.getTarget() instanceof Person;
assertThat(condition).isTrue();
SingletonTargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts, SingletonTargetSource.class);
assertThat(serialized.getTarget()).isInstanceOf(Person.class);
}
@Test
public void testProxySerializableWithoutConfigMixin() throws Exception {
void testProxySerializableWithoutConfigMixin() throws Exception {
Person pooled = (Person) beanFactory.getBean("pooledPerson");
//System.out.println(((Advised) pooled).toProxyConfigString());
boolean condition1 = ((Advised) pooled).getTargetSource() instanceof CommonsPool2TargetSource;
assertThat(condition1).isTrue();
//((Advised) pooled).setTargetSource(new SingletonTargetSource(new SerializablePerson()));
Person serialized = (Person) SerializationTestUtils.serializeAndDeserialize(pooled);
Person serialized = SerializationTestUtils.serializeAndDeserialize(pooled);
boolean condition = ((Advised) serialized).getTargetSource() instanceof SingletonTargetSource;
assertThat(condition).isTrue();
serialized.setAge(25);
@ -135,7 +133,7 @@ public class CommonsPool2TargetSourceTests {
}
@Test
public void testHitMaxSize() throws Exception {
void testHitMaxSize() throws Exception {
int maxSize = 10;
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
@ -166,7 +164,7 @@ public class CommonsPool2TargetSourceTests {
}
@Test
public void testHitMaxSizeLoadedFromContext() throws Exception {
void testHitMaxSizeLoadedFromContext() throws Exception {
Advised person = (Advised) beanFactory.getBean("maxSizePooledPerson");
CommonsPool2TargetSource targetSource = (CommonsPool2TargetSource) person.getTargetSource();
@ -195,14 +193,14 @@ public class CommonsPool2TargetSourceTests {
}
@Test
public void testSetWhenExhaustedAction() {
void testSetWhenExhaustedAction() {
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
targetSource.setBlockWhenExhausted(true);
assertThat(targetSource.isBlockWhenExhausted()).isEqualTo(true);
}
@Test
public void referenceIdentityByDefault() throws Exception {
void referenceIdentityByDefault() throws Exception {
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
targetSource.setMaxWait(1);
prepareTargetSource(targetSource);

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.
@ -33,7 +33,6 @@ import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.testfixture.beans.INestedTestBean;
@ -122,8 +121,7 @@ public class CommonAnnotationBeanPostProcessorTests {
@Test
public void testSerialization() throws Exception {
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
CommonAnnotationBeanPostProcessor bpp2 = (CommonAnnotationBeanPostProcessor)
SerializationTestUtils.serializeAndDeserialize(bpp);
CommonAnnotationBeanPostProcessor bpp2 = SerializationTestUtils.serializeAndDeserialize(bpp);
AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
@ -135,8 +133,7 @@ public class CommonAnnotationBeanPostProcessorTests {
InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
bpp.setInitAnnotationType(PostConstruct.class);
bpp.setDestroyAnnotationType(PreDestroy.class);
InitDestroyAnnotationBeanPostProcessor bpp2 = (InitDestroyAnnotationBeanPostProcessor)
SerializationTestUtils.serializeAndDeserialize(bpp);
InitDestroyAnnotationBeanPostProcessor bpp2 = SerializationTestUtils.serializeAndDeserialize(bpp);
AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
@ -225,7 +222,8 @@ public class CommonAnnotationBeanPostProcessorTests {
}
});
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
@SuppressWarnings("deprecation")
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("tb", "testBean4");
ppc.setProperties(props);
@ -322,7 +320,8 @@ public class CommonAnnotationBeanPostProcessorTests {
bf.addBeanPostProcessor(bpp);
bf.registerResolvableDependency(BeanFactory.class, bf);
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
@SuppressWarnings("deprecation")
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("tb", "testBean3");
ppc.setProperties(props);
@ -374,7 +373,8 @@ public class CommonAnnotationBeanPostProcessorTests {
bf.addBeanPostProcessor(bpp);
bf.registerResolvableDependency(BeanFactory.class, bf);
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
@SuppressWarnings("deprecation")
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("tb", "testBean3");
ppc.setProperties(props);

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.
@ -212,7 +212,7 @@ public class ComponentScanAnnotationIntegrationTests {
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
// test serializability
assertThat(bean.foo(1)).isEqualTo("bar");
FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean);
FooService deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(deserialized).isNotNull();
assertThat(deserialized.foo(1)).isEqualTo("bar");
}

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.
@ -72,7 +72,7 @@ public class ComponentScanParserScopedProxyTests {
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
// test serializability
assertThat(bean.foo(1)).isEqualTo("bar");
FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean);
FooService deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(deserialized).isNotNull();
assertThat(deserialized.foo(1)).isEqualTo("bar");
context.close();
@ -89,7 +89,7 @@ public class ComponentScanParserScopedProxyTests {
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
// test serializability
assertThat(bean.foo(1)).isEqualTo("bar");
ScopedProxyTestBean deserialized = (ScopedProxyTestBean) SerializationTestUtils.serializeAndDeserialize(bean);
ScopedProxyTestBean deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
assertThat(deserialized).isNotNull();
assertThat(deserialized.foo(1)).isEqualTo("bar");
context.close();

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.
@ -186,7 +186,7 @@ class ApplicationContextExpressionTests {
assertThat(tb3.optionalValue3.isPresent()).isFalse();
assertThat(tb3.tb).isSameAs(tb0);
tb3 = (ValueTestBean) SerializationTestUtils.serializeAndDeserialize(tb3);
tb3 = SerializationTestUtils.serializeAndDeserialize(tb3);
assertThat(tb3.countryFactory.getObject()).isEqualTo("123 UK");
ConstructorValueTestBean tb4 = ac.getBean("tb4", ConstructorValueTestBean.class);

View File

@ -75,10 +75,10 @@ class SocketUtilsTests {
}
@Test
@SuppressWarnings("try")
void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
int port = SocketUtils.findAvailableTcpPort();
try (ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost"))) {
assertThat(socket).isNotNull();
// will only look for the exact port
assertThatIllegalStateException().isThrownBy(() ->
SocketUtils.findAvailableTcpPort(port, port))
@ -149,10 +149,10 @@ class SocketUtilsTests {
}
@Test
@SuppressWarnings("try")
void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
int port = SocketUtils.findAvailableUdpPort();
try (DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"))) {
assertThat(socket).isNotNull();
// will only look for the exact port
assertThatIllegalStateException().isThrownBy(() ->
SocketUtils.findAvailableUdpPort(port, port))

View File

@ -26,9 +26,11 @@ import java.io.OutputStream;
/**
* Utilities for testing serializability of objects.
* Exposes static methods for use in other test cases.
*
* <p>Exposes static methods for use in other test cases.
*
* @author Rod Johnson
* @author Sam Brannen
*/
public class SerializationTestUtils {
@ -49,7 +51,8 @@ public class SerializationTestUtils {
}
}
public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException {
@SuppressWarnings("unchecked")
public static <T> T serializeAndDeserialize(T o) throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(o);
@ -59,7 +62,21 @@ public class SerializationTestUtils {
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
try (ObjectInputStream ois = new ObjectInputStream(is)) {
return ois.readObject();
return (T) ois.readObject();
}
}
public static <T> T serializeAndDeserialize(Object o, Class<T> expectedType) throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(o);
oos.flush();
}
byte[] bytes = baos.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
try (ObjectInputStream ois = new ObjectInputStream(is)) {
return expectedType.cast(ois.readObject());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 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.
@ -459,13 +459,12 @@ public abstract class AbstractAdaptableMessageListener
/**
* A {@link MessagingMessageConverter} that lazily invoke payload extraction and
* delegate it to {@link #extractMessage(javax.jms.Message)} in order to enforce
* A {@link MessagingMessageConverter} that lazily invokes payload extraction and
* delegates it to {@link #extractMessage(javax.jms.Message)} in order to enforce
* backward compatibility.
*/
private class MessagingMessageConverterAdapter extends MessagingMessageConverter {
@SuppressWarnings("unchecked")
@Override
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
return new LazyResolutionMessage(message);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@ -325,6 +325,7 @@ public class StubTextMessage implements TextMessage {
}
@Override
@SuppressWarnings("rawtypes")
public boolean isBodyAssignableTo(Class c) throws JMSException {
return false;
}

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.
@ -87,9 +87,8 @@ public class JmsNamespaceHandlerTests {
containers = context.getBeansOfType(GenericMessageEndpointManager.class);
assertThat(containers.size()).as("Context should contain 3 JCA endpoint containers").isEqualTo(3);
Map<String, JmsListenerContainerFactory> containerFactories =
context.getBeansOfType(JmsListenerContainerFactory.class);
assertThat(containerFactories.size()).as("Context should contain 3 JmsListenerContainerFactory instances").isEqualTo(3);
assertThat(context.getBeansOfType(JmsListenerContainerFactory.class))
.as("Context should contain 3 JmsListenerContainerFactory instances").hasSize(3);
}
@Test

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.
@ -121,6 +121,7 @@ public class SimpleMessageListenerContainerTests {
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
context.refresh();
context.close();
verify(connection).setExceptionListener(this.container);
}
@ -151,6 +152,7 @@ public class SimpleMessageListenerContainerTests {
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
context.refresh();
context.close();
verify(connection).setExceptionListener(this.container);
verify(connection).start();

View File

@ -341,7 +341,7 @@ public class MessagingMessageListenerAdapterTests {
}
protected MessagingMessageListenerAdapter getSimpleInstance(String methodName, Class... parameterTypes) {
protected MessagingMessageListenerAdapter getSimpleInstance(String methodName, Class<?>... parameterTypes) {
Method m = ReflectionUtils.findMethod(SampleBean.class, methodName, parameterTypes);
return createInstance(m);
}
@ -353,7 +353,7 @@ public class MessagingMessageListenerAdapterTests {
}
protected MessagingMessageListenerAdapter getPayloadInstance(final Object payload,
String methodName, Class... parameterTypes) {
String methodName, Class<?>... parameterTypes) {
Method method = ReflectionUtils.findMethod(SampleBean.class, methodName, parameterTypes);
MessagingMessageListenerAdapter adapter = new MessagingMessageListenerAdapter() {
@ -435,6 +435,7 @@ public class MessagingMessageListenerAdapterTests {
interface Summary {};
interface Full extends Summary {};
@SuppressWarnings("unused")
private static class SampleResponse {
private int counter = 42;
@ -445,9 +446,6 @@ public class MessagingMessageListenerAdapterTests {
@JsonView(Full.class)
private String description;
SampleResponse() {
}
public SampleResponse(String name, String description) {
this.name = name;
this.description = description;

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.
@ -392,6 +392,7 @@ public class JmsInvokerTests {
}
@Override
@SuppressWarnings("rawtypes")
public boolean isBodyAssignableTo(Class c) throws JMSException {
return false;
}
@ -451,6 +452,7 @@ public class JmsInvokerTests {
}
@Override
@SuppressWarnings("rawtypes")
public Enumeration getPropertyNames() throws JMSException {
return null;
}

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.
@ -311,6 +311,7 @@ public class MappingJackson2MessageConverterTests {
private interface Full extends Summary {};
@SuppressWarnings("unused")
private static class MyAnotherBean {
@JsonView(Summary.class)

View File

@ -164,7 +164,7 @@ public class MessageHeadersTests {
map.put("name", "joe");
map.put("age", 42);
MessageHeaders input = new MessageHeaders(map);
MessageHeaders output = (MessageHeaders) SerializationTestUtils.serializeAndDeserialize(input);
MessageHeaders output = SerializationTestUtils.serializeAndDeserialize(input);
assertThat(output.get("name")).isEqualTo("joe");
assertThat(output.get("age")).isEqualTo(42);
assertThat(input.get("name")).isEqualTo("joe");
@ -178,7 +178,7 @@ public class MessageHeadersTests {
map.put("name", "joe");
map.put("address", address);
MessageHeaders input = new MessageHeaders(map);
MessageHeaders output = (MessageHeaders) SerializationTestUtils.serializeAndDeserialize(input);
MessageHeaders output = SerializationTestUtils.serializeAndDeserialize(input);
assertThat(output.get("name")).isEqualTo("joe");
assertThat(output.get("address")).isNull();
assertThat(input.get("name")).isEqualTo("joe");

View File

@ -27,8 +27,8 @@ import java.util.function.Function;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Single;
import io.rsocket.AbstractRSocket;
import io.rsocket.Payload;
import io.rsocket.RSocket;
import io.rsocket.metadata.WellKnownMimeType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -248,7 +248,7 @@ public class DefaultRSocketRequesterTests {
}
private static class TestRSocket extends AbstractRSocket {
private static class TestRSocket implements RSocket {
private Mono<Payload> payloadMonoToReturn = Mono.empty();
private Flux<Payload> payloadFluxToReturn = Flux.empty();

View File

@ -23,7 +23,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.ReferenceCounted;
import io.rsocket.AbstractRSocket;
import io.rsocket.RSocket;
import io.rsocket.SocketAcceptor;
import io.rsocket.core.RSocketServer;
@ -240,7 +239,7 @@ class RSocketBufferLeakTests {
* Store all intercepted incoming and outgoing payloads and then use
* {@link #checkForLeaks()} at the end to check reference counts.
*/
private static class PayloadInterceptor extends AbstractRSocket implements RSocketInterceptor {
private static class PayloadInterceptor implements RSocket, RSocketInterceptor {
private final List<PayloadSavingDecorator> rsockets = new CopyOnWriteArrayList<>();
@ -288,7 +287,7 @@ class RSocketBufferLeakTests {
}
private static class PayloadSavingDecorator extends AbstractRSocket {
private static class PayloadSavingDecorator implements RSocket {
private final RSocket delegate;

View File

@ -204,7 +204,7 @@ public class RSocketServerToClientIntegrationTests {
Mono.fromRunnable(testEcho)
.doOnError(ex -> result.onError(ex))
.doOnSuccess(o -> result.onComplete())
.subscribeOn(Schedulers.elastic()) // StepVerifier will block
.subscribeOn(Schedulers.boundedElastic()) // StepVerifier will block
.subscribe();
}
}

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.
@ -384,7 +384,7 @@ public class MessageHeaderAccessorTests {
mutableAccessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
message = new GenericMessage<>(message.getPayload(), mutableAccessor.getMessageHeaders());
Message<?> output = (Message<?>) SerializationTestUtils.serializeAndDeserialize(message);
Message<?> output = SerializationTestUtils.serializeAndDeserialize(message);
assertThat(output.getPayload()).isEqualTo("test");
assertThat(output.getHeaders().get("foo")).isEqualTo("bar");
assertThat(output.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isNotNull();

View File

@ -187,7 +187,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
assertThat(bean.em).isNotNull();
assertThat(SerializationTestUtils.serializeAndDeserialize(bean.em)).isNotNull();
SimpleMapScope serialized = (SimpleMapScope) SerializationTestUtils.serializeAndDeserialize(myScope);
SimpleMapScope serialized = SerializationTestUtils.serializeAndDeserialize(myScope);
serialized.close();
assertThat(DummyInvocationHandler.closed).isTrue();
DummyInvocationHandler.closed = false;

View File

@ -65,7 +65,7 @@ public class AnnotationTransactionAttributeSourceTests {
proxy.getAge();
assertThat(ptm.commits).isEqualTo(1);
ITestBean1 serializedProxy = (ITestBean1) SerializationTestUtils.serializeAndDeserialize(proxy);
ITestBean1 serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
serializedProxy.getAge();
Advised advised = (Advised) serializedProxy;
TransactionInterceptor serializedTi = (TransactionInterceptor) advised.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.
@ -87,7 +87,7 @@ public class AnnotationDrivenTests {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
TransactionalService service = context.getBean("service", TransactionalService.class);
service.setSomething("someName");
service = (TransactionalService) SerializationTestUtils.serializeAndDeserialize(service);
service = SerializationTestUtils.serializeAndDeserialize(service);
service.setSomething("someName");
}
@ -96,7 +96,7 @@ public class AnnotationDrivenTests {
public void serializableWithoutPreviousUsage() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
TransactionalService service = context.getBean("service", TransactionalService.class);
service = (TransactionalService) SerializationTestUtils.serializeAndDeserialize(service);
service = SerializationTestUtils.serializeAndDeserialize(service);
service.setSomething("someName");
}

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.
@ -90,12 +90,11 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
ti.setTransactionAttributes(props);
PlatformTransactionManager ptm = new SerializableTransactionManager();
ti.setTransactionManager(ptm);
ti = (TransactionInterceptor) SerializationTestUtils.serializeAndDeserialize(ti);
ti = SerializationTestUtils.serializeAndDeserialize(ti);
// Check that logger survived deserialization
assertThat(ti.logger).isNotNull();
boolean condition = ti.getTransactionManager() instanceof SerializableTransactionManager;
assertThat(condition).isTrue();
assertThat(ti.getTransactionManager()).isInstanceOf(SerializableTransactionManager.class);
assertThat(ti.getTransactionAttributeSource()).isNotNull();
}
@ -115,7 +114,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
ti.setTransactionAttributeSources(tas1, tas2);
PlatformTransactionManager ptm = new SerializableTransactionManager();
ti.setTransactionManager(ptm);
ti = (TransactionInterceptor) SerializationTestUtils.serializeAndDeserialize(ti);
ti = SerializationTestUtils.serializeAndDeserialize(ti);
boolean condition3 = ti.getTransactionManager() instanceof SerializableTransactionManager;
assertThat(condition3).isTrue();

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.
@ -48,8 +48,7 @@ public class JtaTransactionManagerSerializationTests {
SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder
.emptyActivatedContextBuilder();
jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2);
JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils
.serializeAndDeserialize(jtam);
JtaTransactionManager serializedJtatm = SerializationTestUtils.serializeAndDeserialize(jtam);
// should do client-side lookup
assertThat(serializedJtatm.logger).as("Logger must survive serialization").isNotNull();

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.
@ -171,7 +171,7 @@ public class SessionScopeTests {
serializedState = session.serializeState();
assertThat(bean.wasDestroyed()).isFalse();
serializedState = (Serializable) SerializationTestUtils.serializeAndDeserialize(serializedState);
serializedState = SerializationTestUtils.serializeAndDeserialize(serializedState);
session = new MockHttpSession();
session.deserializeState(serializedState);