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:
Krzysztof Krasoń
2023-04-04 17:34:07 +02:00
committed by GitHub
parent dd97ee4e99
commit 1734deca1e
371 changed files with 3177 additions and 3076 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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());
}

View File

@@ -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();
}

View File

@@ -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");
}

View File

@@ -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();

View File

@@ -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");
}
}

View File

@@ -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");

View File

@@ -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();
}

View File

@@ -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");
}

View File

@@ -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();
}

View File

@@ -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));

View File

@@ -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();
}

View File

@@ -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]);
}

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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"};

View File

@@ -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");

View File

@@ -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

View File

@@ -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");
}

View File

@@ -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);
}

View File

@@ -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.
@@ -146,7 +146,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
ModelMBeanOperationInfo oper = info.getOperation("add");
MBeanParameterInfo[] params = oper.getSignature();
assertThat(params.length).as("Invalid number of params").isEqualTo(2);
assertThat(params).as("Invalid number of params").hasSize(2);
assertThat(params[0].getName()).as("Incorrect name for x param").isEqualTo("x");
assertThat(params[0].getType()).as("Incorrect type for x param").isEqualTo(int.class.getName());
@@ -176,8 +176,8 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
start(exporter);
MBeanInfo inf = getServer().getMBeanInfo(ObjectNameManager.getInstance(objectName));
assertThat(inf.getOperations().length).as("Incorrect number of operations").isEqualTo(getExpectedOperationCount());
assertThat(inf.getAttributes().length).as("Incorrect number of attributes").isEqualTo(getExpectedAttributeCount());
assertThat(inf.getOperations()).as("Incorrect number of operations").hasSize(getExpectedOperationCount());
assertThat(inf.getAttributes()).as("Incorrect number of attributes").hasSize(getExpectedAttributeCount());
assertThat(assembler.includeBean(proxy.getClass(), "some bean name")).as("Not included in autodetection").isTrue();
}

View File

@@ -57,7 +57,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("java:comp/env/foo");
jof.setResourceRef(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
assertThat(jof.getObject()).isSameAs(o);
}
@Test
@@ -68,7 +68,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("java:comp/env/foo");
jof.setResourceRef(false);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
assertThat(jof.getObject()).isSameAs(o);
}
@Test
@@ -79,7 +79,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("java:foo");
jof.setResourceRef(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
assertThat(jof.getObject()).isSameAs(o);
}
@Test
@@ -90,7 +90,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("java:foo");
jof.setResourceRef(false);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
assertThat(jof.getObject()).isSameAs(o);
}
@Test
@@ -101,7 +101,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("foo");
jof.setResourceRef(true);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
assertThat(jof.getObject()).isSameAs(o);
}
@Test
@@ -122,7 +122,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("foo");
jof.setResourceRef(false);
jof.afterPropertiesSet();
assertThat(jof.getObject() == o).isTrue();
assertThat(jof.getObject()).isSameAs(o);
}
@Test
@@ -133,7 +133,7 @@ public class JndiObjectFactoryBeanTests {
jof.setJndiName("foo");
jof.setExpectedType(String.class);
jof.afterPropertiesSet();
assertThat(jof.getObject() == s).isTrue();
assertThat(jof.getObject()).isSameAs(s);
}
@Test

View File

@@ -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.
@@ -38,7 +38,7 @@ public class JndiTemplateEditorTests {
JndiTemplateEditor je = new JndiTemplateEditor();
je.setAsText("");
JndiTemplate jt = (JndiTemplate) je.getValue();
assertThat(jt.getEnvironment() == null).isTrue();
assertThat(jt.getEnvironment()).isNull();
}
@Test
@@ -49,9 +49,10 @@ public class JndiTemplateEditorTests {
// to look anything up
je.setAsText("jndiInitialSomethingOrOther=org.springframework.myjndi.CompleteRubbish\nfoo=bar");
JndiTemplate jt = (JndiTemplate) je.getValue();
assertThat(jt.getEnvironment().size() == 2).isTrue();
assertThat(jt.getEnvironment().getProperty("jndiInitialSomethingOrOther").equals("org.springframework.myjndi.CompleteRubbish")).isTrue();
assertThat(jt.getEnvironment().getProperty("foo").equals("bar")).isTrue();
assertThat(jt.getEnvironment()).hasSize(2);
assertThat(jt.getEnvironment().getProperty("jndiInitialSomethingOrOther")).isEqualTo(
"org.springframework.myjndi.CompleteRubbish");
assertThat(jt.getEnvironment().getProperty("foo")).isEqualTo("bar");
}
}

View File

@@ -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,7 +50,7 @@ public class AnnotationAsyncExecutionInterceptorTests {
}
{ // method and class level -> method value, even if empty, overrides
@Async("qClass") class C { @Async void m() { } }
assertThat(i.getExecutorQualifier(C.class.getDeclaredMethod("m"))).isEqualTo("");
assertThat(i.getExecutorQualifier(C.class.getDeclaredMethod("m"))).isEmpty();
}
{ // meta annotation with qualifier
@MyAsync class C { void m() { } }

View File

@@ -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.
@@ -106,7 +106,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertThat(asyncThread.getName().startsWith("testExecutor")).isTrue();
assertThat(asyncThread.getName()).startsWith("testExecutor");
context.close();
}
@@ -131,7 +131,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertThat(asyncThread.getName().startsWith("testExecutor")).isTrue();
assertThat(asyncThread.getName()).startsWith("testExecutor");
context.close();
}
@@ -160,7 +160,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertThat(asyncThread.getName().startsWith("testExecutor2")).isTrue();
assertThat(asyncThread.getName()).startsWith("testExecutor2");
context.close();
}
@@ -173,7 +173,7 @@ public class AsyncAnnotationBeanPostProcessorTests {
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertThat(asyncThread.getName().startsWith("testExecutor")).isTrue();
assertThat(asyncThread.getName()).startsWith("testExecutor");
TestableAsyncUncaughtExceptionHandler exceptionHandler =
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);

View File

@@ -183,7 +183,9 @@ class ScheduledExecutorFactoryBeanTests {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
@Override
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
assertThat("Bah; the setThreadFactory(..) method must use a default ThreadFactory if a null arg is passed in.").isNotNull();
assertThat(threadFactory)
.withFailMessage("Bah; the setThreadFactory(..) method must use a default ThreadFactory if a null arg is passed in.")
.isNotNull();
return super.createExecutor(poolSize, threadFactory, rejectedExecutionHandler);
}
};
@@ -199,7 +201,6 @@ class ScheduledExecutorFactoryBeanTests {
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean() {
@Override
protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
assertThat("Bah; the setRejectedExecutionHandler(..) method must use a default RejectedExecutionHandler if a null arg is passed in.").isNotNull();
return super.createExecutor(poolSize, threadFactory, rejectedExecutionHandler);
}
};

View File

@@ -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.
@@ -218,8 +218,8 @@ class PeriodicTriggerTests {
private static void assertApproximateDifference(Instant lesser, Instant greater, long expected) {
long diff = greater.toEpochMilli() - lesser.toEpochMilli();
long variance = Math.abs(expected - diff);
assertThat(variance < 100).as("expected approximate difference of " + expected +
", but actual difference was " + diff).isTrue();
assertThat(variance).as("expected approximate difference of " + expected +
", but actual difference was " + diff).isLessThan(100);
}
private static TriggerContext context(@Nullable Object scheduled, @Nullable Object actual,

View File

@@ -69,7 +69,7 @@ class BshScriptFactoryTests {
assertThat(messenger).isEqualTo(messenger);
boolean condition1 = !messenger.equals(calc);
assertThat(condition1).isTrue();
assertThat(messenger.hashCode() != calc.hashCode()).isTrue();
assertThat(messenger.hashCode()).isNotEqualTo(calc.hashCode());
boolean condition = !messenger.toString().equals(calc.toString());
assertThat(condition).isTrue();

View File

@@ -87,7 +87,7 @@ public class GroovyScriptFactoryTests {
assertThat(messenger).isEqualTo(messenger);
boolean condition1 = !messenger.equals(calc);
assertThat(condition1).isTrue();
assertThat(messenger.hashCode() != calc.hashCode()).isTrue();
assertThat(messenger.hashCode()).isNotEqualTo(calc.hashCode());
boolean condition = !messenger.toString().equals(calc.toString());
assertThat(condition).isTrue();
@@ -120,7 +120,7 @@ public class GroovyScriptFactoryTests {
assertThat(messenger).isEqualTo(messenger);
boolean condition1 = !messenger.equals(calc);
assertThat(condition1).isTrue();
assertThat(messenger.hashCode() != calc.hashCode()).isTrue();
assertThat(messenger.hashCode()).isNotEqualTo(calc.hashCode());
boolean condition = !messenger.toString().equals(calc.toString());
assertThat(condition).isTrue();
@@ -455,7 +455,7 @@ public class GroovyScriptFactoryTests {
new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", getClass());
}
catch (BeanCreationException ex) {
assertThat(ex.getMessage().contains("Cannot use proxyTargetClass=true")).isTrue();
assertThat(ex.getMessage()).contains("Cannot use proxyTargetClass=true");
}
}

View File

@@ -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.
@@ -52,11 +52,11 @@ class DataBinderFieldAccessTests {
binder.bind(pvs);
binder.close();
assertThat(rod.getName().equals("Rod")).as("changed name correctly").isTrue();
assertThat(rod.getAge() == 32).as("changed age correctly").isTrue();
assertThat(rod.getName()).as("changed name correctly").isEqualTo("Rod");
assertThat(rod.getAge()).as("changed age correctly").isEqualTo(32);
Map<?, ?> m = binder.getBindingResult().getModel();
assertThat(m.size() == 2).as("There is one element in map").isTrue();
assertThat(m).as("There is one element in map").hasSize(2);
FieldAccessBean tb = (FieldAccessBean) m.get("person");
assertThat(tb.equals(rod)).as("Same object").isTrue();
}

View File

@@ -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.
@@ -95,11 +95,11 @@ class DataBinderTests {
binder.bind(pvs);
binder.close();
assertThat(rod.getName().equals("Rod")).as("changed name correctly").isTrue();
assertThat(rod.getAge() == 32).as("changed age correctly").isTrue();
assertThat(rod.getName()).as("changed name correctly").isEqualTo("Rod");
assertThat(rod.getAge()).as("changed age correctly").isEqualTo(32);
Map<?, ?> map = binder.getBindingResult().getModel();
assertThat(map.size() == 2).as("There is one element in map").isTrue();
assertThat(map).as("There is one element in map").hasSize(2);
TestBean tb = (TestBean) map.get("person");
assertThat(tb.equals(rod)).as("Same object").isTrue();
@@ -576,7 +576,7 @@ class DataBinderTests {
editor = binder.getBindingResult().findEditor("myFloat", null);
assertThat(editor).isNotNull();
editor.setAsText("1,6");
assertThat(((Number) editor.getValue()).floatValue() == 1.6f).isTrue();
assertThat(((Number) editor.getValue()).floatValue()).isEqualTo(1.6f);
}
finally {
LocaleContextHolder.resetLocaleContext();
@@ -752,15 +752,15 @@ class DataBinderTests {
binder.bind(pvs);
binder.close();
assertThat("Rod".equals(rod.getName())).as("changed name correctly").isTrue();
assertThat("Rod".equals(rod.getTouchy())).as("changed touchy correctly").isTrue();
assertThat(rod.getAge() == 0).as("did not change age").isTrue();
assertThat(rod.getName()).as("changed name correctly").isEqualTo("Rod");
assertThat(rod.getTouchy()).as("changed touchy correctly").isEqualTo("Rod");
assertThat(rod.getAge()).as("did not change age").isEqualTo(0);
String[] disallowedFields = binder.getBindingResult().getSuppressedFields();
assertThat(disallowedFields).hasSize(1);
assertThat(disallowedFields[0]).isEqualTo("age");
Map<?,?> m = binder.getBindingResult().getModel();
assertThat(m.size() == 2).as("There is one element in map").isTrue();
assertThat(m).as("There is one element in map").hasSize(2);
TestBean tb = (TestBean) m.get("person");
assertThat(tb.equals(rod)).as("Same object").isTrue();
}
@@ -914,7 +914,7 @@ class DataBinderTests {
binder.getBindingResult().rejectValue("touchy", "someCode", "someMessage");
binder.getBindingResult().rejectValue("spouse.name", "someCode", "someMessage");
assertThat(binder.getBindingResult().getNestedPath()).isEqualTo("");
assertThat(binder.getBindingResult().getNestedPath()).isEmpty();
assertThat(binder.getBindingResult().getFieldValue("name")).isEqualTo("value");
assertThat(binder.getBindingResult().getFieldError("name").getRejectedValue()).isEqualTo("prefixvalue");
assertThat(tb.getName()).isEqualTo("prefixvalue");
@@ -1010,7 +1010,7 @@ class DataBinderTests {
binder.getBindingResult().rejectValue("touchy", "someCode", "someMessage");
binder.getBindingResult().rejectValue("spouse.name", "someCode", "someMessage");
assertThat(binder.getBindingResult().getNestedPath()).isEqualTo("");
assertThat(binder.getBindingResult().getNestedPath()).isEmpty();
assertThat(binder.getBindingResult().getFieldValue("name")).isEqualTo("value");
assertThat(binder.getBindingResult().getFieldError("name").getRejectedValue()).isEqualTo("prefixvalue");
assertThat(tb.getName()).isEqualTo("prefixvalue");
@@ -1148,7 +1148,7 @@ class DataBinderTests {
spouseValidator.validate(tb.getSpouse(), errors);
errors.setNestedPath("");
assertThat(errors.getNestedPath()).isEqualTo("");
assertThat(errors.getNestedPath()).isEmpty();
errors.pushNestedPath("spouse");
assertThat(errors.getNestedPath()).isEqualTo("spouse.");
errors.pushNestedPath("spouse");
@@ -1156,7 +1156,7 @@ class DataBinderTests {
errors.popNestedPath();
assertThat(errors.getNestedPath()).isEqualTo("spouse.");
errors.popNestedPath();
assertThat(errors.getNestedPath()).isEqualTo("");
assertThat(errors.getNestedPath()).isEmpty();
try {
errors.popNestedPath();
}
@@ -1166,7 +1166,7 @@ class DataBinderTests {
errors.pushNestedPath("spouse");
assertThat(errors.getNestedPath()).isEqualTo("spouse.");
errors.setNestedPath("");
assertThat(errors.getNestedPath()).isEqualTo("");
assertThat(errors.getNestedPath()).isEmpty();
try {
errors.popNestedPath();
}

View File

@@ -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.
@@ -200,7 +200,7 @@ public class SpringValidatorAdapterTests {
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(parent, "parent");
validatorAdapter.validate(parent, errors);
assertThat(errors.getErrorCount() > 0).isTrue();
assertThat(errors.getErrorCount()).isGreaterThan(0);
}
@Test // SPR-16177
@@ -212,7 +212,7 @@ public class SpringValidatorAdapterTests {
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(parent, "parent");
validatorAdapter.validate(parent, errors);
assertThat(errors.getErrorCount() > 0).isTrue();
assertThat(errors.getErrorCount()).isGreaterThan(0);
}
private List<Child> createChildren(Parent parent) {

View File

@@ -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.
@@ -76,7 +76,7 @@ class ValidatorFactoryTests {
}
Validator nativeValidator = validator.unwrap(Validator.class);
assertThat(nativeValidator.getClass().getName().startsWith("org.hibernate")).isTrue();
assertThat(nativeValidator.getClass().getName()).startsWith("org.hibernate");
assertThat(validator.unwrap(ValidatorFactory.class)).isInstanceOf(HibernateValidatorFactory.class);
assertThat(validator.unwrap(HibernateValidatorFactory.class)).isInstanceOf(HibernateValidatorFactory.class);
@@ -100,7 +100,7 @@ class ValidatorFactoryTests {
}
Validator nativeValidator = validator.unwrap(Validator.class);
assertThat(nativeValidator.getClass().getName().startsWith("org.hibernate")).isTrue();
assertThat(nativeValidator.getClass().getName()).startsWith("org.hibernate");
assertThat(validator.unwrap(ValidatorFactory.class)).isInstanceOf(HibernateValidatorFactory.class);
assertThat(validator.unwrap(HibernateValidatorFactory.class)).isInstanceOf(HibernateValidatorFactory.class);
@@ -120,8 +120,8 @@ class ValidatorFactoryTests {
assertThat(result).hasSize(1);
Iterator<ConstraintViolation<ValidPerson>> iterator = result.iterator();
ConstraintViolation<?> cv = iterator.next();
assertThat(cv.getPropertyPath().toString()).isEqualTo("");
assertThat(cv.getConstraintDescriptor().getAnnotation() instanceof NameAddressValid).isTrue();
assertThat(cv.getPropertyPath().toString()).isEmpty();
assertThat(cv.getConstraintDescriptor().getAnnotation()).isInstanceOf(NameAddressValid.class);
validator.destroy();
}