Refactor AssertJ assertions into more idiomatic ones
This commit refactors some AssertJ assertions into more idiomatic and readable ones. Using the dedicated assertion instead of a generic one will produce more meaningful error messages. For instance, consider collection size: ``` // expected: 5 but was: 2 assertThat(collection.size()).equals(5); // Expected size: 5 but was: 2 in: [1, 2] assertThat(collection).hasSize(5); ``` Closes gh-30104
This commit is contained in:
parent
dd97ee4e99
commit
1734deca1e
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -99,7 +99,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
|||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(oldRequest));
|
||||
assertThat(requestScoped.getName()).isEqualTo(bram);
|
||||
|
||||
assertThat(((Advised) requestScoped).getAdvisors().length > 0).as("Should have advisors").isTrue();
|
||||
assertThat(((Advised) requestScoped).getAdvisors()).as("Should have advisors").isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -131,7 +131,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
|||
request.setSession(oldSession);
|
||||
assertThat(sessionScoped.getName()).isEqualTo(bram);
|
||||
|
||||
assertThat(((Advised) sessionScoped).getAdvisors().length > 0).as("Should have advisors").isTrue();
|
||||
assertThat(((Advised) sessionScoped).getAdvisors()).as("Should have advisors").isNotEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -52,25 +52,25 @@ class ComponentBeanDefinitionParserTests {
|
|||
@Test
|
||||
void testBionicBasic() {
|
||||
Component cp = getBionicFamily();
|
||||
assertThat("Bionic-1").isEqualTo(cp.getName());
|
||||
assertThat(cp.getName()).isEqualTo("Bionic-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBionicFirstLevelChildren() {
|
||||
Component cp = getBionicFamily();
|
||||
List<Component> components = cp.getComponents();
|
||||
assertThat(2).isEqualTo(components.size());
|
||||
assertThat("Mother-1").isEqualTo(components.get(0).getName());
|
||||
assertThat("Rock-1").isEqualTo(components.get(1).getName());
|
||||
assertThat(components).hasSize(2);
|
||||
assertThat(components.get(0).getName()).isEqualTo("Mother-1");
|
||||
assertThat(components.get(1).getName()).isEqualTo("Rock-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBionicSecondLevelChildren() {
|
||||
Component cp = getBionicFamily();
|
||||
List<Component> components = cp.getComponents().get(0).getComponents();
|
||||
assertThat(2).isEqualTo(components.size());
|
||||
assertThat("Karate-1").isEqualTo(components.get(0).getName());
|
||||
assertThat("Sport-1").isEqualTo(components.get(1).getName());
|
||||
assertThat(components).hasSize(2);
|
||||
assertThat(components.get(0).getName()).isEqualTo("Karate-1");
|
||||
assertThat(components.get(1).getName()).isEqualTo("Sport-1");
|
||||
}
|
||||
|
||||
private Component getBionicFamily() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -70,7 +70,7 @@ public class MethodInvocationProceedingJoinPointTests {
|
|||
AtomicInteger depth = new AtomicInteger();
|
||||
pf.addAdvice((MethodBeforeAdvice) (method, args, target) -> {
|
||||
JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
|
||||
assertThat(jp.toString().contains(method.getName())).as("Method named in toString").isTrue();
|
||||
assertThat(jp.toString()).as("Method named in toString").contains(method.getName());
|
||||
// Ensure that these don't cause problems
|
||||
jp.toShortString();
|
||||
jp.toLongString();
|
||||
|
|
|
|||
|
|
@ -319,10 +319,10 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
@Test
|
||||
void introductionOnTargetNotImplementingInterface() {
|
||||
NotLockable notLockableTarget = new NotLockable();
|
||||
assertThat(notLockableTarget instanceof Lockable).isFalse();
|
||||
assertThat(notLockableTarget).isNotInstanceOf(Lockable.class);
|
||||
NotLockable notLockable1 = createProxy(notLockableTarget, NotLockable.class,
|
||||
getAdvisorFactory().getAdvisors(aspectInstanceFactory(new MakeLockable(), "someBean")));
|
||||
assertThat(notLockable1 instanceof Lockable).isTrue();
|
||||
assertThat(notLockable1).isInstanceOf(Lockable.class);
|
||||
Lockable lockable = (Lockable) notLockable1;
|
||||
assertThat(lockable.locked()).isFalse();
|
||||
lockable.lock();
|
||||
|
|
@ -331,7 +331,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
NotLockable notLockable2Target = new NotLockable();
|
||||
NotLockable notLockable2 = createProxy(notLockable2Target, NotLockable.class,
|
||||
getAdvisorFactory().getAdvisors(aspectInstanceFactory(new MakeLockable(), "someBean")));
|
||||
assertThat(notLockable2 instanceof Lockable).isTrue();
|
||||
assertThat(notLockable2).isInstanceOf(Lockable.class);
|
||||
Lockable lockable2 = (Lockable) notLockable2;
|
||||
assertThat(lockable2.locked()).isFalse();
|
||||
notLockable2.setIntValue(1);
|
||||
|
|
@ -345,7 +345,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
assertThat(AopUtils.findAdvisorsThatCanApply(
|
||||
getAdvisorFactory().getAdvisors(
|
||||
aspectInstanceFactory(new MakeLockable(), "someBean")),
|
||||
CannotBeUnlocked.class).isEmpty()).isTrue();
|
||||
CannotBeUnlocked.class)).isEmpty();
|
||||
assertThat(AopUtils.findAdvisorsThatCanApply(getAdvisorFactory().getAdvisors(
|
||||
aspectInstanceFactory(new MakeLockable(),"someBean")), NotLockable.class)).hasSize(2);
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
AopUtils.findAdvisorsThatCanApply(
|
||||
getAdvisorFactory().getAdvisors(aspectInstanceFactory(new MakeLockable(), "someBean")),
|
||||
List.class));
|
||||
assertThat(proxy instanceof Lockable).as("Type pattern must have excluded mixin").isFalse();
|
||||
assertThat(proxy).as("Type pattern must have excluded mixin").isNotInstanceOf(Lockable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -430,7 +430,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
UnsupportedOperationException expectedException = new UnsupportedOperationException();
|
||||
List<Advisor> advisors = getAdvisorFactory().getAdvisors(
|
||||
aspectInstanceFactory(new ExceptionThrowingAspect(expectedException), "someBean"));
|
||||
assertThat(advisors.size()).as("One advice method was found").isEqualTo(1);
|
||||
assertThat(advisors).as("One advice method was found").hasSize(1);
|
||||
ITestBean itb = createProxy(target, ITestBean.class, advisors);
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(itb::getAge);
|
||||
}
|
||||
|
|
@ -443,7 +443,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
RemoteException expectedException = new RemoteException();
|
||||
List<Advisor> advisors = getAdvisorFactory().getAdvisors(
|
||||
aspectInstanceFactory(new ExceptionThrowingAspect(expectedException), "someBean"));
|
||||
assertThat(advisors.size()).as("One advice method was found").isEqualTo(1);
|
||||
assertThat(advisors).as("One advice method was found").hasSize(1);
|
||||
ITestBean itb = createProxy(target, ITestBean.class, advisors);
|
||||
assertThatExceptionOfType(UndeclaredThrowableException.class)
|
||||
.isThrownBy(itb::getAge)
|
||||
|
|
@ -456,7 +456,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
|||
TwoAdviceAspect twoAdviceAspect = new TwoAdviceAspect();
|
||||
List<Advisor> advisors = getAdvisorFactory().getAdvisors(
|
||||
aspectInstanceFactory(twoAdviceAspect, "someBean"));
|
||||
assertThat(advisors.size()).as("Two advice methods found").isEqualTo(2);
|
||||
assertThat(advisors).as("Two advice methods found").hasSize(2);
|
||||
ITestBean itb = createProxy(target, ITestBean.class, advisors);
|
||||
itb.setName("");
|
||||
assertThat(itb.getAge()).isEqualTo(0);
|
||||
|
|
|
|||
|
|
@ -197,11 +197,11 @@ public class ProxyFactoryTests {
|
|||
TestBeanSubclass raw = new TestBeanSubclass();
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
//System.out.println("Proxied interfaces are " + StringUtils.arrayToDelimitedString(factory.getProxiedInterfaces(), ","));
|
||||
assertThat(factory.getProxiedInterfaces().length).as("Found correct number of interfaces").isEqualTo(5);
|
||||
assertThat(factory.getProxiedInterfaces()).as("Found correct number of interfaces").hasSize(5);
|
||||
ITestBean tb = (ITestBean) factory.getProxy();
|
||||
assertThat(tb).as("Picked up secondary interface").isInstanceOf(IOther.class);
|
||||
raw.setAge(25);
|
||||
assertThat(tb.getAge() == raw.getAge()).isTrue();
|
||||
assertThat(tb.getAge()).isEqualTo(raw.getAge());
|
||||
|
||||
long t = 555555L;
|
||||
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t);
|
||||
|
|
@ -211,10 +211,10 @@ public class ProxyFactoryTests {
|
|||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
||||
|
||||
Class<?>[] newProxiedInterfaces = factory.getProxiedInterfaces();
|
||||
assertThat(newProxiedInterfaces.length).as("Advisor proxies one more interface after introduction").isEqualTo(oldProxiedInterfaces.length + 1);
|
||||
assertThat(newProxiedInterfaces).as("Advisor proxies one more interface after introduction").hasSize(oldProxiedInterfaces.length + 1);
|
||||
|
||||
TimeStamped ts = (TimeStamped) factory.getProxy();
|
||||
assertThat(ts.getTimeStamp() == t).isTrue();
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(t);
|
||||
// Shouldn't fail;
|
||||
((IOther) ts).absquatulate();
|
||||
}
|
||||
|
|
@ -234,13 +234,13 @@ public class ProxyFactoryTests {
|
|||
factory.addAdvice(0, di);
|
||||
assertThat(factory.getProxy()).isInstanceOf(ITestBean.class);
|
||||
assertThat(factory.adviceIncluded(di)).isTrue();
|
||||
assertThat(!factory.adviceIncluded(diUnused)).isTrue();
|
||||
assertThat(factory.countAdvicesOfType(NopInterceptor.class) == 1).isTrue();
|
||||
assertThat(factory.countAdvicesOfType(MyInterceptor.class) == 0).isTrue();
|
||||
assertThat(factory.adviceIncluded(diUnused)).isFalse();
|
||||
assertThat(factory.countAdvicesOfType(NopInterceptor.class)).isEqualTo(1);
|
||||
assertThat(factory.countAdvicesOfType(MyInterceptor.class)).isEqualTo(0);
|
||||
|
||||
factory.addAdvice(0, diUnused);
|
||||
assertThat(factory.adviceIncluded(diUnused)).isTrue();
|
||||
assertThat(factory.countAdvicesOfType(NopInterceptor.class) == 2).isTrue();
|
||||
assertThat(factory.countAdvicesOfType(NopInterceptor.class)).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -260,7 +260,8 @@ public class ProxyFactoryTests {
|
|||
public void testCanAddAndRemoveAspectInterfacesOnSingleton() {
|
||||
ProxyFactory config = new ProxyFactory(new TestBean());
|
||||
|
||||
assertThat(config.getProxy() instanceof TimeStamped).as("Shouldn't implement TimeStamped before manipulation").isFalse();
|
||||
assertThat(config.getProxy()).as("Shouldn't implement TimeStamped before manipulation")
|
||||
.isNotInstanceOf(TimeStamped.class);
|
||||
|
||||
long time = 666L;
|
||||
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor();
|
||||
|
|
@ -270,26 +271,26 @@ public class ProxyFactoryTests {
|
|||
int oldCount = config.getAdvisors().length;
|
||||
config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
||||
|
||||
assertThat(config.getAdvisors().length == oldCount + 1).isTrue();
|
||||
assertThat(config.getAdvisors()).hasSize(oldCount + 1);
|
||||
|
||||
TimeStamped ts = (TimeStamped) config.getProxy();
|
||||
assertThat(ts.getTimeStamp() == time).isTrue();
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(time);
|
||||
|
||||
// Can remove
|
||||
config.removeAdvice(ti);
|
||||
|
||||
assertThat(config.getAdvisors().length == oldCount).isTrue();
|
||||
assertThat(config.getAdvisors()).hasSize(oldCount);
|
||||
|
||||
assertThatRuntimeException()
|
||||
.as("Existing object won't implement this interface any more")
|
||||
.isThrownBy(ts::getTimeStamp); // Existing reference will fail
|
||||
|
||||
assertThat(config.getProxy() instanceof TimeStamped).as("Should no longer implement TimeStamped").isFalse();
|
||||
assertThat(config.getProxy()).as("Should no longer implement TimeStamped").isNotInstanceOf(TimeStamped.class);
|
||||
|
||||
// Now check non-effect of removing interceptor that isn't there
|
||||
config.removeAdvice(new DebugInterceptor());
|
||||
|
||||
assertThat(config.getAdvisors().length == oldCount).isTrue();
|
||||
assertThat(config.getAdvisors()).hasSize(oldCount);
|
||||
|
||||
ITestBean it = (ITestBean) ts;
|
||||
DebugInterceptor debugInterceptor = new DebugInterceptor();
|
||||
|
|
@ -299,7 +300,7 @@ public class ProxyFactoryTests {
|
|||
config.removeAdvice(debugInterceptor);
|
||||
it.getSpouse();
|
||||
// not invoked again
|
||||
assertThat(debugInterceptor.getCount() == 1).isTrue();
|
||||
assertThat(debugInterceptor.getCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -308,13 +309,13 @@ public class ProxyFactoryTests {
|
|||
pf.setTargetClass(ITestBean.class);
|
||||
Object proxy = pf.getProxy();
|
||||
assertThat(AopUtils.isJdkDynamicProxy(proxy)).as("Proxy is a JDK proxy").isTrue();
|
||||
assertThat(proxy instanceof ITestBean).isTrue();
|
||||
assertThat(proxy).isInstanceOf(ITestBean.class);
|
||||
assertThat(AopProxyUtils.ultimateTargetClass(proxy)).isEqualTo(ITestBean.class);
|
||||
|
||||
ProxyFactory pf2 = new ProxyFactory(proxy);
|
||||
Object proxy2 = pf2.getProxy();
|
||||
assertThat(AopUtils.isJdkDynamicProxy(proxy2)).as("Proxy is a JDK proxy").isTrue();
|
||||
assertThat(proxy2 instanceof ITestBean).isTrue();
|
||||
assertThat(proxy2).isInstanceOf(ITestBean.class);
|
||||
assertThat(AopProxyUtils.ultimateTargetClass(proxy2)).isEqualTo(ITestBean.class);
|
||||
}
|
||||
|
||||
|
|
@ -324,14 +325,14 @@ public class ProxyFactoryTests {
|
|||
pf.setTargetClass(TestBean.class);
|
||||
Object proxy = pf.getProxy();
|
||||
assertThat(AopUtils.isCglibProxy(proxy)).as("Proxy is a CGLIB proxy").isTrue();
|
||||
assertThat(proxy instanceof TestBean).isTrue();
|
||||
assertThat(proxy).isInstanceOf(TestBean.class);
|
||||
assertThat(AopProxyUtils.ultimateTargetClass(proxy)).isEqualTo(TestBean.class);
|
||||
|
||||
ProxyFactory pf2 = new ProxyFactory(proxy);
|
||||
pf2.setProxyTargetClass(true);
|
||||
Object proxy2 = pf2.getProxy();
|
||||
assertThat(AopUtils.isCglibProxy(proxy2)).as("Proxy is a CGLIB proxy").isTrue();
|
||||
assertThat(proxy2 instanceof TestBean).isTrue();
|
||||
assertThat(proxy2).isInstanceOf(TestBean.class);
|
||||
assertThat(AopProxyUtils.ultimateTargetClass(proxy2)).isEqualTo(TestBean.class);
|
||||
}
|
||||
|
||||
|
|
@ -341,8 +342,8 @@ public class ProxyFactoryTests {
|
|||
JFrame frame = new JFrame();
|
||||
ProxyFactory proxyFactory = new ProxyFactory(frame);
|
||||
Object proxy = proxyFactory.getProxy();
|
||||
assertThat(proxy instanceof RootPaneContainer).isTrue();
|
||||
assertThat(proxy instanceof Accessible).isTrue();
|
||||
assertThat(proxy).isInstanceOf(RootPaneContainer.class);
|
||||
assertThat(proxy).isInstanceOf(Accessible.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -26,7 +26,7 @@ class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean
|
|||
|
||||
@Override
|
||||
protected void assertions(MethodInvocation invocation) {
|
||||
assertThat(invocation.getThis() == this).isTrue();
|
||||
assertThat(invocation.getThis()).isSameAs(this);
|
||||
assertThat(ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass())).as("Invocation should be on ITestBean: " + invocation.getMethod()).isTrue();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -128,7 +128,7 @@ class ScopedProxyBeanRegistrationAotProcessorTests {
|
|||
this.beanFactory.registerBeanDefinition("test", scopedBean);
|
||||
compile((freshBeanFactory, compiled) -> {
|
||||
Object bean = freshBeanFactory.getBean("test");
|
||||
assertThat(bean).isNotNull().isInstanceOf(NumberHolder.class).isInstanceOf(AopInfrastructureBean.class);
|
||||
assertThat(bean).isInstanceOf(NumberHolder.class).isInstanceOf(AopInfrastructureBean.class);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -142,7 +142,7 @@ public class ComposablePointcutTests {
|
|||
pc1.intersection(GETTER_METHOD_MATCHER);
|
||||
|
||||
assertThat(pc1.equals(pc2)).isFalse();
|
||||
assertThat(pc1.hashCode() == pc2.hashCode()).isFalse();
|
||||
assertThat(pc1.hashCode()).isNotEqualTo(pc2.hashCode());
|
||||
|
||||
pc2.intersection(GETTER_METHOD_MATCHER);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -97,7 +97,7 @@ public class ControlFlowPointcutTests {
|
|||
assertThat(new ControlFlowPointcut(One.class, "getAge").equals(new ControlFlowPointcut(One.class))).isFalse();
|
||||
assertThat(new ControlFlowPointcut(One.class).hashCode()).isEqualTo(new ControlFlowPointcut(One.class).hashCode());
|
||||
assertThat(new ControlFlowPointcut(One.class, "getAge").hashCode()).isEqualTo(new ControlFlowPointcut(One.class, "getAge").hashCode());
|
||||
assertThat(new ControlFlowPointcut(One.class, "getAge").hashCode() == new ControlFlowPointcut(One.class).hashCode()).isFalse();
|
||||
assertThat(new ControlFlowPointcut(One.class, "getAge").hashCode()).isNotEqualTo(new ControlFlowPointcut(One.class).hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DelegatingIntroductionInterceptorTests {
|
|||
@Test
|
||||
void testIntroductionInterceptorWithDelegation() throws Exception {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(! (raw instanceof TimeStamped)).isTrue();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
TimeStamped ts = mock();
|
||||
|
|
@ -66,13 +66,13 @@ class DelegatingIntroductionInterceptorTests {
|
|||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts)));
|
||||
|
||||
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
||||
assertThat(tsp.getTimeStamp() == timestamp).isTrue();
|
||||
assertThat(tsp.getTimeStamp()).isEqualTo(timestamp);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithInterfaceHierarchy() throws Exception {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(! (raw instanceof SubTimeStamped)).isTrue();
|
||||
assertThat(raw).isNotInstanceOf(SubTimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
SubTimeStamped ts = mock();
|
||||
|
|
@ -82,13 +82,13 @@ class DelegatingIntroductionInterceptorTests {
|
|||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), SubTimeStamped.class));
|
||||
|
||||
SubTimeStamped tsp = (SubTimeStamped) factory.getProxy();
|
||||
assertThat(tsp.getTimeStamp() == timestamp).isTrue();
|
||||
assertThat(tsp.getTimeStamp()).isEqualTo(timestamp);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithSuperInterface() throws Exception {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(! (raw instanceof TimeStamped)).isTrue();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
SubTimeStamped ts = mock();
|
||||
|
|
@ -98,8 +98,8 @@ class DelegatingIntroductionInterceptorTests {
|
|||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), TimeStamped.class));
|
||||
|
||||
TimeStamped tsp = (TimeStamped) factory.getProxy();
|
||||
assertThat(!(tsp instanceof SubTimeStamped)).isTrue();
|
||||
assertThat(tsp.getTimeStamp() == timestamp).isTrue();
|
||||
assertThat(tsp).isNotInstanceOf(SubTimeStamped.class);
|
||||
assertThat(tsp.getTimeStamp()).isEqualTo(timestamp);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -125,7 +125,7 @@ class DelegatingIntroductionInterceptorTests {
|
|||
//assertTrue(Arrays.binarySearch(pf.getProxiedInterfaces(), TimeStamped.class) != -1);
|
||||
TimeStamped ts = (TimeStamped) pf.getProxy();
|
||||
|
||||
assertThat(ts.getTimeStamp() == t).isTrue();
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(t);
|
||||
((ITester) ts).foo();
|
||||
|
||||
((ITestBean) ts).getAge();
|
||||
|
|
@ -160,10 +160,10 @@ class DelegatingIntroductionInterceptorTests {
|
|||
|
||||
assertThat(ts).isInstanceOf(TimeStamped.class);
|
||||
// Shouldn't proxy framework interfaces
|
||||
assertThat(!(ts instanceof MethodInterceptor)).isTrue();
|
||||
assertThat(!(ts instanceof IntroductionInterceptor)).isTrue();
|
||||
assertThat(ts).isNotInstanceOf(MethodInterceptor.class);
|
||||
assertThat(ts).isNotInstanceOf(IntroductionInterceptor.class);
|
||||
|
||||
assertThat(ts.getTimeStamp() == t).isTrue();
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(t);
|
||||
((ITester) ts).foo();
|
||||
((ITestBean) ts).getAge();
|
||||
|
||||
|
|
@ -174,14 +174,14 @@ class DelegatingIntroductionInterceptorTests {
|
|||
pf = new ProxyFactory(target);
|
||||
pf.addAdvisor(0, new DefaultIntroductionAdvisor(ii));
|
||||
Object o = pf.getProxy();
|
||||
assertThat(!(o instanceof TimeStamped)).isTrue();
|
||||
assertThat(o).isNotInstanceOf(TimeStamped.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
void testIntroductionInterceptorDoesntReplaceToString() throws Exception {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(! (raw instanceof TimeStamped)).isTrue();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
|
||||
TimeStamped ts = new SerializableTimeStamped(0);
|
||||
|
|
@ -266,7 +266,7 @@ class DelegatingIntroductionInterceptorTests {
|
|||
|
||||
TimeStamped ts = (TimeStamped) pf.getProxy();
|
||||
// From introduction interceptor, not target
|
||||
assertThat(ts.getTimeStamp() == t).isTrue();
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(t);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -129,7 +129,7 @@ public class NameMatchMethodPointcutTests {
|
|||
|
||||
pc1.setMappedName(foo);
|
||||
assertThat(pc1.equals(pc2)).isFalse();
|
||||
assertThat(pc1.hashCode() != pc2.hashCode()).isTrue();
|
||||
assertThat(pc1.hashCode()).isNotEqualTo(pc2.hashCode());
|
||||
|
||||
pc2.setMappedName(foo);
|
||||
assertThat(pc2).isEqualTo(pc1);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -543,7 +543,7 @@ public abstract class AbstractCacheAnnotationTests {
|
|||
Object r1 = service.multiConditionalCacheAndEvict(key);
|
||||
Object r3 = service.multiConditionalCacheAndEvict(key);
|
||||
|
||||
assertThat(!r1.equals(r3)).isTrue();
|
||||
assertThat(r1.equals(r3)).isFalse();
|
||||
assertThat(primary.get(key)).isNull();
|
||||
|
||||
Object key2 = 3;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -92,7 +92,7 @@ public class AspectJEnableCachingIsolatedTests {
|
|||
load(MultiCacheManagerConfig.class);
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
assertThat(ex.getMessage().contains("bean of type CacheManager")).isTrue();
|
||||
assertThat(ex.getMessage()).contains("bean of type CacheManager");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ public class AspectJEnableCachingIsolatedTests {
|
|||
load(MultiCacheManagerConfigurer.class, EnableCachingConfig.class);
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
assertThat(ex.getMessage().contains("implementations of CachingConfigurer")).isTrue();
|
||||
assertThat(ex.getMessage()).contains("implementations of CachingConfigurer");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ public class AspectJEnableCachingIsolatedTests {
|
|||
load(EmptyConfig.class);
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
assertThat(ex.getMessage().contains("no bean of type CacheManager")).isTrue();
|
||||
assertThat(ex.getMessage()).contains("no bean of type CacheManager");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -205,11 +205,11 @@ abstract class AbstractPropertyAccessorTests {
|
|||
kerry.setSpouse(target);
|
||||
AbstractPropertyAccessor accessor = createAccessor(target);
|
||||
Integer KA = (Integer) accessor.getPropertyValue("spouse.age");
|
||||
assertThat(KA == 35).as("kerry is 35").isTrue();
|
||||
assertThat(KA).as("kerry is 35").isEqualTo(35);
|
||||
Integer RA = (Integer) accessor.getPropertyValue("spouse.spouse.age");
|
||||
assertThat(RA == 31).as("rod is 31, not" + RA).isTrue();
|
||||
assertThat(RA).as("rod is 31, not" + RA).isEqualTo(31);
|
||||
ITestBean spousesSpouse = (ITestBean) accessor.getPropertyValue("spouse.spouse");
|
||||
assertThat(target == spousesSpouse).as("spousesSpouse = initial point").isTrue();
|
||||
assertThat(target).as("spousesSpouse = initial point").isSameAs(spousesSpouse);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -242,7 +242,7 @@ abstract class AbstractPropertyAccessorTests {
|
|||
accessor.setConversionService(new DefaultConversionService());
|
||||
accessor.setAutoGrowNestedPaths(true);
|
||||
accessor.setPropertyValue("listOfMaps[0]['luckyNumber']", "9");
|
||||
assertThat(target.listOfMaps.get(0).get("luckyNumber")).isEqualTo("9");
|
||||
assertThat(target.listOfMaps.get(0)).containsEntry("luckyNumber", "9");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -298,13 +298,14 @@ abstract class AbstractPropertyAccessorTests {
|
|||
accessor.setPropertyValue("spouse.company", "Lewisham");
|
||||
assertThat(kerry.getName()).as("kerry name is Kerry").isEqualTo("Kerry");
|
||||
|
||||
assertThat(target.getSpouse() == kerry).as("nested set worked").isTrue();
|
||||
assertThat(target.getSpouse()).as("nested set worked").isSameAs(kerry);
|
||||
assertThat(kerry.getSpouse()).as("no back relation").isNull();
|
||||
accessor.setPropertyValue(new PropertyValue("spouse.spouse", target));
|
||||
assertThat(kerry.getSpouse() == target).as("nested set worked").isTrue();
|
||||
assertThat(kerry.getSpouse()).as("nested set worked").isSameAs(target);
|
||||
|
||||
AbstractPropertyAccessor kerryAccessor = createAccessor(kerry);
|
||||
assertThat("Lewisham".equals(kerryAccessor.getPropertyValue("spouse.spouse.spouse.spouse.company"))).as("spouse.spouse.spouse.spouse.company=Lewisham").isTrue();
|
||||
assertThat(kerryAccessor.getPropertyValue("spouse.spouse.spouse.spouse.company")).as("spouse.spouse.spouse.spouse.company=Lewisham")
|
||||
.isEqualTo("Lewisham");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -315,13 +316,13 @@ abstract class AbstractPropertyAccessorTests {
|
|||
AbstractPropertyAccessor accessor = createAccessor(target);
|
||||
accessor.setPropertyValue("spouse", kerry);
|
||||
|
||||
assertThat(target.getSpouse() == kerry).as("nested set worked").isTrue();
|
||||
assertThat(target.getSpouse()).as("nested set worked").isSameAs(kerry);
|
||||
assertThat(kerry.getSpouse()).as("no back relation").isNull();
|
||||
accessor.setPropertyValue(new PropertyValue("spouse.spouse", target));
|
||||
assertThat(kerry.getSpouse() == target).as("nested set worked").isTrue();
|
||||
assertThat(kerry.getAge() == 0).as("kerry age not set").isTrue();
|
||||
assertThat(kerry.getSpouse()).as("nested set worked").isSameAs(target);
|
||||
assertThat(kerry.getAge()).as("kerry age not set").isEqualTo(0);
|
||||
accessor.setPropertyValue(new PropertyValue("spouse.age", 35));
|
||||
assertThat(kerry.getAge() == 35).as("Set primitive on spouse").isTrue();
|
||||
assertThat(kerry.getAge()).as("Set primitive on spouse").isEqualTo(35);
|
||||
|
||||
assertThat(accessor.getPropertyValue("spouse")).isEqualTo(kerry);
|
||||
assertThat(accessor.getPropertyValue("spouse.spouse")).isEqualTo(target);
|
||||
|
|
@ -359,7 +360,7 @@ abstract class AbstractPropertyAccessorTests {
|
|||
accessor.getPropertyValue("spouse.bla");
|
||||
}
|
||||
catch (NotReadablePropertyException ex) {
|
||||
assertThat(ex.getMessage().contains(TestBean.class.getName())).isTrue();
|
||||
assertThat(ex.getMessage()).contains(TestBean.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -442,12 +443,12 @@ abstract class AbstractPropertyAccessorTests {
|
|||
target.setAge(age);
|
||||
target.setName(name);
|
||||
AbstractPropertyAccessor accessor = createAccessor(target);
|
||||
assertThat(target.getAge() == age).as("age is OK").isTrue();
|
||||
assertThat(name.equals(target.getName())).as("name is OK").isTrue();
|
||||
assertThat(target.getAge()).as("age is OK").isEqualTo(age);
|
||||
assertThat(name).as("name is OK").isEqualTo(target.getName());
|
||||
accessor.setPropertyValues(new MutablePropertyValues());
|
||||
// Check its unchanged
|
||||
assertThat(target.getAge() == age).as("age is OK").isTrue();
|
||||
assertThat(name.equals(target.getName())).as("name is OK").isTrue();
|
||||
assertThat(target.getAge()).as("age is OK").isEqualTo(age);
|
||||
assertThat(name).as("name is OK").isEqualTo(target.getName());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -463,9 +464,9 @@ abstract class AbstractPropertyAccessorTests {
|
|||
pvs.addPropertyValue(new PropertyValue("name", newName));
|
||||
pvs.addPropertyValue(new PropertyValue("touchy", newTouchy));
|
||||
accessor.setPropertyValues(pvs);
|
||||
assertThat(target.getName().equals(newName)).as("Name property should have changed").isTrue();
|
||||
assertThat(target.getTouchy().equals(newTouchy)).as("Touchy property should have changed").isTrue();
|
||||
assertThat(target.getAge() == newAge).as("Age property should have changed").isTrue();
|
||||
assertThat(target.getName()).as("Name property should have changed").isEqualTo(newName);
|
||||
assertThat(target.getTouchy()).as("Touchy property should have changed").isEqualTo(newTouchy);
|
||||
assertThat(target.getAge()).as("Age property should have changed").isEqualTo(newAge);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -480,7 +481,7 @@ abstract class AbstractPropertyAccessorTests {
|
|||
accessor.setPropertyValue(new PropertyValue("touchy", newTouchy));
|
||||
assertThat(target.getName()).as("Name property should have changed").isEqualTo(newName);
|
||||
assertThat(target.getTouchy()).as("Touchy property should have changed").isEqualTo(newTouchy);
|
||||
assertThat(target.getAge() == newAge).as("Age property should have changed").isTrue();
|
||||
assertThat(target.getAge()).as("Age property should have changed").isEqualTo(newAge);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -559,11 +560,11 @@ abstract class AbstractPropertyAccessorTests {
|
|||
}
|
||||
});
|
||||
accessor.setPropertyValue("name", new String[] {});
|
||||
assertThat(target.getName()).isEqualTo("");
|
||||
assertThat(target.getName()).isEmpty();
|
||||
accessor.setPropertyValue("name", new String[] {"a1", "b2"});
|
||||
assertThat(target.getName()).isEqualTo("a1-b2");
|
||||
accessor.setPropertyValue("name", null);
|
||||
assertThat(target.getName()).isEqualTo("");
|
||||
assertThat(target.getName()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -577,7 +578,7 @@ abstract class AbstractPropertyAccessorTests {
|
|||
|
||||
accessor.setPropertyValue("bool2", "false");
|
||||
assertThat(Boolean.FALSE.equals(accessor.getPropertyValue("bool2"))).as("Correct bool2 value").isTrue();
|
||||
assertThat(!target.getBool2()).as("Correct bool2 value").isTrue();
|
||||
assertThat(target.getBool2()).as("Correct bool2 value").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -729,7 +730,7 @@ abstract class AbstractPropertyAccessorTests {
|
|||
String freedomVal = target.properties.getProperty("freedom");
|
||||
String peaceVal = target.properties.getProperty("peace");
|
||||
assertThat(peaceVal).as("peace==war").isEqualTo("war");
|
||||
assertThat(freedomVal.equals("slavery")).as("Freedom==slavery").isTrue();
|
||||
assertThat(freedomVal).as("Freedom==slavery").isEqualTo("slavery");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1344,7 +1345,7 @@ abstract class AbstractPropertyAccessorTests {
|
|||
pvs.addPropertyValue(new PropertyValue("more.garbage", new Object()));
|
||||
AbstractPropertyAccessor accessor = createAccessor(target);
|
||||
accessor.setPropertyValues(pvs, true);
|
||||
assertThat(target.getName().equals("rod")).as("Set valid and ignored invalid").isTrue();
|
||||
assertThat(target.getName()).as("Set valid and ignored invalid").isEqualTo("rod");
|
||||
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
|
||||
accessor.setPropertyValues(pvs, false)); // Don't ignore: should fail
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -31,7 +31,7 @@ public abstract class AbstractPropertyValuesTests {
|
|||
* Must contain: forname=Tony surname=Blair age=50
|
||||
*/
|
||||
protected void doTestTony(PropertyValues pvs) {
|
||||
assertThat(pvs.getPropertyValues().length == 3).as("Contains 3").isTrue();
|
||||
assertThat(pvs.getPropertyValues()).as("Contains 3").hasSize(3);
|
||||
assertThat(pvs.contains("forname")).as("Contains forname").isTrue();
|
||||
assertThat(pvs.contains("surname")).as("Contains surname").isTrue();
|
||||
assertThat(pvs.contains("age")).as("Contains age").isTrue();
|
||||
|
|
@ -45,13 +45,13 @@ public abstract class AbstractPropertyValuesTests {
|
|||
m.put("age", "50");
|
||||
for (PropertyValue element : ps) {
|
||||
Object val = m.get(element.getName());
|
||||
assertThat(val != null).as("Can't have unexpected value").isTrue();
|
||||
assertThat(val).as("Can't have unexpected value").isNotNull();
|
||||
boolean condition = val instanceof String;
|
||||
assertThat(condition).as("Val i string").isTrue();
|
||||
assertThat(val.equals(element.getValue())).as("val matches expected").isTrue();
|
||||
m.remove(element.getName());
|
||||
}
|
||||
assertThat(m.size() == 0).as("Map size is 0").isTrue();
|
||||
assertThat(m).as("Map size is 0").isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -135,7 +135,7 @@ class BeanUtilsTests {
|
|||
PropertyDescriptor[] actual = Introspector.getBeanInfo(TestBean.class).getPropertyDescriptors();
|
||||
PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(TestBean.class);
|
||||
assertThat(descriptors).as("Descriptors should not be null").isNotNull();
|
||||
assertThat(descriptors.length).as("Invalid number of descriptors returned").isEqualTo(actual.length);
|
||||
assertThat(descriptors).as("Invalid number of descriptors returned").hasSameSizeAs(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -161,13 +161,13 @@ class BeanUtilsTests {
|
|||
tb.setAge(32);
|
||||
tb.setTouchy("touchy");
|
||||
TestBean tb2 = new TestBean();
|
||||
assertThat(tb2.getName() == null).as("Name empty").isTrue();
|
||||
assertThat(tb2.getAge() == 0).as("Age empty").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy empty").isTrue();
|
||||
assertThat(tb2.getName()).as("Name empty").isNull();
|
||||
assertThat(tb2.getAge()).as("Age empty").isEqualTo(0);
|
||||
assertThat(tb2.getTouchy()).as("Touchy empty").isNull();
|
||||
BeanUtils.copyProperties(tb, tb2);
|
||||
assertThat(tb2.getName().equals(tb.getName())).as("Name copied").isTrue();
|
||||
assertThat(tb2.getAge() == tb.getAge()).as("Age copied").isTrue();
|
||||
assertThat(tb2.getTouchy().equals(tb.getTouchy())).as("Touchy copied").isTrue();
|
||||
assertThat(tb2.getName()).as("Name copied").isEqualTo(tb.getName());
|
||||
assertThat(tb2.getAge()).as("Age copied").isEqualTo(tb.getAge());
|
||||
assertThat(tb2.getTouchy()).as("Touchy copied").isEqualTo(tb.getTouchy());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -177,13 +177,13 @@ class BeanUtilsTests {
|
|||
tb.setAge(32);
|
||||
tb.setTouchy("touchy");
|
||||
TestBean tb2 = new TestBean();
|
||||
assertThat(tb2.getName() == null).as("Name empty").isTrue();
|
||||
assertThat(tb2.getAge() == 0).as("Age empty").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy empty").isTrue();
|
||||
assertThat(tb2.getName()).as("Name empty").isNull();
|
||||
assertThat(tb2.getAge()).as("Age empty").isEqualTo(0);
|
||||
assertThat(tb2.getTouchy()).as("Touchy empty").isNull();
|
||||
BeanUtils.copyProperties(tb, tb2);
|
||||
assertThat(tb2.getName().equals(tb.getName())).as("Name copied").isTrue();
|
||||
assertThat(tb2.getAge() == tb.getAge()).as("Age copied").isTrue();
|
||||
assertThat(tb2.getTouchy().equals(tb.getTouchy())).as("Touchy copied").isTrue();
|
||||
assertThat(tb2.getName()).as("Name copied").isEqualTo(tb.getName());
|
||||
assertThat(tb2.getAge()).as("Age copied").isEqualTo(tb.getAge());
|
||||
assertThat(tb2.getTouchy()).as("Touchy copied").isEqualTo(tb.getTouchy());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -193,13 +193,13 @@ class BeanUtilsTests {
|
|||
tb.setAge(32);
|
||||
tb.setTouchy("touchy");
|
||||
DerivedTestBean tb2 = new DerivedTestBean();
|
||||
assertThat(tb2.getName() == null).as("Name empty").isTrue();
|
||||
assertThat(tb2.getAge() == 0).as("Age empty").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy empty").isTrue();
|
||||
assertThat(tb2.getName()).as("Name empty").isNull();
|
||||
assertThat(tb2.getAge()).as("Age empty").isEqualTo(0);
|
||||
assertThat(tb2.getTouchy()).as("Touchy empty").isNull();
|
||||
BeanUtils.copyProperties(tb, tb2);
|
||||
assertThat(tb2.getName().equals(tb.getName())).as("Name copied").isTrue();
|
||||
assertThat(tb2.getAge() == tb.getAge()).as("Age copied").isTrue();
|
||||
assertThat(tb2.getTouchy().equals(tb.getTouchy())).as("Touchy copied").isTrue();
|
||||
assertThat(tb2.getName()).as("Name copied").isEqualTo(tb.getName());
|
||||
assertThat(tb2.getAge()).as("Age copied").isEqualTo(tb.getAge());
|
||||
assertThat(tb2.getTouchy()).as("Touchy copied").isEqualTo(tb.getTouchy());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -342,37 +342,37 @@ class BeanUtilsTests {
|
|||
@Test
|
||||
void copyPropertiesWithEditable() throws Exception {
|
||||
TestBean tb = new TestBean();
|
||||
assertThat(tb.getName() == null).as("Name empty").isTrue();
|
||||
assertThat(tb.getName()).as("Name empty").isNull();
|
||||
tb.setAge(32);
|
||||
tb.setTouchy("bla");
|
||||
TestBean tb2 = new TestBean();
|
||||
tb2.setName("rod");
|
||||
assertThat(tb2.getAge() == 0).as("Age empty").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy empty").isTrue();
|
||||
assertThat(tb2.getAge()).as("Age empty").isEqualTo(0);
|
||||
assertThat(tb2.getTouchy()).as("Touchy empty").isNull();
|
||||
|
||||
// "touchy" should not be copied: it's not defined in ITestBean
|
||||
BeanUtils.copyProperties(tb, tb2, ITestBean.class);
|
||||
assertThat(tb2.getName() == null).as("Name copied").isTrue();
|
||||
assertThat(tb2.getAge() == 32).as("Age copied").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy still empty").isTrue();
|
||||
assertThat(tb2.getName()).as("Name copied").isNull();
|
||||
assertThat(tb2.getAge()).as("Age copied").isEqualTo(32);
|
||||
assertThat(tb2.getTouchy()).as("Touchy still empty").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void copyPropertiesWithIgnore() throws Exception {
|
||||
TestBean tb = new TestBean();
|
||||
assertThat(tb.getName() == null).as("Name empty").isTrue();
|
||||
assertThat(tb.getName()).as("Name empty").isNull();
|
||||
tb.setAge(32);
|
||||
tb.setTouchy("bla");
|
||||
TestBean tb2 = new TestBean();
|
||||
tb2.setName("rod");
|
||||
assertThat(tb2.getAge() == 0).as("Age empty").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy empty").isTrue();
|
||||
assertThat(tb2.getAge()).as("Age empty").isEqualTo(0);
|
||||
assertThat(tb2.getTouchy()).as("Touchy empty").isNull();
|
||||
|
||||
// "spouse", "touchy", "age" should not be copied
|
||||
BeanUtils.copyProperties(tb, tb2, "spouse", "touchy", "age");
|
||||
assertThat(tb2.getName() == null).as("Name copied").isTrue();
|
||||
assertThat(tb2.getAge() == 0).as("Age still empty").isTrue();
|
||||
assertThat(tb2.getTouchy() == null).as("Touchy still empty").isTrue();
|
||||
assertThat(tb2.getName()).as("Name copied").isNull();
|
||||
assertThat(tb2.getAge()).as("Age still empty").isEqualTo(0);
|
||||
assertThat(tb2.getTouchy()).as("Touchy still empty").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -381,7 +381,7 @@ class BeanUtilsTests {
|
|||
source.setName("name");
|
||||
TestBean target = new TestBean();
|
||||
BeanUtils.copyProperties(source, target, "specialProperty");
|
||||
assertThat("name").isEqualTo(target.getName());
|
||||
assertThat(target.getName()).isEqualTo("name");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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,15 +90,15 @@ public class BeanWrapperAutoGrowingTests {
|
|||
|
||||
@Test
|
||||
public void getPropertyValueAutoGrow2dArray() {
|
||||
assertNotNull(wrapper.getPropertyValue("multiArray[0][0]"));
|
||||
assertThat(wrapper.getPropertyValue("multiArray[0][0]")).isNotNull();
|
||||
assertThat(bean.getMultiArray()[0]).hasSize(1);
|
||||
assertThat(bean.getMultiArray()[0][0]).isInstanceOf(Bean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPropertyValueAutoGrow3dArray() {
|
||||
assertNotNull(wrapper.getPropertyValue("threeDimensionalArray[1][2][3]"));
|
||||
assertThat(bean.getThreeDimensionalArray()[1].length).isEqualTo(3);
|
||||
assertThat(wrapper.getPropertyValue("threeDimensionalArray[1][2][3]")).isNotNull();
|
||||
assertThat(bean.getThreeDimensionalArray()[1]).hasNumberOfRows(3);
|
||||
assertThat(bean.getThreeDimensionalArray()[1][2][3]).isInstanceOf(Bean.class);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -161,8 +161,8 @@ class BeanWrapperGenericsTests {
|
|||
value2.add(Boolean.TRUE);
|
||||
input.put("2", value2);
|
||||
bw.setPropertyValue("collectionMap", input);
|
||||
assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue();
|
||||
assertThat(gb.getCollectionMap().get(2) instanceof ArrayList).isTrue();
|
||||
assertThat(gb.getCollectionMap().get(1)).isInstanceOf(HashSet.class);
|
||||
assertThat(gb.getCollectionMap().get(2)).isInstanceOf(ArrayList.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -174,7 +174,7 @@ class BeanWrapperGenericsTests {
|
|||
HashSet<Integer> value1 = new HashSet<>();
|
||||
value1.add(1);
|
||||
bw.setPropertyValue("collectionMap[1]", value1);
|
||||
assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue();
|
||||
assertThat(gb.getCollectionMap().get(1)).isInstanceOf(HashSet.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -320,7 +320,7 @@ class BeanWrapperGenericsTests {
|
|||
bw.setPropertyValue("mapOfInteger", map);
|
||||
|
||||
Object obj = gb.getMapOfInteger().get("testKey");
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(obj).isInstanceOf(Integer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -334,7 +334,7 @@ class BeanWrapperGenericsTests {
|
|||
bw.setPropertyValue("mapOfListOfInteger", map);
|
||||
|
||||
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(obj).isInstanceOf(Integer.class);
|
||||
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ class BeanWrapperGenericsTests {
|
|||
bw.setPropertyValue("listOfMapOfInteger", list);
|
||||
|
||||
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(obj).isInstanceOf(Integer.class);
|
||||
assertThat(((Integer) obj).intValue()).isEqualTo(5);
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ class BeanWrapperGenericsTests {
|
|||
bw.setPropertyValue("mapOfListOfListOfInteger", map);
|
||||
|
||||
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
|
||||
assertThat(obj instanceof Integer).isTrue();
|
||||
assertThat(obj).isInstanceOf(Integer.class);
|
||||
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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,16 +246,16 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
|||
|
||||
accessor.setPropertyValue("object", tb);
|
||||
assertThat(target.value).isSameAs(tb);
|
||||
assertThat(target.getObject().get()).isSameAs(tb);
|
||||
assertThat(((Optional<TestBean>) accessor.getPropertyValue("object")).get()).isSameAs(tb);
|
||||
assertThat(target.getObject()).containsSame(tb);
|
||||
assertThat(((Optional<TestBean>) accessor.getPropertyValue("object"))).containsSame(tb);
|
||||
assertThat(target.value.getName()).isEqualTo("x");
|
||||
assertThat(target.getObject().get().getName()).isEqualTo("x");
|
||||
assertThat(accessor.getPropertyValue("object.name")).isEqualTo("x");
|
||||
|
||||
accessor.setPropertyValue("object.name", "y");
|
||||
assertThat(target.value).isSameAs(tb);
|
||||
assertThat(target.getObject().get()).isSameAs(tb);
|
||||
assertThat(((Optional<TestBean>) accessor.getPropertyValue("object")).get()).isSameAs(tb);
|
||||
assertThat(target.getObject()).containsSame(tb);
|
||||
assertThat(((Optional<TestBean>) accessor.getPropertyValue("object"))).containsSame(tb);
|
||||
assertThat(target.value.getName()).isEqualTo("y");
|
||||
assertThat(target.getObject().get().getName()).isEqualTo("y");
|
||||
assertThat(accessor.getPropertyValue("object.name")).isEqualTo("y");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -585,7 +585,7 @@ class ExtendedBeanInfoTests {
|
|||
assertThat(hasReadMethodForProperty(ebi, "foo")).isTrue();
|
||||
assertThat(hasWriteMethodForProperty(ebi, "foo")).isTrue();
|
||||
|
||||
assertThat(ebi.getPropertyDescriptors()).hasSize(bi.getPropertyDescriptors().length);
|
||||
assertThat(ebi.getPropertyDescriptors()).hasSameSizeAs(bi.getPropertyDescriptors());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -711,7 +711,7 @@ class ExtendedBeanInfoTests {
|
|||
BeanInfo bi = Introspector.getBeanInfo(TestBean.class);
|
||||
BeanInfo ebi = new ExtendedBeanInfo(bi);
|
||||
|
||||
assertThat(ebi.getPropertyDescriptors()).hasSize(bi.getPropertyDescriptors().length);
|
||||
assertThat(ebi.getPropertyDescriptors()).hasSameSizeAs(bi.getPropertyDescriptors());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -70,7 +70,7 @@ public class MutablePropertyValuesTests extends AbstractPropertyValuesTests {
|
|||
pvs.addPropertyValue(new PropertyValue("age", "50"));
|
||||
MutablePropertyValues pvs2 = pvs;
|
||||
PropertyValues changes = pvs2.changesSince(pvs);
|
||||
assertThat(changes.getPropertyValues().length == 0).as("changes are empty").isTrue();
|
||||
assertThat(changes.getPropertyValues().length).as("changes are empty").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -82,26 +82,28 @@ public class MutablePropertyValuesTests extends AbstractPropertyValuesTests {
|
|||
|
||||
MutablePropertyValues pvs2 = new MutablePropertyValues(pvs);
|
||||
PropertyValues changes = pvs2.changesSince(pvs);
|
||||
assertThat(changes.getPropertyValues().length == 0).as("changes are empty, not of length " + changes.getPropertyValues().length).isTrue();
|
||||
assertThat(changes.getPropertyValues().length).as("changes are empty, not of length " + changes.getPropertyValues().length)
|
||||
.isEqualTo(0);
|
||||
|
||||
pvs2.addPropertyValue(new PropertyValue("forname", "Gordon"));
|
||||
changes = pvs2.changesSince(pvs);
|
||||
assertThat(changes.getPropertyValues().length).as("1 change").isEqualTo(1);
|
||||
PropertyValue fn = changes.getPropertyValue("forname");
|
||||
assertThat(fn != null).as("change is forname").isTrue();
|
||||
assertThat(fn).as("change is forname").isNotNull();
|
||||
assertThat(fn.getValue().equals("Gordon")).as("new value is gordon").isTrue();
|
||||
|
||||
MutablePropertyValues pvs3 = new MutablePropertyValues(pvs);
|
||||
changes = pvs3.changesSince(pvs);
|
||||
assertThat(changes.getPropertyValues().length == 0).as("changes are empty, not of length " + changes.getPropertyValues().length).isTrue();
|
||||
assertThat(changes.getPropertyValues().length).as("changes are empty, not of length " + changes.getPropertyValues().length)
|
||||
.isEqualTo(0);
|
||||
|
||||
// add new
|
||||
pvs3.addPropertyValue(new PropertyValue("foo", "bar"));
|
||||
pvs3.addPropertyValue(new PropertyValue("fi", "fum"));
|
||||
changes = pvs3.changesSince(pvs);
|
||||
assertThat(changes.getPropertyValues().length == 2).as("2 change").isTrue();
|
||||
assertThat(changes.getPropertyValues().length).as("2 change").isEqualTo(2);
|
||||
fn = changes.getPropertyValue("foo");
|
||||
assertThat(fn != null).as("change in foo").isTrue();
|
||||
assertThat(fn).as("change in foo").isNotNull();
|
||||
assertThat(fn.getValue().equals("bar")).as("new value is bar").isTrue();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -30,8 +30,8 @@ public class PropertyAccessorUtilsTests {
|
|||
|
||||
@Test
|
||||
public void getPropertyName() {
|
||||
assertThat(PropertyAccessorUtils.getPropertyName("")).isEqualTo("");
|
||||
assertThat(PropertyAccessorUtils.getPropertyName("[user]")).isEqualTo("");
|
||||
assertThat(PropertyAccessorUtils.getPropertyName("")).isEmpty();
|
||||
assertThat(PropertyAccessorUtils.getPropertyName("[user]")).isEmpty();
|
||||
assertThat(PropertyAccessorUtils.getPropertyName("user")).isEqualTo("user");
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ public class PropertyAccessorUtilsTests {
|
|||
|
||||
@Test
|
||||
public void canonicalPropertyName() {
|
||||
assertThat(PropertyAccessorUtils.canonicalPropertyName(null)).isEqualTo("");
|
||||
assertThat(PropertyAccessorUtils.canonicalPropertyName(null)).isEmpty();
|
||||
assertThat(PropertyAccessorUtils.canonicalPropertyName("map")).isEqualTo("map");
|
||||
assertThat(PropertyAccessorUtils.canonicalPropertyName("map[key1]")).isEqualTo("map[key1]");
|
||||
assertThat(PropertyAccessorUtils.canonicalPropertyName("map['key1']")).isEqualTo("map[key1]");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -85,7 +85,7 @@ public class BeanFactoryUtilsTests {
|
|||
StaticListableBeanFactory lbf = new StaticListableBeanFactory();
|
||||
lbf.addBean("t1", new TestBean());
|
||||
lbf.addBean("t2", new TestBean());
|
||||
assertThat(BeanFactoryUtils.countBeansIncludingAncestors(lbf) == 2).isTrue();
|
||||
assertThat(BeanFactoryUtils.countBeansIncludingAncestors(lbf)).isEqualTo(2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,9 +94,10 @@ public class BeanFactoryUtilsTests {
|
|||
@Test
|
||||
public void testHierarchicalCountBeansWithOverride() {
|
||||
// Leaf count
|
||||
assertThat(this.listableBeanFactory.getBeanDefinitionCount() == 1).isTrue();
|
||||
assertThat(this.listableBeanFactory.getBeanDefinitionCount()).isEqualTo(1);
|
||||
// Count minus duplicate
|
||||
assertThat(BeanFactoryUtils.countBeansIncludingAncestors(this.listableBeanFactory) == 8).as("Should count 8 beans, not " + BeanFactoryUtils.countBeansIncludingAncestors(this.listableBeanFactory)).isTrue();
|
||||
assertThat(BeanFactoryUtils.countBeansIncludingAncestors(this.listableBeanFactory)).as("Should count 8 beans, not " + BeanFactoryUtils.countBeansIncludingAncestors(this.listableBeanFactory))
|
||||
.isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -113,7 +114,7 @@ public class BeanFactoryUtilsTests {
|
|||
assertThat(names).hasSize(1);
|
||||
assertThat(names.contains("indexedBean")).isTrue();
|
||||
// Distinguish from default ListableBeanFactory behavior
|
||||
assertThat(listableBeanFactory.getBeanNamesForType(IndexedTestBean.class).length == 0).isTrue();
|
||||
assertThat(listableBeanFactory.getBeanNamesForType(IndexedTestBean.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -288,7 +289,7 @@ public class BeanFactoryUtilsTests {
|
|||
assertThat(names).hasSize(1);
|
||||
assertThat(names.contains("annotatedBean")).isTrue();
|
||||
// Distinguish from default ListableBeanFactory behavior
|
||||
assertThat(listableBeanFactory.getBeanNamesForAnnotation(TestAnnotation.class).length == 0).isTrue();
|
||||
assertThat(listableBeanFactory.getBeanNamesForAnnotation(TestAnnotation.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class DefaultListableBeanFactoryTests {
|
|||
KnowsIfInstantiated.clearInstantiationRecord();
|
||||
Properties p = new Properties();
|
||||
p.setProperty("x1.(class)", KnowsIfInstantiated.class.getName());
|
||||
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
|
||||
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isFalse();
|
||||
registerBeanDefinitions(p);
|
||||
lbf.preInstantiateSingletons();
|
||||
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton was instantiated").isTrue();
|
||||
|
|
@ -149,12 +149,12 @@ class DefaultListableBeanFactoryTests {
|
|||
Properties p = new Properties();
|
||||
p.setProperty("x1.(class)", KnowsIfInstantiated.class.getName());
|
||||
p.setProperty("x1.(lazy-init)", "true");
|
||||
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
|
||||
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isFalse();
|
||||
registerBeanDefinitions(p);
|
||||
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
|
||||
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isFalse();
|
||||
lbf.preInstantiateSingletons();
|
||||
|
||||
assertThat(!KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isTrue();
|
||||
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton not instantiated").isFalse();
|
||||
lbf.getBean("x1");
|
||||
assertThat(KnowsIfInstantiated.wasInstantiated()).as("singleton was instantiated").isTrue();
|
||||
}
|
||||
|
|
@ -166,13 +166,13 @@ class DefaultListableBeanFactoryTests {
|
|||
// Reset static state
|
||||
DummyFactory.reset();
|
||||
p.setProperty("x1.singleton", "false");
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
registerBeanDefinitions(p);
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
lbf.preInstantiateSingletons();
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
lbf.getBean("x1");
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.containsBean("x1")).isTrue();
|
||||
|
|
@ -190,7 +190,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty("x1.singleton", "false");
|
||||
registerBeanDefinitions(p);
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
assertBeanNamesForType(TestBean.class, false, false);
|
||||
assertThat(lbf.getBeanNamesForAnnotation(SuppressWarnings.class)).isEmpty();
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(lbf.isTypeMatch("&x1", ResolvableType.forClassWithGenerics(FactoryBean.class, String.class))).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(DummyFactory.class);
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -222,7 +222,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty("x1.singleton", "true");
|
||||
registerBeanDefinitions(p);
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
assertBeanNamesForType(TestBean.class, false, false);
|
||||
assertThat(lbf.getBeanNamesForAnnotation(SuppressWarnings.class)).isEmpty();
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(lbf.isTypeMatch("&x1", ResolvableType.forClassWithGenerics(FactoryBean.class, String.class))).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(DummyFactory.class);
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -253,7 +253,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty("x1.singleton", "false");
|
||||
registerBeanDefinitions(p);
|
||||
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
assertBeanNamesForType(TestBean.class, false, false);
|
||||
assertThat(lbf.getBeanNamesForAnnotation(SuppressWarnings.class)).isEmpty();
|
||||
|
||||
|
|
@ -272,7 +272,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(lbf.isTypeMatch("&x1", ResolvableType.forClassWithGenerics(FactoryBean.class, String.class))).isFalse();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(DummyFactory.class);
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -303,7 +303,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(lbf.isTypeMatch("&x1", Object.class)).isTrue();
|
||||
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
|
||||
assertThat(lbf.getType("&x1")).isEqualTo(DummyFactory.class);
|
||||
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
|
||||
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
|
||||
|
||||
lbf.registerAlias("x1", "x2");
|
||||
assertThat(lbf.containsBean("x2")).isTrue();
|
||||
|
|
@ -449,9 +449,9 @@ class DefaultListableBeanFactoryTests {
|
|||
|
||||
@Test
|
||||
void empty() {
|
||||
assertThat(lbf.getBeanDefinitionNames() != null).as("No beans defined --> array != null").isTrue();
|
||||
assertThat(lbf.getBeanDefinitionNames().length == 0).as("No beans defined after no arg constructor").isTrue();
|
||||
assertThat(lbf.getBeanDefinitionCount() == 0).as("No beans defined after no arg constructor").isTrue();
|
||||
assertThat(lbf.getBeanDefinitionNames()).as("No beans defined --> array != null").isNotNull();
|
||||
assertThat(lbf.getBeanDefinitionNames()).as("No beans defined after no arg constructor").isEmpty();
|
||||
assertThat(lbf.getBeanDefinitionCount()).as("No beans defined after no arg constructor").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -459,7 +459,7 @@ class DefaultListableBeanFactoryTests {
|
|||
Properties p = new Properties();
|
||||
registerBeanDefinitions(p);
|
||||
|
||||
assertThat(lbf.getBeanDefinitionCount() == 0).as("No beans defined after ignorable invalid").isTrue();
|
||||
assertThat(lbf.getBeanDefinitionCount()).as("No beans defined after ignorable invalid").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -469,7 +469,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty("qwert", "er");
|
||||
registerBeanDefinitions(p, "test");
|
||||
|
||||
assertThat(lbf.getBeanDefinitionCount() == 0).as("No beans defined after harmless ignorable rubbish").isTrue();
|
||||
assertThat(lbf.getBeanDefinitionCount()).as("No beans defined after harmless ignorable rubbish").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -480,7 +480,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty("test.age", "48");
|
||||
int count = registerBeanDefinitions(p);
|
||||
|
||||
assertThat(count == 1).as("1 beans registered, not " + count).isTrue();
|
||||
assertThat(count).as("1 beans registered, not " + count).isEqualTo(1);
|
||||
testPropertiesPopulation(lbf);
|
||||
}
|
||||
|
||||
|
|
@ -493,7 +493,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty(PREFIX + "test.age", "0x30");
|
||||
int count = registerBeanDefinitions(p, PREFIX);
|
||||
|
||||
assertThat(count == 1).as("1 beans registered, not " + count).isTrue();
|
||||
assertThat(count).as("1 beans registered, not " + count).isEqualTo(1);
|
||||
testPropertiesPopulation(lbf);
|
||||
}
|
||||
|
||||
|
|
@ -524,13 +524,13 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty(PREFIX + "kerry.spouse(ref)", "rod");
|
||||
|
||||
int count = registerBeanDefinitions(p, PREFIX);
|
||||
assertThat(count == 2).as("2 beans registered, not " + count).isTrue();
|
||||
assertThat(count).as("2 beans registered, not " + count).isEqualTo(2);
|
||||
|
||||
TestBean kerry = lbf.getBean("kerry", TestBean.class);
|
||||
assertThat("Kerry".equals(kerry.getName())).as("Kerry name is Kerry").isTrue();
|
||||
assertThat(kerry.getName()).as("Kerry name is Kerry").isEqualTo("Kerry");
|
||||
ITestBean spouse = kerry.getSpouse();
|
||||
assertThat(spouse != null).as("Kerry spouse is non null").isTrue();
|
||||
assertThat("Rod".equals(spouse.getName())).as("Kerry spouse name is Rod").isTrue();
|
||||
assertThat(spouse).as("Kerry spouse is non null").isNotNull();
|
||||
assertThat(spouse.getName()).as("Kerry spouse name is Rod").isEqualTo("Rod");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -541,7 +541,7 @@ class DefaultListableBeanFactoryTests {
|
|||
p.setProperty("tb.someMap[my.key]", "my.value");
|
||||
|
||||
int count = registerBeanDefinitions(p);
|
||||
assertThat(count == 1).as("1 beans registered, not " + count).isTrue();
|
||||
assertThat(count).as("1 beans registered, not " + count).isEqualTo(1);
|
||||
assertThat(lbf.getBeanDefinitionCount()).isEqualTo(1);
|
||||
|
||||
TestBean tb = lbf.getBean("tb", TestBean.class);
|
||||
|
|
@ -682,8 +682,8 @@ class DefaultListableBeanFactoryTests {
|
|||
registerBeanDefinitions(p);
|
||||
TestBean kerry1 = (TestBean) lbf.getBean("kerry");
|
||||
TestBean kerry2 = (TestBean) lbf.getBean("kerry");
|
||||
assertThat(kerry1 != null).as("Non null").isTrue();
|
||||
assertThat(kerry1 == kerry2).as("Singletons equal").isTrue();
|
||||
assertThat(kerry1).as("Non null").isNotNull();
|
||||
assertThat(kerry1).as("Singletons equal").isSameAs(kerry2);
|
||||
|
||||
p = new Properties();
|
||||
p.setProperty("kerry.(class)", TestBean.class.getName());
|
||||
|
|
@ -692,8 +692,8 @@ class DefaultListableBeanFactoryTests {
|
|||
registerBeanDefinitions(p);
|
||||
kerry1 = (TestBean) lbf.getBean("kerry");
|
||||
kerry2 = (TestBean) lbf.getBean("kerry");
|
||||
assertThat(kerry1 != null).as("Non null").isTrue();
|
||||
assertThat(kerry1 != kerry2).as("Prototypes NOT equal").isTrue();
|
||||
assertThat(kerry1).as("Non null").isNotNull();
|
||||
assertThat(kerry1).as("Prototypes NOT equal").isNotSameAs(kerry2);
|
||||
|
||||
p = new Properties();
|
||||
p.setProperty("kerry.(class)", TestBean.class.getName());
|
||||
|
|
@ -702,8 +702,8 @@ class DefaultListableBeanFactoryTests {
|
|||
registerBeanDefinitions(p);
|
||||
kerry1 = (TestBean) lbf.getBean("kerry");
|
||||
kerry2 = (TestBean) lbf.getBean("kerry");
|
||||
assertThat(kerry1 != null).as("Non null").isTrue();
|
||||
assertThat(kerry1 == kerry2).as("Specified singletons equal").isTrue();
|
||||
assertThat(kerry1).as("Non null").isNotNull();
|
||||
assertThat(kerry1).as("Specified singletons equal").isSameAs(kerry2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -737,7 +737,7 @@ class DefaultListableBeanFactoryTests {
|
|||
TestBean kerry2 = (TestBean) lbf.getBean("kerry");
|
||||
assertThat(kerry1.getName()).isEqualTo("kerry");
|
||||
assertThat(kerry1).as("Non null").isNotNull();
|
||||
assertThat(kerry1 == kerry2).as("Singletons equal").isTrue();
|
||||
assertThat(kerry1).as("Singletons equal").isSameAs(kerry2);
|
||||
|
||||
p = new Properties();
|
||||
p.setProperty("wife.(class)", TestBean.class.getName());
|
||||
|
|
@ -750,8 +750,8 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(lbf.isSingleton("kerry")).isFalse();
|
||||
kerry1 = (TestBean) lbf.getBean("kerry");
|
||||
kerry2 = (TestBean) lbf.getBean("kerry");
|
||||
assertThat(kerry1 != null).as("Non null").isTrue();
|
||||
assertThat(kerry1 != kerry2).as("Prototypes NOT equal").isTrue();
|
||||
assertThat(kerry1).as("Non null").isNotNull();
|
||||
assertThat(kerry1).as("Prototypes NOT equal").isNotSameAs(kerry2);
|
||||
|
||||
p = new Properties();
|
||||
p.setProperty("kerry.(class)", TestBean.class.getName());
|
||||
|
|
@ -760,8 +760,8 @@ class DefaultListableBeanFactoryTests {
|
|||
registerBeanDefinitions(p);
|
||||
kerry1 = (TestBean) lbf.getBean("kerry");
|
||||
kerry2 = (TestBean) lbf.getBean("kerry");
|
||||
assertThat(kerry1 != null).as("Non null").isTrue();
|
||||
assertThat(kerry1 == kerry2).as("Specified singletons equal").isTrue();
|
||||
assertThat(kerry1).as("Non null").isNotNull();
|
||||
assertThat(kerry1).as("Specified singletons equal").isSameAs(kerry2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -972,7 +972,7 @@ class DefaultListableBeanFactoryTests {
|
|||
|
||||
TestBean k = (TestBean) lbf.getBean("k");
|
||||
TestBean r = (TestBean) lbf.getBean("r");
|
||||
assertThat(k.getSpouse() == r).isTrue();
|
||||
assertThat(k.getSpouse()).isSameAs(r);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -984,7 +984,7 @@ class DefaultListableBeanFactoryTests {
|
|||
registerBeanDefinitions(p);
|
||||
|
||||
TestBean r = (TestBean) lbf.getBean("r");
|
||||
assertThat(r.getName().equals(name)).isTrue();
|
||||
assertThat(r.getName()).isEqualTo(name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1000,7 +1000,7 @@ class DefaultListableBeanFactoryTests {
|
|||
lbf.registerBeanDefinition("testBean", bd);
|
||||
|
||||
TestBean testBean = (TestBean) lbf.getBean("testBean");
|
||||
assertThat(testBean.getMyFloat() == 1.1f).isTrue();
|
||||
assertThat(testBean.getMyFloat()).isEqualTo(1.1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1024,7 +1024,7 @@ class DefaultListableBeanFactoryTests {
|
|||
lbf.registerBeanDefinition("testBean", bd);
|
||||
|
||||
TestBean testBean = (TestBean) lbf.getBean("testBean");
|
||||
assertThat(testBean.getMyFloat() == 1.1f).isTrue();
|
||||
assertThat(testBean.getMyFloat()).isEqualTo(1.1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1041,7 +1041,7 @@ class DefaultListableBeanFactoryTests {
|
|||
lbf.registerSingleton("myFloat", "1,1");
|
||||
|
||||
TestBean testBean = (TestBean) lbf.getBean("testBean");
|
||||
assertThat(testBean.getMyFloat() == 1.1f).isTrue();
|
||||
assertThat(testBean.getMyFloat()).isEqualTo(1.1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1058,7 +1058,7 @@ class DefaultListableBeanFactoryTests {
|
|||
TestBean testBean = (TestBean) lbf.getBean("testBean");
|
||||
assertThat(testBean.getName()).isEqualTo("myName");
|
||||
assertThat(testBean.getAge()).isEqualTo(5);
|
||||
assertThat(testBean.getMyFloat() == 1.1f).isTrue();
|
||||
assertThat(testBean.getMyFloat()).isEqualTo(1.1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1076,7 +1076,7 @@ class DefaultListableBeanFactoryTests {
|
|||
TestBean testBean = (TestBean) lbf.getBean("testBean");
|
||||
assertThat(testBean.getName()).isEqualTo("myName");
|
||||
assertThat(testBean.getAge()).isEqualTo(5);
|
||||
assertThat(testBean.getMyFloat() == 1.1f).isTrue();
|
||||
assertThat(testBean.getMyFloat()).isEqualTo(1.1f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1300,7 +1300,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(lbf.getBeanDefinitionCount()).isEqualTo(1);
|
||||
Object registered = lbf.autowire(NoDependencies.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
|
||||
assertThat(lbf.getBeanDefinitionCount()).isEqualTo(1);
|
||||
assertThat(registered instanceof NoDependencies).isTrue();
|
||||
assertThat(registered).isInstanceOf(NoDependencies.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1371,8 +1371,8 @@ class DefaultListableBeanFactoryTests {
|
|||
lbf.autowire(ConstructorDependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, true);
|
||||
|
||||
Object spouse = lbf.getBean("spouse");
|
||||
assertThat(bean.getSpouse1() == spouse).isTrue();
|
||||
assertThat(BeanFactoryUtils.beanOfType(lbf, TestBean.class) == spouse).isTrue();
|
||||
assertThat(bean.getSpouse1()).isSameAs(spouse);
|
||||
assertThat(BeanFactoryUtils.beanOfType(lbf, TestBean.class)).isSameAs(spouse);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1384,7 +1384,7 @@ class DefaultListableBeanFactoryTests {
|
|||
|
||||
TestBean spouse = (TestBean) lbf.getBean("spouse");
|
||||
assertThat(bean.getSpouse()).isEqualTo(spouse);
|
||||
assertThat(BeanFactoryUtils.beanOfType(lbf, TestBean.class) == spouse).isTrue();
|
||||
assertThat(BeanFactoryUtils.beanOfType(lbf, TestBean.class)).isSameAs(spouse);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -2248,7 +2248,7 @@ class DefaultListableBeanFactoryTests {
|
|||
for (int i = 0; i < 1000; i++) {
|
||||
TestBean bean = (TestBean) lbf.getBean("bean" + i);
|
||||
TestBean otherBean = (TestBean) lbf.getBean("bean" + (i < 99 ? i + 1 : 0));
|
||||
assertThat(bean.getSpouse() == otherBean).isTrue();
|
||||
assertThat(bean.getSpouse()).isSameAs(otherBean);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2350,8 +2350,8 @@ class DefaultListableBeanFactoryTests {
|
|||
factory.registerBeanDefinition("tb2", bd2);
|
||||
factory.registerBeanDefinition("tb3", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
assertThat(((AbstractBeanDefinition) factory.getMergedBeanDefinition("tb1")).getLazyInit()).isEqualTo(Boolean.TRUE);
|
||||
assertThat(((AbstractBeanDefinition) factory.getMergedBeanDefinition("tb2")).getLazyInit()).isEqualTo(Boolean.FALSE);
|
||||
assertThat(((AbstractBeanDefinition) factory.getMergedBeanDefinition("tb1")).getLazyInit()).isTrue();
|
||||
assertThat(((AbstractBeanDefinition) factory.getMergedBeanDefinition("tb2")).getLazyInit()).isFalse();
|
||||
assertThat(((AbstractBeanDefinition) factory.getMergedBeanDefinition("tb3")).getLazyInit()).isNull();
|
||||
|
||||
factory.preInstantiateSingletons();
|
||||
|
|
@ -2405,7 +2405,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(tb.getBeanName()).isEqualTo("myBeanName");
|
||||
|
||||
DerivedTestBean tb2 = (DerivedTestBean) lbf.getBean("test");
|
||||
assertThat(tb != tb2).isTrue();
|
||||
assertThat(tb).isNotSameAs(tb2);
|
||||
assertThat(tb2.getName()).isEqualTo("myName");
|
||||
assertThat(tb2.getBeanName()).isEqualTo("myBeanName");
|
||||
}
|
||||
|
|
@ -2424,7 +2424,7 @@ class DefaultListableBeanFactoryTests {
|
|||
assertThat(tb.getBeanName()).isEqualTo("myBeanName");
|
||||
|
||||
DerivedTestBean tb2 = (DerivedTestBean) lbf.getBean("test");
|
||||
assertThat(tb != tb2).isTrue();
|
||||
assertThat(tb).isNotSameAs(tb2);
|
||||
assertThat(tb2.getName()).isEqualTo("myName");
|
||||
assertThat(tb2.getBeanName()).isEqualTo("myBeanName");
|
||||
}
|
||||
|
|
@ -2747,7 +2747,7 @@ class DefaultListableBeanFactoryTests {
|
|||
bd.setFactoryMethodName("empty");
|
||||
lbf.registerBeanDefinition("optionalBean", bd);
|
||||
|
||||
assertThat((Optional<?>) lbf.getBean(Optional.class)).isSameAs(Optional.empty());
|
||||
assertThat((Optional<?>) lbf.getBean(Optional.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -494,7 +494,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
OptionalFieldInjectionBean bean = (OptionalFieldInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isTrue();
|
||||
assertThat(bean.getTestBean()).isPresent();
|
||||
assertThat(bean.getTestBean().get()).isSameAs(bf.getBean("testBean"));
|
||||
}
|
||||
|
||||
|
|
@ -503,7 +503,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalFieldInjectionBean.class));
|
||||
|
||||
OptionalFieldInjectionBean bean = (OptionalFieldInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -512,7 +512,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
OptionalMethodInjectionBean bean = (OptionalMethodInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isTrue();
|
||||
assertThat(bean.getTestBean()).isPresent();
|
||||
assertThat(bean.getTestBean().get()).isSameAs(bf.getBean("testBean"));
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalMethodInjectionBean.class));
|
||||
|
||||
OptionalMethodInjectionBean bean = (OptionalMethodInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -530,7 +530,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
OptionalListFieldInjectionBean bean = (OptionalListFieldInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isTrue();
|
||||
assertThat(bean.getTestBean()).isPresent();
|
||||
assertThat(bean.getTestBean().get().get(0)).isSameAs(bf.getBean("testBean"));
|
||||
}
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalListFieldInjectionBean.class));
|
||||
|
||||
OptionalListFieldInjectionBean bean = (OptionalListFieldInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -548,7 +548,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
OptionalListMethodInjectionBean bean = (OptionalListMethodInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isTrue();
|
||||
assertThat(bean.getTestBean()).isPresent();
|
||||
assertThat(bean.getTestBean().get().get(0)).isSameAs(bf.getBean("testBean"));
|
||||
}
|
||||
|
||||
|
|
@ -557,7 +557,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(OptionalListMethodInjectionBean.class));
|
||||
|
||||
OptionalListMethodInjectionBean bean = (OptionalListMethodInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -566,7 +566,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
ProviderOfOptionalFieldInjectionBean bean = (ProviderOfOptionalFieldInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isTrue();
|
||||
assertThat(bean.getTestBean()).isPresent();
|
||||
assertThat(bean.getTestBean().get()).isSameAs(bf.getBean("testBean"));
|
||||
}
|
||||
|
||||
|
|
@ -575,7 +575,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ProviderOfOptionalFieldInjectionBean.class));
|
||||
|
||||
ProviderOfOptionalFieldInjectionBean bean = (ProviderOfOptionalFieldInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -584,7 +584,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class));
|
||||
|
||||
ProviderOfOptionalMethodInjectionBean bean = (ProviderOfOptionalMethodInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isTrue();
|
||||
assertThat(bean.getTestBean()).isPresent();
|
||||
assertThat(bean.getTestBean().get()).isSameAs(bf.getBean("testBean"));
|
||||
}
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
|||
bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ProviderOfOptionalMethodInjectionBean.class));
|
||||
|
||||
ProviderOfOptionalMethodInjectionBean bean = (ProviderOfOptionalMethodInjectionBean) bf.getBean("annotatedBean");
|
||||
assertThat(bean.getTestBean().isPresent()).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ class BeanDefinitionMethodGeneratorTests {
|
|||
compile(method, (actual, compiled) -> {
|
||||
ManagedList<RootBeanDefinition> actualPropertyValue = (ManagedList<RootBeanDefinition>) actual
|
||||
.getPropertyValues().get("someList");
|
||||
assertThat(actualPropertyValue).isNotNull().hasSize(2);
|
||||
assertThat(actualPropertyValue).hasSize(2);
|
||||
assertThat(actualPropertyValue.get(0).getPropertyValues().get("name")).isEqualTo("one");
|
||||
assertThat(actualPropertyValue.get(1).getPropertyValues().get("name")).isEqualTo("two");
|
||||
assertThat(compiled.getSourceFileFromPackage(TestBean.class.getPackageName()))
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
|||
|
||||
Date date1 = (Date) objectFactory.getObject();
|
||||
Date date2 = (Date) objectFactory.getObject();
|
||||
assertThat(date1 != date2).isTrue();
|
||||
assertThat(date1).isNotSameAs(date2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -79,7 +79,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
|||
|
||||
Date date1 = (Date) objectFactory.getObject();
|
||||
Date date2 = (Date) objectFactory.getObject();
|
||||
assertThat(date1 != date2).isTrue();
|
||||
assertThat(date1).isNotSameAs(date2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -89,7 +89,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
|||
|
||||
Date date1 = (Date) provider.get();
|
||||
Date date2 = (Date) provider.get();
|
||||
assertThat(date1 != date2).isTrue();
|
||||
assertThat(date1).isNotSameAs(date2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -101,7 +101,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
|
|||
|
||||
Date date1 = (Date) provider.get();
|
||||
Date date2 = (Date) provider.get();
|
||||
assertThat(date1 != date2).isTrue();
|
||||
assertThat(date1).isNotSameAs(date2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -138,7 +138,7 @@ public class PropertiesFactoryBeanTests {
|
|||
assertThat(props.getProperty("tb.array[0].age")).isEqualTo("99");
|
||||
assertThat(props.getProperty("key2")).isEqualTo("value2");
|
||||
Properties newProps = pfb.getObject();
|
||||
assertThat(props != newProps).isTrue();
|
||||
assertThat(props).isNotSameAs(newProps);
|
||||
assertThat(newProps.getProperty("tb.array[0].age")).isEqualTo("99");
|
||||
assertThat(newProps.getProperty("key2")).isEqualTo("value2");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -51,7 +51,7 @@ public class PropertyPathFactoryBeanTests {
|
|||
Object result2 = xbf.getBean("otb.spouse");
|
||||
boolean condition = result1 instanceof TestBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(result1 == result2).isTrue();
|
||||
assertThat(result1).isSameAs(result2);
|
||||
assertThat(((TestBean) result1).getAge()).isEqualTo(99);
|
||||
}
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ public class PropertyPathFactoryBeanTests {
|
|||
assertThat(((TestBean) result1).getAge()).isEqualTo(11);
|
||||
assertThat(((TestBean) result2).getAge()).isEqualTo(11);
|
||||
assertThat(((TestBean) result3).getAge()).isEqualTo(11);
|
||||
assertThat(result1 != result2).isTrue();
|
||||
assertThat(result1 != result3).isTrue();
|
||||
assertThat(result2 != result3).isTrue();
|
||||
assertThat(result1).isNotSameAs(result2);
|
||||
assertThat(result1).isNotSameAs(result3);
|
||||
assertThat(result2).isNotSameAs(result3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -276,7 +276,7 @@ public class PropertyResourceConfigurerTests {
|
|||
}
|
||||
catch (BeanInitializationException ex) {
|
||||
// prove that the processor chokes on the invalid key
|
||||
assertThat(ex.getMessage().toLowerCase().contains("argh")).isTrue();
|
||||
assertThat(ex.getMessage().toLowerCase()).contains("argh");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ public class ServiceLocatorFactoryBeanTests {
|
|||
assertThat(testBean4).isNotSameAs(testBean2);
|
||||
assertThat(testBean4).isNotSameAs(testBean3);
|
||||
|
||||
assertThat(factory.toString().contains("TestServiceLocator3")).isTrue();
|
||||
assertThat(factory.toString()).contains("TestServiceLocator3");
|
||||
}
|
||||
|
||||
@Disabled @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -180,7 +180,7 @@ class YamlPropertiesFactoryBeanTests {
|
|||
factory.setResources(new ByteArrayResource("foo: bar\nspam:".getBytes()));
|
||||
Properties properties = factory.getObject();
|
||||
assertThat(properties.getProperty("foo")).isEqualTo("bar");
|
||||
assertThat(properties.getProperty("spam")).isEqualTo("");
|
||||
assertThat(properties.getProperty("spam")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -189,7 +189,7 @@ class YamlPropertiesFactoryBeanTests {
|
|||
factory.setResources(new ByteArrayResource("a: alpha\ntest: []".getBytes()));
|
||||
Properties properties = factory.getObject();
|
||||
assertThat(properties.getProperty("a")).isEqualTo("alpha");
|
||||
assertThat(properties.getProperty("test")).isEqualTo("");
|
||||
assertThat(properties.getProperty("test")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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 CustomProblemReporterTests {
|
|||
@Test
|
||||
public void testErrorsAreCollated() {
|
||||
this.reader.loadBeanDefinitions(qualifiedResource(CustomProblemReporterTests.class, "context.xml"));
|
||||
assertThat(this.problemReporter.getErrors().length).as("Incorrect number of errors collated").isEqualTo(4);
|
||||
assertThat(this.problemReporter.getErrors()).as("Incorrect number of errors collated").hasSize(4);
|
||||
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("validBean");
|
||||
assertThat(bean).isNotNull();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -44,7 +44,7 @@ public class BeanDefinitionTests {
|
|||
otherBd.setScope("request");
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -66,7 +66,7 @@ public class BeanDefinitionTests {
|
|||
otherBd.getPropertyValues().add("age", "99");
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -88,7 +88,7 @@ public class BeanDefinitionTests {
|
|||
otherBd.getConstructorArgumentValues().addIndexedArgumentValue(1, 5);
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -111,7 +111,7 @@ public class BeanDefinitionTests {
|
|||
otherBd.getConstructorArgumentValues().addIndexedArgumentValue(1, 5, "long");
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -132,17 +132,17 @@ public class BeanDefinitionTests {
|
|||
otherBd.setParentName("parent");
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
|
||||
bd.getPropertyValues();
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
|
||||
bd.getConstructorArgumentValues();
|
||||
assertThat(bd.equals(otherBd)).isTrue();
|
||||
assertThat(otherBd.equals(bd)).isTrue();
|
||||
assertThat(bd.hashCode() == otherBd.hashCode()).isTrue();
|
||||
assertThat(bd.hashCode()).isEqualTo(otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -163,7 +163,7 @@ public class BeanDefinitionTests {
|
|||
BeanDefinitionHolder otherHolder = new BeanDefinitionHolder(bd, "bd");
|
||||
assertThat(holder.equals(otherHolder)).isTrue();
|
||||
assertThat(otherHolder.equals(holder)).isTrue();
|
||||
assertThat(holder.hashCode() == otherHolder.hashCode()).isTrue();
|
||||
assertThat(holder.hashCode()).isEqualTo(otherHolder.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -39,7 +39,7 @@ public class ManagedMapTests {
|
|||
ManagedMap child = ManagedMap.ofEntries(Map.entry("tree", "three"));
|
||||
child.setMergeEnabled(true);
|
||||
Map mergedMap = (Map) child.merge(parent);
|
||||
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(3);
|
||||
assertThat(mergedMap).as("merge() obviously did not work.").hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -70,7 +70,7 @@ public class ManagedMapTests {
|
|||
ManagedMap child = new ManagedMap();
|
||||
child.setMergeEnabled(true);
|
||||
Map mergedMap = (Map) child.merge(parent);
|
||||
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(2);
|
||||
assertThat(mergedMap).as("merge() obviously did not work.").hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -81,7 +81,7 @@ public class ManagedMapTests {
|
|||
child.setMergeEnabled(true);
|
||||
Map mergedMap = (Map) child.merge(parent);
|
||||
// child value for 'one' must override parent value...
|
||||
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(2);
|
||||
assertThat(mergedMap).as("merge() obviously did not work.").hasSize(2);
|
||||
assertThat(mergedMap.get("one")).as("Parent value not being overridden during merge().").isEqualTo("fork");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -41,7 +41,7 @@ public class ManagedPropertiesTests {
|
|||
child.setProperty("three", "three");
|
||||
child.setMergeEnabled(true);
|
||||
Map mergedMap = (Map) child.merge(parent);
|
||||
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(3);
|
||||
assertThat(mergedMap).as("merge() obviously did not work.").hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -74,7 +74,7 @@ public class ManagedPropertiesTests {
|
|||
ManagedProperties child = new ManagedProperties();
|
||||
child.setMergeEnabled(true);
|
||||
Map mergedMap = (Map) child.merge(parent);
|
||||
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(2);
|
||||
assertThat(mergedMap).as("merge() obviously did not work.").hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -87,7 +87,7 @@ public class ManagedPropertiesTests {
|
|||
child.setMergeEnabled(true);
|
||||
Map mergedMap = (Map) child.merge(parent);
|
||||
// child value for 'one' must override parent value...
|
||||
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(2);
|
||||
assertThat(mergedMap).as("merge() obviously did not work.").hasSize(2);
|
||||
assertThat(mergedMap.get("one")).as("Parent value not being overridden during merge().").isEqualTo("fork");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -73,8 +73,8 @@ public class Spr8954Tests {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, FactoryBean> fbBeans = bf.getBeansOfType(FactoryBean.class);
|
||||
assertThat(1).isEqualTo(fbBeans.size());
|
||||
assertThat("&foo").isEqualTo(fbBeans.keySet().iterator().next());
|
||||
assertThat(fbBeans.size()).isEqualTo(1);
|
||||
assertThat(fbBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
|
||||
Map<String, AnInterface> aiBeans = bf.getBeansOfType(AnInterface.class);
|
||||
assertThat(aiBeans).hasSize(1);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -56,13 +56,13 @@ public class BeanNameGenerationTests {
|
|||
|
||||
GeneratedNameBean child1 = topLevel1.getChild();
|
||||
assertThat(child1.getBeanName()).isNotNull();
|
||||
assertThat(child1.getBeanName().startsWith(className)).isTrue();
|
||||
assertThat(child1.getBeanName()).startsWith(className);
|
||||
|
||||
GeneratedNameBean child2 = topLevel2.getChild();
|
||||
assertThat(child2.getBeanName()).isNotNull();
|
||||
assertThat(child2.getBeanName().startsWith(className)).isTrue();
|
||||
assertThat(child2.getBeanName()).startsWith(className);
|
||||
|
||||
assertThat(child1.getBeanName().equals(child2.getBeanName())).isFalse();
|
||||
assertThat(child1.getBeanName()).isNotEqualTo(child2.getBeanName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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 CollectionMergingTests {
|
|||
public void mergeList() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
|
||||
List list = bean.getSomeList();
|
||||
assertThat(list.size()).as("Incorrect size").isEqualTo(3);
|
||||
assertThat(list).as("Incorrect size").hasSize(3);
|
||||
assertThat(list.get(0)).isEqualTo("Rob Harrop");
|
||||
assertThat(list.get(1)).isEqualTo("Rod Johnson");
|
||||
assertThat(list.get(2)).isEqualTo("Juergen Hoeller");
|
||||
|
|
@ -75,7 +75,7 @@ public class CollectionMergingTests {
|
|||
public void mergeSet() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSet");
|
||||
Set set = bean.getSomeSet();
|
||||
assertThat(set.size()).as("Incorrect size").isEqualTo(2);
|
||||
assertThat(set).as("Incorrect size").hasSize(2);
|
||||
assertThat(set.contains("Rob Harrop")).isTrue();
|
||||
assertThat(set.contains("Sally Greenwood")).isTrue();
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ public class CollectionMergingTests {
|
|||
public void mergeMap() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap");
|
||||
Map map = bean.getSomeMap();
|
||||
assertThat(map.size()).as("Incorrect size").isEqualTo(3);
|
||||
assertThat(map).as("Incorrect size").hasSize(3);
|
||||
assertThat(map.get("Rob")).isEqualTo("Sally");
|
||||
assertThat(map.get("Rod")).isEqualTo("Kerry");
|
||||
assertThat(map.get("Juergen")).isEqualTo("Eva");
|
||||
|
|
@ -121,7 +121,7 @@ public class CollectionMergingTests {
|
|||
public void mergeProperties() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithProps");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertThat(props.size()).as("Incorrect size").isEqualTo(3);
|
||||
assertThat(props).as("Incorrect size").hasSize(3);
|
||||
assertThat(props.getProperty("Rob")).isEqualTo("Sally");
|
||||
assertThat(props.getProperty("Rod")).isEqualTo("Kerry");
|
||||
assertThat(props.getProperty("Juergen")).isEqualTo("Eva");
|
||||
|
|
@ -131,7 +131,7 @@ public class CollectionMergingTests {
|
|||
public void mergeListInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor");
|
||||
List list = bean.getSomeList();
|
||||
assertThat(list.size()).as("Incorrect size").isEqualTo(3);
|
||||
assertThat(list).as("Incorrect size").hasSize(3);
|
||||
assertThat(list.get(0)).isEqualTo("Rob Harrop");
|
||||
assertThat(list.get(1)).isEqualTo("Rod Johnson");
|
||||
assertThat(list.get(2)).isEqualTo("Juergen Hoeller");
|
||||
|
|
@ -152,7 +152,7 @@ public class CollectionMergingTests {
|
|||
public void mergeSetInConstructor() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetInConstructor");
|
||||
Set set = bean.getSomeSet();
|
||||
assertThat(set.size()).as("Incorrect size").isEqualTo(2);
|
||||
assertThat(set).as("Incorrect size").hasSize(2);
|
||||
assertThat(set.contains("Rob Harrop")).isTrue();
|
||||
assertThat(set.contains("Sally Greenwood")).isTrue();
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ public class CollectionMergingTests {
|
|||
public void mergeMapInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor");
|
||||
Map map = bean.getSomeMap();
|
||||
assertThat(map.size()).as("Incorrect size").isEqualTo(3);
|
||||
assertThat(map).as("Incorrect size").hasSize(3);
|
||||
assertThat(map.get("Rob")).isEqualTo("Sally");
|
||||
assertThat(map.get("Rod")).isEqualTo("Kerry");
|
||||
assertThat(map.get("Juergen")).isEqualTo("Eva");
|
||||
|
|
@ -198,7 +198,7 @@ public class CollectionMergingTests {
|
|||
public void mergePropertiesInConstructor() throws Exception {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("childWithPropsInConstructor");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertThat(props.size()).as("Incorrect size").isEqualTo(3);
|
||||
assertThat(props).as("Incorrect size").hasSize(3);
|
||||
assertThat(props.getProperty("Rob")).isEqualTo("Sally");
|
||||
assertThat(props.getProperty("Rod")).isEqualTo("Kerry");
|
||||
assertThat(props.getProperty("Juergen")).isEqualTo("Eva");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -81,15 +81,15 @@ public class CollectionsWithDefaultTypesTests {
|
|||
@SuppressWarnings("rawtypes")
|
||||
public void testBuildCollectionFromMixtureOfReferencesAndValues() throws Exception {
|
||||
MixedCollectionBean jumble = (MixedCollectionBean) this.beanFactory.getBean("jumble");
|
||||
assertThat(jumble.getJumble().size() == 3).as("Expected 3 elements, not " + jumble.getJumble().size()).isTrue();
|
||||
assertThat(jumble.getJumble()).as("Expected 3 elements, not " + jumble.getJumble().size()).hasSize(3);
|
||||
List l = (List) jumble.getJumble();
|
||||
assertThat(l.get(0).equals("literal")).isTrue();
|
||||
Integer[] array1 = (Integer[]) l.get(1);
|
||||
assertThat(array1[0].equals(2)).isTrue();
|
||||
assertThat(array1[1].equals(4)).isTrue();
|
||||
int[] array2 = (int[]) l.get(2);
|
||||
assertThat(array2[0] == 3).isTrue();
|
||||
assertThat(array2[1] == 5).isTrue();
|
||||
assertThat(array2[0]).isEqualTo(3);
|
||||
assertThat(array2[1]).isEqualTo(5);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -282,7 +282,7 @@ public class FactoryMethodTests {
|
|||
FactoryMethods fm2 = (FactoryMethods) xbf.getBean("testBeanOnlyPrototype", tbArg2);
|
||||
assertThat(fm2.getTestBean().getName()).isEqualTo("arg2");
|
||||
assertThat(fm2.getNum()).isEqualTo(fm1.getNum());
|
||||
assertThat("testBeanOnlyPrototypeDISetterString").isEqualTo(fm2.getStringValue());
|
||||
assertThat(fm2.getStringValue()).isEqualTo("testBeanOnlyPrototypeDISetterString");
|
||||
assertThat(fm2.getStringValue()).isEqualTo(fm2.getStringValue());
|
||||
// The TestBean reference is resolved to a prototype in the factory
|
||||
assertThat(fm2.getTestBean()).isSameAs(fm2.getTestBean());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -91,7 +91,7 @@ public class UtilNamespaceHandlerTests {
|
|||
void testNestedProperties() {
|
||||
TestBean bean = (TestBean) this.beanFactory.getBean("testBean");
|
||||
Properties props = bean.getSomeProperties();
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -111,7 +111,7 @@ public class UtilNamespaceHandlerTests {
|
|||
Map<?, ?> map = (Map) this.beanFactory.getBean("simpleMap");
|
||||
assertThat(map.get("foo")).isEqualTo("bar");
|
||||
Map<?, ?> map2 = (Map) this.beanFactory.getBean("simpleMap");
|
||||
assertThat(map == map2).isTrue();
|
||||
assertThat(map).isSameAs(map2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -120,7 +120,7 @@ public class UtilNamespaceHandlerTests {
|
|||
assertThat(map.get("foo")).isEqualTo("bar");
|
||||
Map<?, ?> map2 = (Map) this.beanFactory.getBean("scopedMap");
|
||||
assertThat(map2.get("foo")).isEqualTo("bar");
|
||||
assertThat(map != map2).isTrue();
|
||||
assertThat(map).isNotSameAs(map2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -128,7 +128,7 @@ public class UtilNamespaceHandlerTests {
|
|||
List<?> list = (List) this.beanFactory.getBean("simpleList");
|
||||
assertThat(list.get(0)).isEqualTo("Rob Harrop");
|
||||
List<?> list2 = (List) this.beanFactory.getBean("simpleList");
|
||||
assertThat(list == list2).isTrue();
|
||||
assertThat(list).isSameAs(list2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -137,7 +137,7 @@ public class UtilNamespaceHandlerTests {
|
|||
assertThat(list.get(0)).isEqualTo("Rob Harrop");
|
||||
List<?> list2 = (List) this.beanFactory.getBean("scopedList");
|
||||
assertThat(list2.get(0)).isEqualTo("Rob Harrop");
|
||||
assertThat(list != list2).isTrue();
|
||||
assertThat(list).isNotSameAs(list2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -145,7 +145,7 @@ public class UtilNamespaceHandlerTests {
|
|||
Set<?> set = (Set) this.beanFactory.getBean("simpleSet");
|
||||
assertThat(set.contains("Rob Harrop")).isTrue();
|
||||
Set<?> set2 = (Set) this.beanFactory.getBean("simpleSet");
|
||||
assertThat(set == set2).isTrue();
|
||||
assertThat(set).isSameAs(set2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -154,7 +154,7 @@ public class UtilNamespaceHandlerTests {
|
|||
assertThat(set.contains("Rob Harrop")).isTrue();
|
||||
Set<?> set2 = (Set) this.beanFactory.getBean("scopedSet");
|
||||
assertThat(set2.contains("Rob Harrop")).isTrue();
|
||||
assertThat(set != set2).isTrue();
|
||||
assertThat(set).isNotSameAs(set2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -194,9 +194,9 @@ public class UtilNamespaceHandlerTests {
|
|||
assertThat(bean2.getSomeList()).isEqualTo(list);
|
||||
assertThat(bean2.getSomeSet()).isEqualTo(set);
|
||||
assertThat(bean2.getSomeMap()).isEqualTo(map);
|
||||
assertThat(list == bean2.getSomeList()).isFalse();
|
||||
assertThat(set == bean2.getSomeSet()).isFalse();
|
||||
assertThat(map == bean2.getSomeMap()).isFalse();
|
||||
assertThat(list).isNotSameAs(bean2.getSomeList());
|
||||
assertThat(set).isNotSameAs(bean2.getSomeSet());
|
||||
assertThat(map).isNotSameAs(bean2.getSomeMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -216,11 +216,11 @@ public class UtilNamespaceHandlerTests {
|
|||
|
||||
TestBean bean2 = (TestBean) this.beanFactory.getBean("nestedShortcutCollections");
|
||||
assertThat(Arrays.equals(bean.getStringArray(), bean2.getStringArray())).isTrue();
|
||||
assertThat(bean.getStringArray() == bean2.getStringArray()).isFalse();
|
||||
assertThat(bean.getStringArray()).isNotSameAs(bean2.getStringArray());
|
||||
assertThat(bean2.getSomeList()).isEqualTo(list);
|
||||
assertThat(bean2.getSomeSet()).isEqualTo(set);
|
||||
assertThat(list == bean2.getSomeList()).isFalse();
|
||||
assertThat(set == bean2.getSomeSet()).isFalse();
|
||||
assertThat(list).isNotSameAs(bean2.getSomeList());
|
||||
assertThat(set).isNotSameAs(bean2.getSomeSet());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -244,9 +244,9 @@ public class UtilNamespaceHandlerTests {
|
|||
assertThat(bean2.getSomeList()).isEqualTo(list);
|
||||
assertThat(bean2.getSomeSet()).isEqualTo(set);
|
||||
assertThat(bean2.getSomeMap()).isEqualTo(map);
|
||||
assertThat(list == bean2.getSomeList()).isFalse();
|
||||
assertThat(set == bean2.getSomeSet()).isFalse();
|
||||
assertThat(map == bean2.getSomeMap()).isFalse();
|
||||
assertThat(list).isNotSameAs(bean2.getSomeList());
|
||||
assertThat(set).isNotSameAs(bean2.getSomeSet());
|
||||
assertThat(map).isNotSameAs(bean2.getSomeMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -338,56 +338,56 @@ public class UtilNamespaceHandlerTests {
|
|||
@Test
|
||||
void testLoadProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
assertThat(props).as("Incorrect property value").doesNotContainKey("foo2");
|
||||
Properties props2 = (Properties) this.beanFactory.getBean("myProperties");
|
||||
assertThat(props == props2).isTrue();
|
||||
assertThat(props).isSameAs(props2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScopedProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myScopedProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
assertThat(props).as("Incorrect property value").doesNotContainKey("foo2");
|
||||
Properties props2 = (Properties) this.beanFactory.getBean("myScopedProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isNull();
|
||||
assertThat(props != props2).isTrue();
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
assertThat(props).as("Incorrect property value").doesNotContainKey("foo2");
|
||||
assertThat(props).isNotSameAs(props2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLocalProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myLocalProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isNull();
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("bar2");
|
||||
assertThat(props).as("Incorrect property value").doesNotContainKey("foo");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo2", "bar2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMergedProperties() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("myMergedProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("bar2");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo2", "bar2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLocalOverrideDefault() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("defaultLocalOverrideProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("local2");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo2", "local2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLocalOverrideFalse() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("falseLocalOverrideProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("local2");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "bar");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo2", "local2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLocalOverrideTrue() {
|
||||
Properties props = (Properties) this.beanFactory.getBean("trueLocalOverrideProperties");
|
||||
assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("local");
|
||||
assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("local2");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo", "local");
|
||||
assertThat(props).as("Incorrect property value").containsEntry("foo2", "local2");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -91,25 +91,25 @@ public class XmlBeanCollectionTests {
|
|||
//assertTrue("5 beans in reftypes, not " + this.beanFactory.getBeanDefinitionCount(), this.beanFactory.getBeanDefinitionCount() == 5);
|
||||
TestBean jen = (TestBean) this.beanFactory.getBean("jenny");
|
||||
TestBean dave = (TestBean) this.beanFactory.getBean("david");
|
||||
assertThat(jen.getSpouse() == dave).isTrue();
|
||||
assertThat(jen.getSpouse()).isSameAs(dave);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyWithLiteralValueSubelement() throws Exception {
|
||||
TestBean verbose = (TestBean) this.beanFactory.getBean("verbose");
|
||||
assertThat(verbose.getName().equals("verbose")).isTrue();
|
||||
assertThat(verbose.getName()).isEqualTo("verbose");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyWithIdRefLocalAttrSubelement() throws Exception {
|
||||
TestBean verbose = (TestBean) this.beanFactory.getBean("verbose2");
|
||||
assertThat(verbose.getName().equals("verbose")).isTrue();
|
||||
assertThat(verbose.getName()).isEqualTo("verbose");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyWithIdRefBeanAttrSubelement() throws Exception {
|
||||
TestBean verbose = (TestBean) this.beanFactory.getBean("verbose3");
|
||||
assertThat(verbose.getName().equals("verbose")).isTrue();
|
||||
assertThat(verbose.getName()).isEqualTo("verbose");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -122,10 +122,10 @@ public class XmlBeanCollectionTests {
|
|||
// Our bean doesn't modify the collection:
|
||||
// of course it could be a different copy in a real object.
|
||||
Object[] friends = rod.getFriends().toArray();
|
||||
assertThat(friends.length == 2).isTrue();
|
||||
assertThat(friends.length).isEqualTo(2);
|
||||
|
||||
assertThat(friends[0] == jen).as("First friend must be jen, not " + friends[0]).isTrue();
|
||||
assertThat(friends[1] == dave).isTrue();
|
||||
assertThat(friends[0]).as("First friend must be jen, not " + friends[0]).isSameAs(jen);
|
||||
assertThat(friends[1]).isSameAs(dave);
|
||||
// Should be ordered
|
||||
}
|
||||
|
||||
|
|
@ -136,34 +136,34 @@ public class XmlBeanCollectionTests {
|
|||
TestBean rod = (TestBean) this.beanFactory.getBean("pRod");
|
||||
|
||||
Object[] friends = rod.getFriends().toArray();
|
||||
assertThat(friends.length == 2).isTrue();
|
||||
assertThat(friends[0].toString().equals(jen.toString())).as("First friend must be jen, not " + friends[0]).isTrue();
|
||||
assertThat(friends[0] != jen).as("Jen not same instance").isTrue();
|
||||
assertThat(friends[1].toString().equals(dave.toString())).isTrue();
|
||||
assertThat(friends[1] != dave).as("Dave not same instance").isTrue();
|
||||
assertThat(friends.length).isEqualTo(2);
|
||||
assertThat(friends[0].toString()).as("First friend must be jen, not " + friends[0]).isEqualTo(jen.toString());
|
||||
assertThat(friends[0]).as("Jen not same instance").isNotSameAs(jen);
|
||||
assertThat(friends[1].toString()).isEqualTo(dave.toString());
|
||||
assertThat(friends[1]).as("Dave not same instance").isNotSameAs(dave);
|
||||
assertThat(dave.getSpouse().getName()).isEqualTo("Jen");
|
||||
|
||||
TestBean rod2 = (TestBean) this.beanFactory.getBean("pRod");
|
||||
Object[] friends2 = rod2.getFriends().toArray();
|
||||
assertThat(friends2.length == 2).isTrue();
|
||||
assertThat(friends2[0].toString().equals(jen.toString())).as("First friend must be jen, not " + friends2[0]).isTrue();
|
||||
assertThat(friends2[0] != friends[0]).as("Jen not same instance").isTrue();
|
||||
assertThat(friends2[1].toString().equals(dave.toString())).isTrue();
|
||||
assertThat(friends2[1] != friends[1]).as("Dave not same instance").isTrue();
|
||||
assertThat(friends2.length).isEqualTo(2);
|
||||
assertThat(friends2[0].toString()).as("First friend must be jen, not " + friends2[0]).isEqualTo(jen.toString());
|
||||
assertThat(friends2[0]).as("Jen not same instance").isNotSameAs(friends[0]);
|
||||
assertThat(friends2[1].toString()).isEqualTo(dave.toString());
|
||||
assertThat(friends2[1]).as("Dave not same instance").isNotSameAs(friends[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefSubelementsBuildCollectionFromSingleElement() throws Exception {
|
||||
TestBean loner = (TestBean) this.beanFactory.getBean("loner");
|
||||
TestBean dave = (TestBean) this.beanFactory.getBean("david");
|
||||
assertThat(loner.getFriends().size() == 1).isTrue();
|
||||
assertThat(loner.getFriends().size()).isEqualTo(1);
|
||||
assertThat(loner.getFriends().contains(dave)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildCollectionFromMixtureOfReferencesAndValues() throws Exception {
|
||||
MixedCollectionBean jumble = (MixedCollectionBean) this.beanFactory.getBean("jumble");
|
||||
assertThat(jumble.getJumble().size() == 5).as("Expected 5 elements, not " + jumble.getJumble().size()).isTrue();
|
||||
assertThat(jumble.getJumble().size()).as("Expected 5 elements, not " + jumble.getJumble().size()).isEqualTo(5);
|
||||
List l = (List) jumble.getJumble();
|
||||
assertThat(l.get(0).equals(this.beanFactory.getBean("david"))).isTrue();
|
||||
assertThat(l.get(1).equals("literal")).isTrue();
|
||||
|
|
@ -185,25 +185,25 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testEmptyMap() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("emptyMap");
|
||||
assertThat(hasMap.getMap().size() == 0).isTrue();
|
||||
assertThat(hasMap.getMap().size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapWithLiteralsOnly() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("literalMap");
|
||||
assertThat(hasMap.getMap().size() == 3).isTrue();
|
||||
assertThat(hasMap.getMap().size()).isEqualTo(3);
|
||||
assertThat(hasMap.getMap().get("foo").equals("bar")).isTrue();
|
||||
assertThat(hasMap.getMap().get("fi").equals("fum")).isTrue();
|
||||
assertThat(hasMap.getMap().get("fa") == null).isTrue();
|
||||
assertThat(hasMap.getMap().get("fa")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapWithLiteralsAndReferences() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("mixedMap");
|
||||
assertThat(hasMap.getMap().size() == 5).isTrue();
|
||||
assertThat(hasMap.getMap().size()).isEqualTo(5);
|
||||
assertThat(hasMap.getMap().get("foo").equals(10)).isTrue();
|
||||
TestBean jenny = (TestBean) this.beanFactory.getBean("jenny");
|
||||
assertThat(hasMap.getMap().get("jenny") == jenny).isTrue();
|
||||
assertThat(hasMap.getMap().get("jenny")).isSameAs(jenny);
|
||||
assertThat(hasMap.getMap().get(5).equals("david")).isTrue();
|
||||
boolean condition1 = hasMap.getMap().get("bar") instanceof Long;
|
||||
assertThat(condition1).isTrue();
|
||||
|
|
@ -217,22 +217,22 @@ public class XmlBeanCollectionTests {
|
|||
public void testMapWithLiteralsAndPrototypeReferences() throws Exception {
|
||||
TestBean jenny = (TestBean) this.beanFactory.getBean("pJenny");
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("pMixedMap");
|
||||
assertThat(hasMap.getMap().size() == 2).isTrue();
|
||||
assertThat(hasMap.getMap().size()).isEqualTo(2);
|
||||
assertThat(hasMap.getMap().get("foo").equals("bar")).isTrue();
|
||||
assertThat(hasMap.getMap().get("jenny").toString().equals(jenny.toString())).isTrue();
|
||||
assertThat(hasMap.getMap().get("jenny") != jenny).as("Not same instance").isTrue();
|
||||
assertThat(hasMap.getMap().get("jenny").toString()).isEqualTo(jenny.toString());
|
||||
assertThat(hasMap.getMap().get("jenny")).as("Not same instance").isNotSameAs(jenny);
|
||||
|
||||
HasMap hasMap2 = (HasMap) this.beanFactory.getBean("pMixedMap");
|
||||
assertThat(hasMap2.getMap().size() == 2).isTrue();
|
||||
assertThat(hasMap2.getMap().size()).isEqualTo(2);
|
||||
assertThat(hasMap2.getMap().get("foo").equals("bar")).isTrue();
|
||||
assertThat(hasMap2.getMap().get("jenny").toString().equals(jenny.toString())).isTrue();
|
||||
assertThat(hasMap2.getMap().get("jenny") != hasMap.getMap().get("jenny")).as("Not same instance").isTrue();
|
||||
assertThat(hasMap2.getMap().get("jenny").toString()).isEqualTo(jenny.toString());
|
||||
assertThat(hasMap2.getMap().get("jenny")).as("Not same instance").isNotSameAs(hasMap.getMap().get("jenny"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapWithLiteralsReferencesAndList() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("mixedMapWithList");
|
||||
assertThat(hasMap.getMap().size() == 4).isTrue();
|
||||
assertThat(hasMap.getMap().size()).isEqualTo(4);
|
||||
assertThat(hasMap.getMap().get(null).equals("bar")).isTrue();
|
||||
TestBean jenny = (TestBean) this.beanFactory.getBean("jenny");
|
||||
assertThat(hasMap.getMap().get("jenny").equals(jenny)).isTrue();
|
||||
|
|
@ -240,28 +240,28 @@ public class XmlBeanCollectionTests {
|
|||
// Check list
|
||||
List l = (List) hasMap.getMap().get("list");
|
||||
assertThat(l).isNotNull();
|
||||
assertThat(l.size() == 4).isTrue();
|
||||
assertThat(l.size()).isEqualTo(4);
|
||||
assertThat(l.get(0).equals("zero")).isTrue();
|
||||
assertThat(l.get(3) == null).isTrue();
|
||||
assertThat(l.get(3)).isNull();
|
||||
|
||||
// Check nested map in list
|
||||
Map m = (Map) l.get(1);
|
||||
assertThat(m).isNotNull();
|
||||
assertThat(m.size() == 2).isTrue();
|
||||
assertThat(m.size()).isEqualTo(2);
|
||||
assertThat(m.get("fo").equals("bar")).isTrue();
|
||||
assertThat(m.get("jen").equals(jenny)).as("Map element 'jenny' should be equal to jenny bean, not " + m.get("jen")).isTrue();
|
||||
|
||||
// Check nested list in list
|
||||
l = (List) l.get(2);
|
||||
assertThat(l).isNotNull();
|
||||
assertThat(l.size() == 2).isTrue();
|
||||
assertThat(l.size()).isEqualTo(2);
|
||||
assertThat(l.get(0).equals(jenny)).isTrue();
|
||||
assertThat(l.get(1).equals("ba")).isTrue();
|
||||
|
||||
// Check nested map
|
||||
m = (Map) hasMap.getMap().get("map");
|
||||
assertThat(m).isNotNull();
|
||||
assertThat(m.size() == 2).isTrue();
|
||||
assertThat(m.size()).isEqualTo(2);
|
||||
assertThat(m.get("foo").equals("bar")).isTrue();
|
||||
assertThat(m.get("jenny").equals(jenny)).as("Map element 'jenny' should be equal to jenny bean, not " + m.get("jenny")).isTrue();
|
||||
}
|
||||
|
|
@ -269,13 +269,13 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testEmptySet() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("emptySet");
|
||||
assertThat(hasMap.getSet().size() == 0).isTrue();
|
||||
assertThat(hasMap.getSet().size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPopulatedSet() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("set");
|
||||
assertThat(hasMap.getSet().size() == 3).isTrue();
|
||||
assertThat(hasMap.getSet().size()).isEqualTo(3);
|
||||
assertThat(hasMap.getSet().contains("bar")).isTrue();
|
||||
TestBean jenny = (TestBean) this.beanFactory.getBean("jenny");
|
||||
assertThat(hasMap.getSet().contains(jenny)).isTrue();
|
||||
|
|
@ -289,7 +289,7 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testPopulatedConcurrentSet() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("concurrentSet");
|
||||
assertThat(hasMap.getConcurrentSet().size() == 3).isTrue();
|
||||
assertThat(hasMap.getConcurrentSet().size()).isEqualTo(3);
|
||||
assertThat(hasMap.getConcurrentSet().contains("bar")).isTrue();
|
||||
TestBean jenny = (TestBean) this.beanFactory.getBean("jenny");
|
||||
assertThat(hasMap.getConcurrentSet().contains(jenny)).isTrue();
|
||||
|
|
@ -299,7 +299,7 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testPopulatedIdentityMap() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("identityMap");
|
||||
assertThat(hasMap.getIdentityMap().size() == 2).isTrue();
|
||||
assertThat(hasMap.getIdentityMap().size()).isEqualTo(2);
|
||||
HashSet set = new HashSet(hasMap.getIdentityMap().keySet());
|
||||
assertThat(set.contains("foo")).isTrue();
|
||||
assertThat(set.contains("jenny")).isTrue();
|
||||
|
|
@ -308,14 +308,14 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testEmptyProps() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("emptyProps");
|
||||
assertThat(hasMap.getProps().size() == 0).isTrue();
|
||||
assertThat(hasMap.getProps().size()).isEqualTo(0);
|
||||
assertThat(Properties.class).isEqualTo(hasMap.getProps().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPopulatedProps() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("props");
|
||||
assertThat(hasMap.getProps().size() == 2).isTrue();
|
||||
assertThat(hasMap.getProps().size()).isEqualTo(2);
|
||||
assertThat(hasMap.getProps().get("foo").equals("bar")).isTrue();
|
||||
assertThat(hasMap.getProps().get("2").equals("TWO")).isTrue();
|
||||
}
|
||||
|
|
@ -323,7 +323,7 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testObjectArray() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("objectArray");
|
||||
assertThat(hasMap.getObjectArray().length == 2).isTrue();
|
||||
assertThat(hasMap.getObjectArray().length).isEqualTo(2);
|
||||
assertThat(hasMap.getObjectArray()[0].equals("one")).isTrue();
|
||||
assertThat(hasMap.getObjectArray()[1].equals(this.beanFactory.getBean("jenny"))).isTrue();
|
||||
}
|
||||
|
|
@ -331,16 +331,16 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testIntegerArray() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("integerArray");
|
||||
assertThat(hasMap.getIntegerArray().length == 3).isTrue();
|
||||
assertThat(hasMap.getIntegerArray()[0] == 0).isTrue();
|
||||
assertThat(hasMap.getIntegerArray()[1] == 1).isTrue();
|
||||
assertThat(hasMap.getIntegerArray()[2] == 2).isTrue();
|
||||
assertThat(hasMap.getIntegerArray().length).isEqualTo(3);
|
||||
assertThat(hasMap.getIntegerArray()[0]).isEqualTo(0);
|
||||
assertThat(hasMap.getIntegerArray()[1]).isEqualTo(1);
|
||||
assertThat(hasMap.getIntegerArray()[2]).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassArray() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("classArray");
|
||||
assertThat(hasMap.getClassArray().length == 2).isTrue();
|
||||
assertThat(hasMap.getClassArray().length).isEqualTo(2);
|
||||
assertThat(hasMap.getClassArray()[0].equals(String.class)).isTrue();
|
||||
assertThat(hasMap.getClassArray()[1].equals(Exception.class)).isTrue();
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testClassList() throws Exception {
|
||||
HasMap hasMap = (HasMap) this.beanFactory.getBean("classList");
|
||||
assertThat(hasMap.getClassList().size()== 2).isTrue();
|
||||
assertThat(hasMap.getClassList().size()).isEqualTo(2);
|
||||
assertThat(hasMap.getClassList().get(0).equals(String.class)).isTrue();
|
||||
assertThat(hasMap.getClassList().get(1).equals(Exception.class)).isTrue();
|
||||
}
|
||||
|
|
@ -371,7 +371,7 @@ public class XmlBeanCollectionTests {
|
|||
List list = (List) this.beanFactory.getBean("listFactory");
|
||||
boolean condition = list instanceof LinkedList;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(list.size() == 2).isTrue();
|
||||
assertThat(list.size()).isEqualTo(2);
|
||||
assertThat(list.get(0)).isEqualTo("bar");
|
||||
assertThat(list.get(1)).isEqualTo("jenny");
|
||||
}
|
||||
|
|
@ -381,7 +381,7 @@ public class XmlBeanCollectionTests {
|
|||
List list = (List) this.beanFactory.getBean("pListFactory");
|
||||
boolean condition = list instanceof LinkedList;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(list.size() == 2).isTrue();
|
||||
assertThat(list.size()).isEqualTo(2);
|
||||
assertThat(list.get(0)).isEqualTo("bar");
|
||||
assertThat(list.get(1)).isEqualTo("jenny");
|
||||
}
|
||||
|
|
@ -391,7 +391,7 @@ public class XmlBeanCollectionTests {
|
|||
Set set = (Set) this.beanFactory.getBean("setFactory");
|
||||
boolean condition = set instanceof TreeSet;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(set.size() == 2).isTrue();
|
||||
assertThat(set.size()).isEqualTo(2);
|
||||
assertThat(set.contains("bar")).isTrue();
|
||||
assertThat(set.contains("jenny")).isTrue();
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ public class XmlBeanCollectionTests {
|
|||
Set set = (Set) this.beanFactory.getBean("pSetFactory");
|
||||
boolean condition = set instanceof TreeSet;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(set.size() == 2).isTrue();
|
||||
assertThat(set.size()).isEqualTo(2);
|
||||
assertThat(set.contains("bar")).isTrue();
|
||||
assertThat(set.contains("jenny")).isTrue();
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ public class XmlBeanCollectionTests {
|
|||
Map map = (Map) this.beanFactory.getBean("mapFactory");
|
||||
boolean condition = map instanceof TreeMap;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(map.size() == 2).isTrue();
|
||||
assertThat(map.size()).isEqualTo(2);
|
||||
assertThat(map.get("foo")).isEqualTo("bar");
|
||||
assertThat(map.get("jen")).isEqualTo("jenny");
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ public class XmlBeanCollectionTests {
|
|||
Map map = (Map) this.beanFactory.getBean("pMapFactory");
|
||||
boolean condition = map instanceof TreeMap;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(map.size() == 2).isTrue();
|
||||
assertThat(map.size()).isEqualTo(2);
|
||||
assertThat(map.get("foo")).isEqualTo("bar");
|
||||
assertThat(map.get("jen")).isEqualTo("jenny");
|
||||
}
|
||||
|
|
@ -441,7 +441,7 @@ public class XmlBeanCollectionTests {
|
|||
@Test
|
||||
public void testEnumSetFactory() throws Exception {
|
||||
Set set = (Set) this.beanFactory.getBean("enumSetFactory");
|
||||
assertThat(set.size() == 2).isTrue();
|
||||
assertThat(set.size()).isEqualTo(2);
|
||||
assertThat(set.contains("ONE")).isTrue();
|
||||
assertThat(set.contains("TWO")).isTrue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -124,7 +124,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
|||
@Test
|
||||
public void descriptionButNoProperties() {
|
||||
TestBean validEmpty = (TestBean) getBeanFactory().getBean("validEmptyWithDescription");
|
||||
assertThat(validEmpty.getAge()).isEqualTo(0);
|
||||
assertThat(validEmpty.getAge()).isZero();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -136,71 +136,71 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
|||
|
||||
TestBean tb1 = (TestBean) getBeanFactory().getBean("aliased");
|
||||
TestBean alias1 = (TestBean) getBeanFactory().getBean("myalias");
|
||||
assertThat(tb1 == alias1).isTrue();
|
||||
assertThat(tb1).isSameAs(alias1);
|
||||
List tb1Aliases = Arrays.asList(getBeanFactory().getAliases("aliased"));
|
||||
assertThat(tb1Aliases).hasSize(2);
|
||||
assertThat(tb1Aliases.contains("myalias")).isTrue();
|
||||
assertThat(tb1Aliases.contains("youralias")).isTrue();
|
||||
assertThat(beanNames.contains("aliased")).isTrue();
|
||||
assertThat(beanNames.contains("myalias")).isFalse();
|
||||
assertThat(beanNames.contains("youralias")).isFalse();
|
||||
assertThat(tb1Aliases).contains("myalias");
|
||||
assertThat(tb1Aliases).contains("youralias");
|
||||
assertThat(beanNames).contains("aliased");
|
||||
assertThat(beanNames).doesNotContain("myalias");
|
||||
assertThat(beanNames).doesNotContain("youralias");
|
||||
|
||||
TestBean tb2 = (TestBean) getBeanFactory().getBean("multiAliased");
|
||||
TestBean alias2 = (TestBean) getBeanFactory().getBean("alias1");
|
||||
TestBean alias3 = (TestBean) getBeanFactory().getBean("alias2");
|
||||
TestBean alias3a = (TestBean) getBeanFactory().getBean("alias3");
|
||||
TestBean alias3b = (TestBean) getBeanFactory().getBean("alias4");
|
||||
assertThat(tb2 == alias2).isTrue();
|
||||
assertThat(tb2 == alias3).isTrue();
|
||||
assertThat(tb2 == alias3a).isTrue();
|
||||
assertThat(tb2 == alias3b).isTrue();
|
||||
assertThat(tb2).isSameAs(alias2);
|
||||
assertThat(tb2).isSameAs(alias3);
|
||||
assertThat(tb2).isSameAs(alias3a);
|
||||
assertThat(tb2).isSameAs(alias3b);
|
||||
|
||||
List tb2Aliases = Arrays.asList(getBeanFactory().getAliases("multiAliased"));
|
||||
assertThat(tb2Aliases).hasSize(4);
|
||||
assertThat(tb2Aliases.contains("alias1")).isTrue();
|
||||
assertThat(tb2Aliases.contains("alias2")).isTrue();
|
||||
assertThat(tb2Aliases.contains("alias3")).isTrue();
|
||||
assertThat(tb2Aliases.contains("alias4")).isTrue();
|
||||
assertThat(beanNames.contains("multiAliased")).isTrue();
|
||||
assertThat(beanNames.contains("alias1")).isFalse();
|
||||
assertThat(beanNames.contains("alias2")).isFalse();
|
||||
assertThat(beanNames.contains("alias3")).isFalse();
|
||||
assertThat(beanNames.contains("alias4")).isFalse();
|
||||
assertThat(tb2Aliases).contains("alias1");
|
||||
assertThat(tb2Aliases).contains("alias2");
|
||||
assertThat(tb2Aliases).contains("alias3");
|
||||
assertThat(tb2Aliases).contains("alias4");
|
||||
assertThat(beanNames).contains("multiAliased");
|
||||
assertThat(beanNames).doesNotContain("alias1");
|
||||
assertThat(beanNames).doesNotContain("alias2");
|
||||
assertThat(beanNames).doesNotContain("alias3");
|
||||
assertThat(beanNames).doesNotContain("alias4");
|
||||
|
||||
TestBean tb3 = (TestBean) getBeanFactory().getBean("aliasWithoutId1");
|
||||
TestBean alias4 = (TestBean) getBeanFactory().getBean("aliasWithoutId2");
|
||||
TestBean alias5 = (TestBean) getBeanFactory().getBean("aliasWithoutId3");
|
||||
assertThat(tb3 == alias4).isTrue();
|
||||
assertThat(tb3 == alias5).isTrue();
|
||||
assertThat(tb3).isSameAs(alias4);
|
||||
assertThat(tb3).isSameAs(alias5);
|
||||
List tb3Aliases = Arrays.asList(getBeanFactory().getAliases("aliasWithoutId1"));
|
||||
assertThat(tb3Aliases).hasSize(2);
|
||||
assertThat(tb3Aliases.contains("aliasWithoutId2")).isTrue();
|
||||
assertThat(tb3Aliases.contains("aliasWithoutId3")).isTrue();
|
||||
assertThat(beanNames.contains("aliasWithoutId1")).isTrue();
|
||||
assertThat(beanNames.contains("aliasWithoutId2")).isFalse();
|
||||
assertThat(beanNames.contains("aliasWithoutId3")).isFalse();
|
||||
assertThat(tb3Aliases).contains("aliasWithoutId2");
|
||||
assertThat(tb3Aliases).contains("aliasWithoutId3");
|
||||
assertThat(beanNames).contains("aliasWithoutId1");
|
||||
assertThat(beanNames).doesNotContain("aliasWithoutId2");
|
||||
assertThat(beanNames).doesNotContain("aliasWithoutId3");
|
||||
|
||||
TestBean tb4 = (TestBean) getBeanFactory().getBean(TestBean.class.getName() + "#0");
|
||||
assertThat(tb4.getName()).isNull();
|
||||
|
||||
Map drs = getListableBeanFactory().getBeansOfType(DummyReferencer.class, false, false);
|
||||
assertThat(drs).hasSize(5);
|
||||
assertThat(drs.containsKey(DummyReferencer.class.getName() + "#0")).isTrue();
|
||||
assertThat(drs.containsKey(DummyReferencer.class.getName() + "#1")).isTrue();
|
||||
assertThat(drs.containsKey(DummyReferencer.class.getName() + "#2")).isTrue();
|
||||
assertThat(drs).containsKey(DummyReferencer.class.getName() + "#0");
|
||||
assertThat(drs).containsKey(DummyReferencer.class.getName() + "#1");
|
||||
assertThat(drs).containsKey(DummyReferencer.class.getName() + "#2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void factoryNesting() {
|
||||
ITestBean father = (ITestBean) getBeanFactory().getBean("father");
|
||||
assertThat(father != null).as("Bean from root context").isTrue();
|
||||
assertThat(father).as("Bean from root context").isNotNull();
|
||||
|
||||
TestBean rod = (TestBean) getBeanFactory().getBean("rod");
|
||||
assertThat("Rod".equals(rod.getName())).as("Bean from child context").isTrue();
|
||||
assertThat(rod.getSpouse() == father).as("Bean has external reference").isTrue();
|
||||
assertThat(rod.getName()).as("Bean from child context").isEqualTo("Rod");
|
||||
assertThat(rod.getSpouse()).as("Bean has external reference").isSameAs(father);
|
||||
|
||||
rod = (TestBean) parent.getBean("rod");
|
||||
assertThat("Roderick".equals(rod.getName())).as("Bean from root context").isTrue();
|
||||
assertThat(rod.getName()).as("Bean from root context").isEqualTo("Roderick");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -208,25 +208,25 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
|||
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
|
||||
|
||||
DummyReferencer ref = (DummyReferencer) getBeanFactory().getBean("factoryReferencer");
|
||||
assertThat(ref.getTestBean1() == ref.getTestBean2()).isTrue();
|
||||
assertThat(ref.getDummyFactory() == factory).isTrue();
|
||||
assertThat(ref.getTestBean1()).isSameAs(ref.getTestBean2());
|
||||
assertThat(ref.getDummyFactory()).isSameAs(factory);
|
||||
|
||||
DummyReferencer ref2 = (DummyReferencer) getBeanFactory().getBean("factoryReferencerWithConstructor");
|
||||
assertThat(ref2.getTestBean1() == ref2.getTestBean2()).isTrue();
|
||||
assertThat(ref2.getDummyFactory() == factory).isTrue();
|
||||
assertThat(ref2.getTestBean1()).isSameAs(ref2.getTestBean2());
|
||||
assertThat(ref2.getDummyFactory()).isSameAs(factory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prototypeReferences() {
|
||||
// check that not broken by circular reference resolution mechanism
|
||||
DummyReferencer ref1 = (DummyReferencer) getBeanFactory().getBean("prototypeReferencer");
|
||||
assertThat(ref1.getTestBean1() != ref1.getTestBean2()).as("Not referencing same bean twice").isTrue();
|
||||
assertThat(ref1.getTestBean1()).as("Not referencing same bean twice").isNotSameAs(ref1.getTestBean2());
|
||||
DummyReferencer ref2 = (DummyReferencer) getBeanFactory().getBean("prototypeReferencer");
|
||||
assertThat(ref1 != ref2).as("Not the same referencer").isTrue();
|
||||
assertThat(ref2.getTestBean1() != ref2.getTestBean2()).as("Not referencing same bean twice").isTrue();
|
||||
assertThat(ref1.getTestBean1() != ref2.getTestBean1()).as("Not referencing same bean twice").isTrue();
|
||||
assertThat(ref1.getTestBean2() != ref2.getTestBean2()).as("Not referencing same bean twice").isTrue();
|
||||
assertThat(ref1.getTestBean1() != ref2.getTestBean2()).as("Not referencing same bean twice").isTrue();
|
||||
assertThat(ref1).as("Not the same referencer").isNotSameAs(ref2);
|
||||
assertThat(ref2.getTestBean1()).as("Not referencing same bean twice").isNotSameAs(ref2.getTestBean2());
|
||||
assertThat(ref1.getTestBean1()).as("Not referencing same bean twice").isNotSameAs(ref2.getTestBean1());
|
||||
assertThat(ref1.getTestBean2()).as("Not referencing same bean twice").isNotSameAs(ref2.getTestBean2());
|
||||
assertThat(ref1.getTestBean1()).as("Not referencing same bean twice").isNotSameAs(ref2.getTestBean2());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -245,8 +245,8 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
|||
public void emptyValues() {
|
||||
TestBean rod = (TestBean) getBeanFactory().getBean("rod");
|
||||
TestBean kerry = (TestBean) getBeanFactory().getBean("kerry");
|
||||
assertThat("".equals(rod.getTouchy())).as("Touchy is empty").isTrue();
|
||||
assertThat("".equals(kerry.getTouchy())).as("Touchy is empty").isTrue();
|
||||
assertThat(rod.getTouchy()).as("Touchy is empty").isEqualTo("");
|
||||
assertThat(kerry.getTouchy()).as("Touchy is empty").isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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,7 +37,7 @@ public class ByteArrayPropertyEditorTests {
|
|||
byteEditor.setAsText(text);
|
||||
|
||||
Object value = byteEditor.getValue();
|
||||
assertThat(value).isNotNull().isInstanceOf(byte[].class);
|
||||
assertThat(value).isInstanceOf(byte[].class);
|
||||
byte[] bytes = (byte[]) value;
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
assertThat(bytes[i]).as("cyte[] differs at index '" + i + "'").isEqualTo((byte) text.charAt(i));
|
||||
|
|
@ -47,10 +47,10 @@ public class ByteArrayPropertyEditorTests {
|
|||
|
||||
@Test
|
||||
public void getAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
assertThat(byteEditor.getAsText()).isEqualTo("");
|
||||
assertThat(byteEditor.getAsText()).isEmpty();
|
||||
|
||||
byteEditor.setAsText(null);
|
||||
assertThat(byteEditor.getAsText()).isEqualTo("");
|
||||
assertThat(byteEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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,7 +37,7 @@ public class CharArrayPropertyEditorTests {
|
|||
charEditor.setAsText(text);
|
||||
|
||||
Object value = charEditor.getValue();
|
||||
assertThat(value).isNotNull().isInstanceOf(char[].class);
|
||||
assertThat(value).isInstanceOf(char[].class);
|
||||
char[] chars = (char[]) value;
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
assertThat(chars[i]).as("char[] differs at index '" + i + "'").isEqualTo(text.charAt(i));
|
||||
|
|
@ -47,10 +47,10 @@ public class CharArrayPropertyEditorTests {
|
|||
|
||||
@Test
|
||||
public void getAsTextReturnsEmptyStringIfValueIsNull() throws Exception {
|
||||
assertThat(charEditor.getAsText()).isEqualTo("");
|
||||
assertThat(charEditor.getAsText()).isEmpty();
|
||||
|
||||
charEditor.setAsText(null);
|
||||
assertThat(charEditor.getAsText()).isEqualTo("");
|
||||
assertThat(charEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -62,7 +62,7 @@ public class CustomCollectionEditorTests {
|
|||
boolean condition = value instanceof ArrayList;
|
||||
assertThat(condition).isTrue();
|
||||
List<?> list = (List<?>) value;
|
||||
assertThat(list.size()).as("There must be 3 elements in the converted collection").isEqualTo(3);
|
||||
assertThat(list).as("There must be 3 elements in the converted collection").hasSize(3);
|
||||
assertThat(list.get(0)).isEqualTo(0);
|
||||
assertThat(list.get(1)).isEqualTo(1);
|
||||
assertThat(list.get(2)).isEqualTo(2);
|
||||
|
|
@ -74,7 +74,7 @@ public class CustomCollectionEditorTests {
|
|||
editor.setValue("0, 1, 2");
|
||||
Collection<?> value = (Collection<?>) editor.getValue();
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value.size()).as("There must be 1 element in the converted collection").isEqualTo(1);
|
||||
assertThat(value).as("There must be 1 element in the converted collection").hasSize(1);
|
||||
assertThat(value.iterator().next()).isEqualTo("0, 1, 2");
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ public class CustomCollectionEditorTests {
|
|||
boolean condition = value instanceof ArrayList;
|
||||
assertThat(condition).isTrue();
|
||||
List<?> list = (List<?>) value;
|
||||
assertThat(list.size()).as("There must be 1 element in the converted collection").isEqualTo(1);
|
||||
assertThat(list).as("There must be 1 element in the converted collection").hasSize(1);
|
||||
assertThat(list.get(0)).isEqualTo("0, 1, 2");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -350,30 +350,30 @@ class CustomEditorTests {
|
|||
bw.setPropertyValue("double2", "6.1");
|
||||
bw.setPropertyValue("bigDecimal", "4.5");
|
||||
|
||||
assertThat(Short.valueOf("1").equals(bw.getPropertyValue("short1"))).as("Correct short1 value").isTrue();
|
||||
assertThat(tb.getShort1() == 1).as("Correct short1 value").isTrue();
|
||||
assertThat(Short.valueOf("2").equals(bw.getPropertyValue("short2"))).as("Correct short2 value").isTrue();
|
||||
assertThat(Short.valueOf("2").equals(tb.getShort2())).as("Correct short2 value").isTrue();
|
||||
assertThat(Integer.valueOf("7").equals(bw.getPropertyValue("int1"))).as("Correct int1 value").isTrue();
|
||||
assertThat(tb.getInt1() == 7).as("Correct int1 value").isTrue();
|
||||
assertThat(Integer.valueOf("8").equals(bw.getPropertyValue("int2"))).as("Correct int2 value").isTrue();
|
||||
assertThat(Integer.valueOf("8").equals(tb.getInt2())).as("Correct int2 value").isTrue();
|
||||
assertThat(Long.valueOf("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(tb.getLong1() == 5).as("Correct long1 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
assertThat(new BigInteger("3").equals(bw.getPropertyValue("bigInteger"))).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new BigInteger("3").equals(tb.getBigInteger())).as("Correct bigInteger value").isTrue();
|
||||
assertThat(Float.valueOf("7.1").equals(bw.getPropertyValue("float1"))).as("Correct float1 value").isTrue();
|
||||
assertThat(Float.valueOf("7.1").equals(tb.getFloat1())).as("Correct float1 value").isTrue();
|
||||
assertThat(Float.valueOf("8.1").equals(bw.getPropertyValue("float2"))).as("Correct float2 value").isTrue();
|
||||
assertThat(Float.valueOf("8.1").equals(tb.getFloat2())).as("Correct float2 value").isTrue();
|
||||
assertThat(Double.valueOf("5.1").equals(bw.getPropertyValue("double1"))).as("Correct double1 value").isTrue();
|
||||
assertThat(tb.getDouble1() == 5.1).as("Correct double1 value").isTrue();
|
||||
assertThat(Double.valueOf("6.1").equals(bw.getPropertyValue("double2"))).as("Correct double2 value").isTrue();
|
||||
assertThat(Double.valueOf("6.1").equals(tb.getDouble2())).as("Correct double2 value").isTrue();
|
||||
assertThat(new BigDecimal("4.5").equals(bw.getPropertyValue("bigDecimal"))).as("Correct bigDecimal value").isTrue();
|
||||
assertThat(new BigDecimal("4.5").equals(tb.getBigDecimal())).as("Correct bigDecimal value").isTrue();
|
||||
assertThat(Short.valueOf("1")).as("Correct short1 value").isEqualTo(bw.getPropertyValue("short1"));
|
||||
assertThat(tb.getShort1()).as("Correct short1 value").isOne();
|
||||
assertThat(Short.valueOf("2")).as("Correct short2 value").isEqualTo(bw.getPropertyValue("short2"));
|
||||
assertThat(Short.valueOf("2")).as("Correct short2 value").isEqualTo(tb.getShort2());
|
||||
assertThat(Integer.valueOf("7")).as("Correct int1 value").isEqualTo(bw.getPropertyValue("int1"));
|
||||
assertThat(tb.getInt1()).as("Correct int1 value").isEqualTo(7);
|
||||
assertThat(Integer.valueOf("8")).as("Correct int2 value").isEqualTo(bw.getPropertyValue("int2"));
|
||||
assertThat(Integer.valueOf("8")).as("Correct int2 value").isEqualTo(tb.getInt2());
|
||||
assertThat(Long.valueOf("5")).as("Correct long1 value").isEqualTo(bw.getPropertyValue("long1"));
|
||||
assertThat(tb.getLong1()).as("Correct long1 value").isEqualTo(5);
|
||||
assertThat(Long.valueOf("6")).as("Correct long2 value").isEqualTo(bw.getPropertyValue("long2"));
|
||||
assertThat(Long.valueOf("6")).as("Correct long2 value").isEqualTo(tb.getLong2());
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(bw.getPropertyValue("bigInteger"));
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(tb.getBigInteger());
|
||||
assertThat(Float.valueOf("7.1")).as("Correct float1 value").isEqualTo(bw.getPropertyValue("float1"));
|
||||
assertThat(Float.valueOf("7.1")).as("Correct float1 value").isEqualTo(tb.getFloat1());
|
||||
assertThat(Float.valueOf("8.1")).as("Correct float2 value").isEqualTo(bw.getPropertyValue("float2"));
|
||||
assertThat(Float.valueOf("8.1")).as("Correct float2 value").isEqualTo(tb.getFloat2());
|
||||
assertThat(Double.valueOf("5.1")).as("Correct double1 value").isEqualTo(bw.getPropertyValue("double1"));
|
||||
assertThat(tb.getDouble1()).as("Correct double1 value").isEqualTo(5.1);
|
||||
assertThat(Double.valueOf("6.1")).as("Correct double2 value").isEqualTo(bw.getPropertyValue("double2"));
|
||||
assertThat(Double.valueOf("6.1")).as("Correct double2 value").isEqualTo(tb.getDouble2());
|
||||
assertThat(new BigDecimal("4.5")).as("Correct bigDecimal value").isEqualTo(bw.getPropertyValue("bigDecimal"));
|
||||
assertThat(new BigDecimal("4.5")).as("Correct bigDecimal value").isEqualTo(tb.getBigDecimal());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -408,29 +408,29 @@ class CustomEditorTests {
|
|||
bw.setPropertyValue("bigDecimal", "4,5");
|
||||
|
||||
assertThat(bw.getPropertyValue("short1")).as("Correct short1 value").isEqualTo(Short.valueOf("1"));
|
||||
assertThat(tb.getShort1() == 1).as("Correct short1 value").isTrue();
|
||||
assertThat(tb.getShort1()).as("Correct short1 value").isOne();
|
||||
assertThat(bw.getPropertyValue("short2")).as("Correct short2 value").isEqualTo(Short.valueOf("2"));
|
||||
assertThat(tb.getShort2()).as("Correct short2 value").isEqualTo(Short.valueOf("2"));
|
||||
assertThat(bw.getPropertyValue("int1")).as("Correct int1 value").isEqualTo(Integer.valueOf("7"));
|
||||
assertThat(tb.getInt1() == 7).as("Correct int1 value").isTrue();
|
||||
assertThat(tb.getInt1()).as("Correct int1 value").isEqualTo(7);
|
||||
assertThat(bw.getPropertyValue("int2")).as("Correct int2 value").isEqualTo(Integer.valueOf("8"));
|
||||
assertThat(tb.getInt2()).as("Correct int2 value").isEqualTo(Integer.valueOf("8"));
|
||||
assertThat(bw.getPropertyValue("long1")).as("Correct long1 value").isEqualTo(Long.valueOf("5"));
|
||||
assertThat(tb.getLong1() == 5).as("Correct long1 value").isTrue();
|
||||
assertThat(tb.getLong1()).as("Correct long1 value").isEqualTo(5);
|
||||
assertThat(bw.getPropertyValue("long2")).as("Correct long2 value").isEqualTo(Long.valueOf("6"));
|
||||
assertThat(tb.getLong2()).as("Correct long2 value").isEqualTo(Long.valueOf("6"));
|
||||
assertThat(new BigInteger("3").equals(bw.getPropertyValue("bigInteger"))).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new BigInteger("3").equals(tb.getBigInteger())).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(bw.getPropertyValue("bigInteger"));
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(tb.getBigInteger());
|
||||
assertThat(bw.getPropertyValue("float1")).as("Correct float1 value").isEqualTo(Float.valueOf("7.1"));
|
||||
assertThat(Float.valueOf(tb.getFloat1())).as("Correct float1 value").isEqualTo(Float.valueOf("7.1"));
|
||||
assertThat(bw.getPropertyValue("float2")).as("Correct float2 value").isEqualTo(Float.valueOf("8.1"));
|
||||
assertThat(tb.getFloat2()).as("Correct float2 value").isEqualTo(Float.valueOf("8.1"));
|
||||
assertThat(bw.getPropertyValue("double1")).as("Correct double1 value").isEqualTo(Double.valueOf("5.1"));
|
||||
assertThat(tb.getDouble1() == 5.1).as("Correct double1 value").isTrue();
|
||||
assertThat(tb.getDouble1()).as("Correct double1 value").isEqualTo(5.1);
|
||||
assertThat(bw.getPropertyValue("double2")).as("Correct double2 value").isEqualTo(Double.valueOf("6.1"));
|
||||
assertThat(tb.getDouble2()).as("Correct double2 value").isEqualTo(Double.valueOf("6.1"));
|
||||
assertThat(new BigDecimal("4.5").equals(bw.getPropertyValue("bigDecimal"))).as("Correct bigDecimal value").isTrue();
|
||||
assertThat(new BigDecimal("4.5").equals(tb.getBigDecimal())).as("Correct bigDecimal value").isTrue();
|
||||
assertThat(new BigDecimal("4.5")).as("Correct bigDecimal value").isEqualTo(bw.getPropertyValue("bigDecimal"));
|
||||
assertThat(new BigDecimal("4.5")).as("Correct bigDecimal value").isEqualTo(tb.getBigDecimal());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -444,13 +444,13 @@ class CustomEditorTests {
|
|||
bw.setPropertyValue("long1", "5");
|
||||
bw.setPropertyValue("long2", "6");
|
||||
assertThat(Long.valueOf("5").equals(bw.getPropertyValue("long1"))).as("Correct long1 value").isTrue();
|
||||
assertThat(tb.getLong1() == 5).as("Correct long1 value").isTrue();
|
||||
assertThat(tb.getLong1()).as("Correct long1 value").isEqualTo(5);
|
||||
assertThat(Long.valueOf("6").equals(bw.getPropertyValue("long2"))).as("Correct long2 value").isTrue();
|
||||
assertThat(Long.valueOf("6").equals(tb.getLong2())).as("Correct long2 value").isTrue();
|
||||
|
||||
bw.setPropertyValue("long2", "");
|
||||
assertThat(bw.getPropertyValue("long2") == null).as("Correct long2 value").isTrue();
|
||||
assertThat(tb.getLong2() == null).as("Correct long2 value").isTrue();
|
||||
assertThat(bw.getPropertyValue("long2")).as("Correct long2 value").isNull();
|
||||
assertThat(tb.getLong2()).as("Correct long2 value").isNull();
|
||||
assertThatExceptionOfType(BeansException.class).isThrownBy(() ->
|
||||
bw.setPropertyValue("long1", ""));
|
||||
assertThat(bw.getPropertyValue("long1")).isEqualTo(5L);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -42,7 +42,7 @@ public class FileEditorTests {
|
|||
boolean condition = value instanceof File;
|
||||
assertThat(condition).isTrue();
|
||||
File file = (File) value;
|
||||
assertThat(file.exists()).isTrue();
|
||||
assertThat(file).exists();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -86,9 +86,9 @@ public class FileEditorTests {
|
|||
boolean condition = value instanceof File;
|
||||
assertThat(condition).isTrue();
|
||||
File file = (File) value;
|
||||
assertThat(file.exists()).isTrue();
|
||||
assertThat(file).exists();
|
||||
String absolutePath = file.getAbsolutePath().replace('\\', '/');
|
||||
assertThat(absolutePath.endsWith(fileName)).isTrue();
|
||||
assertThat(absolutePath).endsWith(fileName);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -101,9 +101,9 @@ public class FileEditorTests {
|
|||
boolean condition = value instanceof File;
|
||||
assertThat(condition).isTrue();
|
||||
File file = (File) value;
|
||||
assertThat(file.exists()).isFalse();
|
||||
assertThat(file).doesNotExist();
|
||||
String absolutePath = file.getAbsolutePath().replace('\\', '/');
|
||||
assertThat(absolutePath.endsWith(fileName)).isTrue();
|
||||
assertThat(absolutePath).endsWith(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -52,7 +52,7 @@ public class InputStreamEditorTests {
|
|||
boolean condition = value instanceof InputStream;
|
||||
assertThat(condition).isTrue();
|
||||
stream = (InputStream) value;
|
||||
assertThat(stream.available() > 0).isTrue();
|
||||
assertThat(stream.available()).isGreaterThan(0);
|
||||
}
|
||||
finally {
|
||||
if (stream != null) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -39,9 +39,9 @@ public class PathEditorTests {
|
|||
pathEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
|
||||
ClassUtils.getShortName(getClass()) + ".class");
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
assertThat(path.toFile().exists()).isTrue();
|
||||
assertThat(path.toFile()).exists();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -56,9 +56,9 @@ public class PathEditorTests {
|
|||
PropertyEditor pathEditor = new PathEditor();
|
||||
pathEditor.setAsText("file:/no_way_this_file_is_found.doc");
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
assertThat(!path.toFile().exists()).isTrue();
|
||||
assertThat(path.toFile()).doesNotExist();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -66,9 +66,9 @@ public class PathEditorTests {
|
|||
PropertyEditor pathEditor = new PathEditor();
|
||||
pathEditor.setAsText("/no_way_this_file_is_found.doc");
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
assertThat(!path.toFile().exists()).isTrue();
|
||||
assertThat(path.toFile()).doesNotExist();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -76,9 +76,9 @@ public class PathEditorTests {
|
|||
PropertyEditor pathEditor = new PathEditor();
|
||||
pathEditor.setAsText("C:\\no_way_this_file_is_found.doc");
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
assertThat(!path.toFile().exists()).isTrue();
|
||||
assertThat(path.toFile()).doesNotExist();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -87,9 +87,9 @@ public class PathEditorTests {
|
|||
try {
|
||||
pathEditor.setAsText("file://C:\\no_way_this_file_is_found.doc");
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
assertThat(!path.toFile().exists()).isTrue();
|
||||
assertThat(path.toFile()).doesNotExist();
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (File.separatorChar == '\\') { // on Windows, otherwise silently ignore
|
||||
|
|
@ -105,15 +105,15 @@ public class PathEditorTests {
|
|||
ClassUtils.getShortName(getClass()) + ".class";
|
||||
pathEditor.setAsText(fileName);
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
File file = path.toFile();
|
||||
assertThat(file.exists()).isTrue();
|
||||
assertThat(file).exists();
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
if (File.separatorChar == '\\') {
|
||||
absolutePath = absolutePath.replace('\\', '/');
|
||||
}
|
||||
assertThat(absolutePath.endsWith(fileName)).isTrue();
|
||||
assertThat(absolutePath).endsWith(fileName);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -123,15 +123,15 @@ public class PathEditorTests {
|
|||
ClassUtils.getShortName(getClass()) + ".clazz";
|
||||
pathEditor.setAsText(fileName);
|
||||
Object value = pathEditor.getValue();
|
||||
assertThat(value instanceof Path).isTrue();
|
||||
assertThat(value).isInstanceOf(Path.class);
|
||||
Path path = (Path) value;
|
||||
File file = path.toFile();
|
||||
assertThat(file.exists()).isFalse();
|
||||
assertThat(file).doesNotExist();
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
if (File.separatorChar == '\\') {
|
||||
absolutePath = absolutePath.replace('\\', '/');
|
||||
}
|
||||
assertThat(absolutePath.endsWith(fileName)).isTrue();
|
||||
assertThat(absolutePath).endsWith(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -40,7 +40,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.entrySet().size() == 1).as("contains one entry").isTrue();
|
||||
assertThat(p.entrySet().size()).as("contains one entry").isEqualTo(1);
|
||||
assertThat(p.get("foo").equals("bar")).as("foo=bar").isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.entrySet().size() == 2).as("contains two entries").isTrue();
|
||||
assertThat(p.entrySet().size()).as("contains two entries").isEqualTo(2);
|
||||
assertThat(p.get("foo").equals("bar with whitespace")).as("foo=bar with whitespace").isTrue();
|
||||
assertThat(p.get("me").equals("mi")).as("me=mi").isTrue();
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.entrySet().size() == 3).as("contains two entries").isTrue();
|
||||
assertThat(p.entrySet().size()).as("contains two entries").isEqualTo(3);
|
||||
assertThat(p.get("foo").equals("bar")).as("foo=bar").isTrue();
|
||||
assertThat(p.get("me").equals("mi")).as("me=mi").isTrue();
|
||||
assertThat(p.get("x").equals("y=z")).as("x='y=z'").isTrue();
|
||||
|
|
@ -76,7 +76,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.entrySet().size() == 3).as("contains two entries").isTrue();
|
||||
assertThat(p.entrySet().size()).as("contains two entries").isEqualTo(3);
|
||||
assertThat(p.get("foo").equals("bar")).as("foo=bar").isTrue();
|
||||
assertThat(p.get("me").equals("mi")).as("me=mi").isTrue();
|
||||
assertThat(p.get("x").equals("")).as("x='y=z'").isTrue();
|
||||
|
|
@ -88,7 +88,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.entrySet().size() == 3).as("contains three entries").isTrue();
|
||||
assertThat(p.entrySet().size()).as("contains three entries").isEqualTo(3);
|
||||
assertThat(p.get("foo").equals("")).as("foo is empty").isTrue();
|
||||
assertThat(p.get("me").equals("mi")).as("me=mi").isTrue();
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.entrySet().size() == 3).as("contains three entries").isTrue();
|
||||
assertThat(p.entrySet().size()).as("contains three entries").isEqualTo(3);
|
||||
assertThat(p.get("foo").equals("bar")).as("foo is bar").isTrue();
|
||||
assertThat(p.get("me").equals("mi")).as("me=mi").isTrue();
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ public class PropertiesEditorTests {
|
|||
PropertiesEditor pe= new PropertiesEditor();
|
||||
pe.setAsText(s);
|
||||
Properties p = (Properties) pe.getValue();
|
||||
assertThat(p.size() == 3).as("contains 3 entries, not " + p.size()).isTrue();
|
||||
assertThat(p.size()).as("contains 3 entries, not " + p.size()).isEqualTo(3);
|
||||
assertThat(p.get("foo").equals("bar")).as("foo is bar").isTrue();
|
||||
assertThat(p.get("me").equals("mi")).as("me=mi").isTrue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -99,7 +99,7 @@ public class URIEditorTests {
|
|||
assertThat(condition).isTrue();
|
||||
URI uri = (URI) value;
|
||||
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
|
||||
assertThat(uri.getScheme().startsWith("classpath")).isTrue();
|
||||
assertThat(uri.getScheme()).startsWith("classpath");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -107,13 +107,13 @@ public class URIEditorTests {
|
|||
PropertyEditor uriEditor = new URIEditor();
|
||||
uriEditor.setAsText(null);
|
||||
assertThat(uriEditor.getValue()).isNull();
|
||||
assertThat(uriEditor.getAsText()).isEqualTo("");
|
||||
assertThat(uriEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAsTextReturnsEmptyStringIfValueNotSet() throws Exception {
|
||||
PropertyEditor uriEditor = new URIEditor();
|
||||
assertThat(uriEditor.getAsText()).isEqualTo("");
|
||||
assertThat(uriEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -86,13 +86,13 @@ public class URLEditorTests {
|
|||
PropertyEditor urlEditor = new URLEditor();
|
||||
urlEditor.setAsText(null);
|
||||
assertThat(urlEditor.getValue()).isNull();
|
||||
assertThat(urlEditor.getAsText()).isEqualTo("");
|
||||
assertThat(urlEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAsTextReturnsEmptyStringIfValueNotSet() throws Exception {
|
||||
PropertyEditor urlEditor = new URLEditor();
|
||||
assertThat(urlEditor.getAsText()).isEqualTo("");
|
||||
assertThat(urlEditor.getAsText()).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -60,7 +60,7 @@ class ZoneIdEditorTests {
|
|||
|
||||
@Test
|
||||
void getNullAsText() {
|
||||
assertThat(editor.getAsText()).as("The returned value is not correct.").isEqualTo("");
|
||||
assertThat(editor.getAsText()).as("The returned value is not correct.").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -52,101 +52,101 @@ public class PagedListHolderTests {
|
|||
tbs.add(tb3);
|
||||
|
||||
PagedListHolder holder = new PagedListHolder(tbs);
|
||||
assertThat(holder.getSource() == tbs).as("Correct source").isTrue();
|
||||
assertThat(holder.getNrOfElements() == 3).as("Correct number of elements").isTrue();
|
||||
assertThat(holder.getPageCount() == 1).as("Correct number of pages").isTrue();
|
||||
assertThat(holder.getPageSize() == PagedListHolder.DEFAULT_PAGE_SIZE).as("Correct page size").isTrue();
|
||||
assertThat(holder.getPage() == 0).as("Correct page number").isTrue();
|
||||
assertThat(holder.getSource()).as("Correct source").isSameAs(tbs);
|
||||
assertThat(holder.getNrOfElements()).as("Correct number of elements").isEqualTo(3);
|
||||
assertThat(holder.getPageCount()).as("Correct number of pages").isEqualTo(1);
|
||||
assertThat(holder.getPageSize()).as("Correct page size").isEqualTo(PagedListHolder.DEFAULT_PAGE_SIZE);
|
||||
assertThat(holder.getPage()).as("Correct page number").isEqualTo(0);
|
||||
assertThat(holder.isFirstPage()).as("First page").isTrue();
|
||||
assertThat(holder.isLastPage()).as("Last page").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage() == 0).as("Correct first element").isTrue();
|
||||
assertThat(holder.getLastElementOnPage() == 2).as("Correct first element").isTrue();
|
||||
assertThat(holder.getPageList().size() == 3).as("Correct page list size").isTrue();
|
||||
assertThat(holder.getPageList().get(0) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb2).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(2) == tb3).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage()).as("Correct first element").isEqualTo(0);
|
||||
assertThat(holder.getLastElementOnPage()).as("Correct first element").isEqualTo(2);
|
||||
assertThat(holder.getPageList().size()).as("Correct page list size").isEqualTo(3);
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb1);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb2);
|
||||
assertThat(holder.getPageList().get(2)).as("Correct page list contents").isSameAs(tb3);
|
||||
|
||||
holder.setPageSize(2);
|
||||
assertThat(holder.getPageCount() == 2).as("Correct number of pages").isTrue();
|
||||
assertThat(holder.getPageSize() == 2).as("Correct page size").isTrue();
|
||||
assertThat(holder.getPage() == 0).as("Correct page number").isTrue();
|
||||
assertThat(holder.getPageCount()).as("Correct number of pages").isEqualTo(2);
|
||||
assertThat(holder.getPageSize()).as("Correct page size").isEqualTo(2);
|
||||
assertThat(holder.getPage()).as("Correct page number").isEqualTo(0);
|
||||
assertThat(holder.isFirstPage()).as("First page").isTrue();
|
||||
assertThat(holder.isLastPage()).as("Last page").isFalse();
|
||||
assertThat(holder.getFirstElementOnPage() == 0).as("Correct first element").isTrue();
|
||||
assertThat(holder.getLastElementOnPage() == 1).as("Correct last element").isTrue();
|
||||
assertThat(holder.getPageList().size() == 2).as("Correct page list size").isTrue();
|
||||
assertThat(holder.getPageList().get(0) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb2).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage()).as("Correct first element").isEqualTo(0);
|
||||
assertThat(holder.getLastElementOnPage()).as("Correct last element").isEqualTo(1);
|
||||
assertThat(holder.getPageList().size()).as("Correct page list size").isEqualTo(2);
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb1);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb2);
|
||||
|
||||
holder.setPage(1);
|
||||
assertThat(holder.getPage() == 1).as("Correct page number").isTrue();
|
||||
assertThat(holder.getPage()).as("Correct page number").isEqualTo(1);
|
||||
assertThat(holder.isFirstPage()).as("First page").isFalse();
|
||||
assertThat(holder.isLastPage()).as("Last page").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage() == 2).as("Correct first element").isTrue();
|
||||
assertThat(holder.getLastElementOnPage() == 2).as("Correct last element").isTrue();
|
||||
assertThat(holder.getPageList().size() == 1).as("Correct page list size").isTrue();
|
||||
assertThat(holder.getPageList().get(0) == tb3).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage()).as("Correct first element").isEqualTo(2);
|
||||
assertThat(holder.getLastElementOnPage()).as("Correct last element").isEqualTo(2);
|
||||
assertThat(holder.getPageList().size()).as("Correct page list size").isEqualTo(1);
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb3);
|
||||
|
||||
holder.setPageSize(3);
|
||||
assertThat(holder.getPageCount() == 1).as("Correct number of pages").isTrue();
|
||||
assertThat(holder.getPageSize() == 3).as("Correct page size").isTrue();
|
||||
assertThat(holder.getPage() == 0).as("Correct page number").isTrue();
|
||||
assertThat(holder.getPageCount()).as("Correct number of pages").isEqualTo(1);
|
||||
assertThat(holder.getPageSize()).as("Correct page size").isEqualTo(3);
|
||||
assertThat(holder.getPage()).as("Correct page number").isEqualTo(0);
|
||||
assertThat(holder.isFirstPage()).as("First page").isTrue();
|
||||
assertThat(holder.isLastPage()).as("Last page").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage() == 0).as("Correct first element").isTrue();
|
||||
assertThat(holder.getLastElementOnPage() == 2).as("Correct last element").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage()).as("Correct first element").isEqualTo(0);
|
||||
assertThat(holder.getLastElementOnPage()).as("Correct last element").isEqualTo(2);
|
||||
|
||||
holder.setPage(1);
|
||||
holder.setPageSize(2);
|
||||
assertThat(holder.getPageCount() == 2).as("Correct number of pages").isTrue();
|
||||
assertThat(holder.getPageSize() == 2).as("Correct page size").isTrue();
|
||||
assertThat(holder.getPage() == 1).as("Correct page number").isTrue();
|
||||
assertThat(holder.getPageCount()).as("Correct number of pages").isEqualTo(2);
|
||||
assertThat(holder.getPageSize()).as("Correct page size").isEqualTo(2);
|
||||
assertThat(holder.getPage()).as("Correct page number").isEqualTo(1);
|
||||
assertThat(holder.isFirstPage()).as("First page").isFalse();
|
||||
assertThat(holder.isLastPage()).as("Last page").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage() == 2).as("Correct first element").isTrue();
|
||||
assertThat(holder.getLastElementOnPage() == 2).as("Correct last element").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage()).as("Correct first element").isEqualTo(2);
|
||||
assertThat(holder.getLastElementOnPage()).as("Correct last element").isEqualTo(2);
|
||||
|
||||
holder.setPageSize(2);
|
||||
holder.setPage(1);
|
||||
((MutableSortDefinition) holder.getSort()).setProperty("name");
|
||||
((MutableSortDefinition) holder.getSort()).setIgnoreCase(false);
|
||||
holder.resort();
|
||||
assertThat(holder.getSource() == tbs).as("Correct source").isTrue();
|
||||
assertThat(holder.getNrOfElements() == 3).as("Correct number of elements").isTrue();
|
||||
assertThat(holder.getPageCount() == 2).as("Correct number of pages").isTrue();
|
||||
assertThat(holder.getPageSize() == 2).as("Correct page size").isTrue();
|
||||
assertThat(holder.getPage() == 0).as("Correct page number").isTrue();
|
||||
assertThat(holder.getSource()).as("Correct source").isSameAs(tbs);
|
||||
assertThat(holder.getNrOfElements()).as("Correct number of elements").isEqualTo(3);
|
||||
assertThat(holder.getPageCount()).as("Correct number of pages").isEqualTo(2);
|
||||
assertThat(holder.getPageSize()).as("Correct page size").isEqualTo(2);
|
||||
assertThat(holder.getPage()).as("Correct page number").isEqualTo(0);
|
||||
assertThat(holder.isFirstPage()).as("First page").isTrue();
|
||||
assertThat(holder.isLastPage()).as("Last page").isFalse();
|
||||
assertThat(holder.getFirstElementOnPage() == 0).as("Correct first element").isTrue();
|
||||
assertThat(holder.getLastElementOnPage() == 1).as("Correct last element").isTrue();
|
||||
assertThat(holder.getPageList().size() == 2).as("Correct page list size").isTrue();
|
||||
assertThat(holder.getPageList().get(0) == tb3).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getFirstElementOnPage()).as("Correct first element").isEqualTo(0);
|
||||
assertThat(holder.getLastElementOnPage()).as("Correct last element").isEqualTo(1);
|
||||
assertThat(holder.getPageList().size()).as("Correct page list size").isEqualTo(2);
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb3);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb1);
|
||||
|
||||
((MutableSortDefinition) holder.getSort()).setProperty("name");
|
||||
holder.resort();
|
||||
assertThat(holder.getPageList().get(0) == tb2).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb2);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb1);
|
||||
|
||||
((MutableSortDefinition) holder.getSort()).setProperty("name");
|
||||
holder.resort();
|
||||
assertThat(holder.getPageList().get(0) == tb3).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb3);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb1);
|
||||
|
||||
holder.setPage(1);
|
||||
assertThat(holder.getPageList().size() == 1).as("Correct page list size").isTrue();
|
||||
assertThat(holder.getPageList().get(0) == tb2).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().size()).as("Correct page list size").isEqualTo(1);
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb2);
|
||||
|
||||
((MutableSortDefinition) holder.getSort()).setProperty("age");
|
||||
holder.resort();
|
||||
assertThat(holder.getPageList().get(0) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb3).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb1);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb3);
|
||||
|
||||
((MutableSortDefinition) holder.getSort()).setIgnoreCase(true);
|
||||
holder.resort();
|
||||
assertThat(holder.getPageList().get(0) == tb1).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(1) == tb3).as("Correct page list contents").isTrue();
|
||||
assertThat(holder.getPageList().get(0)).as("Correct page list contents").isSameAs(tb1);
|
||||
assertThat(holder.getPageList().get(1)).as("Correct page list contents").isSameAs(tb3);
|
||||
|
||||
holder.nextPage();
|
||||
assertThat(holder.getPage()).isEqualTo(1);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -39,9 +39,9 @@ public class PropertyComparatorTests {
|
|||
dog2.setNickName("biscy");
|
||||
|
||||
PropertyComparator<Dog> c = new PropertyComparator<>("nickName", false, true);
|
||||
assertThat(c.compare(dog, dog2) > 0).isTrue();
|
||||
assertThat(c.compare(dog, dog) == 0).isTrue();
|
||||
assertThat(c.compare(dog2, dog) < 0).isTrue();
|
||||
assertThat(c.compare(dog, dog2)).isGreaterThan(0);
|
||||
assertThat(c.compare(dog, dog)).isEqualTo(0);
|
||||
assertThat(c.compare(dog2, dog)).isLessThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -49,7 +49,7 @@ public class PropertyComparatorTests {
|
|||
Dog dog = new Dog();
|
||||
Dog dog2 = new Dog();
|
||||
PropertyComparator<Dog> c = new PropertyComparator<>("nickName", false, true);
|
||||
assertThat(c.compare(dog, dog2) == 0).isTrue();
|
||||
assertThat(c.compare(dog, dog2)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -64,13 +64,13 @@ public class PropertyComparatorTests {
|
|||
dog2.setFirstName("biscuit");
|
||||
dog2.setLastName("grayspots");
|
||||
|
||||
assertThat(c.compare(dog1, dog2) == 0).isTrue();
|
||||
assertThat(c.compare(dog1, dog2)).isEqualTo(0);
|
||||
|
||||
c = c.thenComparing(new PropertyComparator<>("firstName", false, true));
|
||||
assertThat(c.compare(dog1, dog2) > 0).isTrue();
|
||||
assertThat(c.compare(dog1, dog2)).isGreaterThan(0);
|
||||
|
||||
dog2.setLastName("konikk dog");
|
||||
assertThat(c.compare(dog2, dog1) > 0).isTrue();
|
||||
assertThat(c.compare(dog2, dog1)).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -86,9 +86,9 @@ public class PropertyComparatorTests {
|
|||
dog2.setFirstName("biscuit");
|
||||
dog2.setLastName("grayspots");
|
||||
|
||||
assertThat(c.compare(dog1, dog2) > 0).isTrue();
|
||||
assertThat(c.compare(dog1, dog2)).isGreaterThan(0);
|
||||
c = c.reversed();
|
||||
assertThat(c.compare(dog1, dog2) < 0).isTrue();
|
||||
assertThat(c.compare(dog1, dog2)).isLessThan(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -58,11 +58,11 @@ public abstract class AbstractBeanFactoryTests {
|
|||
assertThat(getBeanFactory().containsBean("roderick")).isTrue();
|
||||
TestBean rod = (TestBean) getBeanFactory().getBean("rod");
|
||||
TestBean roderick = (TestBean) getBeanFactory().getBean("roderick");
|
||||
assertThat(rod != roderick).as("not == ").isTrue();
|
||||
assertThat(rod).as("not == ").isNotSameAs(roderick);
|
||||
assertThat(rod.getName().equals("Rod")).as("rod.name is Rod").isTrue();
|
||||
assertThat(rod.getAge() == 31).as("rod.age is 31").isTrue();
|
||||
assertThat(rod.getAge()).as("rod.age is 31").isEqualTo(31);
|
||||
assertThat(roderick.getName().equals("Roderick")).as("roderick.name is Roderick").isTrue();
|
||||
assertThat(roderick.getAge() == rod.getAge()).as("roderick.age was inherited").isTrue();
|
||||
assertThat(roderick.getAge()).as("roderick.age was inherited").isEqualTo(rod.getAge());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -104,7 +104,7 @@ public abstract class AbstractBeanFactoryTests {
|
|||
assertThat(condition).as("Rod bean is a TestBean").isTrue();
|
||||
TestBean rod = (TestBean) o;
|
||||
assertThat(rod.getName().equals("Rod")).as("rod.name is Rod").isTrue();
|
||||
assertThat(rod.getAge() == 31).as("rod.age is 31").isTrue();
|
||||
assertThat(rod.getAge()).as("rod.age is 31").isEqualTo(31);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -158,19 +158,19 @@ public abstract class AbstractBeanFactoryTests {
|
|||
Object o1 = getBeanFactory().getBean("rod");
|
||||
boolean condition = o1 instanceof TestBean;
|
||||
assertThat(condition).as("Rod bean2 is a TestBean").isTrue();
|
||||
assertThat(o == o1).as("Object equals applies").isTrue();
|
||||
assertThat(o).as("Object equals applies").isSameAs(o1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prototypeInstancesAreIndependent() {
|
||||
TestBean tb1 = (TestBean) getBeanFactory().getBean("kathy");
|
||||
TestBean tb2 = (TestBean) getBeanFactory().getBean("kathy");
|
||||
assertThat(tb1 != tb2).as("ref equal DOES NOT apply").isTrue();
|
||||
assertThat(tb1).as("ref equal DOES NOT apply").isNotSameAs(tb2);
|
||||
assertThat(tb1.equals(tb2)).as("object equal true").isTrue();
|
||||
tb1.setAge(1);
|
||||
tb2.setAge(2);
|
||||
assertThat(tb1.getAge() == 1).as("1 age independent = 1").isTrue();
|
||||
assertThat(tb2.getAge() == 2).as("2 age independent = 2").isTrue();
|
||||
assertThat(tb1.getAge()).as("1 age independent = 1").isEqualTo(1);
|
||||
assertThat(tb2.getAge()).as("2 age independent = 2").isEqualTo(2);
|
||||
boolean condition = !tb1.equals(tb2);
|
||||
assertThat(condition).as("object equal now false").isTrue();
|
||||
}
|
||||
|
|
@ -212,8 +212,8 @@ public abstract class AbstractBeanFactoryTests {
|
|||
assertThat(tb.getName().equals(DummyFactory.SINGLETON_NAME)).as("Singleton from factory has correct name, not " + tb.getName()).isTrue();
|
||||
DummyFactory factory = (DummyFactory) getBeanFactory().getBean("&singletonFactory");
|
||||
TestBean tb2 = (TestBean) getBeanFactory().getBean("singletonFactory");
|
||||
assertThat(tb == tb2).as("Singleton references ==").isTrue();
|
||||
assertThat(factory.getBeanFactory() != null).as("FactoryBean is BeanFactoryAware").isTrue();
|
||||
assertThat(tb).as("Singleton references ==").isSameAs(tb2);
|
||||
assertThat(factory.getBeanFactory()).as("FactoryBean is BeanFactoryAware").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -224,7 +224,7 @@ public abstract class AbstractBeanFactoryTests {
|
|||
boolean condition = !tb.getName().equals(DummyFactory.SINGLETON_NAME);
|
||||
assertThat(condition).isTrue();
|
||||
TestBean tb2 = (TestBean) getBeanFactory().getBean("prototypeFactory");
|
||||
assertThat(tb != tb2).as("Prototype references !=").isTrue();
|
||||
assertThat(tb).as("Prototype references !=").isNotSameAs(tb2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -274,7 +274,7 @@ public abstract class AbstractBeanFactoryTests {
|
|||
cbf.registerAlias("rod", alias);
|
||||
Object rod = getBeanFactory().getBean("rod");
|
||||
Object aliasRod = getBeanFactory().getBean(alias);
|
||||
assertThat(rod == aliasRod).isTrue();
|
||||
assertThat(rod).isSameAs(aliasRod);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -50,24 +50,25 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
|||
|
||||
protected final void assertCount(int count) {
|
||||
String[] defnames = getListableBeanFactory().getBeanDefinitionNames();
|
||||
assertThat(defnames.length == count).as("We should have " + count + " beans, not " + defnames.length).isTrue();
|
||||
assertThat(defnames.length).as("We should have " + count + " beans, not " + defnames.length).isEqualTo(count);
|
||||
}
|
||||
|
||||
protected void assertTestBeanCount(int count) {
|
||||
String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false);
|
||||
assertThat(defNames.length == count).as("We should have " + count + " beans for class org.springframework.beans.testfixture.beans.TestBean, not " +
|
||||
defNames.length).isTrue();
|
||||
assertThat(defNames.length).as("We should have " + count + " beans for class org.springframework.beans.testfixture.beans.TestBean, not " +
|
||||
defNames.length).isEqualTo(count);
|
||||
|
||||
int countIncludingFactoryBeans = count + 2;
|
||||
String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true);
|
||||
assertThat(names.length == countIncludingFactoryBeans).as("We should have " + countIncludingFactoryBeans +
|
||||
" beans for class org.springframework.beans.testfixture.beans.TestBean, not " + names.length).isTrue();
|
||||
assertThat(names.length).as("We should have " + countIncludingFactoryBeans +
|
||||
" beans for class org.springframework.beans.testfixture.beans.TestBean, not " + names.length)
|
||||
.isEqualTo(countIncludingFactoryBeans);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefinitionsForNoSuchClass() {
|
||||
String[] defnames = getListableBeanFactory().getBeanNamesForType(String.class);
|
||||
assertThat(defnames.length == 0).as("No string definitions").isTrue();
|
||||
assertThat(defnames.length).as("No string definitions").isEqualTo(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,11 +77,11 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
|||
*/
|
||||
@Test
|
||||
public void getCountForFactoryClass() {
|
||||
assertThat(getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2).as("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).isTrue();
|
||||
assertThat(getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).as("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).isEqualTo(2);
|
||||
|
||||
assertThat(getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2).as("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).isTrue();
|
||||
assertThat(getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).as("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -222,7 +222,7 @@ class CandidateComponentsIndexerTests {
|
|||
for (Class<?> c : classes) {
|
||||
assertThat(metadata).has(Metadata.of(c, Component.class));
|
||||
}
|
||||
assertThat(metadata.getItems()).hasSize(classes.length);
|
||||
assertThat(metadata.getItems()).hasSameSizeAs(classes);
|
||||
}
|
||||
|
||||
private void testSingleComponent(Class<?> target, Class<?>... stereotypes) {
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ public class CaffeineCacheManagerTests {
|
|||
Cache cache1x = cm.getCache("c1");
|
||||
boolean condition1 = cache1x instanceof CaffeineCache;
|
||||
assertThat(condition1).isTrue();
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
Cache cache2x = cm.getCache("c2");
|
||||
boolean condition = cache2x instanceof CaffeineCache;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(cache2x != cache2).isTrue();
|
||||
assertThat(cache2x).isNotSameAs(cache2);
|
||||
Cache cache3x = cm.getCache("c3");
|
||||
assertThat(cache3x).isNull();
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ public class CaffeineCacheManagerTests {
|
|||
Caffeine<Object, Object> caffeine = Caffeine.newBuilder().maximumSize(10);
|
||||
cm.setCaffeine(caffeine);
|
||||
Cache cache1x = cm.getCache("c1");
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
|
||||
cm.setCaffeine(caffeine); // Set same instance
|
||||
Cache cache1xx = cm.getCache("c1");
|
||||
|
|
@ -137,7 +137,7 @@ public class CaffeineCacheManagerTests {
|
|||
|
||||
cm.setCaffeineSpec(CaffeineSpec.parse("maximumSize=10"));
|
||||
Cache cache1x = cm.getCache("c1");
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -147,7 +147,7 @@ public class CaffeineCacheManagerTests {
|
|||
|
||||
cm.setCacheSpecification("maximumSize=10");
|
||||
Cache cache1x = cm.getCache("c1");
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -160,7 +160,7 @@ public class CaffeineCacheManagerTests {
|
|||
|
||||
cm.setCacheLoader(loader);
|
||||
Cache cache1x = cm.getCache("c1");
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
|
||||
cm.setCacheLoader(loader); // Set same instance
|
||||
Cache cache1xx = cm.getCache("c1");
|
||||
|
|
@ -201,11 +201,11 @@ public class CaffeineCacheManagerTests {
|
|||
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
Cache cache2 = cm.getCache("c2");
|
||||
assertThat(nc == cache2.getNativeCache()).isTrue();
|
||||
assertThat(nc).isSameAs(cache2.getNativeCache());
|
||||
|
||||
cm.setCaffeine(Caffeine.newBuilder().maximumSize(10));
|
||||
assertThat(cm.getCache("c1") != cache1).isTrue();
|
||||
assertThat(cm.getCache("c2") == cache2).isTrue();
|
||||
assertThat(cm.getCache("c1")).isNotSameAs(cache1);
|
||||
assertThat(cm.getCache("c2")).isSameAs(cache2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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 JCacheCustomInterceptorTests {
|
|||
@Test
|
||||
public void onlyOneInterceptorIsAvailable() {
|
||||
Map<String, JCacheInterceptor> interceptors = ctx.getBeansOfType(JCacheInterceptor.class);
|
||||
assertThat(interceptors.size()).as("Only one interceptor should be defined").isEqualTo(1);
|
||||
assertThat(interceptors).as("Only one interceptor should be defined").hasSize(1);
|
||||
JCacheInterceptor interceptor = interceptors.values().iterator().next();
|
||||
assertThat(interceptor.getClass()).as("Custom interceptor not defined").isEqualTo(TestCacheInterceptor.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -45,7 +45,8 @@ public abstract class AbstractCacheOperationTests<O extends JCacheOperation<?>>
|
|||
public void simple() {
|
||||
O operation = createSimpleOperation();
|
||||
assertThat(operation.getCacheName()).as("Wrong cache name").isEqualTo("simpleCache");
|
||||
assertThat(operation.getAnnotations().size()).as("Unexpected number of annotation on " + operation.getMethod()).isEqualTo(1);
|
||||
assertThat(operation.getAnnotations()).as("Unexpected number of annotation on " + operation.getMethod())
|
||||
.hasSize(1);
|
||||
assertThat(operation.getAnnotations().iterator().next()).as("Wrong method annotation").isEqualTo(operation.getCacheAnnotation());
|
||||
|
||||
assertThat(operation.getCacheResolver()).as("cache resolver should be set").isNotNull();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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,25 +37,25 @@ public class InternetAddressEditorTests {
|
|||
|
||||
@Test
|
||||
public void uninitialized() {
|
||||
assertThat(editor.getAsText()).as("Uninitialized editor did not return empty value string").isEqualTo(EMPTY);
|
||||
assertThat(editor.getAsText()).as("Uninitialized editor did not return empty value string").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setNull() {
|
||||
editor.setAsText(null);
|
||||
assertThat(editor.getAsText()).as("Setting null did not result in empty value string").isEqualTo(EMPTY);
|
||||
assertThat(editor.getAsText()).as("Setting null did not result in empty value string").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setEmpty() {
|
||||
editor.setAsText(EMPTY);
|
||||
assertThat(editor.getAsText()).as("Setting empty string did not result in empty value string").isEqualTo(EMPTY);
|
||||
assertThat(editor.getAsText()).as("Setting empty string did not result in empty value string").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allWhitespace() {
|
||||
editor.setAsText(" ");
|
||||
assertThat(editor.getAsText()).as("All whitespace was not recognized").isEqualTo(EMPTY);
|
||||
assertThat(editor.getAsText()).as("All whitespace was not recognized").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -39,8 +39,8 @@ public class QuartzSchedulerLifecycleTests {
|
|||
sw.start("lazyScheduler");
|
||||
context.close();
|
||||
sw.stop();
|
||||
assertThat(sw.getTotalTimeMillis() < 500).as("Quartz Scheduler with lazy-init is hanging on destruction: " +
|
||||
sw.getTotalTimeMillis()).isTrue();
|
||||
assertThat(sw.getTotalTimeMillis()).as("Quartz Scheduler with lazy-init is hanging on destruction: " +
|
||||
sw.getTotalTimeMillis()).isLessThan(500);
|
||||
}
|
||||
|
||||
@Test // SPR-6354
|
||||
|
|
@ -52,8 +52,8 @@ public class QuartzSchedulerLifecycleTests {
|
|||
sw.start("lazyScheduler");
|
||||
context.close();
|
||||
sw.stop();
|
||||
assertThat(sw.getTotalTimeMillis() < 500).as("Quartz Scheduler with lazy-init is hanging on destruction: " +
|
||||
sw.getTotalTimeMillis()).isTrue();
|
||||
assertThat(sw.getTotalTimeMillis()).as("Quartz Scheduler with lazy-init is hanging on destruction: " +
|
||||
sw.getTotalTimeMillis()).isLessThan(500);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class QuartzSupportTests {
|
|||
bean.start();
|
||||
|
||||
Thread.sleep(500);
|
||||
assertThat(DummyJob.count > 0).as("DummyJob should have been executed at least once.").isTrue();
|
||||
assertThat(DummyJob.count).as("DummyJob should have been executed at least once.").isGreaterThan(0);
|
||||
assertThat(taskExecutor.count).isEqualTo(DummyJob.count);
|
||||
|
||||
bean.destroy();
|
||||
|
|
@ -168,7 +168,7 @@ class QuartzSupportTests {
|
|||
|
||||
Thread.sleep(500);
|
||||
assertThat(DummyJobBean.param).isEqualTo(10);
|
||||
assertThat(DummyJobBean.count > 0).isTrue();
|
||||
assertThat(DummyJobBean.count).isGreaterThan(0);
|
||||
|
||||
bean.destroy();
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ class QuartzSupportTests {
|
|||
|
||||
Thread.sleep(500);
|
||||
assertThat(DummyJob.param).isEqualTo(10);
|
||||
assertThat(DummyJob.count > 0).as("DummyJob should have been executed at least once.").isTrue();
|
||||
assertThat(DummyJob.count).as("DummyJob should have been executed at least once.").isGreaterThan(0);
|
||||
|
||||
bean.destroy();
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ class QuartzSupportTests {
|
|||
|
||||
Thread.sleep(500);
|
||||
assertThat(DummyJob.param).isEqualTo(0);
|
||||
assertThat(DummyJob.count == 0).isTrue();
|
||||
assertThat(DummyJob.count).isEqualTo(0);
|
||||
|
||||
bean.destroy();
|
||||
}
|
||||
|
|
@ -273,7 +273,7 @@ class QuartzSupportTests {
|
|||
|
||||
Thread.sleep(500);
|
||||
assertThat(DummyJobBean.param).isEqualTo(10);
|
||||
assertThat(DummyJobBean.count > 0).isTrue();
|
||||
assertThat(DummyJobBean.count).isGreaterThan(0);
|
||||
|
||||
bean.destroy();
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ class QuartzSupportTests {
|
|||
|
||||
Thread.sleep(500);
|
||||
assertThat(DummyJob.param).isEqualTo(10);
|
||||
assertThat(DummyJob.count > 0).as("DummyJob should have been executed at least once.").isTrue();
|
||||
assertThat(DummyJob.count).as("DummyJob should have been executed at least once.").isGreaterThan(0);
|
||||
|
||||
bean.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -74,8 +74,9 @@ class ProceedTests {
|
|||
@Test
|
||||
void testProceedWithArgsInSameAspect() {
|
||||
this.testBean.setMyFloat(1.0F);
|
||||
assertThat(this.testBean.getMyFloat() > 1.9F).as("value changed in around advice").isTrue();
|
||||
assertThat(this.firstTestAspect.getLastBeforeFloatValue() > 1.9F).as("changed value visible to next advice in chain").isTrue();
|
||||
assertThat(this.testBean.getMyFloat()).as("value changed in around advice").isGreaterThan(1.9F);
|
||||
assertThat(this.firstTestAspect.getLastBeforeFloatValue()).as("changed value visible to next advice in chain")
|
||||
.isGreaterThan(1.9F);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class AspectJAutoProxyCreatorTests {
|
|||
AdviceUsingThisJoinPoint aspectInstance = (AdviceUsingThisJoinPoint) bf.getBean("aspect");
|
||||
//(AdviceUsingThisJoinPoint) Aspects.aspectOf(AdviceUsingThisJoinPoint.class);
|
||||
//assertEquals("method-execution(int TestBean.getAge())",aspectInstance.getLastMethodEntered());
|
||||
assertThat(aspectInstance.getLastMethodEntered().indexOf("TestBean.getAge())") != 0).isTrue();
|
||||
assertThat(aspectInstance.getLastMethodEntered()).doesNotStartWith("TestBean.getAge())");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -129,7 +129,7 @@ class BenchmarkTests {
|
|||
|
||||
assertThat(AopUtils.isAopProxy(adrian)).isTrue();
|
||||
Advised a = (Advised) adrian;
|
||||
assertThat(a.getAdvisors().length >= 3).isTrue();
|
||||
assertThat(a.getAdvisors()).hasSizeGreaterThanOrEqualTo(3);
|
||||
assertThat(adrian.getName()).isEqualTo("adrian");
|
||||
|
||||
for (int i = 0; i < howmany; i++) {
|
||||
|
|
@ -151,7 +151,7 @@ class BenchmarkTests {
|
|||
|
||||
assertThat(AopUtils.isAopProxy(adrian)).isTrue();
|
||||
Advised a = (Advised) adrian;
|
||||
assertThat(a.getAdvisors().length >= 3).isTrue();
|
||||
assertThat(a.getAdvisors()).hasSizeGreaterThanOrEqualTo(3);
|
||||
// Hits joinpoint
|
||||
adrian.setAge(25);
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ class BenchmarkTests {
|
|||
|
||||
assertThat(AopUtils.isAopProxy(adrian)).isTrue();
|
||||
Advised a = (Advised) adrian;
|
||||
assertThat(a.getAdvisors().length >= 3).isTrue();
|
||||
assertThat(a.getAdvisors()).hasSizeGreaterThanOrEqualTo(3);
|
||||
|
||||
for (int i = 0; i < howmany; i++) {
|
||||
// Hit all 3 joinpoints
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -62,7 +62,7 @@ public class AopNamespaceHandlerTests {
|
|||
Advised advised = (Advised) bean;
|
||||
Advisor[] advisors = advised.getAdvisors();
|
||||
|
||||
assertThat(advisors.length > 0).as("Advisors should not be empty").isTrue();
|
||||
assertThat(advisors).as("Advisors should not be empty").isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -195,14 +195,14 @@ public abstract class AbstractAopProxyTests {
|
|||
Person p = (Person) createAopProxy(pf).getProxy();
|
||||
|
||||
p.echo(null);
|
||||
assertThat(cta.getCalls()).isEqualTo(0);
|
||||
assertThat(cta.getCalls()).isZero();
|
||||
try {
|
||||
p.echo(new IOException());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
/* expected */
|
||||
}
|
||||
assertThat(cta.getCalls()).isEqualTo(1);
|
||||
assertThat(cta.getCalls()).isOne();
|
||||
|
||||
// Will throw exception if it fails
|
||||
Person p2 = SerializationTestUtils.serializeAndDeserialize(p);
|
||||
|
|
@ -214,7 +214,7 @@ public abstract class AbstractAopProxyTests {
|
|||
Advised a1 = (Advised) p;
|
||||
Advised a2 = (Advised) p2;
|
||||
// Check we can manipulate state of p2
|
||||
assertThat(a2.getAdvisors()).hasSize(a1.getAdvisors().length);
|
||||
assertThat(a2.getAdvisors()).hasSameSizeAs(a1.getAdvisors());
|
||||
|
||||
// This should work as SerializablePerson is equal
|
||||
assertThat(p2).as("Proxies should be equal, even after one was serialized").isEqualTo(p);
|
||||
|
|
@ -590,7 +590,7 @@ public abstract class AbstractAopProxyTests {
|
|||
|
||||
t.setName(null);
|
||||
// Null replacement magic should work
|
||||
assertThat(t.getName()).isEqualTo("");
|
||||
assertThat(t.getName()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -607,7 +607,7 @@ public abstract class AbstractAopProxyTests {
|
|||
assertThat(di.getCount()).isEqualTo(2);
|
||||
|
||||
Advised advised = (Advised) t;
|
||||
assertThat(advised.getAdvisors().length).as("Have 1 advisor").isEqualTo(1);
|
||||
assertThat(advised.getAdvisors()).as("Have 1 advisor").hasSize(1);
|
||||
assertThat(advised.getAdvisors()[0].getAdvice()).isEqualTo(di);
|
||||
NopInterceptor di2 = new NopInterceptor();
|
||||
advised.addAdvice(1, di2);
|
||||
|
|
@ -814,7 +814,7 @@ public abstract class AbstractAopProxyTests {
|
|||
HashMap<ITestBean, Object> h = new HashMap<>();
|
||||
Object value1 = "foo";
|
||||
Object value2 = "bar";
|
||||
assertThat(h.get(proxy1)).isNull();
|
||||
assertThat(h).doesNotContainKey(proxy1);
|
||||
h.put(proxy1, value1);
|
||||
h.put(proxy2, value2);
|
||||
assertThat(value1).isEqualTo(h.get(proxy1));
|
||||
|
|
@ -836,8 +836,8 @@ public abstract class AbstractAopProxyTests {
|
|||
ITestBean proxied = (ITestBean) createProxy(pc);
|
||||
|
||||
String proxyConfigString = ((Advised) proxied).toProxyConfigString();
|
||||
assertThat(proxyConfigString.contains(advisor.toString())).isTrue();
|
||||
assertThat(proxyConfigString.contains("1 interface")).isTrue();
|
||||
assertThat(proxyConfigString).contains(advisor.toString());
|
||||
assertThat(proxyConfigString).contains("1 interface");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -914,24 +914,24 @@ public abstract class AbstractAopProxyTests {
|
|||
NopInterceptor nop = new NopInterceptor();
|
||||
pc.addAdvice(nop);
|
||||
ITestBean proxy = (ITestBean) createProxy(pc);
|
||||
assertThat(0).isEqualTo(nop.getCount());
|
||||
assertThat(nop.getCount()).isZero();
|
||||
assertThat(proxy.getAge()).isEqualTo(tb1.getAge());
|
||||
assertThat(1).isEqualTo(nop.getCount());
|
||||
assertThat(nop.getCount()).isOne();
|
||||
// Change to a new static target
|
||||
pc.setTarget(tb2);
|
||||
assertThat(proxy.getAge()).isEqualTo(tb2.getAge());
|
||||
assertThat(2).isEqualTo(nop.getCount());
|
||||
assertThat(nop.getCount()).isEqualTo(2);
|
||||
|
||||
// Change to a new dynamic target
|
||||
HotSwappableTargetSource hts = new HotSwappableTargetSource(tb3);
|
||||
pc.setTargetSource(hts);
|
||||
assertThat(proxy.getAge()).isEqualTo(tb3.getAge());
|
||||
assertThat(3).isEqualTo(nop.getCount());
|
||||
assertThat(nop.getCount()).isEqualTo(3);
|
||||
hts.swap(tb1);
|
||||
assertThat(proxy.getAge()).isEqualTo(tb1.getAge());
|
||||
tb1.setName("Colin");
|
||||
assertThat(proxy.getName()).isEqualTo(tb1.getName());
|
||||
assertThat(5).isEqualTo(nop.getCount());
|
||||
assertThat(nop.getCount()).isEqualTo(5);
|
||||
|
||||
// Change back, relying on casting to Advised
|
||||
Advised advised = (Advised) proxy;
|
||||
|
|
@ -993,12 +993,12 @@ public abstract class AbstractAopProxyTests {
|
|||
pc.addAdvisor(sp);
|
||||
pc.setTarget(tb);
|
||||
ITestBean it = (ITestBean) createProxy(pc);
|
||||
assertThat(0).isEqualTo(di.getCount());
|
||||
assertThat(di.getCount()).isEqualTo(0);
|
||||
it.getAge();
|
||||
assertThat(1).isEqualTo(di.getCount());
|
||||
assertThat(di.getCount()).isEqualTo(1);
|
||||
it.setAge(11);
|
||||
assertThat(11).isEqualTo(it.getAge());
|
||||
assertThat(2).isEqualTo(di.getCount());
|
||||
assertThat(it.getAge()).isEqualTo(11);
|
||||
assertThat(di.getCount()).isEqualTo(2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1173,7 +1173,7 @@ public abstract class AbstractAopProxyTests {
|
|||
IOther proxyA = (IOther) createProxy(pfa);
|
||||
IOther proxyB = (IOther) createProxy(pfb);
|
||||
|
||||
assertThat(pfb.getAdvisors()).hasSize(pfa.getAdvisors().length);
|
||||
assertThat(pfb.getAdvisors()).hasSameSizeAs(pfa.getAdvisors());
|
||||
assertThat(b).isEqualTo(a);
|
||||
assertThat(i2).isEqualTo(i1);
|
||||
assertThat(proxyB).isEqualTo(proxyA);
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
|
|||
|
||||
Object proxy = aop.getProxy();
|
||||
assertThat(AopUtils.isCglibProxy(proxy)).isTrue();
|
||||
assertThat(proxy instanceof ITestBean).isTrue();
|
||||
assertThat(proxy instanceof TestBean).isTrue();
|
||||
assertThat(proxy).isInstanceOf(ITestBean.class);
|
||||
assertThat(proxy).isInstanceOf(TestBean.class);
|
||||
|
||||
TestBean tb = (TestBean) proxy;
|
||||
assertThat(tb.getAge()).isEqualTo(32);
|
||||
|
|
@ -312,7 +312,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
|
|||
cglib = new CglibAopProxy(as);
|
||||
|
||||
ITestBean proxy2 = (ITestBean) cglib.getProxy();
|
||||
assertThat(proxy2 instanceof Serializable).isTrue();
|
||||
assertThat(proxy2).isInstanceOf(Serializable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -331,7 +331,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab
|
|||
proxy.doTest();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
assertThat(ex instanceof ApplicationContextException).as("Invalid exception class").isTrue();
|
||||
assertThat(ex).as("Invalid exception class").isInstanceOf(ApplicationContextException.class);
|
||||
}
|
||||
|
||||
assertThat(proxy.isCatchInvoked()).as("Catch was not invoked").isTrue();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -167,7 +167,7 @@ public class ProxyFactoryBeanTests {
|
|||
assertThat(cba.getCalls()).isEqualTo(0);
|
||||
|
||||
ITestBean tb = (ITestBean) bf.getBean("directTarget");
|
||||
assertThat(tb.getName().equals("Adam")).isTrue();
|
||||
assertThat(tb.getName()).isEqualTo("Adam");
|
||||
assertThat(cba.getCalls()).isEqualTo(1);
|
||||
|
||||
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&directTarget");
|
||||
|
|
@ -179,7 +179,7 @@ public class ProxyFactoryBeanTests {
|
|||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource(TARGETSOURCE_CONTEXT, CLASS));
|
||||
ITestBean tb = (ITestBean) bf.getBean("viaTargetSource");
|
||||
assertThat(tb.getName().equals("Adam")).isTrue();
|
||||
assertThat(tb.getName()).isEqualTo("Adam");
|
||||
ProxyFactoryBean pfb = (ProxyFactoryBean) bf.getBean("&viaTargetSource");
|
||||
assertThat(TestBean.class.isAssignableFrom(pfb.getObjectType())).as("Has correct object type").isTrue();
|
||||
}
|
||||
|
|
@ -219,10 +219,10 @@ public class ProxyFactoryBeanTests {
|
|||
pc1.addAdvice(1, di);
|
||||
assertThat(pc2.getAdvisors()).isEqualTo(pc1.getAdvisors());
|
||||
assertThat(pc2.getAdvisors().length).as("Now have one more advisor").isEqualTo((oldLength + 1));
|
||||
assertThat(0).isEqualTo(di.getCount());
|
||||
assertThat(di.getCount()).isEqualTo(0);
|
||||
test1.setAge(5);
|
||||
assertThat(test1.getAge()).isEqualTo(test1_1.getAge());
|
||||
assertThat(3).isEqualTo(di.getCount());
|
||||
assertThat(di.getCount()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -230,8 +230,8 @@ public class ProxyFactoryBeanTests {
|
|||
assertThat(ITestBean.class.isAssignableFrom(factory.getType("prototype"))).as("Has correct object type").isTrue();
|
||||
ITestBean test2 = (ITestBean) factory.getBean("prototype");
|
||||
ITestBean test2_1 = (ITestBean) factory.getBean("prototype");
|
||||
assertThat(test2 != test2_1).as("Prototype instances !=").isTrue();
|
||||
assertThat(test2.equals(test2_1)).as("Prototype instances equal").isTrue();
|
||||
assertThat(test2).as("Prototype instances !=").isNotSameAs(test2_1);
|
||||
assertThat(test2).as("Prototype instances equal").isEqualTo(test2_1);
|
||||
assertThat(ITestBean.class.isAssignableFrom(factory.getType("prototype"))).as("Has correct object type").isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ public class ProxyFactoryBeanTests {
|
|||
assertThat(prototype2FirstInstance.getCount()).isEqualTo(INITIAL_COUNT + 1);
|
||||
|
||||
SideEffectBean prototype2SecondInstance = (SideEffectBean) bf.getBean(beanName);
|
||||
assertThat(prototype2FirstInstance == prototype2SecondInstance).as("Prototypes are not ==").isFalse();
|
||||
assertThat(prototype2FirstInstance).as("Prototypes are not ==").isNotSameAs(prototype2SecondInstance);
|
||||
assertThat(prototype2SecondInstance.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
assertThat(prototype2FirstInstance.getCount()).isEqualTo(INITIAL_COUNT + 1);
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ public class ProxyFactoryBeanTests {
|
|||
TestBean target = (TestBean) factory.getBean("test");
|
||||
target.setName(name);
|
||||
ITestBean autoInvoker = (ITestBean) factory.getBean("autoInvoker");
|
||||
assertThat(autoInvoker.getName().equals(name)).isTrue();
|
||||
assertThat(autoInvoker.getName()).isEqualTo(name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -308,7 +308,7 @@ public class ProxyFactoryBeanTests {
|
|||
config.addAdvice(0, (MethodInterceptor) invocation -> {
|
||||
throw ex;
|
||||
});
|
||||
assertThat(config.getAdvisors().length).as("Have correct advisor count").isEqualTo(2);
|
||||
assertThat(config.getAdvisors()).as("Have correct advisor count").hasSize(2);
|
||||
|
||||
ITestBean tb1 = (ITestBean) factory.getBean("test1");
|
||||
assertThatException()
|
||||
|
|
@ -348,31 +348,31 @@ public class ProxyFactoryBeanTests {
|
|||
// Add to head of interceptor chain
|
||||
int oldCount = config.getAdvisors().length;
|
||||
config.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
||||
assertThat(config.getAdvisors().length == oldCount + 1).isTrue();
|
||||
assertThat(config.getAdvisors()).hasSize(oldCount + 1);
|
||||
|
||||
TimeStamped ts = (TimeStamped) factory.getBean("test2");
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(time);
|
||||
|
||||
// Can remove
|
||||
config.removeAdvice(ti);
|
||||
assertThat(config.getAdvisors().length == oldCount).isTrue();
|
||||
assertThat(config.getAdvisors()).hasSize(oldCount);
|
||||
|
||||
// Check no change on existing object reference
|
||||
assertThat(ts.getTimeStamp() == time).isTrue();
|
||||
assertThat(ts.getTimeStamp()).isEqualTo(time);
|
||||
|
||||
assertThat(factory.getBean("test2")).as("Should no longer implement TimeStamped")
|
||||
.isNotInstanceOf(TimeStamped.class);
|
||||
|
||||
// Now check non-effect of removing interceptor that isn't there
|
||||
config.removeAdvice(new DebugInterceptor());
|
||||
assertThat(config.getAdvisors().length == oldCount).isTrue();
|
||||
assertThat(config.getAdvisors()).hasSize(oldCount);
|
||||
|
||||
ITestBean it = (ITestBean) ts;
|
||||
DebugInterceptor debugInterceptor = new DebugInterceptor();
|
||||
config.addAdvice(0, debugInterceptor);
|
||||
it.getSpouse();
|
||||
// Won't affect existing reference
|
||||
assertThat(debugInterceptor.getCount() == 0).isTrue();
|
||||
assertThat(debugInterceptor.getCount()).isEqualTo(0);
|
||||
it = (ITestBean) factory.getBean("test2");
|
||||
it.getSpouse();
|
||||
assertThat(debugInterceptor.getCount()).isEqualTo(1);
|
||||
|
|
@ -412,16 +412,16 @@ public class ProxyFactoryBeanTests {
|
|||
public void testMethodPointcuts() {
|
||||
ITestBean tb = (ITestBean) factory.getBean("pointcuts");
|
||||
PointcutForVoid.reset();
|
||||
assertThat(PointcutForVoid.methodNames.isEmpty()).as("No methods intercepted").isTrue();
|
||||
assertThat(PointcutForVoid.methodNames).as("No methods intercepted").isEmpty();
|
||||
tb.getAge();
|
||||
assertThat(PointcutForVoid.methodNames.isEmpty()).as("Not void: shouldn't have intercepted").isTrue();
|
||||
assertThat(PointcutForVoid.methodNames).as("Not void: shouldn't have intercepted").isEmpty();
|
||||
tb.setAge(1);
|
||||
tb.getAge();
|
||||
tb.setName("Tristan");
|
||||
tb.toString();
|
||||
assertThat(PointcutForVoid.methodNames.size()).as("Recorded wrong number of invocations").isEqualTo(2);
|
||||
assertThat(PointcutForVoid.methodNames.get(0).equals("setAge")).isTrue();
|
||||
assertThat(PointcutForVoid.methodNames.get(1).equals("setName")).isTrue();
|
||||
assertThat(PointcutForVoid.methodNames).as("Recorded wrong number of invocations").hasSize(2);
|
||||
assertThat(PointcutForVoid.methodNames.get(0)).isEqualTo("setAge");
|
||||
assertThat(PointcutForVoid.methodNames.get(1)).isEqualTo("setName");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -498,17 +498,17 @@ public class ProxyFactoryBeanTests {
|
|||
@Test
|
||||
public void testGlobalsCanAddAspectInterfaces() {
|
||||
AddedGlobalInterface agi = (AddedGlobalInterface) factory.getBean("autoInvoker");
|
||||
assertThat(agi.globalsAdded() == -1).isTrue();
|
||||
assertThat(agi.globalsAdded()).isEqualTo(-1);
|
||||
|
||||
ProxyFactoryBean pfb = (ProxyFactoryBean) factory.getBean("&validGlobals");
|
||||
// Trigger lazy initialization.
|
||||
pfb.getObject();
|
||||
// 2 globals + 2 explicit
|
||||
assertThat(pfb.getAdvisors().length).as("Have 2 globals and 2 explicit advisors").isEqualTo(3);
|
||||
assertThat(pfb.getAdvisors()).as("Have 2 globals and 2 explicit advisors").hasSize(3);
|
||||
|
||||
ApplicationListener<?> l = (ApplicationListener<?>) factory.getBean("validGlobals");
|
||||
agi = (AddedGlobalInterface) l;
|
||||
assertThat(agi.globalsAdded() == -1).isTrue();
|
||||
assertThat(agi.globalsAdded()).isEqualTo(-1);
|
||||
|
||||
assertThat(factory.getBean("test1")).as("Aspect interface shouldn't be implemented without globals")
|
||||
.isNotInstanceOf(AddedGlobalInterface.class);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -202,7 +202,7 @@ public class AdvisorAutoProxyCreatorTests {
|
|||
|
||||
|
||||
ITestBean test2 = (ITestBean) bf.getBean("!test");
|
||||
assertThat(test == test2).as("Prototypes cannot be the same object").isFalse();
|
||||
assertThat(test).as("Prototypes cannot be the same object").isNotSameAs(test2);
|
||||
assertThat(test2.getName()).isEqualTo("Rod");
|
||||
assertThat(test2.getSpouse().getName()).isEqualTo("Kerry");
|
||||
bf.close();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -141,10 +141,10 @@ class XmlBeanFactoryTests {
|
|||
TestBean georgia = (TestBean) xbf.getBean("georgia");
|
||||
ITestBean emmasJenks = emma.getSpouse();
|
||||
ITestBean georgiasJenks = georgia.getSpouse();
|
||||
assertThat(emmasJenks != georgiasJenks).as("Emma and georgia think they have a different boyfriend").isTrue();
|
||||
assertThat(emmasJenks.getName().equals("Andrew")).as("Emmas jenks has right name").isTrue();
|
||||
assertThat(emmasJenks != xbf.getBean("jenks")).as("Emmas doesn't equal new ref").isTrue();
|
||||
assertThat(georgiasJenks.getName().equals("Andrew")).as("Georgias jenks has right name").isTrue();
|
||||
assertThat(emmasJenks).as("Emma and georgia think they have a different boyfriend").isNotSameAs(georgiasJenks);
|
||||
assertThat(emmasJenks.getName()).as("Emmas jenks has right name").isEqualTo("Andrew");
|
||||
assertThat(emmasJenks).as("Emmas doesn't equal new ref").isNotSameAs(xbf.getBean("jenks"));
|
||||
assertThat(georgiasJenks.getName()).as("Georgias jenks has right name").isEqualTo("Andrew");
|
||||
assertThat(emmasJenks.equals(georgiasJenks)).as("They are object equal").isTrue();
|
||||
assertThat(emmasJenks.equals(xbf.getBean("jenks"))).as("They object equal direct ref").isTrue();
|
||||
}
|
||||
|
|
@ -161,8 +161,8 @@ class XmlBeanFactoryTests {
|
|||
TestBean jenks = (TestBean) xbf.getBean("jenks");
|
||||
ITestBean davesJen = dave.getSpouse();
|
||||
ITestBean jenksJen = jenks.getSpouse();
|
||||
assertThat(davesJen == jenksJen).as("1 jen instance").isTrue();
|
||||
assertThat(davesJen == jen).as("1 jen instance").isTrue();
|
||||
assertThat(davesJen).as("1 jen instance").isSameAs(jenksJen);
|
||||
assertThat(davesJen).as("1 jen instance").isSameAs(jen);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -193,7 +193,7 @@ class XmlBeanFactoryTests {
|
|||
assertThat(friends).hasSize(3);
|
||||
DerivedTestBean inner2 = (DerivedTestBean) friends[0];
|
||||
assertThat(inner2.getName()).isEqualTo("inner2");
|
||||
assertThat(inner2.getBeanName().startsWith(DerivedTestBean.class.getName())).isTrue();
|
||||
assertThat(inner2.getBeanName()).startsWith(DerivedTestBean.class.getName());
|
||||
assertThat(xbf.containsBean("innerBean#1")).isFalse();
|
||||
assertThat(inner2).isNotNull();
|
||||
assertThat(inner2.getAge()).isEqualTo(7);
|
||||
|
|
@ -235,7 +235,7 @@ class XmlBeanFactoryTests {
|
|||
xbf.destroySingletons();
|
||||
assertThat(inner1.wasDestroyed()).isTrue();
|
||||
assertThat(inner2.wasDestroyed()).isTrue();
|
||||
assertThat(innerFactory.getName() == null).isTrue();
|
||||
assertThat(innerFactory.getName()).isNull();
|
||||
assertThat(inner5.wasDestroyed()).isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ class XmlBeanFactoryTests {
|
|||
assertThat(hasInnerBeans.getAge()).isEqualTo(5);
|
||||
TestBean inner1 = (TestBean) hasInnerBeans.getSpouse();
|
||||
assertThat(inner1).isNotNull();
|
||||
assertThat(inner1.getBeanName().startsWith("innerBean")).isTrue();
|
||||
assertThat(inner1.getBeanName()).startsWith("innerBean");
|
||||
assertThat(inner1.getName()).isEqualTo("inner1");
|
||||
assertThat(inner1.getAge()).isEqualTo(6);
|
||||
|
||||
|
|
@ -264,13 +264,13 @@ class XmlBeanFactoryTests {
|
|||
assertThat(friends).hasSize(3);
|
||||
DerivedTestBean inner2 = (DerivedTestBean) friends[0];
|
||||
assertThat(inner2.getName()).isEqualTo("inner2");
|
||||
assertThat(inner2.getBeanName().startsWith(DerivedTestBean.class.getName())).isTrue();
|
||||
assertThat(inner2.getBeanName()).startsWith(DerivedTestBean.class.getName());
|
||||
assertThat(inner2).isNotNull();
|
||||
assertThat(inner2.getAge()).isEqualTo(7);
|
||||
TestBean innerFactory = (TestBean) friends[1];
|
||||
assertThat(innerFactory.getName()).isEqualTo(DummyFactory.SINGLETON_NAME);
|
||||
TestBean inner5 = (TestBean) friends[2];
|
||||
assertThat(inner5.getBeanName().startsWith("innerBean")).isTrue();
|
||||
assertThat(inner5.getBeanName()).startsWith("innerBean");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -286,8 +286,8 @@ class XmlBeanFactoryTests {
|
|||
catch (BeanCreationException ex) {
|
||||
// Check whether message contains outer bean name.
|
||||
ex.printStackTrace();
|
||||
assertThat(ex.getMessage().contains("failsOnInnerBean")).isTrue();
|
||||
assertThat(ex.getMessage().contains("someMap")).isTrue();
|
||||
assertThat(ex.getMessage()).contains("failsOnInnerBean");
|
||||
assertThat(ex.getMessage()).contains("someMap");
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -296,8 +296,8 @@ class XmlBeanFactoryTests {
|
|||
catch (BeanCreationException ex) {
|
||||
// Check whether message contains outer bean name.
|
||||
ex.printStackTrace();
|
||||
assertThat(ex.getMessage().contains("failsOnInnerBeanForConstructor")).isTrue();
|
||||
assertThat(ex.getMessage().contains("constructor argument")).isTrue();
|
||||
assertThat(ex.getMessage()).contains("failsOnInnerBeanForConstructor");
|
||||
assertThat(ex.getMessage()).contains("constructor argument");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -310,11 +310,11 @@ class XmlBeanFactoryTests {
|
|||
assertThat(child.getType("inheritsFromParentFactory")).isEqualTo(TestBean.class);
|
||||
TestBean inherits = (TestBean) child.getBean("inheritsFromParentFactory");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("override")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("override");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 1).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(1);
|
||||
TestBean inherits2 = (TestBean) child.getBean("inheritsFromParentFactory");
|
||||
assertThat(inherits2 == inherits).isFalse();
|
||||
assertThat(inherits2).isNotSameAs(inherits);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -326,9 +326,9 @@ class XmlBeanFactoryTests {
|
|||
assertThat(child.getType("inheritsWithClass")).isEqualTo(DerivedTestBean.class);
|
||||
DerivedTestBean inherits = (DerivedTestBean) child.getBean("inheritsWithDifferentClass");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("override")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("override");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 1).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(1);
|
||||
assertThat(inherits.wasInitialized()).isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -341,9 +341,9 @@ class XmlBeanFactoryTests {
|
|||
assertThat(child.getType("inheritsWithClass")).isEqualTo(DerivedTestBean.class);
|
||||
DerivedTestBean inherits = (DerivedTestBean) child.getBean("inheritsWithClass");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("override")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("override");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 1).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(1);
|
||||
assertThat(inherits.wasInitialized()).isTrue();
|
||||
}
|
||||
|
||||
|
|
@ -356,15 +356,15 @@ class XmlBeanFactoryTests {
|
|||
assertThat(child.getType("prototypeInheritsFromParentFactoryPrototype")).isEqualTo(TestBean.class);
|
||||
TestBean inherits = (TestBean) child.getBean("prototypeInheritsFromParentFactoryPrototype");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("prototype-override")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("prototype-override");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 2).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(2);
|
||||
TestBean inherits2 = (TestBean) child.getBean("prototypeInheritsFromParentFactoryPrototype");
|
||||
assertThat(inherits2 == inherits).isFalse();
|
||||
assertThat(inherits2).isNotSameAs(inherits);
|
||||
inherits2.setAge(13);
|
||||
assertThat(inherits2.getAge() == 13).isTrue();
|
||||
assertThat(inherits2.getAge()).isEqualTo(13);
|
||||
// Shouldn't have changed first instance
|
||||
assertThat(inherits.getAge() == 2).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -375,15 +375,15 @@ class XmlBeanFactoryTests {
|
|||
new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
|
||||
TestBean inherits = (TestBean) child.getBean("protoypeInheritsFromParentFactorySingleton");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("prototypeOverridesInheritedSingleton")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("prototypeOverridesInheritedSingleton");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 1).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(1);
|
||||
TestBean inherits2 = (TestBean) child.getBean("protoypeInheritsFromParentFactorySingleton");
|
||||
assertThat(inherits2 == inherits).isFalse();
|
||||
assertThat(inherits2).isNotSameAs(inherits);
|
||||
inherits2.setAge(13);
|
||||
assertThat(inherits2.getAge() == 13).isTrue();
|
||||
assertThat(inherits2.getAge()).isEqualTo(13);
|
||||
// Shouldn't have changed first instance
|
||||
assertThat(inherits.getAge() == 1).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -419,7 +419,7 @@ class XmlBeanFactoryTests {
|
|||
parent.getBean("inheritedTestBeanWithoutClass"));
|
||||
|
||||
// non-abstract bean should work, even if it serves as parent
|
||||
assertThat(parent.getBean("inheritedTestBeanPrototype") instanceof TestBean).isTrue();
|
||||
assertThat(parent.getBean("inheritedTestBeanPrototype")).isInstanceOf(TestBean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -438,7 +438,7 @@ class XmlBeanFactoryTests {
|
|||
DummyBoImpl bos = (DummyBoImpl) xbf.getBean("boSingleton");
|
||||
DummyBoImpl bop = (DummyBoImpl) xbf.getBean("boPrototype");
|
||||
assertThat(bop).isNotSameAs(bos);
|
||||
assertThat(bos.dao == bop.dao).isTrue();
|
||||
assertThat(bos.dao).isSameAs(bop.dao);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -449,11 +449,11 @@ class XmlBeanFactoryTests {
|
|||
new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
|
||||
TestBean inherits = (TestBean) child.getBean("inheritedTestBean");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("overrideParentBean")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("overrideParentBean");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 1).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(1);
|
||||
TestBean inherits2 = (TestBean) child.getBean("inheritedTestBean");
|
||||
assertThat(inherits2 != inherits).isTrue();
|
||||
assertThat(inherits2).isNotSameAs(inherits);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -485,11 +485,11 @@ class XmlBeanFactoryTests {
|
|||
new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
|
||||
TestBean inherits = (TestBean) child.getBean("singletonInheritsFromParentFactoryPrototype");
|
||||
// Name property value is overridden
|
||||
assertThat(inherits.getName().equals("prototype-override")).isTrue();
|
||||
assertThat(inherits.getName()).isEqualTo("prototype-override");
|
||||
// Age property is inherited from bean in parent factory
|
||||
assertThat(inherits.getAge() == 2).isTrue();
|
||||
assertThat(inherits.getAge()).isEqualTo(2);
|
||||
TestBean inherits2 = (TestBean) child.getBean("singletonInheritsFromParentFactoryPrototype");
|
||||
assertThat(inherits2 == inherits).isTrue();
|
||||
assertThat(inherits2).isSameAs(inherits);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -500,7 +500,7 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
|
||||
new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
|
||||
TestBean beanFromChild = (TestBean) child.getBean("inheritedTestBeanSingleton");
|
||||
assertThat(beanFromParent == beanFromChild).as("singleton from parent and child is the same").isTrue();
|
||||
assertThat(beanFromParent).as("singleton from parent and child is the same").isSameAs(beanFromChild);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -524,11 +524,11 @@ class XmlBeanFactoryTests {
|
|||
TestBean ego = (TestBean) xbf.getBean("ego");
|
||||
TestBean complexInnerEgo = (TestBean) xbf.getBean("complexInnerEgo");
|
||||
TestBean complexEgo = (TestBean) xbf.getBean("complexEgo");
|
||||
assertThat(jenny.getSpouse() == david).as("Correct circular reference").isTrue();
|
||||
assertThat(david.getSpouse() == jenny).as("Correct circular reference").isTrue();
|
||||
assertThat(ego.getSpouse() == ego).as("Correct circular reference").isTrue();
|
||||
assertThat(complexInnerEgo.getSpouse().getSpouse() == complexInnerEgo).as("Correct circular reference").isTrue();
|
||||
assertThat(complexEgo.getSpouse().getSpouse() == complexEgo).as("Correct circular reference").isTrue();
|
||||
assertThat(jenny.getSpouse()).as("Correct circular reference").isSameAs(david);
|
||||
assertThat(david.getSpouse()).as("Correct circular reference").isSameAs(jenny);
|
||||
assertThat(ego.getSpouse()).as("Correct circular reference").isSameAs(ego);
|
||||
assertThat(complexInnerEgo.getSpouse().getSpouse()).as("Correct circular reference").isSameAs(complexInnerEgo);
|
||||
assertThat(complexEgo.getSpouse().getSpouse()).as("Correct circular reference").isSameAs(complexEgo);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -579,7 +579,7 @@ class XmlBeanFactoryTests {
|
|||
reader.loadBeanDefinitions(REFTYPES_CONTEXT);
|
||||
xbf.getBean("egoBridge");
|
||||
TestBean complexEgo = (TestBean) xbf.getBean("complexEgo");
|
||||
assertThat(complexEgo.getSpouse().getSpouse() == complexEgo).as("Correct circular reference").isTrue();
|
||||
assertThat(complexEgo.getSpouse().getSpouse()).as("Correct circular reference").isSameAs(complexEgo);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -589,9 +589,9 @@ class XmlBeanFactoryTests {
|
|||
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
|
||||
reader.loadBeanDefinitions(REFTYPES_CONTEXT);
|
||||
TestBean ego1 = (TestBean) xbf.getBean("ego1");
|
||||
assertThat(ego1.getSpouse().getSpouse() == ego1).as("Correct circular reference").isTrue();
|
||||
assertThat(ego1.getSpouse().getSpouse()).as("Correct circular reference").isSameAs(ego1);
|
||||
TestBean ego3 = (TestBean) xbf.getBean("ego3");
|
||||
assertThat(ego3.getSpouse().getSpouse() == ego3).as("Correct circular reference").isTrue();
|
||||
assertThat(ego3.getSpouse().getSpouse()).as("Correct circular reference").isSameAs(ego3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -636,7 +636,7 @@ class XmlBeanFactoryTests {
|
|||
assertThat(david.getSpouse().getName()).isEqualTo("Jenny");
|
||||
assertThat(david.getSpouse().getSpouse()).isSameAs(david);
|
||||
assertThat(AopUtils.isAopProxy(jenny.getSpouse())).isTrue();
|
||||
assertThat(!AopUtils.isAopProxy(david.getSpouse())).isTrue();
|
||||
assertThat(AopUtils.isAopProxy(david.getSpouse())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -645,7 +645,7 @@ class XmlBeanFactoryTests {
|
|||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(FACTORY_CIRCLE_CONTEXT);
|
||||
TestBean tb = (TestBean) xbf.getBean("singletonFactory");
|
||||
DummyFactory db = (DummyFactory) xbf.getBean("&singletonFactory");
|
||||
assertThat(tb == db.getOtherTestBean()).isTrue();
|
||||
assertThat(tb).isSameAs(db.getOtherTestBean());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -765,7 +765,7 @@ class XmlBeanFactoryTests {
|
|||
xbf.getBean("lazy-and-bad");
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
assertThat(ex.getCause() instanceof IOException).isTrue();
|
||||
assertThat(ex.getCause()).isInstanceOf(IOException.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -857,12 +857,12 @@ class XmlBeanFactoryTests {
|
|||
DependenciesBean rod1 = (DependenciesBean) xbf.getBean("rod1");
|
||||
// should have been autowired
|
||||
assertThat(rod1.getSpouse()).isNotNull();
|
||||
assertThat(rod1.getSpouse().getName().equals("Kerry")).isTrue();
|
||||
assertThat(rod1.getSpouse().getName()).isEqualTo("Kerry");
|
||||
|
||||
DependenciesBean rod2 = (DependenciesBean) xbf.getBean("rod2");
|
||||
// should have been autowired
|
||||
assertThat(rod2.getSpouse()).isNotNull();
|
||||
assertThat(rod2.getSpouse().getName().equals("Kerry")).isTrue();
|
||||
assertThat(rod2.getSpouse().getName()).isEqualTo("Kerry");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -922,7 +922,7 @@ class XmlBeanFactoryTests {
|
|||
DerivedConstructorDependenciesBean rod6 = (DerivedConstructorDependenciesBean) xbf.getBean("rod6");
|
||||
// should have been autowired
|
||||
assertThat(rod6.initialized).isTrue();
|
||||
assertThat(!rod6.destroyed).isTrue();
|
||||
assertThat(rod6.destroyed).isFalse();
|
||||
assertThat(rod6.getSpouse1()).isEqualTo(kerry2);
|
||||
assertThat(rod6.getSpouse2()).isEqualTo(kerry1);
|
||||
assertThat(rod6.getOther()).isEqualTo(other);
|
||||
|
|
@ -943,7 +943,7 @@ class XmlBeanFactoryTests {
|
|||
}
|
||||
catch (BeanCreationException ex) {
|
||||
ex.printStackTrace();
|
||||
assertThat(ex.toString().contains("touchy")).isTrue();
|
||||
assertThat(ex.toString()).contains("touchy");
|
||||
assertThat((Object) ex.getRelatedCauses()).isNull();
|
||||
}
|
||||
}
|
||||
|
|
@ -1144,7 +1144,7 @@ class XmlBeanFactoryTests {
|
|||
// comes from "resource.xml"
|
||||
ResourceTestBean resource2 = (ResourceTestBean) xbf.getBean("resource2");
|
||||
|
||||
assertThat(resource1.getResource() instanceof ClassPathResource).isTrue();
|
||||
assertThat(resource1.getResource()).isInstanceOf(ClassPathResource.class);
|
||||
StringWriter writer = new StringWriter();
|
||||
FileCopyUtils.copy(new InputStreamReader(resource1.getResource().getInputStream()), writer);
|
||||
assertThat(writer.toString()).isEqualTo("test");
|
||||
|
|
@ -1244,7 +1244,7 @@ class XmlBeanFactoryTests {
|
|||
sw.stop();
|
||||
// System.out.println(sw);
|
||||
if (!LogFactory.getLog(DefaultListableBeanFactory.class).isDebugEnabled()) {
|
||||
assertThat(sw.getTotalTimeMillis() < 2000).isTrue();
|
||||
assertThat(sw.getTotalTimeMillis()).isLessThan(2000);
|
||||
}
|
||||
|
||||
// Now test distinct bean with swapped value in factory, to ensure the two are independent
|
||||
|
|
@ -1305,7 +1305,7 @@ class XmlBeanFactoryTests {
|
|||
assertThat(jenny2).isNotSameAs(jenny1);
|
||||
|
||||
TestBean notJenny = oom.getPrototypeDependency("someParam");
|
||||
assertThat(!"Jenny".equals(notJenny.getName())).isTrue();
|
||||
assertThat(notJenny.getName()).isNotEqualTo("Jenny");
|
||||
|
||||
// Now try protected method, and singleton
|
||||
TestBean dave1 = oom.protectedOverrideSingleton();
|
||||
|
|
@ -1391,12 +1391,12 @@ class XmlBeanFactoryTests {
|
|||
TestBean jenny1 = (TestBean) xbf.getBean("jennyChild");
|
||||
assertThat(jenny1.getFriends()).hasSize(1);
|
||||
Object friend1 = jenny1.getFriends().iterator().next();
|
||||
assertThat(friend1 instanceof TestBean).isTrue();
|
||||
assertThat(friend1).isInstanceOf(TestBean.class);
|
||||
|
||||
TestBean jenny2 = (TestBean) xbf.getBean("jennyChild");
|
||||
assertThat(jenny2.getFriends()).hasSize(1);
|
||||
Object friend2 = jenny2.getFriends().iterator().next();
|
||||
assertThat(friend2 instanceof TestBean).isTrue();
|
||||
assertThat(friend2).isInstanceOf(TestBean.class);
|
||||
|
||||
assertThat(jenny2).isNotSameAs(jenny1);
|
||||
assertThat(friend2).isNotSameAs(friend1);
|
||||
|
|
@ -1433,8 +1433,8 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBoolean");
|
||||
assertThat(bean.boolean1).isEqualTo(Boolean.TRUE);
|
||||
assertThat(bean.boolean2).isEqualTo(Boolean.FALSE);
|
||||
assertThat(bean.boolean1).isTrue();
|
||||
assertThat(bean.boolean2).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1442,8 +1442,8 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
DoubleBooleanConstructorBean bean = (DoubleBooleanConstructorBean) xbf.getBean("beanWithDoubleBooleanAndIndex");
|
||||
assertThat(bean.boolean1).isEqualTo(Boolean.FALSE);
|
||||
assertThat(bean.boolean2).isEqualTo(Boolean.TRUE);
|
||||
assertThat(bean.boolean1).isFalse();
|
||||
assertThat(bean.boolean2).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1451,7 +1451,7 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBean");
|
||||
assertThat(bean.tb instanceof DerivedTestBean).isTrue();
|
||||
assertThat(bean.tb).isInstanceOf(DerivedTestBean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1459,7 +1459,7 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBeanFactoryMethod");
|
||||
assertThat(bean.tb instanceof DerivedTestBean).isTrue();
|
||||
assertThat(bean.tb).isInstanceOf(DerivedTestBean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -1509,7 +1509,7 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArray");
|
||||
assertThat(bean.array instanceof int[]).isTrue();
|
||||
assertThat(bean.array).isInstanceOf(int[].class);
|
||||
assertThat(((int[]) bean.array)).hasSize(1);
|
||||
assertThat(((int[]) bean.array)[0]).isEqualTo(1);
|
||||
}
|
||||
|
|
@ -1519,7 +1519,7 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("indexedConstructorArray");
|
||||
assertThat(bean.array instanceof int[]).isTrue();
|
||||
assertThat(bean.array).isInstanceOf(int[].class);
|
||||
assertThat(((int[]) bean.array)).hasSize(1);
|
||||
assertThat(((int[]) bean.array)[0]).isEqualTo(1);
|
||||
}
|
||||
|
|
@ -1529,7 +1529,7 @@ class XmlBeanFactoryTests {
|
|||
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
|
||||
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType");
|
||||
assertThat(bean.array instanceof String[]).isTrue();
|
||||
assertThat(bean.array).isInstanceOf(String[].class);
|
||||
assertThat(((String[]) bean.array)).isEmpty();
|
||||
}
|
||||
|
||||
|
|
@ -1540,7 +1540,7 @@ class XmlBeanFactoryTests {
|
|||
AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("constructorArrayNoType");
|
||||
bd.setLenientConstructorResolution(false);
|
||||
ConstructorArrayTestBean bean = (ConstructorArrayTestBean) xbf.getBean("constructorArrayNoType");
|
||||
assertThat(bean.array instanceof String[]).isTrue();
|
||||
assertThat(bean.array).isInstanceOf(String[].class);
|
||||
assertThat(((String[]) bean.array)).isEmpty();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -115,7 +115,7 @@ public class CustomNamespaceHandlerTests {
|
|||
assertTestBean(bean);
|
||||
assertThat(AopUtils.isAopProxy(bean)).isTrue();
|
||||
Advisor[] advisors = ((Advised) bean).getAdvisors();
|
||||
assertThat(advisors.length).as("Incorrect number of advisors").isEqualTo(1);
|
||||
assertThat(advisors).as("Incorrect number of advisors").hasSize(1);
|
||||
assertThat(advisors[0].getAdvice().getClass()).as("Incorrect advice class").isEqualTo(DebugInterceptor.class);
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ public class CustomNamespaceHandlerTests {
|
|||
assertTestBean(bean);
|
||||
assertThat(AopUtils.isAopProxy(bean)).isTrue();
|
||||
Advisor[] advisors = ((Advised) bean).getAdvisors();
|
||||
assertThat(advisors.length).as("Incorrect number of advisors").isEqualTo(2);
|
||||
assertThat(advisors).as("Incorrect number of advisors").hasSize(2);
|
||||
assertThat(advisors[0].getAdvice().getClass()).as("Incorrect advice class").isEqualTo(DebugInterceptor.class);
|
||||
assertThat(advisors[1].getAdvice().getClass()).as("Incorrect advice class").isEqualTo(NopInterceptor.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -139,7 +139,7 @@ class CacheReproTests {
|
|||
|
||||
TestBean tb = new TestBean("tb1");
|
||||
bean.insertItem(tb);
|
||||
assertThat(bean.findById("tb1").get()).isSameAs(tb);
|
||||
assertThat(bean.findById("tb1")).containsSame(tb);
|
||||
assertThat(cache.get("tb1").get()).isSameAs(tb);
|
||||
|
||||
cache.clear();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -49,23 +49,23 @@ public class AnnotationCacheOperationSourceTests {
|
|||
@Test
|
||||
public void singularAnnotation() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singular", 1);
|
||||
assertThat(ops.iterator().next() instanceof CacheableOperation).isTrue();
|
||||
assertThat(ops.iterator().next()).isInstanceOf(CacheableOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleAnnotation() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multiple", 2);
|
||||
Iterator<CacheOperation> it = ops.iterator();
|
||||
assertThat(it.next() instanceof CacheableOperation).isTrue();
|
||||
assertThat(it.next() instanceof CacheEvictOperation).isTrue();
|
||||
assertThat(it.next()).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(it.next()).isInstanceOf(CacheEvictOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void caching() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "caching", 2);
|
||||
Iterator<CacheOperation> it = ops.iterator();
|
||||
assertThat(it.next() instanceof CacheableOperation).isTrue();
|
||||
assertThat(it.next() instanceof CacheEvictOperation).isTrue();
|
||||
assertThat(it.next()).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(it.next()).isInstanceOf(CacheEvictOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -76,20 +76,20 @@ public class AnnotationCacheOperationSourceTests {
|
|||
@Test
|
||||
public void singularStereotype() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleStereotype", 1);
|
||||
assertThat(ops.iterator().next() instanceof CacheEvictOperation).isTrue();
|
||||
assertThat(ops.iterator().next()).isInstanceOf(CacheEvictOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleStereotypes() {
|
||||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleStereotype", 3);
|
||||
Iterator<CacheOperation> it = ops.iterator();
|
||||
assertThat(it.next() instanceof CacheableOperation).isTrue();
|
||||
assertThat(it.next()).isInstanceOf(CacheableOperation.class);
|
||||
CacheOperation next = it.next();
|
||||
assertThat(next instanceof CacheEvictOperation).isTrue();
|
||||
assertThat(next.getCacheNames().contains("foo")).isTrue();
|
||||
assertThat(next).isInstanceOf(CacheEvictOperation.class);
|
||||
assertThat(next.getCacheNames()).contains("foo");
|
||||
next = it.next();
|
||||
assertThat(next instanceof CacheEvictOperation).isTrue();
|
||||
assertThat(next.getCacheNames().contains("bar")).isTrue();
|
||||
assertThat(next).isInstanceOf(CacheEvictOperation.class);
|
||||
assertThat(next.getCacheNames()).contains("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -100,7 +100,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
CacheOperation cacheOperation = it.next();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("directly declared"));
|
||||
assertThat(cacheOperation.getKey()).isEqualTo("");
|
||||
assertThat(cacheOperation.getKey()).isEmpty();
|
||||
|
||||
cacheOperation = it.next();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
|
||||
|
|
@ -116,7 +116,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
CacheOperation cacheOperation = it.next();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("directly declared"));
|
||||
assertThat(cacheOperation.getKey()).isEqualTo("");
|
||||
assertThat(cacheOperation.getKey()).isEmpty();
|
||||
|
||||
cacheOperation = it.next();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
|
||||
|
|
@ -126,7 +126,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
cacheOperation = it.next();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("foo"));
|
||||
assertThat(cacheOperation.getKey()).isEqualTo("");
|
||||
assertThat(cacheOperation.getKey()).isEmpty();
|
||||
|
||||
cacheOperation = it.next();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheEvictOperation.class);
|
||||
|
|
@ -222,7 +222,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "noCacheNameSpecified");
|
||||
CacheOperation cacheOperation = ops.iterator().next();
|
||||
assertThat(cacheOperation.getCacheNames()).as("cache names set must not be null").isNotNull();
|
||||
assertThat(cacheOperation.getCacheNames().size()).as("no cache names specified").isEqualTo(0);
|
||||
assertThat(cacheOperation.getCacheNames()).as("no cache names specified").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -251,7 +251,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
|
||||
assertThat(ops.size()).isSameAs(1);
|
||||
CacheOperation cacheOperation = ops.iterator().next();
|
||||
assertThat(cacheOperation instanceof CacheableOperation).isTrue();
|
||||
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -278,7 +278,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
|
||||
private Collection<CacheOperation> getOps(Class<?> target, String name, int expectedNumberOfOperations) {
|
||||
Collection<CacheOperation> result = getOps(target, name);
|
||||
assertThat(result.size()).as("Wrong number of operation(s) for '" + name + "'").isEqualTo(expectedNumberOfOperations);
|
||||
assertThat(result).as("Wrong number of operation(s) for '" + name + "'").hasSize(expectedNumberOfOperations);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ public class AnnotationCacheOperationSourceTests {
|
|||
assertThat(actual.getKeyGenerator()).as("Wrong key manager").isEqualTo(keyGenerator);
|
||||
assertThat(actual.getCacheManager()).as("Wrong cache manager").isEqualTo(cacheManager);
|
||||
assertThat(actual.getCacheResolver()).as("Wrong cache resolver").isEqualTo(cacheResolver);
|
||||
assertThat(actual.getCacheNames().size()).as("Wrong number of cache names").isEqualTo(cacheNames.length);
|
||||
assertThat(actual.getCacheNames()).as("Wrong number of cache names").hasSameSizeAs(cacheNames);
|
||||
Arrays.stream(cacheNames).forEach(cacheName -> assertThat(actual.getCacheNames().contains(cacheName)).as("Cache '" + cacheName + "' not found in " + actual.getCacheNames()).isTrue());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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,15 +33,15 @@ public class ConcurrentMapCacheManagerTests {
|
|||
public void testDynamicMode() {
|
||||
CacheManager cm = new ConcurrentMapCacheManager();
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
assertThat(cache1 instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache1).isInstanceOf(ConcurrentMapCache.class);
|
||||
Cache cache1again = cm.getCache("c1");
|
||||
assertThat(cache1).isSameAs(cache1again);
|
||||
Cache cache2 = cm.getCache("c2");
|
||||
assertThat(cache2 instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache2).isInstanceOf(ConcurrentMapCache.class);
|
||||
Cache cache2again = cm.getCache("c2");
|
||||
assertThat(cache2).isSameAs(cache2again);
|
||||
Cache cache3 = cm.getCache("c3");
|
||||
assertThat(cache3 instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache3).isInstanceOf(ConcurrentMapCache.class);
|
||||
Cache cache3again = cm.getCache("c3");
|
||||
assertThat(cache3).isSameAs(cache3again);
|
||||
|
||||
|
|
@ -71,11 +71,11 @@ public class ConcurrentMapCacheManagerTests {
|
|||
public void testStaticMode() {
|
||||
ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager("c1", "c2");
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
assertThat(cache1 instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache1).isInstanceOf(ConcurrentMapCache.class);
|
||||
Cache cache1again = cm.getCache("c1");
|
||||
assertThat(cache1).isSameAs(cache1again);
|
||||
Cache cache2 = cm.getCache("c2");
|
||||
assertThat(cache2 instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache2).isInstanceOf(ConcurrentMapCache.class);
|
||||
Cache cache2again = cm.getCache("c2");
|
||||
assertThat(cache2).isSameAs(cache2again);
|
||||
Cache cache3 = cm.getCache("c3");
|
||||
|
|
@ -92,11 +92,11 @@ public class ConcurrentMapCacheManagerTests {
|
|||
|
||||
cm.setAllowNullValues(false);
|
||||
Cache cache1x = cm.getCache("c1");
|
||||
assertThat(cache1x instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isInstanceOf(ConcurrentMapCache.class);
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
Cache cache2x = cm.getCache("c2");
|
||||
assertThat(cache2x instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache2x != cache2).isTrue();
|
||||
assertThat(cache2x).isInstanceOf(ConcurrentMapCache.class);
|
||||
assertThat(cache2x).isNotSameAs(cache2);
|
||||
Cache cache3x = cm.getCache("c3");
|
||||
assertThat(cache3x).isNull();
|
||||
|
||||
|
|
@ -119,15 +119,15 @@ public class ConcurrentMapCacheManagerTests {
|
|||
ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager("c1", "c2");
|
||||
assertThat(cm.isStoreByValue()).isFalse();
|
||||
Cache cache1 = cm.getCache("c1");
|
||||
assertThat(cache1 instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache1).isInstanceOf(ConcurrentMapCache.class);
|
||||
assertThat(((ConcurrentMapCache) cache1).isStoreByValue()).isFalse();
|
||||
cache1.put("key", "value");
|
||||
|
||||
cm.setStoreByValue(true);
|
||||
assertThat(cm.isStoreByValue()).isTrue();
|
||||
Cache cache1x = cm.getCache("c1");
|
||||
assertThat(cache1x instanceof ConcurrentMapCache).isTrue();
|
||||
assertThat(cache1x != cache1).isTrue();
|
||||
assertThat(cache1x).isInstanceOf(ConcurrentMapCache.class);
|
||||
assertThat(cache1x).isNotSameAs(cache1);
|
||||
assertThat(cache1x.get("key")).isNull();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -64,11 +64,11 @@ public class ExpressionEvaluatorTests {
|
|||
assertThat(ops).hasSize(2);
|
||||
Iterator<CacheOperation> it = ops.iterator();
|
||||
CacheOperation next = it.next();
|
||||
assertThat(next instanceof CacheableOperation).isTrue();
|
||||
assertThat(next).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(next.getCacheNames().contains("test")).isTrue();
|
||||
assertThat(next.getKey()).isEqualTo("#a");
|
||||
next = it.next();
|
||||
assertThat(next instanceof CacheableOperation).isTrue();
|
||||
assertThat(next).isInstanceOf(CacheableOperation.class);
|
||||
assertThat(next.getCacheNames().contains("test")).isTrue();
|
||||
assertThat(next.getKey()).isEqualTo("#b");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -43,9 +43,9 @@ public abstract class AbstractCircularImportDetectionTests {
|
|||
newParser().parse(loadAsConfigurationSource(A.class), "A");
|
||||
}
|
||||
catch (BeanDefinitionParsingException ex) {
|
||||
assertThat(ex.getMessage().contains(
|
||||
"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " +
|
||||
"to import class 'AbstractCircularImportDetectionTests.A'")).as("Wrong message. Got: " + ex.getMessage()).isTrue();
|
||||
assertThat(ex.getMessage()).as("Wrong message. Got: " + ex.getMessage())
|
||||
.contains("Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " +
|
||||
"to import class 'AbstractCircularImportDetectionTests.A'");
|
||||
threw = true;
|
||||
}
|
||||
assertThat(threw).isTrue();
|
||||
|
|
@ -58,9 +58,9 @@ public abstract class AbstractCircularImportDetectionTests {
|
|||
newParser().parse(loadAsConfigurationSource(X.class), "X");
|
||||
}
|
||||
catch (BeanDefinitionParsingException ex) {
|
||||
assertThat(ex.getMessage().contains(
|
||||
"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.Z2' " +
|
||||
"to import class 'AbstractCircularImportDetectionTests.Z'")).as("Wrong message. Got: " + ex.getMessage()).isTrue();
|
||||
assertThat(ex.getMessage()).as("Wrong message. Got: " + ex.getMessage())
|
||||
.contains("Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.Z2' " +
|
||||
"to import class 'AbstractCircularImportDetectionTests.Z'");
|
||||
threw = true;
|
||||
}
|
||||
assertThat(threw).isTrue();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -71,8 +71,8 @@ public class AggressiveFactoryBeanInstantiationTests {
|
|||
ex.printStackTrace(pw);
|
||||
pw.flush();
|
||||
String stackTrace = baos.toString();
|
||||
assertThat(stackTrace.contains(".<clinit>")).isTrue();
|
||||
assertThat(stackTrace.contains("java.lang.NoClassDefFoundError")).isFalse();
|
||||
assertThat(stackTrace).contains(".<clinit>");
|
||||
assertThat(stackTrace).doesNotContain("java.lang.NoClassDefFoundError");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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 ClassPathFactoryBeanDefinitionScannerTests {
|
|||
context.refresh();
|
||||
|
||||
FactoryMethodComponent fmc = context.getBean("factoryMethodComponent", FactoryMethodComponent.class);
|
||||
assertThat(fmc.getClass().getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)).isFalse();
|
||||
assertThat(fmc.getClass().getName()).doesNotContain(ClassUtils.CGLIB_CLASS_SEPARATOR);
|
||||
|
||||
TestBean tb = (TestBean) context.getBean("publicInstance"); //2
|
||||
assertThat(tb.getName()).isEqualTo("publicInstance");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -105,9 +105,9 @@ class NestedConfigurationClassTests {
|
|||
ctx.refresh();
|
||||
|
||||
S1Config config = ctx.getBean(S1Config.class);
|
||||
assertThat(config != ctx.getBean(S1Config.class)).isTrue();
|
||||
assertThat(config).isNotSameAs(ctx.getBean(S1Config.class));
|
||||
TestBean tb = ctx.getBean("l0Bean", TestBean.class);
|
||||
assertThat(tb == ctx.getBean("l0Bean", TestBean.class)).isTrue();
|
||||
assertThat(tb).isSameAs(ctx.getBean("l0Bean", TestBean.class));
|
||||
|
||||
ctx.getBean(L0Config.L1Config.class);
|
||||
ctx.getBean("l1Bean");
|
||||
|
|
@ -118,12 +118,12 @@ class NestedConfigurationClassTests {
|
|||
// ensure that override order is correct and that it is a singleton
|
||||
TestBean ob = ctx.getBean("overrideBean", TestBean.class);
|
||||
assertThat(ob.getName()).isEqualTo("override-s1");
|
||||
assertThat(ob == ctx.getBean("overrideBean", TestBean.class)).isTrue();
|
||||
assertThat(ob).isSameAs(ctx.getBean("overrideBean", TestBean.class));
|
||||
|
||||
TestBean pb1 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
TestBean pb2 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
assertThat(pb1 != pb2).isTrue();
|
||||
assertThat(pb1.getFriends().iterator().next() != pb2.getFriends().iterator().next()).isTrue();
|
||||
assertThat(pb1).isNotSameAs(pb2);
|
||||
assertThat(pb1.getFriends().iterator().next()).isNotSameAs(pb2.getFriends().iterator().next());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
@ -134,9 +134,9 @@ class NestedConfigurationClassTests {
|
|||
ctx.refresh();
|
||||
|
||||
S1Config config = ctx.getBean(S1Config.class);
|
||||
assertThat(config != ctx.getBean(S1Config.class)).isTrue();
|
||||
assertThat(config).isNotSameAs(ctx.getBean(S1Config.class));
|
||||
TestBean tb = ctx.getBean("l0Bean", TestBean.class);
|
||||
assertThat(tb == ctx.getBean("l0Bean", TestBean.class)).isTrue();
|
||||
assertThat(tb).isSameAs(ctx.getBean("l0Bean", TestBean.class));
|
||||
|
||||
ctx.getBean(L0Config.L1Config.class);
|
||||
ctx.getBean("l1Bean");
|
||||
|
|
@ -147,12 +147,12 @@ class NestedConfigurationClassTests {
|
|||
// ensure that override order is correct and that it is a singleton
|
||||
TestBean ob = ctx.getBean("overrideBean", TestBean.class);
|
||||
assertThat(ob.getName()).isEqualTo("override-s1");
|
||||
assertThat(ob == ctx.getBean("overrideBean", TestBean.class)).isTrue();
|
||||
assertThat(ob).isSameAs(ctx.getBean("overrideBean", TestBean.class));
|
||||
|
||||
TestBean pb1 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
TestBean pb2 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
assertThat(pb1 != pb2).isTrue();
|
||||
assertThat(pb1.getFriends().iterator().next() != pb2.getFriends().iterator().next()).isTrue();
|
||||
assertThat(pb1).isNotSameAs(pb2);
|
||||
assertThat(pb1.getFriends().iterator().next()).isNotSameAs(pb2.getFriends().iterator().next());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
@ -163,9 +163,9 @@ class NestedConfigurationClassTests {
|
|||
ctx.refresh();
|
||||
|
||||
S1ConfigWithProxy config = ctx.getBean(S1ConfigWithProxy.class);
|
||||
assertThat(config == ctx.getBean(S1ConfigWithProxy.class)).isTrue();
|
||||
assertThat(config).isSameAs(ctx.getBean(S1ConfigWithProxy.class));
|
||||
TestBean tb = ctx.getBean("l0Bean", TestBean.class);
|
||||
assertThat(tb == ctx.getBean("l0Bean", TestBean.class)).isTrue();
|
||||
assertThat(tb).isSameAs(ctx.getBean("l0Bean", TestBean.class));
|
||||
|
||||
ctx.getBean(L0Config.L1Config.class);
|
||||
ctx.getBean("l1Bean");
|
||||
|
|
@ -176,12 +176,12 @@ class NestedConfigurationClassTests {
|
|||
// ensure that override order is correct and that it is a singleton
|
||||
TestBean ob = ctx.getBean("overrideBean", TestBean.class);
|
||||
assertThat(ob.getName()).isEqualTo("override-s1");
|
||||
assertThat(ob == ctx.getBean("overrideBean", TestBean.class)).isTrue();
|
||||
assertThat(ob).isSameAs(ctx.getBean("overrideBean", TestBean.class));
|
||||
|
||||
TestBean pb1 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
TestBean pb2 = ctx.getBean("prototypeBean", TestBean.class);
|
||||
assertThat(pb1 != pb2).isTrue();
|
||||
assertThat(pb1.getFriends().iterator().next() != pb2.getFriends().iterator().next()).isTrue();
|
||||
assertThat(pb1).isNotSameAs(pb2);
|
||||
assertThat(pb1.getFriends().iterator().next()).isNotSameAs(pb2.getFriends().iterator().next());
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
@ -194,15 +194,15 @@ class NestedConfigurationClassTests {
|
|||
assertThat(ctx.getBeanFactory().containsSingleton("l0ConfigEmpty")).isFalse();
|
||||
Object l0i1 = ctx.getBean(L0ConfigEmpty.class);
|
||||
Object l0i2 = ctx.getBean(L0ConfigEmpty.class);
|
||||
assertThat(l0i1 == l0i2).isTrue();
|
||||
assertThat(l0i1).isSameAs(l0i2);
|
||||
|
||||
Object l1i1 = ctx.getBean(L0ConfigEmpty.L1ConfigEmpty.class);
|
||||
Object l1i2 = ctx.getBean(L0ConfigEmpty.L1ConfigEmpty.class);
|
||||
assertThat(l1i1 != l1i2).isTrue();
|
||||
assertThat(l1i1).isNotSameAs(l1i2);
|
||||
|
||||
Object l2i1 = ctx.getBean(L0ConfigEmpty.L1ConfigEmpty.L2ConfigEmpty.class);
|
||||
Object l2i2 = ctx.getBean(L0ConfigEmpty.L1ConfigEmpty.L2ConfigEmpty.class);
|
||||
assertThat(l2i1 == l2i2).isTrue();
|
||||
assertThat(l2i1).isSameAs(l2i2);
|
||||
assertThat(l2i2.toString()).isNotEqualTo(l2i1.toString());
|
||||
ctx.close();
|
||||
}
|
||||
|
|
@ -216,15 +216,15 @@ class NestedConfigurationClassTests {
|
|||
assertThat(ctx.getBeanFactory().containsSingleton("l0ConfigConcrete")).isFalse();
|
||||
Object l0i1 = ctx.getBean(L0ConfigConcrete.class);
|
||||
Object l0i2 = ctx.getBean(L0ConfigConcrete.class);
|
||||
assertThat(l0i1 == l0i2).isTrue();
|
||||
assertThat(l0i1).isSameAs(l0i2);
|
||||
|
||||
Object l1i1 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.class);
|
||||
Object l1i2 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.class);
|
||||
assertThat(l1i1 != l1i2).isTrue();
|
||||
assertThat(l1i1).isNotSameAs(l1i2);
|
||||
|
||||
Object l2i1 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.L2ConfigEmpty.class);
|
||||
Object l2i2 = ctx.getBean(L0ConfigConcrete.L1ConfigEmpty.L2ConfigEmpty.class);
|
||||
assertThat(l2i1 == l2i2).isTrue();
|
||||
assertThat(l2i1).isSameAs(l2i2);
|
||||
assertThat(l2i2.toString()).isNotEqualTo(l2i1.toString());
|
||||
ctx.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -57,12 +57,12 @@ public class Spr8954Tests {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, FactoryBean> fbBeans = bf.getBeansOfType(FactoryBean.class);
|
||||
assertThat(1).isEqualTo(fbBeans.size());
|
||||
assertThat("&foo").isEqualTo(fbBeans.keySet().iterator().next());
|
||||
assertThat(fbBeans.size()).isEqualTo(1);
|
||||
assertThat(fbBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
|
||||
Map<String, AnInterface> aiBeans = bf.getBeansOfType(AnInterface.class);
|
||||
assertThat(1).isEqualTo(aiBeans.size());
|
||||
assertThat("&foo").isEqualTo(aiBeans.keySet().iterator().next());
|
||||
assertThat(aiBeans.size()).isEqualTo(1);
|
||||
assertThat(aiBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -76,12 +76,12 @@ public class Spr8954Tests {
|
|||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map<String, FactoryBean> fbBeans = bf.getBeansOfType(FactoryBean.class);
|
||||
assertThat(1).isEqualTo(fbBeans.size());
|
||||
assertThat("&foo").isEqualTo(fbBeans.keySet().iterator().next());
|
||||
assertThat(fbBeans.size()).isEqualTo(1);
|
||||
assertThat(fbBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
|
||||
Map<String, AnInterface> aiBeans = bf.getBeansOfType(AnInterface.class);
|
||||
assertThat(1).isEqualTo(aiBeans.size());
|
||||
assertThat("&foo").isEqualTo(aiBeans.keySet().iterator().next());
|
||||
assertThat(aiBeans.size()).isEqualTo(1);
|
||||
assertThat(aiBeans.keySet().iterator().next()).isEqualTo("&foo");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class AutowiredConfigurationTests {
|
|||
OptionalAutowiredMethodConfig.class);
|
||||
|
||||
assertThat(context.getBeansOfType(Colour.class).isEmpty()).isTrue();
|
||||
assertThat(context.getBean(TestBean.class).getName()).isEqualTo("");
|
||||
assertThat(context.getBean(TestBean.class).getName()).isEmpty();
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,12 +162,12 @@ class AnnotationDrivenEventListenerTests {
|
|||
ContextEventListener listener = this.context.getBean(ContextEventListener.class);
|
||||
|
||||
List<Object> events = this.eventCollector.getEvents(listener);
|
||||
assertThat(events.size()).as("Wrong number of initial context events").isEqualTo(1);
|
||||
assertThat(events).as("Wrong number of initial context events").hasSize(1);
|
||||
assertThat(events.get(0).getClass()).isEqualTo(ContextRefreshedEvent.class);
|
||||
|
||||
this.context.stop();
|
||||
List<Object> eventsAfterStop = this.eventCollector.getEvents(listener);
|
||||
assertThat(eventsAfterStop.size()).as("Wrong number of context events on shutdown").isEqualTo(2);
|
||||
assertThat(eventsAfterStop).as("Wrong number of context events on shutdown").hasSize(2);
|
||||
assertThat(eventsAfterStop.get(1).getClass()).isEqualTo(ContextStoppedEvent.class);
|
||||
this.eventCollector.assertTotalEventsCount(2);
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ class AnnotationDrivenEventListenerTests {
|
|||
load(ScopedProxyTestBean.class);
|
||||
|
||||
SimpleService proxy = this.context.getBean(SimpleService.class);
|
||||
assertThat(proxy instanceof Advised).as("bean should be a proxy").isTrue();
|
||||
assertThat(proxy).as("bean should be a proxy").isInstanceOf(Advised.class);
|
||||
this.eventCollector.assertNoEventReceived(proxy.getId());
|
||||
|
||||
this.context.publishEvent(new ContextRefreshedEvent(this.context));
|
||||
|
|
@ -351,7 +351,7 @@ class AnnotationDrivenEventListenerTests {
|
|||
load(AnnotatedProxyTestBean.class);
|
||||
|
||||
AnnotatedSimpleService proxy = this.context.getBean(AnnotatedSimpleService.class);
|
||||
assertThat(proxy instanceof Advised).as("bean should be a proxy").isTrue();
|
||||
assertThat(proxy).as("bean should be a proxy").isInstanceOf(Advised.class);
|
||||
this.eventCollector.assertNoEventReceived(proxy.getId());
|
||||
|
||||
this.context.publishEvent(new ContextRefreshedEvent(this.context));
|
||||
|
|
|
|||
|
|
@ -112,9 +112,9 @@ class EventPublicationInterceptorTests {
|
|||
testBean.getAge();
|
||||
|
||||
// two events: ContextRefreshedEvent and TestEvent
|
||||
assertThat(listener.getEventCount() == 2).as("Interceptor must have published 2 events").isTrue();
|
||||
assertThat(listener.getEventCount()).as("Interceptor must have published 2 events").isEqualTo(2);
|
||||
TestApplicationListener otherListener = (TestApplicationListener) ctx.getBean("&otherListener");
|
||||
assertThat(otherListener.getEventCount() == 2).as("Interceptor must have published 2 events").isTrue();
|
||||
assertThat(otherListener.getEventCount()).as("Interceptor must have published 2 events").isEqualTo(2);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -58,7 +58,7 @@ public class EventCollector {
|
|||
*/
|
||||
public void assertNoEventReceived(String listenerId) {
|
||||
List<Object> events = this.content.getOrDefault(listenerId, Collections.emptyList());
|
||||
assertThat(events.size()).as("Expected no events but got " + events).isEqualTo(0);
|
||||
assertThat(events).as("Expected no events but got " + events).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +74,7 @@ public class EventCollector {
|
|||
*/
|
||||
public void assertEvent(String listenerId, Object... events) {
|
||||
List<Object> actual = this.content.getOrDefault(listenerId, Collections.emptyList());
|
||||
assertThat(actual.size()).as("Wrong number of events").isEqualTo(events.length);
|
||||
assertThat(actual).as("Wrong number of events").hasSameSizeAs(events);
|
||||
for (int i = 0; i < events.length; i++) {
|
||||
assertThat(actual.get(i)).as("Wrong event at index " + i).isEqualTo(events[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -169,9 +169,9 @@ class ApplicationContextExpressionTests {
|
|||
System.getProperties().put("country", "UK");
|
||||
assertThat(tb3.country).isEqualTo("123 UK");
|
||||
assertThat(tb3.countryFactory.getObject()).isEqualTo("123 UK");
|
||||
assertThat(tb3.optionalValue1.get()).isEqualTo("123");
|
||||
assertThat(tb3.optionalValue2.get()).isEqualTo("123");
|
||||
assertThat(tb3.optionalValue3.isPresent()).isFalse();
|
||||
assertThat(tb3.optionalValue1).contains("123");
|
||||
assertThat(tb3.optionalValue2).contains("123");
|
||||
assertThat(tb3.optionalValue3).isNotPresent();
|
||||
assertThat(tb3.tb).isSameAs(tb0);
|
||||
|
||||
tb3 = SerializationTestUtils.serializeAndDeserialize(tb3);
|
||||
|
|
@ -246,7 +246,7 @@ class ApplicationContextExpressionTests {
|
|||
ac.refresh();
|
||||
|
||||
String str = ac.getBean("str", String.class);
|
||||
assertThat(str.startsWith("test-")).isTrue();
|
||||
assertThat(str).startsWith("test-");
|
||||
ac.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -45,7 +45,7 @@ public class CachedExpressionEvaluatorTests {
|
|||
Expression expression = expressionEvaluator.getTestExpression("true", method, getClass());
|
||||
hasParsedExpression("true");
|
||||
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
|
||||
assertThat(expressionEvaluator.testCache.size()).as("Expression should be in cache").isEqualTo(1);
|
||||
assertThat(expressionEvaluator.testCache).as("Expression should be in cache").hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -56,7 +56,7 @@ public class CachedExpressionEvaluatorTests {
|
|||
expressionEvaluator.getTestExpression("true", method, getClass());
|
||||
expressionEvaluator.getTestExpression("true", method, getClass());
|
||||
hasParsedExpression("true");
|
||||
assertThat(expressionEvaluator.testCache.size()).as("Only one expression should be in cache").isEqualTo(1);
|
||||
assertThat(expressionEvaluator.testCache).as("Only one expression should be in cache").hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -64,7 +64,7 @@ public class CachedExpressionEvaluatorTests {
|
|||
Method method = ReflectionUtils.findMethod(getClass(), "toString");
|
||||
expressionEvaluator.getTestExpression("true", method, getClass());
|
||||
expressionEvaluator.getTestExpression("true", method, Object.class);
|
||||
assertThat(expressionEvaluator.testCache.size()).as("Cached expression should be based on type").isEqualTo(2);
|
||||
assertThat(expressionEvaluator.testCache).as("Cached expression should be based on type").hasSize(2);
|
||||
}
|
||||
|
||||
private void hasParsedExpression(String expression) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -73,14 +73,14 @@ class ApplicationContextLifecycleTests {
|
|||
LifecycleTestBean bean3 = (LifecycleTestBean) context.getBean("bean3");
|
||||
LifecycleTestBean bean4 = (LifecycleTestBean) context.getBean("bean4");
|
||||
String notStartedError = "bean was not started";
|
||||
assertThat(bean1.getStartOrder() > 0).as(notStartedError).isTrue();
|
||||
assertThat(bean2.getStartOrder() > 0).as(notStartedError).isTrue();
|
||||
assertThat(bean3.getStartOrder() > 0).as(notStartedError).isTrue();
|
||||
assertThat(bean4.getStartOrder() > 0).as(notStartedError).isTrue();
|
||||
assertThat(bean1.getStartOrder()).as(notStartedError).isGreaterThan(0);
|
||||
assertThat(bean2.getStartOrder()).as(notStartedError).isGreaterThan(0);
|
||||
assertThat(bean3.getStartOrder()).as(notStartedError).isGreaterThan(0);
|
||||
assertThat(bean4.getStartOrder()).as(notStartedError).isGreaterThan(0);
|
||||
String orderError = "dependent bean must start after the bean it depends on";
|
||||
assertThat(bean2.getStartOrder() > bean1.getStartOrder()).as(orderError).isTrue();
|
||||
assertThat(bean3.getStartOrder() > bean2.getStartOrder()).as(orderError).isTrue();
|
||||
assertThat(bean4.getStartOrder() > bean2.getStartOrder()).as(orderError).isTrue();
|
||||
assertThat(bean2.getStartOrder()).as(orderError).isGreaterThan(bean1.getStartOrder());
|
||||
assertThat(bean3.getStartOrder()).as(orderError).isGreaterThan(bean2.getStartOrder());
|
||||
assertThat(bean4.getStartOrder()).as(orderError).isGreaterThan(bean2.getStartOrder());
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
|
@ -94,14 +94,14 @@ class ApplicationContextLifecycleTests {
|
|||
LifecycleTestBean bean3 = (LifecycleTestBean) context.getBean("bean3");
|
||||
LifecycleTestBean bean4 = (LifecycleTestBean) context.getBean("bean4");
|
||||
String notStoppedError = "bean was not stopped";
|
||||
assertThat(bean1.getStopOrder() > 0).as(notStoppedError).isTrue();
|
||||
assertThat(bean2.getStopOrder() > 0).as(notStoppedError).isTrue();
|
||||
assertThat(bean3.getStopOrder() > 0).as(notStoppedError).isTrue();
|
||||
assertThat(bean4.getStopOrder() > 0).as(notStoppedError).isTrue();
|
||||
assertThat(bean1.getStopOrder()).as(notStoppedError).isGreaterThan(0);
|
||||
assertThat(bean2.getStopOrder()).as(notStoppedError).isGreaterThan(0);
|
||||
assertThat(bean3.getStopOrder()).as(notStoppedError).isGreaterThan(0);
|
||||
assertThat(bean4.getStopOrder()).as(notStoppedError).isGreaterThan(0);
|
||||
String orderError = "dependent bean must stop before the bean it depends on";
|
||||
assertThat(bean2.getStopOrder() < bean1.getStopOrder()).as(orderError).isTrue();
|
||||
assertThat(bean3.getStopOrder() < bean2.getStopOrder()).as(orderError).isTrue();
|
||||
assertThat(bean4.getStopOrder() < bean2.getStopOrder()).as(orderError).isTrue();
|
||||
assertThat(bean2.getStopOrder()).as(orderError).isLessThan(bean1.getStopOrder());
|
||||
assertThat(bean3.getStopOrder()).as(orderError).isLessThan(bean2.getStopOrder());
|
||||
assertThat(bean4.getStopOrder()).as(orderError).isLessThan(bean2.getStopOrder());
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -154,8 +154,8 @@ public class ClassPathXmlApplicationContextTests {
|
|||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ex.printStackTrace(new PrintStream(baos));
|
||||
String dump = FileCopyUtils.copyToString(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));
|
||||
assertThat(dump.contains("someMessageSource")).isTrue();
|
||||
assertThat(dump.contains("useCodeAsDefaultMessage")).isTrue();
|
||||
assertThat(dump).contains("someMessageSource");
|
||||
assertThat(dump).contains("useCodeAsDefaultMessage");
|
||||
}
|
||||
catch (IOException ioex) {
|
||||
throw new IllegalStateException(ioex);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -118,12 +118,12 @@ class ConversionServiceFactoryBeanTests {
|
|||
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(fileName, getClass());
|
||||
ResourceTestBean tb = ctx.getBean("resourceTestBean", ResourceTestBean.class);
|
||||
assertThat(resourceClass.isInstance(tb.getResource())).isTrue();
|
||||
assertThat(tb.getResourceArray().length > 0).isTrue();
|
||||
assertThat(tb.getResourceArray()).isNotEmpty();
|
||||
assertThat(resourceClass.isInstance(tb.getResourceArray()[0])).isTrue();
|
||||
assertThat(tb.getResourceMap().size() == 1).isTrue();
|
||||
assertThat(tb.getResourceMap()).hasSize(1);
|
||||
assertThat(resourceClass.isInstance(tb.getResourceMap().get("key1"))).isTrue();
|
||||
assertThat(tb.getResourceArrayMap().size() == 1).isTrue();
|
||||
assertThat(tb.getResourceArrayMap().get("key1").length > 0).isTrue();
|
||||
assertThat(tb.getResourceArrayMap()).hasSize(1);
|
||||
assertThat(tb.getResourceArrayMap().get("key1")).isNotEmpty();
|
||||
assertThat(resourceClass.isInstance(tb.getResourceArrayMap().get("key1")[0])).isTrue();
|
||||
ctx.close();
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ class ConversionServiceFactoryBeanTests {
|
|||
static class ComplexConstructorArgument {
|
||||
|
||||
ComplexConstructorArgument(Map<String, Class<?>> map) {
|
||||
assertThat(!map.isEmpty()).isTrue();
|
||||
assertThat(map.isEmpty()).isFalse();
|
||||
assertThat(map.keySet().iterator().next()).isInstanceOf(String.class);
|
||||
assertThat(map.values().iterator().next()).isInstanceOf(Class.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -407,7 +407,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
|
|||
ppc.setEnvironment(env);
|
||||
ppc.setIgnoreUnresolvablePlaceholders(true);
|
||||
ppc.postProcessBeanFactory(bf);
|
||||
assertThat(bf.getBean(OptionalTestBean.class).getName()).isEqualTo(Optional.of("myValue"));
|
||||
assertThat(bf.getBean(OptionalTestBean.class).getName()).contains("myValue");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -427,7 +427,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
|
|||
ppc.setIgnoreUnresolvablePlaceholders(true);
|
||||
ppc.setNullValue("");
|
||||
ppc.postProcessBeanFactory(bf);
|
||||
assertThat(bf.getBean(OptionalTestBean.class).getName()).isEqualTo(Optional.empty());
|
||||
assertThat(bf.getBean(OptionalTestBean.class).getName()).isNotPresent();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -70,15 +70,15 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
|||
@Test
|
||||
public void getMessageWithDefaultPassedInAndFoundInMsgCatalog() {
|
||||
// Try with Locale.US
|
||||
assertThat(sac.getMessage("message.format.example2", null, "This is a default msg if not found in MessageSource.", Locale.US)
|
||||
.equals("This is a test message in the message catalog with no args.")).as("valid msg from staticMsgSource with default msg passed in returned msg from msg catalog for Locale.US").isTrue();
|
||||
assertThat(sac.getMessage("message.format.example2", null, "This is a default msg if not found in MessageSource.", Locale.US)).as("valid msg from staticMsgSource with default msg passed in returned msg from msg catalog for Locale.US")
|
||||
.isEqualTo("This is a test message in the message catalog with no args.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMessageWithDefaultPassedInAndNotFoundInMsgCatalog() {
|
||||
// Try with Locale.US
|
||||
assertThat(sac.getMessage("bogus.message", null, "This is a default msg if not found in MessageSource.", Locale.US)
|
||||
.equals("This is a default msg if not found in MessageSource.")).as("bogus msg from staticMsgSource with default msg passed in returned default msg for Locale.US").isTrue();
|
||||
assertThat(sac.getMessage("bogus.message", null, "This is a default msg if not found in MessageSource.", Locale.US)).as("bogus msg from staticMsgSource with default msg passed in returned default msg for Locale.US")
|
||||
.isEqualTo("This is a default msg if not found in MessageSource.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,8 +100,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
|||
sac.getMessage("message.format.example1", arguments, Locale.US);
|
||||
|
||||
// Now msg better be as expected
|
||||
assertThat(sac.getMessage("message.format.example1", arguments, Locale.US).
|
||||
contains("there was \"a disturbance in the Force\" on planet 7.")).as("2nd search within MsgFormat cache returned expected message for Locale.US").isTrue();
|
||||
assertThat(sac.getMessage("message.format.example1", arguments, Locale.US)).as("2nd search within MsgFormat cache returned expected message for Locale.US")
|
||||
.contains("there was \"a disturbance in the Force\" on planet 7.");
|
||||
|
||||
Object[] newArguments = {
|
||||
8, new Date(System.currentTimeMillis()),
|
||||
|
|
@ -109,8 +109,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
|||
};
|
||||
|
||||
// Now msg better be as expected even with different args
|
||||
assertThat(sac.getMessage("message.format.example1", newArguments, Locale.US).
|
||||
contains("there was \"a disturbance in the Force\" on planet 8.")).as("2nd search within MsgFormat cache with different args returned expected message for Locale.US").isTrue();
|
||||
assertThat(sac.getMessage("message.format.example1", newArguments, Locale.US)).as("2nd search within MsgFormat cache with different args returned expected message for Locale.US")
|
||||
.contains("there was \"a disturbance in the Force\" on planet 8.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -131,16 +131,16 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
|||
and the time the ResourceBundleMessageSource resolves the msg the
|
||||
minutes of the time might not be the same.
|
||||
*/
|
||||
assertThat(sac.getMessage("message.format.example1", arguments, Locale.US).
|
||||
contains("there was \"a disturbance in the Force\" on planet 7.")).as("msg from staticMsgSource for Locale.US substituting args for placeholders is as expected").isTrue();
|
||||
assertThat(sac.getMessage("message.format.example1", arguments, Locale.US)).as("msg from staticMsgSource for Locale.US substituting args for placeholders is as expected")
|
||||
.contains("there was \"a disturbance in the Force\" on planet 7.");
|
||||
|
||||
// Try with Locale.UK
|
||||
assertThat(sac.getMessage("message.format.example1", arguments, Locale.UK).
|
||||
contains("there was \"a disturbance in the Force\" on station number 7.")).as("msg from staticMsgSource for Locale.UK substituting args for placeholders is as expected").isTrue();
|
||||
assertThat(sac.getMessage("message.format.example1", arguments, Locale.UK)).as("msg from staticMsgSource for Locale.UK substituting args for placeholders is as expected")
|
||||
.contains("there was \"a disturbance in the Force\" on station number 7.");
|
||||
|
||||
// Try with Locale.US - Use a different test msg that requires no args
|
||||
assertThat(sac.getMessage("message.format.example2", null, Locale.US)
|
||||
.equals("This is a test message in the message catalog with no args.")).as("msg from staticMsgSource for Locale.US that requires no args is as expected").isTrue();
|
||||
assertThat(sac.getMessage("message.format.example2", null, Locale.US)).as("msg from staticMsgSource for Locale.US that requires no args is as expected")
|
||||
.isEqualTo("This is a test message in the message catalog with no args.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -155,17 +155,17 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
|
|||
// first code valid
|
||||
String[] codes1 = new String[] {"message.format.example3", "message.format.example2"};
|
||||
MessageSourceResolvable resolvable1 = new DefaultMessageSourceResolvable(codes1, null, "default");
|
||||
assertThat(MSG_TXT3_US.equals(sac.getMessage(resolvable1, Locale.US))).as("correct message retrieved").isTrue();
|
||||
assertThat(sac.getMessage(resolvable1, Locale.US)).as("correct message retrieved").isEqualTo(MSG_TXT3_US);
|
||||
|
||||
// only second code valid
|
||||
String[] codes2 = new String[] {"message.format.example99", "message.format.example2"};
|
||||
MessageSourceResolvable resolvable2 = new DefaultMessageSourceResolvable(codes2, null, "default");
|
||||
assertThat(MSG_TXT2_US.equals(sac.getMessage(resolvable2, Locale.US))).as("correct message retrieved").isTrue();
|
||||
assertThat(sac.getMessage(resolvable2, Locale.US)).as("correct message retrieved").isEqualTo(MSG_TXT2_US);
|
||||
|
||||
// no code valid, but default given
|
||||
String[] codes3 = new String[] {"message.format.example99", "message.format.example98"};
|
||||
MessageSourceResolvable resolvable3 = new DefaultMessageSourceResolvable(codes3, null, "default");
|
||||
assertThat("default".equals(sac.getMessage(resolvable3, Locale.US))).as("correct message retrieved").isTrue();
|
||||
assertThat(sac.getMessage(resolvable3, Locale.US)).as("correct message retrieved").isEqualTo("default");
|
||||
|
||||
// no code valid, no default
|
||||
String[] codes4 = new String[] {"message.format.example99", "message.format.example98"};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -78,8 +78,8 @@ public class DateTimeFormatterFactoryTests {
|
|||
public void createDateTimeFormatterInOrderOfPropertyPriority() {
|
||||
factory.setStylePattern("SS");
|
||||
String value = applyLocale(factory.createDateTimeFormatter()).format(dateTime);
|
||||
assertThat(value.startsWith("10/21/09")).isTrue();
|
||||
assertThat(value.endsWith("12:10 PM")).isTrue();
|
||||
assertThat(value).startsWith("10/21/09");
|
||||
assertThat(value).endsWith("12:10 PM");
|
||||
|
||||
factory.setIso(ISO.DATE);
|
||||
assertThat(applyLocale(factory.createDateTimeFormatter()).format(dateTime)).isEqualTo("2009-10-21");
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("period", "P6Y3M1D");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("period").toString().equals("P6Y3M1D")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("period").toString()).isEqualTo("P6Y3M1D");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -472,7 +472,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("duration", "PT8H6M12.345S");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("duration").toString().equals("PT8H6M12.345S")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("duration").toString()).isEqualTo("PT8H6M12.345S");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -481,7 +481,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("year", "2007");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("year").toString().equals("2007")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("year").toString()).isEqualTo("2007");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -490,7 +490,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("month", "JULY");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("month").toString().equals("JULY")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("month").toString()).isEqualTo("JULY");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -499,7 +499,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("month", "July");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("month").toString().equals("JULY")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("month").toString()).isEqualTo("JULY");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -508,7 +508,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("yearMonth", "2007-12");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("yearMonth").toString().equals("2007-12")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("yearMonth").toString()).isEqualTo("2007-12");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -527,7 +527,7 @@ class DateTimeFormattingTests {
|
|||
propertyValues.add("monthDay", "--12-03");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isZero();
|
||||
assertThat(binder.getBindingResult().getFieldValue("monthDay").toString().equals("--12-03")).isTrue();
|
||||
assertThat(binder.getBindingResult().getFieldValue("monthDay").toString()).isEqualTo("--12-03");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -67,7 +67,7 @@ public class MoneyFormattingTests {
|
|||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("USD10.50");
|
||||
assertThat(binder.getBindingResult().getFieldValue("unit")).isEqualTo("USD");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
|
||||
LocaleContextHolder.setLocale(Locale.CANADA);
|
||||
|
|
@ -76,7 +76,7 @@ public class MoneyFormattingTests {
|
|||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("USD10.50");
|
||||
assertThat(binder.getBindingResult().getFieldValue("unit")).isEqualTo("USD");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ public class MoneyFormattingTests {
|
|||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("$10.50");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
|
||||
LocaleContextHolder.setLocale(Locale.CANADA);
|
||||
|
|
@ -99,7 +99,7 @@ public class MoneyFormattingTests {
|
|||
LocaleContextHolder.setLocale(Locale.US);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("$10.50");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("CAD");
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ public class MoneyFormattingTests {
|
|||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("10.5");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ public class MoneyFormattingTests {
|
|||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("10%");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 0.1d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(0.1d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ public class MoneyFormattingTests {
|
|||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("010.500");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ public class MoneyFormattingTests {
|
|||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("USD 010.500");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
|
||||
LocaleContextHolder.setLocale(Locale.CANADA);
|
||||
|
|
@ -167,7 +167,7 @@ public class MoneyFormattingTests {
|
|||
LocaleContextHolder.setLocale(Locale.US);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("amount")).isEqualTo("USD 010.500");
|
||||
assertThat(bean.getAmount().getNumber().doubleValue() == 10.5d).isTrue();
|
||||
assertThat(bean.getAmount().getNumber().doubleValue()).isEqualTo(10.5d);
|
||||
assertThat(bean.getAmount().getCurrency().getCurrencyCode()).isEqualTo("USD");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -522,7 +522,8 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
|
|||
|
||||
this.server.unregisterMBean(new ObjectName(OBJECT_NAME));
|
||||
exporter.destroy();
|
||||
assertThat(listener.getUnregistered().size()).as("Listener should not have been invoked (MBean previously unregistered by external agent)").isEqualTo(0);
|
||||
assertThat(listener.getUnregistered()).as("Listener should not have been invoked (MBean previously unregistered by external agent)")
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test // SPR-3302
|
||||
|
|
@ -664,8 +665,8 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
|
|||
|
||||
private void assertListener(MockMBeanExporterListener listener) throws MalformedObjectNameException {
|
||||
ObjectName desired = ObjectNameManager.getInstance(OBJECT_NAME);
|
||||
assertThat(listener.getRegistered().size()).as("Incorrect number of registrations").isEqualTo(1);
|
||||
assertThat(listener.getUnregistered().size()).as("Incorrect number of unregistrations").isEqualTo(1);
|
||||
assertThat(listener.getRegistered()).as("Incorrect number of registrations").hasSize(1);
|
||||
assertThat(listener.getUnregistered()).as("Incorrect number of unregistrations").hasSize(1);
|
||||
assertThat(listener.getRegistered().get(0)).as("Incorrect ObjectName in register").isEqualTo(desired);
|
||||
assertThat(listener.getUnregistered().get(0)).as("Incorrect ObjectName in unregister").isEqualTo(desired);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue