Polish SerializationTestUtils, clean up warnings, etc.
This commit is contained in:
parent
9d5881e0ad
commit
ab0e651547
|
|
@ -70,7 +70,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||||
assertThat(singletonScoped.getName()).isEqualTo(rob);
|
assertThat(singletonScoped.getName()).isEqualTo(rob);
|
||||||
singletonScoped.setName(bram);
|
singletonScoped.setName(bram);
|
||||||
assertThat(singletonScoped.getName()).isEqualTo(bram);
|
assertThat(singletonScoped.getName()).isEqualTo(bram);
|
||||||
ITestBean deserialized = (ITestBean) SerializationTestUtils.serializeAndDeserialize(singletonScoped);
|
ITestBean deserialized = SerializationTestUtils.serializeAndDeserialize(singletonScoped);
|
||||||
assertThat(deserialized.getName()).isEqualTo(bram);
|
assertThat(deserialized.getName()).isEqualTo(bram);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -83,13 +83,12 @@ public class AspectProxyFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testSerializable() throws Exception {
|
public void testSerializable() throws Exception {
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||||
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
||||||
ITestBean proxy = proxyFactory.getProxy();
|
ITestBean proxy = proxyFactory.getProxy();
|
||||||
assertThat(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();
|
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();
|
assertThat(tb.doWithVarargs(MyEnum.A, MyOtherEnum.C)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +107,7 @@ public class AspectProxyFactoryTests {
|
||||||
ITestBean proxy = proxyFactory.getProxy();
|
ITestBean proxy = proxyFactory.getProxy();
|
||||||
assertThat(proxy.getAge()).isEqualTo((target.getAge() * multiple));
|
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));
|
assertThat(serializedProxy.getAge()).isEqualTo((target.getAge() * multiple));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +119,6 @@ public class AspectProxyFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-13328
|
@Test // SPR-13328
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testProxiedVarargsWithEnumArray() throws Exception {
|
public void testProxiedVarargsWithEnumArray() throws Exception {
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||||
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
||||||
|
|
@ -129,7 +127,6 @@ public class AspectProxyFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-13328
|
@Test // SPR-13328
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testUnproxiedVarargsWithEnumArray() throws Exception {
|
public void testUnproxiedVarargsWithEnumArray() throws Exception {
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||||
proxyFactory.addAspect(LoggingAspectOnSetter.class);
|
proxyFactory.addAspect(LoggingAspectOnSetter.class);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
ITestBean proxy = (ITestBean) proxyFactory.getProxy();
|
||||||
proxy.getAge();
|
proxy.getAge();
|
||||||
|
|
||||||
ITestBean serializedProxy = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
|
ITestBean serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
|
||||||
Advised advised = (Advised) serializedProxy;
|
Advised advised = (Advised) serializedProxy;
|
||||||
ConcurrencyThrottleInterceptor serializedCti =
|
ConcurrencyThrottleInterceptor serializedCti =
|
||||||
(ConcurrencyThrottleInterceptor) advised.getAdvisors()[0].getAdvice();
|
(ConcurrencyThrottleInterceptor) advised.getAdvisors()[0].getAdvice();
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public abstract class AbstractRegexpMethodPointcutTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerializationWithNoPatternSupplied() throws Exception {
|
public void testSerializationWithNoPatternSupplied() throws Exception {
|
||||||
rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc);
|
rpc = SerializationTestUtils.serializeAndDeserialize(rpc);
|
||||||
noPatternSuppliedTests(rpc);
|
noPatternSuppliedTests(rpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ public abstract class AbstractRegexpMethodPointcutTests {
|
||||||
public void testExactMatch() throws Exception {
|
public void testExactMatch() throws Exception {
|
||||||
rpc.setPattern("java.lang.Object.hashCode");
|
rpc.setPattern("java.lang.Object.hashCode");
|
||||||
exactMatchTests(rpc);
|
exactMatchTests(rpc);
|
||||||
rpc = (AbstractRegexpMethodPointcut) SerializationTestUtils.serializeAndDeserialize(rpc);
|
rpc = SerializationTestUtils.serializeAndDeserialize(rpc);
|
||||||
exactMatchTests(rpc);
|
exactMatchTests(rpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ public class DelegatingIntroductionInterceptorTests {
|
||||||
assertThat(p.getName()).isEqualTo(name);
|
assertThat(p.getName()).isEqualTo(name);
|
||||||
assertThat(((TimeStamped) p).getTimeStamp()).isEqualTo(time);
|
assertThat(((TimeStamped) p).getTimeStamp()).isEqualTo(time);
|
||||||
|
|
||||||
Person p1 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
|
Person p1 = SerializationTestUtils.serializeAndDeserialize(p);
|
||||||
assertThat(p1.getName()).isEqualTo(name);
|
assertThat(p1.getName()).isEqualTo(name);
|
||||||
assertThat(((TimeStamped) p1).getTimeStamp()).isEqualTo(time);
|
assertThat(((TimeStamped) p1).getTimeStamp()).isEqualTo(time);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public void testSerializable() throws Throwable {
|
||||||
testSets();
|
testSets();
|
||||||
// Count is now 2
|
// Count is now 2
|
||||||
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(proxied);
|
Person p2 = SerializationTestUtils.serializeAndDeserialize(proxied);
|
||||||
NopInterceptor nop2 = (NopInterceptor) ((Advised) p2).getAdvisors()[0].getAdvice();
|
NopInterceptor nop2 = (NopInterceptor) ((Advised) p2).getAdvisors()[0].getAdvice();
|
||||||
p2.getName();
|
p2.getName();
|
||||||
assertThat(nop2.getCount()).isEqualTo(2);
|
assertThat(nop2.getCount()).isEqualTo(2);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
assertThat(nop.getCount()).isEqualTo(2);
|
||||||
|
|
||||||
// Serialize and continue...
|
// Serialize and continue...
|
||||||
p = (Person) SerializationTestUtils.serializeAndDeserialize(p);
|
p = SerializationTestUtils.serializeAndDeserialize(p);
|
||||||
assertThat(p.getAge()).isEqualTo(newAge);
|
assertThat(p.getAge()).isEqualTo(newAge);
|
||||||
// Remembers count, but we need to get a new reference to nop...
|
// Remembers count, but we need to get a new reference to nop...
|
||||||
nop = (SerializableNopInterceptor) ((Advised) p).getAdvisors()[0].getAdvice();
|
nop = (SerializableNopInterceptor) ((Advised) p).getAdvisors()[0].getAdvice();
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -134,7 +134,7 @@ public class HotSwappableTargetSourceTests {
|
||||||
hts.swap(sp2);
|
hts.swap(sp2);
|
||||||
assertThat(p.getName()).isEqualTo(sp2.getName());
|
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
|
// We need to get a reference to the client-side targetsource
|
||||||
hts = (HotSwappableTargetSource) ((Advised) p).getTargetSource();
|
hts = (HotSwappableTargetSource) ((Advised) p).getTargetSource();
|
||||||
assertThat(p.getName()).isEqualTo(sp2.getName());
|
assertThat(p.getName()).isEqualTo(sp2.getName());
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
bf.registerBeanDefinition("person", bd);
|
||||||
|
|
||||||
TestTargetSource cpts = (TestTargetSource) bf.getBean("ts");
|
TestTargetSource cpts = (TestTargetSource) bf.getBean("ts");
|
||||||
TargetSource serialized = (TargetSource) SerializationTestUtils.serializeAndDeserialize(cpts);
|
TargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts);
|
||||||
boolean condition = serialized instanceof SingletonTargetSource;
|
boolean condition = serialized instanceof SingletonTargetSource;
|
||||||
assertThat(condition).as("Changed to SingletonTargetSource on deserialization").isTrue();
|
assertThat(condition).as("Changed to SingletonTargetSource on deserialization").isTrue();
|
||||||
SingletonTargetSource sts = (SingletonTargetSource) serialized;
|
SingletonTargetSource sts = (SingletonTargetSource) serialized;
|
||||||
|
|
|
||||||
|
|
@ -806,7 +806,6 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||||
* @param propertyPath property path, which may be nested
|
* @param propertyPath property path, which may be nested
|
||||||
* @return a property accessor for the target bean
|
* @return a property accessor for the target bean
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // avoid nested generic
|
|
||||||
protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) {
|
protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) {
|
||||||
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
|
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
|
||||||
// Handle nested properties recursively.
|
// Handle nested properties recursively.
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,6 @@ public abstract class BeanUtils {
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @see <a href="https://kotlinlang.org/docs/reference/classes.html#constructors">Kotlin docs</a>
|
* @see <a href="https://kotlinlang.org/docs/reference/classes.html#constructors">Kotlin docs</a>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz) {
|
public static <T> Constructor<T> findPrimaryConstructor(Class<T> clazz) {
|
||||||
Assert.notNull(clazz, "Class must not be null");
|
Assert.notNull(clazz, "Class must not be null");
|
||||||
|
|
|
||||||
|
|
@ -1787,7 +1787,7 @@ class DefaultListableBeanFactoryTests {
|
||||||
lbf.setSerializationId("test");
|
lbf.setSerializationId("test");
|
||||||
|
|
||||||
ObjectProvider<ConstructorDependency> provider = lbf.getBeanProvider(ConstructorDependency.class);
|
ObjectProvider<ConstructorDependency> provider = lbf.getBeanProvider(ConstructorDependency.class);
|
||||||
ObjectProvider deserialized = (ObjectProvider) SerializationTestUtils.serializeAndDeserialize(provider);
|
ObjectProvider deserialized = SerializationTestUtils.serializeAndDeserialize(provider);
|
||||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(
|
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(
|
||||||
deserialized::getObject);
|
deserialized::getObject);
|
||||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
|
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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");
|
ObjectFactoryFieldInjectionBean bean = (ObjectFactoryFieldInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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");
|
ObjectFactoryFieldInjectionBean bean = (ObjectFactoryFieldInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,7 +406,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||||
|
|
||||||
ObjectFactoryMethodInjectionBean bean = (ObjectFactoryMethodInjectionBean) bf.getBean("annotatedBean");
|
ObjectFactoryMethodInjectionBean bean = (ObjectFactoryMethodInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -418,7 +418,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||||
|
|
||||||
ObjectFactoryListFieldInjectionBean bean = (ObjectFactoryListFieldInjectionBean) bf.getBean("annotatedBean");
|
ObjectFactoryListFieldInjectionBean bean = (ObjectFactoryListFieldInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryListFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -430,7 +430,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||||
|
|
||||||
ObjectFactoryListMethodInjectionBean bean = (ObjectFactoryListMethodInjectionBean) bf.getBean("annotatedBean");
|
ObjectFactoryListMethodInjectionBean bean = (ObjectFactoryListMethodInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryListMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,7 +442,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||||
|
|
||||||
ObjectFactoryMapFieldInjectionBean bean = (ObjectFactoryMapFieldInjectionBean) bf.getBean("annotatedBean");
|
ObjectFactoryMapFieldInjectionBean bean = (ObjectFactoryMapFieldInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryMapFieldInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,7 +454,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||||
|
|
||||||
ObjectFactoryMapMethodInjectionBean bean = (ObjectFactoryMapMethodInjectionBean) bf.getBean("annotatedBean");
|
ObjectFactoryMapMethodInjectionBean bean = (ObjectFactoryMapMethodInjectionBean) bf.getBean("annotatedBean");
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
bean = (ObjectFactoryMapMethodInjectionBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
bean = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
assertThat(bean.getTestBean()).isSameAs(bf.getBean("testBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -72,12 +72,11 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public void testFactorySerialization() throws Exception {
|
public void testFactorySerialization() throws Exception {
|
||||||
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
|
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
|
||||||
ObjectFactory<?> objectFactory = testBean.getObjectFactory();
|
ObjectFactory<?> objectFactory = testBean.getObjectFactory();
|
||||||
|
|
||||||
objectFactory = (ObjectFactory) SerializationTestUtils.serializeAndDeserialize(objectFactory);
|
objectFactory = SerializationTestUtils.serializeAndDeserialize(objectFactory);
|
||||||
|
|
||||||
Date date1 = (Date) objectFactory.getObject();
|
Date date1 = (Date) objectFactory.getObject();
|
||||||
Date date2 = (Date) objectFactory.getObject();
|
Date date2 = (Date) objectFactory.getObject();
|
||||||
|
|
@ -95,12 +94,11 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public void testProviderSerialization() throws Exception {
|
public void testProviderSerialization() throws Exception {
|
||||||
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
|
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
|
||||||
Provider<?> provider = testBean.getProvider();
|
Provider<?> provider = testBean.getProvider();
|
||||||
|
|
||||||
provider = (Provider) SerializationTestUtils.serializeAndDeserialize(provider);
|
provider = SerializationTestUtils.serializeAndDeserialize(provider);
|
||||||
|
|
||||||
Date date1 = (Date) provider.get();
|
Date date1 = (Date) provider.get();
|
||||||
Date date2 = (Date) provider.get();
|
Date date2 = (Date) provider.get();
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
assertThat(cta.getCalls()).isEqualTo(1);
|
||||||
|
|
||||||
// Will throw exception if it fails
|
// Will throw exception if it fails
|
||||||
Person p2 = (Person) SerializationTestUtils.serializeAndDeserialize(p);
|
Person p2 = SerializationTestUtils.serializeAndDeserialize(p);
|
||||||
assertThat(p2).isNotSameAs(p);
|
assertThat(p2).isNotSameAs(p);
|
||||||
assertThat(p2.getName()).isEqualTo(p.getName());
|
assertThat(p2.getName()).isEqualTo(p.getName());
|
||||||
assertThat(p2.getAge()).isEqualTo(p.getAge());
|
assertThat(p2.getAge()).isEqualTo(p.getAge());
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@ public class ProxyFactoryBeanTests {
|
||||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||||
Person p = (Person) bf.getBean("serializableSingleton");
|
Person p = (Person) bf.getBean("serializableSingleton");
|
||||||
assertThat(bf.getBean("serializableSingleton")).as("Should be a Singleton").isSameAs(p);
|
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).isEqualTo(p);
|
||||||
assertThat(p2).isNotSameAs(p);
|
assertThat(p2).isNotSameAs(p);
|
||||||
assertThat(p2.getName()).isEqualTo("serializableSingleton");
|
assertThat(p2.getName()).isEqualTo("serializableSingleton");
|
||||||
|
|
@ -546,7 +546,7 @@ public class ProxyFactoryBeanTests {
|
||||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||||
Person p = (Person) bf.getBean("serializablePrototype");
|
Person p = (Person) bf.getBean("serializablePrototype");
|
||||||
assertThat(bf.getBean("serializablePrototype")).as("Should not be a Singleton").isNotSameAs(p);
|
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).isEqualTo(p);
|
||||||
assertThat(p2).isNotSameAs(p);
|
assertThat(p2).isNotSameAs(p);
|
||||||
assertThat(p2.getName()).isEqualTo("serializablePrototype");
|
assertThat(p2.getName()).isEqualTo("serializablePrototype");
|
||||||
|
|
@ -558,7 +558,7 @@ public class ProxyFactoryBeanTests {
|
||||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(SERIALIZATION_CONTEXT, CLASS));
|
||||||
Person p = (Person) bf.getBean("serializableSingleton");
|
Person p = (Person) bf.getBean("serializableSingleton");
|
||||||
ProxyFactoryBean pfb = (ProxyFactoryBean) 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();
|
Person p2 = (Person) pfb2.getObject();
|
||||||
assertThat(p2).isEqualTo(p);
|
assertThat(p2).isEqualTo(p);
|
||||||
assertThat(p2).isNotSameAs(p);
|
assertThat(p2).isNotSameAs(p);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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().containsKey("testBeanTarget")).isTrue();
|
||||||
assertThat(scope.getMap().get("testBeanTarget").getClass()).isEqualTo(TestBean.class);
|
assertThat(scope.getMap().get("testBeanTarget").getClass()).isEqualTo(TestBean.class);
|
||||||
|
|
||||||
ITestBean deserialized = (ITestBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
ITestBean deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(deserialized).isNotNull();
|
assertThat(deserialized).isNotNull();
|
||||||
assertThat(AopUtils.isJdkDynamicProxy(deserialized)).isTrue();
|
assertThat(AopUtils.isJdkDynamicProxy(deserialized)).isTrue();
|
||||||
assertThat(bean.getAge()).isEqualTo(101);
|
assertThat(bean.getAge()).isEqualTo(101);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* Tests for pooling invoker interceptor.
|
||||||
|
*
|
||||||
* TODO: need to make these tests stronger: it's hard to
|
* TODO: need to make these tests stronger: it's hard to
|
||||||
* make too many assumptions about a pool.
|
* make too many assumptions about a pool.
|
||||||
*
|
*
|
||||||
|
|
@ -45,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
public class CommonsPool2TargetSourceTests {
|
class CommonsPool2TargetSourceTests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial count value set in bean factory XML
|
* Initial count value set in bean factory XML
|
||||||
|
|
@ -55,7 +56,7 @@ public class CommonsPool2TargetSourceTests {
|
||||||
private DefaultListableBeanFactory beanFactory;
|
private DefaultListableBeanFactory beanFactory;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
void setUp() throws Exception {
|
||||||
this.beanFactory = new DefaultListableBeanFactory();
|
this.beanFactory = new DefaultListableBeanFactory();
|
||||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||||
new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
|
new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass()));
|
||||||
|
|
@ -65,7 +66,7 @@ public class CommonsPool2TargetSourceTests {
|
||||||
* We must simulate container shutdown, which should clear threads.
|
* We must simulate container shutdown, which should clear threads.
|
||||||
*/
|
*/
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void tearDown() {
|
void tearDown() {
|
||||||
// Will call pool.close()
|
// Will call pool.close()
|
||||||
this.beanFactory.destroySingletons();
|
this.beanFactory.destroySingletons();
|
||||||
}
|
}
|
||||||
|
|
@ -84,17 +85,17 @@ public class CommonsPool2TargetSourceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFunctionality() {
|
void testFunctionality() {
|
||||||
testFunctionality("pooled");
|
testFunctionality("pooled");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFunctionalityWithNoInterceptors() {
|
void testFunctionalityWithNoInterceptors() {
|
||||||
testFunctionality("pooledNoInterceptors");
|
testFunctionality("pooledNoInterceptors");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConfigMixin() {
|
void testConfigMixin() {
|
||||||
SideEffectBean pooled = (SideEffectBean) beanFactory.getBean("pooledWithMixin");
|
SideEffectBean pooled = (SideEffectBean) beanFactory.getBean("pooledWithMixin");
|
||||||
assertThat(pooled.getCount()).isEqualTo(INITIAL_COUNT);
|
assertThat(pooled.getCount()).isEqualTo(INITIAL_COUNT);
|
||||||
PoolingConfig conf = (PoolingConfig) beanFactory.getBean("pooledWithMixin");
|
PoolingConfig conf = (PoolingConfig) beanFactory.getBean("pooledWithMixin");
|
||||||
|
|
@ -109,25 +110,22 @@ public class CommonsPool2TargetSourceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTargetSourceSerializableWithoutConfigMixin() throws Exception {
|
void testTargetSourceSerializableWithoutConfigMixin() throws Exception {
|
||||||
CommonsPool2TargetSource cpts = (CommonsPool2TargetSource) beanFactory.getBean("personPoolTargetSource");
|
CommonsPool2TargetSource cpts = (CommonsPool2TargetSource) beanFactory.getBean("personPoolTargetSource");
|
||||||
|
|
||||||
SingletonTargetSource serialized = (SingletonTargetSource) SerializationTestUtils.serializeAndDeserialize(cpts);
|
SingletonTargetSource serialized = SerializationTestUtils.serializeAndDeserialize(cpts, SingletonTargetSource.class);
|
||||||
boolean condition = serialized.getTarget() instanceof Person;
|
assertThat(serialized.getTarget()).isInstanceOf(Person.class);
|
||||||
assertThat(condition).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProxySerializableWithoutConfigMixin() throws Exception {
|
void testProxySerializableWithoutConfigMixin() throws Exception {
|
||||||
Person pooled = (Person) beanFactory.getBean("pooledPerson");
|
Person pooled = (Person) beanFactory.getBean("pooledPerson");
|
||||||
|
|
||||||
//System.out.println(((Advised) pooled).toProxyConfigString());
|
|
||||||
boolean condition1 = ((Advised) pooled).getTargetSource() instanceof CommonsPool2TargetSource;
|
boolean condition1 = ((Advised) pooled).getTargetSource() instanceof CommonsPool2TargetSource;
|
||||||
assertThat(condition1).isTrue();
|
assertThat(condition1).isTrue();
|
||||||
|
|
||||||
//((Advised) pooled).setTargetSource(new SingletonTargetSource(new SerializablePerson()));
|
//((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;
|
boolean condition = ((Advised) serialized).getTargetSource() instanceof SingletonTargetSource;
|
||||||
assertThat(condition).isTrue();
|
assertThat(condition).isTrue();
|
||||||
serialized.setAge(25);
|
serialized.setAge(25);
|
||||||
|
|
@ -135,7 +133,7 @@ public class CommonsPool2TargetSourceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHitMaxSize() throws Exception {
|
void testHitMaxSize() throws Exception {
|
||||||
int maxSize = 10;
|
int maxSize = 10;
|
||||||
|
|
||||||
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
||||||
|
|
@ -166,7 +164,7 @@ public class CommonsPool2TargetSourceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHitMaxSizeLoadedFromContext() throws Exception {
|
void testHitMaxSizeLoadedFromContext() throws Exception {
|
||||||
Advised person = (Advised) beanFactory.getBean("maxSizePooledPerson");
|
Advised person = (Advised) beanFactory.getBean("maxSizePooledPerson");
|
||||||
CommonsPool2TargetSource targetSource = (CommonsPool2TargetSource) person.getTargetSource();
|
CommonsPool2TargetSource targetSource = (CommonsPool2TargetSource) person.getTargetSource();
|
||||||
|
|
||||||
|
|
@ -195,14 +193,14 @@ public class CommonsPool2TargetSourceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetWhenExhaustedAction() {
|
void testSetWhenExhaustedAction() {
|
||||||
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
||||||
targetSource.setBlockWhenExhausted(true);
|
targetSource.setBlockWhenExhausted(true);
|
||||||
assertThat(targetSource.isBlockWhenExhausted()).isEqualTo(true);
|
assertThat(targetSource.isBlockWhenExhausted()).isEqualTo(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void referenceIdentityByDefault() throws Exception {
|
void referenceIdentityByDefault() throws Exception {
|
||||||
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource();
|
||||||
targetSource.setMaxWait(1);
|
targetSource.setMaxWait(1);
|
||||||
prepareTargetSource(targetSource);
|
prepareTargetSource(targetSource);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.annotation.InitDestroyAnnotationBeanPostProcessor;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
|
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.DefaultListableBeanFactory;
|
||||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||||
import org.springframework.beans.testfixture.beans.INestedTestBean;
|
import org.springframework.beans.testfixture.beans.INestedTestBean;
|
||||||
|
|
@ -122,8 +121,7 @@ public class CommonAnnotationBeanPostProcessorTests {
|
||||||
@Test
|
@Test
|
||||||
public void testSerialization() throws Exception {
|
public void testSerialization() throws Exception {
|
||||||
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
|
CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor();
|
||||||
CommonAnnotationBeanPostProcessor bpp2 = (CommonAnnotationBeanPostProcessor)
|
CommonAnnotationBeanPostProcessor bpp2 = SerializationTestUtils.serializeAndDeserialize(bpp);
|
||||||
SerializationTestUtils.serializeAndDeserialize(bpp);
|
|
||||||
|
|
||||||
AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
|
AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
|
||||||
bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
|
bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
|
||||||
|
|
@ -135,8 +133,7 @@ public class CommonAnnotationBeanPostProcessorTests {
|
||||||
InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
|
InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor();
|
||||||
bpp.setInitAnnotationType(PostConstruct.class);
|
bpp.setInitAnnotationType(PostConstruct.class);
|
||||||
bpp.setDestroyAnnotationType(PreDestroy.class);
|
bpp.setDestroyAnnotationType(PreDestroy.class);
|
||||||
InitDestroyAnnotationBeanPostProcessor bpp2 = (InitDestroyAnnotationBeanPostProcessor)
|
InitDestroyAnnotationBeanPostProcessor bpp2 = SerializationTestUtils.serializeAndDeserialize(bpp);
|
||||||
SerializationTestUtils.serializeAndDeserialize(bpp);
|
|
||||||
|
|
||||||
AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
|
AnnotatedInitDestroyBean bean = new AnnotatedInitDestroyBean();
|
||||||
bpp2.postProcessBeforeDestruction(bean, "annotatedBean");
|
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();
|
Properties props = new Properties();
|
||||||
props.setProperty("tb", "testBean4");
|
props.setProperty("tb", "testBean4");
|
||||||
ppc.setProperties(props);
|
ppc.setProperties(props);
|
||||||
|
|
@ -322,7 +320,8 @@ public class CommonAnnotationBeanPostProcessorTests {
|
||||||
bf.addBeanPostProcessor(bpp);
|
bf.addBeanPostProcessor(bpp);
|
||||||
bf.registerResolvableDependency(BeanFactory.class, bf);
|
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();
|
Properties props = new Properties();
|
||||||
props.setProperty("tb", "testBean3");
|
props.setProperty("tb", "testBean3");
|
||||||
ppc.setProperties(props);
|
ppc.setProperties(props);
|
||||||
|
|
@ -374,7 +373,8 @@ public class CommonAnnotationBeanPostProcessorTests {
|
||||||
bf.addBeanPostProcessor(bpp);
|
bf.addBeanPostProcessor(bpp);
|
||||||
bf.registerResolvableDependency(BeanFactory.class, bf);
|
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();
|
Properties props = new Properties();
|
||||||
props.setProperty("tb", "testBean3");
|
props.setProperty("tb", "testBean3");
|
||||||
ppc.setProperties(props);
|
ppc.setProperties(props);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
|
||||||
// test serializability
|
// test serializability
|
||||||
assertThat(bean.foo(1)).isEqualTo("bar");
|
assertThat(bean.foo(1)).isEqualTo("bar");
|
||||||
FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean);
|
FooService deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(deserialized).isNotNull();
|
assertThat(deserialized).isNotNull();
|
||||||
assertThat(deserialized.foo(1)).isEqualTo("bar");
|
assertThat(deserialized.foo(1)).isEqualTo("bar");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
|
||||||
// test serializability
|
// test serializability
|
||||||
assertThat(bean.foo(1)).isEqualTo("bar");
|
assertThat(bean.foo(1)).isEqualTo("bar");
|
||||||
FooService deserialized = (FooService) SerializationTestUtils.serializeAndDeserialize(bean);
|
FooService deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(deserialized).isNotNull();
|
assertThat(deserialized).isNotNull();
|
||||||
assertThat(deserialized.foo(1)).isEqualTo("bar");
|
assertThat(deserialized.foo(1)).isEqualTo("bar");
|
||||||
context.close();
|
context.close();
|
||||||
|
|
@ -89,7 +89,7 @@ public class ComponentScanParserScopedProxyTests {
|
||||||
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
|
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
|
||||||
// test serializability
|
// test serializability
|
||||||
assertThat(bean.foo(1)).isEqualTo("bar");
|
assertThat(bean.foo(1)).isEqualTo("bar");
|
||||||
ScopedProxyTestBean deserialized = (ScopedProxyTestBean) SerializationTestUtils.serializeAndDeserialize(bean);
|
ScopedProxyTestBean deserialized = SerializationTestUtils.serializeAndDeserialize(bean);
|
||||||
assertThat(deserialized).isNotNull();
|
assertThat(deserialized).isNotNull();
|
||||||
assertThat(deserialized.foo(1)).isEqualTo("bar");
|
assertThat(deserialized.foo(1)).isEqualTo("bar");
|
||||||
context.close();
|
context.close();
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.optionalValue3.isPresent()).isFalse();
|
||||||
assertThat(tb3.tb).isSameAs(tb0);
|
assertThat(tb3.tb).isSameAs(tb0);
|
||||||
|
|
||||||
tb3 = (ValueTestBean) SerializationTestUtils.serializeAndDeserialize(tb3);
|
tb3 = SerializationTestUtils.serializeAndDeserialize(tb3);
|
||||||
assertThat(tb3.countryFactory.getObject()).isEqualTo("123 UK");
|
assertThat(tb3.countryFactory.getObject()).isEqualTo("123 UK");
|
||||||
|
|
||||||
ConstructorValueTestBean tb4 = ac.getBean("tb4", ConstructorValueTestBean.class);
|
ConstructorValueTestBean tb4 = ac.getBean("tb4", ConstructorValueTestBean.class);
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,10 @@ class SocketUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("try")
|
|
||||||
void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
|
void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
|
||||||
int port = SocketUtils.findAvailableTcpPort();
|
int port = SocketUtils.findAvailableTcpPort();
|
||||||
try (ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost"))) {
|
try (ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost"))) {
|
||||||
|
assertThat(socket).isNotNull();
|
||||||
// will only look for the exact port
|
// will only look for the exact port
|
||||||
assertThatIllegalStateException().isThrownBy(() ->
|
assertThatIllegalStateException().isThrownBy(() ->
|
||||||
SocketUtils.findAvailableTcpPort(port, port))
|
SocketUtils.findAvailableTcpPort(port, port))
|
||||||
|
|
@ -149,10 +149,10 @@ class SocketUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("try")
|
|
||||||
void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
|
void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
|
||||||
int port = SocketUtils.findAvailableUdpPort();
|
int port = SocketUtils.findAvailableUdpPort();
|
||||||
try (DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"))) {
|
try (DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"))) {
|
||||||
|
assertThat(socket).isNotNull();
|
||||||
// will only look for the exact port
|
// will only look for the exact port
|
||||||
assertThatIllegalStateException().isThrownBy(() ->
|
assertThatIllegalStateException().isThrownBy(() ->
|
||||||
SocketUtils.findAvailableUdpPort(port, port))
|
SocketUtils.findAvailableUdpPort(port, port))
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,11 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for testing serializability of objects.
|
* 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 Rod Johnson
|
||||||
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
public class SerializationTestUtils {
|
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();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||||
oos.writeObject(o);
|
oos.writeObject(o);
|
||||||
|
|
@ -59,7 +62,21 @@ public class SerializationTestUtils {
|
||||||
|
|
||||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||||
try (ObjectInputStream ois = new ObjectInputStream(is)) {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
* A {@link MessagingMessageConverter} that lazily invokes payload extraction and
|
||||||
* delegate it to {@link #extractMessage(javax.jms.Message)} in order to enforce
|
* delegates it to {@link #extractMessage(javax.jms.Message)} in order to enforce
|
||||||
* backward compatibility.
|
* backward compatibility.
|
||||||
*/
|
*/
|
||||||
private class MessagingMessageConverterAdapter extends MessagingMessageConverter {
|
private class MessagingMessageConverterAdapter extends MessagingMessageConverter {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
|
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
|
||||||
return new LazyResolutionMessage(message);
|
return new LazyResolutionMessage(message);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -325,6 +325,7 @@ public class StubTextMessage implements TextMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public boolean isBodyAssignableTo(Class c) throws JMSException {
|
public boolean isBodyAssignableTo(Class c) throws JMSException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
containers = context.getBeansOfType(GenericMessageEndpointManager.class);
|
||||||
assertThat(containers.size()).as("Context should contain 3 JCA endpoint containers").isEqualTo(3);
|
assertThat(containers.size()).as("Context should contain 3 JCA endpoint containers").isEqualTo(3);
|
||||||
|
|
||||||
Map<String, JmsListenerContainerFactory> containerFactories =
|
assertThat(context.getBeansOfType(JmsListenerContainerFactory.class))
|
||||||
context.getBeansOfType(JmsListenerContainerFactory.class);
|
.as("Context should contain 3 JmsListenerContainerFactory instances").hasSize(3);
|
||||||
assertThat(containerFactories.size()).as("Context should contain 3 JmsListenerContainerFactory instances").isEqualTo(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
|
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
|
||||||
context.refresh();
|
context.refresh();
|
||||||
|
context.close();
|
||||||
|
|
||||||
verify(connection).setExceptionListener(this.container);
|
verify(connection).setExceptionListener(this.container);
|
||||||
}
|
}
|
||||||
|
|
@ -151,6 +152,7 @@ public class SimpleMessageListenerContainerTests {
|
||||||
GenericApplicationContext context = new GenericApplicationContext();
|
GenericApplicationContext context = new GenericApplicationContext();
|
||||||
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
|
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
|
||||||
context.refresh();
|
context.refresh();
|
||||||
|
context.close();
|
||||||
|
|
||||||
verify(connection).setExceptionListener(this.container);
|
verify(connection).setExceptionListener(this.container);
|
||||||
verify(connection).start();
|
verify(connection).start();
|
||||||
|
|
|
||||||
|
|
@ -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);
|
Method m = ReflectionUtils.findMethod(SampleBean.class, methodName, parameterTypes);
|
||||||
return createInstance(m);
|
return createInstance(m);
|
||||||
}
|
}
|
||||||
|
|
@ -353,7 +353,7 @@ public class MessagingMessageListenerAdapterTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MessagingMessageListenerAdapter getPayloadInstance(final Object payload,
|
protected MessagingMessageListenerAdapter getPayloadInstance(final Object payload,
|
||||||
String methodName, Class... parameterTypes) {
|
String methodName, Class<?>... parameterTypes) {
|
||||||
|
|
||||||
Method method = ReflectionUtils.findMethod(SampleBean.class, methodName, parameterTypes);
|
Method method = ReflectionUtils.findMethod(SampleBean.class, methodName, parameterTypes);
|
||||||
MessagingMessageListenerAdapter adapter = new MessagingMessageListenerAdapter() {
|
MessagingMessageListenerAdapter adapter = new MessagingMessageListenerAdapter() {
|
||||||
|
|
@ -435,6 +435,7 @@ public class MessagingMessageListenerAdapterTests {
|
||||||
interface Summary {};
|
interface Summary {};
|
||||||
interface Full extends Summary {};
|
interface Full extends Summary {};
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class SampleResponse {
|
private static class SampleResponse {
|
||||||
|
|
||||||
private int counter = 42;
|
private int counter = 42;
|
||||||
|
|
@ -445,9 +446,6 @@ public class MessagingMessageListenerAdapterTests {
|
||||||
@JsonView(Full.class)
|
@JsonView(Full.class)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
SampleResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public SampleResponse(String name, String description) {
|
public SampleResponse(String name, String description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -392,6 +392,7 @@ public class JmsInvokerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public boolean isBodyAssignableTo(Class c) throws JMSException {
|
public boolean isBodyAssignableTo(Class c) throws JMSException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -451,6 +452,7 @@ public class JmsInvokerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public Enumeration getPropertyNames() throws JMSException {
|
public Enumeration getPropertyNames() throws JMSException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {};
|
private interface Full extends Summary {};
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static class MyAnotherBean {
|
private static class MyAnotherBean {
|
||||||
|
|
||||||
@JsonView(Summary.class)
|
@JsonView(Summary.class)
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ public class MessageHeadersTests {
|
||||||
map.put("name", "joe");
|
map.put("name", "joe");
|
||||||
map.put("age", 42);
|
map.put("age", 42);
|
||||||
MessageHeaders input = new MessageHeaders(map);
|
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("name")).isEqualTo("joe");
|
||||||
assertThat(output.get("age")).isEqualTo(42);
|
assertThat(output.get("age")).isEqualTo(42);
|
||||||
assertThat(input.get("name")).isEqualTo("joe");
|
assertThat(input.get("name")).isEqualTo("joe");
|
||||||
|
|
@ -178,7 +178,7 @@ public class MessageHeadersTests {
|
||||||
map.put("name", "joe");
|
map.put("name", "joe");
|
||||||
map.put("address", address);
|
map.put("address", address);
|
||||||
MessageHeaders input = new MessageHeaders(map);
|
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("name")).isEqualTo("joe");
|
||||||
assertThat(output.get("address")).isNull();
|
assertThat(output.get("address")).isNull();
|
||||||
assertThat(input.get("name")).isEqualTo("joe");
|
assertThat(input.get("name")).isEqualTo("joe");
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ import java.util.function.Function;
|
||||||
import io.reactivex.rxjava3.core.Completable;
|
import io.reactivex.rxjava3.core.Completable;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
import io.reactivex.rxjava3.core.Single;
|
import io.reactivex.rxjava3.core.Single;
|
||||||
import io.rsocket.AbstractRSocket;
|
|
||||||
import io.rsocket.Payload;
|
import io.rsocket.Payload;
|
||||||
|
import io.rsocket.RSocket;
|
||||||
import io.rsocket.metadata.WellKnownMimeType;
|
import io.rsocket.metadata.WellKnownMimeType;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
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 Mono<Payload> payloadMonoToReturn = Mono.empty();
|
||||||
private Flux<Payload> payloadFluxToReturn = Flux.empty();
|
private Flux<Payload> payloadFluxToReturn = Flux.empty();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import io.netty.buffer.PooledByteBufAllocator;
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
import io.netty.util.ReferenceCounted;
|
import io.netty.util.ReferenceCounted;
|
||||||
import io.rsocket.AbstractRSocket;
|
|
||||||
import io.rsocket.RSocket;
|
import io.rsocket.RSocket;
|
||||||
import io.rsocket.SocketAcceptor;
|
import io.rsocket.SocketAcceptor;
|
||||||
import io.rsocket.core.RSocketServer;
|
import io.rsocket.core.RSocketServer;
|
||||||
|
|
@ -240,7 +239,7 @@ class RSocketBufferLeakTests {
|
||||||
* Store all intercepted incoming and outgoing payloads and then use
|
* Store all intercepted incoming and outgoing payloads and then use
|
||||||
* {@link #checkForLeaks()} at the end to check reference counts.
|
* {@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<>();
|
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;
|
private final RSocket delegate;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ public class RSocketServerToClientIntegrationTests {
|
||||||
Mono.fromRunnable(testEcho)
|
Mono.fromRunnable(testEcho)
|
||||||
.doOnError(ex -> result.onError(ex))
|
.doOnError(ex -> result.onError(ex))
|
||||||
.doOnSuccess(o -> result.onComplete())
|
.doOnSuccess(o -> result.onComplete())
|
||||||
.subscribeOn(Schedulers.elastic()) // StepVerifier will block
|
.subscribeOn(Schedulers.boundedElastic()) // StepVerifier will block
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
mutableAccessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
|
||||||
|
|
||||||
message = new GenericMessage<>(message.getPayload(), mutableAccessor.getMessageHeaders());
|
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.getPayload()).isEqualTo("test");
|
||||||
assertThat(output.getHeaders().get("foo")).isEqualTo("bar");
|
assertThat(output.getHeaders().get("foo")).isEqualTo("bar");
|
||||||
assertThat(output.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isNotNull();
|
assertThat(output.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isNotNull();
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT
|
||||||
assertThat(bean.em).isNotNull();
|
assertThat(bean.em).isNotNull();
|
||||||
assertThat(SerializationTestUtils.serializeAndDeserialize(bean.em)).isNotNull();
|
assertThat(SerializationTestUtils.serializeAndDeserialize(bean.em)).isNotNull();
|
||||||
|
|
||||||
SimpleMapScope serialized = (SimpleMapScope) SerializationTestUtils.serializeAndDeserialize(myScope);
|
SimpleMapScope serialized = SerializationTestUtils.serializeAndDeserialize(myScope);
|
||||||
serialized.close();
|
serialized.close();
|
||||||
assertThat(DummyInvocationHandler.closed).isTrue();
|
assertThat(DummyInvocationHandler.closed).isTrue();
|
||||||
DummyInvocationHandler.closed = false;
|
DummyInvocationHandler.closed = false;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class AnnotationTransactionAttributeSourceTests {
|
||||||
proxy.getAge();
|
proxy.getAge();
|
||||||
assertThat(ptm.commits).isEqualTo(1);
|
assertThat(ptm.commits).isEqualTo(1);
|
||||||
|
|
||||||
ITestBean1 serializedProxy = (ITestBean1) SerializationTestUtils.serializeAndDeserialize(proxy);
|
ITestBean1 serializedProxy = SerializationTestUtils.serializeAndDeserialize(proxy);
|
||||||
serializedProxy.getAge();
|
serializedProxy.getAge();
|
||||||
Advised advised = (Advised) serializedProxy;
|
Advised advised = (Advised) serializedProxy;
|
||||||
TransactionInterceptor serializedTi = (TransactionInterceptor) advised.getAdvisors()[0].getAdvice();
|
TransactionInterceptor serializedTi = (TransactionInterceptor) advised.getAdvisors()[0].getAdvice();
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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());
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
|
||||||
TransactionalService service = context.getBean("service", TransactionalService.class);
|
TransactionalService service = context.getBean("service", TransactionalService.class);
|
||||||
service.setSomething("someName");
|
service.setSomething("someName");
|
||||||
service = (TransactionalService) SerializationTestUtils.serializeAndDeserialize(service);
|
service = SerializationTestUtils.serializeAndDeserialize(service);
|
||||||
service.setSomething("someName");
|
service.setSomething("someName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ public class AnnotationDrivenTests {
|
||||||
public void serializableWithoutPreviousUsage() throws Exception {
|
public void serializableWithoutPreviousUsage() throws Exception {
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("annotationDrivenProxyTargetClassTests.xml", getClass());
|
||||||
TransactionalService service = context.getBean("service", TransactionalService.class);
|
TransactionalService service = context.getBean("service", TransactionalService.class);
|
||||||
service = (TransactionalService) SerializationTestUtils.serializeAndDeserialize(service);
|
service = SerializationTestUtils.serializeAndDeserialize(service);
|
||||||
service.setSomething("someName");
|
service.setSomething("someName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
ti.setTransactionAttributes(props);
|
||||||
PlatformTransactionManager ptm = new SerializableTransactionManager();
|
PlatformTransactionManager ptm = new SerializableTransactionManager();
|
||||||
ti.setTransactionManager(ptm);
|
ti.setTransactionManager(ptm);
|
||||||
ti = (TransactionInterceptor) SerializationTestUtils.serializeAndDeserialize(ti);
|
ti = SerializationTestUtils.serializeAndDeserialize(ti);
|
||||||
|
|
||||||
// Check that logger survived deserialization
|
// Check that logger survived deserialization
|
||||||
assertThat(ti.logger).isNotNull();
|
assertThat(ti.logger).isNotNull();
|
||||||
boolean condition = ti.getTransactionManager() instanceof SerializableTransactionManager;
|
assertThat(ti.getTransactionManager()).isInstanceOf(SerializableTransactionManager.class);
|
||||||
assertThat(condition).isTrue();
|
|
||||||
assertThat(ti.getTransactionAttributeSource()).isNotNull();
|
assertThat(ti.getTransactionAttributeSource()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +114,7 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
|
||||||
ti.setTransactionAttributeSources(tas1, tas2);
|
ti.setTransactionAttributeSources(tas1, tas2);
|
||||||
PlatformTransactionManager ptm = new SerializableTransactionManager();
|
PlatformTransactionManager ptm = new SerializableTransactionManager();
|
||||||
ti.setTransactionManager(ptm);
|
ti.setTransactionManager(ptm);
|
||||||
ti = (TransactionInterceptor) SerializationTestUtils.serializeAndDeserialize(ti);
|
ti = SerializationTestUtils.serializeAndDeserialize(ti);
|
||||||
|
|
||||||
boolean condition3 = ti.getTransactionManager() instanceof SerializableTransactionManager;
|
boolean condition3 = ti.getTransactionManager() instanceof SerializableTransactionManager;
|
||||||
assertThat(condition3).isTrue();
|
assertThat(condition3).isTrue();
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -48,8 +48,7 @@ public class JtaTransactionManagerSerializationTests {
|
||||||
SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder
|
SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder
|
||||||
.emptyActivatedContextBuilder();
|
.emptyActivatedContextBuilder();
|
||||||
jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2);
|
jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2);
|
||||||
JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils
|
JtaTransactionManager serializedJtatm = SerializationTestUtils.serializeAndDeserialize(jtam);
|
||||||
.serializeAndDeserialize(jtam);
|
|
||||||
|
|
||||||
// should do client-side lookup
|
// should do client-side lookup
|
||||||
assertThat(serializedJtatm.logger).as("Logger must survive serialization").isNotNull();
|
assertThat(serializedJtatm.logger).as("Logger must survive serialization").isNotNull();
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -171,7 +171,7 @@ public class SessionScopeTests {
|
||||||
serializedState = session.serializeState();
|
serializedState = session.serializeState();
|
||||||
assertThat(bean.wasDestroyed()).isFalse();
|
assertThat(bean.wasDestroyed()).isFalse();
|
||||||
|
|
||||||
serializedState = (Serializable) SerializationTestUtils.serializeAndDeserialize(serializedState);
|
serializedState = SerializationTestUtils.serializeAndDeserialize(serializedState);
|
||||||
|
|
||||||
session = new MockHttpSession();
|
session = new MockHttpSession();
|
||||||
session.deserializeState(serializedState);
|
session.deserializeState(serializedState);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue