From df263d01b9518977aced32582b58c198694fbcc9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 10 Jan 2022 14:15:55 +0100 Subject: [PATCH] Use idiomatic AssertJ assertions for true, false, and null --- ...ansactionalAnnotationIntegrationTests.java | 4 +- .../beans/BeanWrapperEnumTests.java | 6 +- .../DefaultListableBeanFactoryTests.java | 8 +-- .../PropertyResourceConfigurerTests.java | 8 +-- .../security/CallbacksSecurityTests.java | 6 +- .../beans/factory/xml/FactoryMethodTests.java | 8 +-- .../xml/UtilNamespaceHandlerTests.java | 10 +-- .../factory/xml/XmlBeanCollectionTests.java | 4 +- .../xml/XmlListableBeanFactoryTests.java | 4 +- .../cache/caffeine/CaffeineCacheTests.java | 4 +- .../target/CommonsPool2TargetSourceTests.java | 4 +- .../factory/xml/XmlBeanFactoryTests.java | 16 ++--- ...PrimitiveBeanLookupAndAutowiringTests.java | 10 +-- .../CachedExpressionEvaluatorTests.java | 5 +- .../MethodBasedEvaluationContextTests.java | 9 +-- ...ertySourcesPlaceholderConfigurerTests.java | 4 +- .../FormattingConversionServiceTests.java | 4 +- .../jndi/JndiLocatorDelegateTests.java | 4 +- .../ExecutorBeanDefinitionParserTests.java | 12 ++-- .../validation/DataBinderTests.java | 8 +-- .../core/GenericTypeResolverTests.java | 6 +- .../core/ReactiveAdapterRegistryTests.java | 8 +-- .../annotation/AnnotationAttributesTests.java | 6 +- .../DefaultConversionServiceTests.java | 40 ++++++------ .../GenericConversionServiceTests.java | 4 +- .../core/env/PropertySourceTests.java | 4 +- .../SystemEnvironmentPropertySourceTests.java | 62 +++++++++---------- .../core/io/PathResourceTests.java | 18 +++--- .../core/type/AnnotationMetadataTests.java | 4 +- .../util/PatternMatchUtilsTests.java | 6 +- .../util/StringUtilsTests.java | 32 +++++----- .../expression/spel/ExpressionStateTests.java | 8 +-- .../expression/spel/IndexingTests.java | 4 +- .../spel/SpelCompilationCoverageTests.java | 39 ++++++------ .../spel/standard/SpelCompilerTests.java | 7 ++- .../AbstractJmsAnnotationDrivenTests.java | 4 +- .../JmsListenerContainerFactoryTests.java | 16 ++--- .../jms/config/JmsNamespaceHandlerTests.java | 24 +++---- .../MethodJmsListenerEndpointTests.java | 5 +- .../DefaultMessageListenerContainerTests.java | 10 +-- .../JmsMessageEndpointManagerTests.java | 14 ++--- .../JmsMessageHeaderAccessorTests.java | 4 +- .../MessageBrokerConfigurationTests.java | 4 +- .../ExecutorSubscribableChannelTests.java | 10 +-- .../oxm/jaxb/Jaxb2MarshallerTests.java | 18 +++--- ...TestExecutionListenerIntegrationTests.java | 4 +- ...RegisterExtensionSpringExtensionTests.java | 4 +- .../junit/jupiter/SpringExtensionTests.java | 4 +- .../test/util/ReflectionTestUtilsTests.java | 10 +-- .../htmlunit/HtmlUnitRequestBuilderTests.java | 12 ++-- ...aTransactionManagerSerializationTests.java | 4 +- .../ServletWebRequestHttpMethodsTests.java | 6 +- .../CommonsMultipartResolverTests.java | 10 +-- .../web/util/UriComponentsBuilderTests.java | 6 +- .../reactive/config/CorsRegistryTests.java | 4 +- .../condition/RequestMappingInfoTests.java | 6 +- .../GlobalCorsConfigIntegrationTests.java | 4 +- .../view/script/ScriptTemplateViewTests.java | 9 +-- ...tationDrivenBeanDefinitionParserTests.java | 5 +- .../web/servlet/config/MvcNamespaceTests.java | 7 ++- .../config/annotation/CorsRegistryTests.java | 4 +- .../DelegatingWebMvcConfigurationTests.java | 8 +-- ...MvcConfigurationSupportExtensionTests.java | 5 +- .../i18n/CookieLocaleResolverTests.java | 8 +-- .../mvc/method/RequestMappingInfoTests.java | 6 +- ...ExtendedServletRequestDataBinderTests.java | 4 +- ...lAndViewMethodReturnValueHandlerTests.java | 4 +- .../RequestMappingHandlerAdapterTests.java | 4 +- .../json/MappingJackson2JsonViewTests.java | 4 +- .../view/script/ScriptTemplateViewTests.java | 9 +-- .../view/xml/MappingJackson2XmlViewTests.java | 4 +- .../view/xml/MarshallingViewTests.java | 6 +- ...essageBrokerBeanDefinitionParserTests.java | 5 +- ...essageBrokerConfigurationSupportTests.java | 5 +- .../client/ClientSockJsSessionTests.java | 12 ++-- 75 files changed, 345 insertions(+), 333 deletions(-) diff --git a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java index 16db4fc393a1..9062d6e3f615 100644 --- a/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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,7 +74,7 @@ void succeedsWhenSubclassProxyAndScheduledMethodNotPresentOnInterface() throws I MyRepository repository = ctx.getBean(MyRepository.class); CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class); - assertThat(AopUtils.isCglibProxy(repository)).isEqualTo(true); + assertThat(AopUtils.isCglibProxy(repository)).isTrue(); assertThat(repository.getInvocationCount()).isGreaterThan(0); assertThat(txManager.commits).isGreaterThan(0); } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java index 3a5ac3717127..95bd30cfb846 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -46,7 +46,7 @@ public void testCustomEnumWithNull() { GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnum", null); - assertThat(gb.getCustomEnum()).isEqualTo(null); + assertThat(gb.getCustomEnum()).isNull(); } @Test @@ -54,7 +54,7 @@ public void testCustomEnumWithEmptyString() { GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnum", ""); - assertThat(gb.getCustomEnum()).isEqualTo(null); + assertThat(gb.getCustomEnum()).isNull(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 8d6f823a7583..1617ccdf993f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -433,7 +433,7 @@ void nonStaticPrototypeFactoryMethodFoundByNonEagerTypeMatching() { assertThat(lbf.isTypeMatch("x1", Object.class)).isTrue(); assertThat(lbf.isTypeMatch("&x1", Object.class)).isFalse(); assertThat(lbf.getType("x1")).isEqualTo(TestBean.class); - assertThat(lbf.getType("&x1")).isEqualTo(null); + assertThat(lbf.getType("&x1")).isNull(); assertThat(TestBeanFactory.initialized).isFalse(); lbf.registerAlias("x1", "x2"); @@ -2622,8 +2622,8 @@ void initSecurityAwarePrototypeBean() { void containsBeanReturnsTrueEvenForAbstractBeanDefinition() { lbf.registerBeanDefinition("abs", BeanDefinitionBuilder .rootBeanDefinition(TestBean.class).setAbstract(true).getBeanDefinition()); - assertThat(lbf.containsBean("abs")).isEqualTo(true); - assertThat(lbf.containsBean("bogus")).isEqualTo(false); + assertThat(lbf.containsBean("abs")).isTrue(); + assertThat(lbf.containsBean("bogus")).isFalse(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index 5dd76865de42..29ecb68699be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -111,7 +111,7 @@ public void testPropertyOverrideConfigurer() { assertThat(tb1.getAge()).isEqualTo(99); assertThat(tb2.getAge()).isEqualTo(99); - assertThat(tb1.getName()).isEqualTo(null); + assertThat(tb1.getName()).isNull(); assertThat(tb2.getName()).isEqualTo("test"); } @@ -310,7 +310,7 @@ public void testPropertyOverrideConfigurerWithIgnoreInvalidKeys() { TestBean tb2 = (TestBean) factory.getBean("tb2"); assertThat(tb1.getAge()).isEqualTo(99); assertThat(tb2.getAge()).isEqualTo(99); - assertThat(tb1.getName()).isEqualTo(null); + assertThat(tb1.getName()).isNull(); assertThat(tb2.getName()).isEqualTo("test"); } @@ -423,7 +423,7 @@ private void doTestPropertyPlaceholderConfigurer(boolean parentChildSeparation) TestBean inner1 = (TestBean) tb2.getSomeMap().get("key3"); TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4"); assertThat(inner1.getAge()).isEqualTo(0); - assertThat(inner1.getName()).isEqualTo(null); + assertThat(inner1.getName()).isNull(); assertThat(inner1.getCountry()).isEqualTo(System.getProperty("os.name")); assertThat(inner2.getAge()).isEqualTo(98); assertThat(inner2.getName()).isEqualTo("namemyvarmyvar${"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java index 368e0b664725..a2bce0b763dd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -449,7 +449,7 @@ public void testTrustedExecution() throws Exception { public Object run() { // sanity check assertThat(getCurrentSubjectName()).isEqualTo("user1"); - assertThat(NonPrivilegedBean.destroyed).isEqualTo(false); + assertThat(NonPrivilegedBean.destroyed).isFalse(); beanFactory.getBean("trusted-spring-callbacks"); beanFactory.getBean("trusted-custom-init-destroy"); @@ -465,7 +465,7 @@ public Object run() { beanFactory.getBean("trusted-working-property-injection"); beanFactory.destroySingletons(); - assertThat(NonPrivilegedBean.destroyed).isEqualTo(true); + assertThat(NonPrivilegedBean.destroyed).isTrue(); return null; } }, provider.getAccessControlContext()); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java index d2f26ee0fe63..ced4e5098d8f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -100,17 +100,17 @@ public void testFactoryMethodsWithNullValue() { FactoryMethods fm = (FactoryMethods) xbf.getBean("fullWithNull"); assertThat(fm.getNum()).isEqualTo(27); - assertThat(fm.getName()).isEqualTo(null); + assertThat(fm.getName()).isNull(); assertThat(fm.getTestBean().getName()).isEqualTo("Juergen"); fm = (FactoryMethods) xbf.getBean("fullWithGenericNull"); assertThat(fm.getNum()).isEqualTo(27); - assertThat(fm.getName()).isEqualTo(null); + assertThat(fm.getName()).isNull(); assertThat(fm.getTestBean().getName()).isEqualTo("Juergen"); fm = (FactoryMethods) xbf.getBean("fullWithNamedNull"); assertThat(fm.getNum()).isEqualTo(27); - assertThat(fm.getName()).isEqualTo(null); + assertThat(fm.getName()).isNull(); assertThat(fm.getTestBean().getName()).isEqualTo("Juergen"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java index 2260a86c52e9..083d6f9de35e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -342,7 +342,7 @@ public void testNestedInConstructor() { public void testLoadProperties() { Properties props = (Properties) this.beanFactory.getBean("myProperties"); assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar"); - assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null); + assertThat(props.get("foo2")).as("Incorrect property value").isNull(); Properties props2 = (Properties) this.beanFactory.getBean("myProperties"); assertThat(props == props2).isTrue(); } @@ -351,17 +351,17 @@ public void testLoadProperties() { public void testScopedProperties() { Properties props = (Properties) this.beanFactory.getBean("myScopedProperties"); assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar"); - assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null); + assertThat(props.get("foo2")).as("Incorrect property value").isNull(); Properties props2 = (Properties) this.beanFactory.getBean("myScopedProperties"); assertThat(props.get("foo")).as("Incorrect property value").isEqualTo("bar"); - assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo(null); + assertThat(props.get("foo2")).as("Incorrect property value").isNull(); assertThat(props != props2).isTrue(); } @Test public void testLocalProperties() { Properties props = (Properties) this.beanFactory.getBean("myLocalProperties"); - assertThat(props.get("foo")).as("Incorrect property value").isEqualTo(null); + assertThat(props.get("foo")).as("Incorrect property value").isNull(); assertThat(props.get("foo2")).as("Incorrect property value").isEqualTo("bar2"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java index e44f0d9df7a0..b9c66fe39c84 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -283,7 +283,7 @@ public void testPopulatedSet() throws Exception { Iterator it = hasMap.getSet().iterator(); assertThat(it.next()).isEqualTo("bar"); assertThat(it.next()).isEqualTo(jenny); - assertThat(it.next()).isEqualTo(null); + assertThat(it.next()).isNull(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java index d48b55f2cb8d..4b5c005788da 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -181,7 +181,7 @@ public void autoAliasing() { assertThat(beanNames.contains("aliasWithoutId3")).isFalse(); TestBean tb4 = (TestBean) getBeanFactory().getBean(TestBean.class.getName() + "#0"); - assertThat(tb4.getName()).isEqualTo(null); + assertThat(tb4.getName()).isNull(); Map drs = getListableBeanFactory().getBeansOfType(DummyReferencer.class, false, false); assertThat(drs.size()).isEqualTo(5); diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java index 215720353304..7f760354d8b9 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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 @@ void testPutIfAbsentNullValue() { Cache.ValueWrapper wrapper = cache.putIfAbsent(key, "anotherValue"); // A value is set but is 'null' assertThat(wrapper).isNotNull(); - assertThat(wrapper.get()).isEqualTo(null); + assertThat(wrapper.get()).isNull(); // not changed assertThat(cache.get(key).get()).isEqualTo(value); } diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index 0cf766f253e9..6708435685c1 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -196,7 +196,7 @@ void testHitMaxSizeLoadedFromContext() throws Exception { void testSetWhenExhaustedAction() { CommonsPool2TargetSource targetSource = new CommonsPool2TargetSource(); targetSource.setBlockWhenExhausted(true); - assertThat(targetSource.isBlockWhenExhausted()).isEqualTo(true); + assertThat(targetSource.isBlockWhenExhausted()).isTrue(); } @Test diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index 6a9e9ede7473..13396f6628e2 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -876,7 +876,7 @@ void autowireByConstructor() { // should have been autowired assertThat(rod1.getSpouse1()).isEqualTo(kerry); assertThat(rod1.getAge()).isEqualTo(0); - assertThat(rod1.getName()).isEqualTo(null); + assertThat(rod1.getName()).isNull(); ConstructorDependenciesBean rod2 = (ConstructorDependenciesBean) xbf.getBean("rod2"); TestBean kerry1 = (TestBean) xbf.getBean("kerry1"); @@ -885,7 +885,7 @@ void autowireByConstructor() { assertThat(rod2.getSpouse1()).isEqualTo(kerry2); assertThat(rod2.getSpouse2()).isEqualTo(kerry1); assertThat(rod2.getAge()).isEqualTo(0); - assertThat(rod2.getName()).isEqualTo(null); + assertThat(rod2.getName()).isNull(); ConstructorDependenciesBean rod = (ConstructorDependenciesBean) xbf.getBean("rod3"); IndexedTestBean other = (IndexedTestBean) xbf.getBean("other"); @@ -894,7 +894,7 @@ void autowireByConstructor() { assertThat(rod.getSpouse2()).isEqualTo(kerry); assertThat(rod.getOther()).isEqualTo(other); assertThat(rod.getAge()).isEqualTo(0); - assertThat(rod.getName()).isEqualTo(null); + assertThat(rod.getName()).isNull(); xbf.getBean("rod4", ConstructorDependenciesBean.class); // should have been autowired @@ -902,7 +902,7 @@ void autowireByConstructor() { assertThat(rod.getSpouse2()).isEqualTo(kerry); assertThat(rod.getOther()).isEqualTo(other); assertThat(rod.getAge()).isEqualTo(0); - assertThat(rod.getName()).isEqualTo(null); + assertThat(rod.getName()).isNull(); } @Test @@ -929,7 +929,7 @@ void autowireByConstructorWithSimpleValues() { assertThat(rod6.getSpouse2()).isEqualTo(kerry1); assertThat(rod6.getOther()).isEqualTo(other); assertThat(rod6.getAge()).isEqualTo(0); - assertThat(rod6.getName()).isEqualTo(null); + assertThat(rod6.getName()).isNull(); xbf.destroySingletons(); assertThat(rod6.destroyed).isTrue(); @@ -967,7 +967,7 @@ void constructorArgResolution() { assertThat(rod9c.getAge()).isEqualTo(97); ConstructorDependenciesBean rod10 = (ConstructorDependenciesBean) xbf.getBean("rod10"); - assertThat(rod10.getName()).isEqualTo(null); + assertThat(rod10.getName()).isNull(); ConstructorDependenciesBean rod11 = (ConstructorDependenciesBean) xbf.getBean("rod11"); assertThat(rod11.getSpouse1()).isEqualTo(kerry2); @@ -1331,7 +1331,7 @@ void replaceMethodOverrideWithSetterInjection() { OverrideOneMethodSubclass ooms = (OverrideOneMethodSubclass) xbf.getBean("replaceVoidMethod"); DoSomethingReplacer dos = (DoSomethingReplacer) xbf.getBean("doSomethingReplacer"); - assertThat(dos.lastArg).isEqualTo(null); + assertThat(dos.lastArg).isNull(); String s1 = ""; String s2 = "foo bar black sheep"; ooms.doSomething(s1); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java index 31a2d7c631d7..a93a0437c4fb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -47,7 +47,7 @@ public class PrimitiveBeanLookupAndAutowiringTests { public void primitiveLookupByName() { ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class); boolean b = ctx.getBean("b", boolean.class); - assertThat(b).isEqualTo(true); + assertThat(b).isTrue(); int i = ctx.getBean("i", int.class); assertThat(i).isEqualTo(42); } @@ -56,7 +56,7 @@ public void primitiveLookupByName() { public void primitiveLookupByType() { ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class); boolean b = ctx.getBean(boolean.class); - assertThat(b).isEqualTo(true); + assertThat(b).isTrue(); int i = ctx.getBean(int.class); assertThat(i).isEqualTo(42); } @@ -65,7 +65,7 @@ public void primitiveLookupByType() { public void primitiveAutowiredInjection() { ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class, AutowiredComponent.class); - assertThat(ctx.getBean(AutowiredComponent.class).b).isEqualTo(true); + assertThat(ctx.getBean(AutowiredComponent.class).b).isTrue(); assertThat(ctx.getBean(AutowiredComponent.class).i).isEqualTo(42); } @@ -73,7 +73,7 @@ public void primitiveAutowiredInjection() { public void primitiveResourceInjection() { ApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class, ResourceComponent.class); - assertThat(ctx.getBean(ResourceComponent.class).b).isEqualTo(true); + assertThat(ctx.getBean(ResourceComponent.class).b).isTrue(); assertThat(ctx.getBean(ResourceComponent.class).i).isEqualTo(42); } diff --git a/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java b/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java index 1594137c0411..4069558efb0b 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -27,6 +27,7 @@ import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -43,7 +44,7 @@ public void parseNewExpression() { Method method = ReflectionUtils.findMethod(getClass(), "toString"); Expression expression = expressionEvaluator.getTestExpression("true", method, getClass()); hasParsedExpression("true"); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); assertThat(expressionEvaluator.testCache.size()).as("Expression should be in cache").isEqualTo(1); } diff --git a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java index de40c7dca4c3..f2f3b151de62 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -25,6 +25,7 @@ import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; /** * Unit tests for {@link MethodBasedEvaluationContext}. @@ -47,9 +48,9 @@ public void simpleArguments() { assertThat(context.lookupVariable("p0")).isEqualTo("test"); assertThat(context.lookupVariable("foo")).isEqualTo("test"); - assertThat(context.lookupVariable("a1")).isEqualTo(true); - assertThat(context.lookupVariable("p1")).isEqualTo(true); - assertThat(context.lookupVariable("flag")).isEqualTo(true); + assertThat(context.lookupVariable("a1")).asInstanceOf(BOOLEAN).isTrue(); + assertThat(context.lookupVariable("p1")).asInstanceOf(BOOLEAN).isTrue(); + assertThat(context.lookupVariable("flag")).asInstanceOf(BOOLEAN).isTrue(); assertThat(context.lookupVariable("a2")).isNull(); assertThat(context.lookupVariable("p2")).isNull(); diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index 8717dba116a5..bdb41244bdd5 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -345,7 +345,7 @@ public void multipleLocationsWithDefaultResolvedValue() throws Exception { .addPropertyValue("jedi", "${jedi:false}") .getBeanDefinition()); ppc.postProcessBeanFactory(bf); - assertThat(bf.getBean(TestBean.class).isJedi()).isEqualTo(true); + assertThat(bf.getBean(TestBean.class).isJedi()).isTrue(); } @Test diff --git a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java index 8aff305f22fa..360e6a88921f 100644 --- a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java +++ b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -281,7 +281,7 @@ public void parseNullPrimitiveProperty() { @Test public void printNullDefault() { assertThat(formattingService - .convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class))).isEqualTo(null); + .convert(null, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class))).isNull(); } @Test diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java index c3601d3b1a26..700860e11d6d 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public void isDefaultJndiEnvironmentAvailableFalse() throws Exception { builderField.set(null, null); try { - assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()).isEqualTo(false); + assertThat(JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()).isFalse(); } finally { builderField.set(null, oldBuilder); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java index a52f768abdcb..8dbae46f7776 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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,7 +57,7 @@ public void defaultExecutor() throws Exception { assertThat(getMaxPoolSize(executor)).isEqualTo(Integer.MAX_VALUE); assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE); assertThat(getKeepAliveSeconds(executor)).isEqualTo(60); - assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false); + assertThat(getAllowCoreThreadTimeOut(executor)).isFalse(); FutureTask task = new FutureTask<>(new Callable() { @Override @@ -96,7 +96,7 @@ public void rangeWithUnboundedQueue() { assertThat(getCorePoolSize(executor)).isEqualTo(9); assertThat(getMaxPoolSize(executor)).isEqualTo(9); assertThat(getKeepAliveSeconds(executor)).isEqualTo(37); - assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(true); + assertThat(getAllowCoreThreadTimeOut(executor)).isTrue(); assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE); } @@ -106,7 +106,7 @@ public void propertyPlaceholderWithSingleSize() { assertThat(getCorePoolSize(executor)).isEqualTo(123); assertThat(getMaxPoolSize(executor)).isEqualTo(123); assertThat(getKeepAliveSeconds(executor)).isEqualTo(60); - assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false); + assertThat(getAllowCoreThreadTimeOut(executor)).isFalse(); assertThat(getQueueCapacity(executor)).isEqualTo(Integer.MAX_VALUE); } @@ -115,7 +115,7 @@ public void propertyPlaceholderWithRange() { Object executor = this.context.getBean("propertyPlaceholderWithRange"); assertThat(getCorePoolSize(executor)).isEqualTo(5); assertThat(getMaxPoolSize(executor)).isEqualTo(25); - assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(false); + assertThat(getAllowCoreThreadTimeOut(executor)).isFalse(); assertThat(getQueueCapacity(executor)).isEqualTo(10); } @@ -124,7 +124,7 @@ public void propertyPlaceholderWithRangeAndCoreThreadTimeout() { Object executor = this.context.getBean("propertyPlaceholderWithRangeAndCoreThreadTimeout"); assertThat(getCorePoolSize(executor)).isEqualTo(99); assertThat(getMaxPoolSize(executor)).isEqualTo(99); - assertThat(getAllowCoreThreadTimeOut(executor)).isEqualTo(true); + assertThat(getAllowCoreThreadTimeOut(executor)).isTrue(); } @Test diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index a820d40a6a43..3d39e2ecd309 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -1242,7 +1242,7 @@ void testValidatorWithErrors() { assertThat(errors.getFieldError("name").getCodes()[2]).isEqualTo("NOT_ROD.java.lang.String"); assertThat(errors.getFieldError("name").getCodes()[3]).isEqualTo("NOT_ROD"); assertThat((errors.getFieldErrors("name").get(0)).getField()).isEqualTo("name"); - assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isEqualTo(null); + assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isNull(); assertThat(errors.hasFieldErrors("spouse.age")).isTrue(); assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1); @@ -1314,7 +1314,7 @@ void testValidatorWithErrorsAndCodesPrefix() { assertThat(errors.getFieldError("name").getCodes()[2]).isEqualTo("validation.NOT_ROD.java.lang.String"); assertThat(errors.getFieldError("name").getCodes()[3]).isEqualTo("validation.NOT_ROD"); assertThat((errors.getFieldErrors("name").get(0)).getField()).isEqualTo("name"); - assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isEqualTo(null); + assertThat((errors.getFieldErrors("name").get(0)).getRejectedValue()).isNull(); assertThat(errors.hasFieldErrors("spouse.age")).isTrue(); assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1); @@ -1339,7 +1339,7 @@ void testValidatorWithNestedObjectNull() { assertThat(errors.getFieldErrorCount("spouse")).isEqualTo(1); assertThat(errors.getFieldError("spouse").getCode()).isEqualTo("SPOUSE_NOT_AVAILABLE"); assertThat((errors.getFieldErrors("spouse").get(0)).getObjectName()).isEqualTo("tb"); - assertThat((errors.getFieldErrors("spouse").get(0)).getRejectedValue()).isEqualTo(null); + assertThat((errors.getFieldErrors("spouse").get(0)).getRejectedValue()).isNull(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 21e1d73cbe82..80eee82c8454 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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 @@ void nullIfNotResolvable() { void methodReturnTypes() { assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)).isEqualTo(Integer.class); assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)).isEqualTo(String.class); - assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isEqualTo(null); - assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)).isEqualTo(null); + assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isNull(); + assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class)).isNull(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java b/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java index 25269a4c40fa..35683ac0cbee 100644 --- a/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java +++ b/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -370,9 +370,9 @@ void defaultAdapterRegistrations() { @Test void deferred() { - assertThat(getAdapter(CompletableFuture.class).getDescriptor().isDeferred()).isEqualTo(false); - assertThat(getAdapter(Deferred.class).getDescriptor().isDeferred()).isEqualTo(true); - assertThat(getAdapter(kotlinx.coroutines.flow.Flow.class).getDescriptor().isDeferred()).isEqualTo(true); + assertThat(getAdapter(CompletableFuture.class).getDescriptor().isDeferred()).isFalse(); + assertThat(getAdapter(Deferred.class).getDescriptor().isDeferred()).isTrue(); + assertThat(getAdapter(kotlinx.coroutines.flow.Flow.class).getDescriptor().isDeferred()).isTrue(); } } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java index 4d99c42d9ed2..415e89b979bf 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,8 +60,8 @@ void typeSafeAttributeAccess() { assertThat(attributes.getString("name")).isEqualTo("dave"); assertThat(attributes.getStringArray("names")).isEqualTo(new String[] {"dave", "frank", "hal"}); - assertThat(attributes.getBoolean("bool1")).isEqualTo(true); - assertThat(attributes.getBoolean("bool2")).isEqualTo(false); + assertThat(attributes.getBoolean("bool1")).isTrue(); + assertThat(attributes.getBoolean("bool2")).isFalse(); assertThat(attributes.getEnum("color")).isEqualTo(Color.RED); assertThat(attributes.getClass("class").equals(Integer.class)).isTrue(); assertThat(attributes.getClassArray("classes")).isEqualTo(new Class[] {Number.class, Short.class, Integer.class}); diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java index a538c8da76aa..058a72adf3bf 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -79,7 +79,7 @@ void stringToCharacter() { @Test void stringToCharacterEmptyString() { - assertThat(conversionService.convert("", Character.class)).isEqualTo(null); + assertThat(conversionService.convert("", Character.class)).isNull(); } @Test @@ -95,29 +95,29 @@ void characterToString() { @Test void stringToBooleanTrue() { - assertThat(conversionService.convert("true", Boolean.class)).isEqualTo(true); - assertThat(conversionService.convert("on", Boolean.class)).isEqualTo(true); - assertThat(conversionService.convert("yes", Boolean.class)).isEqualTo(true); - assertThat(conversionService.convert("1", Boolean.class)).isEqualTo(true); - assertThat(conversionService.convert("TRUE", Boolean.class)).isEqualTo(true); - assertThat(conversionService.convert("ON", Boolean.class)).isEqualTo(true); - assertThat(conversionService.convert("YES", Boolean.class)).isEqualTo(true); + assertThat(conversionService.convert("true", Boolean.class)).isTrue(); + assertThat(conversionService.convert("on", Boolean.class)).isTrue(); + assertThat(conversionService.convert("yes", Boolean.class)).isTrue(); + assertThat(conversionService.convert("1", Boolean.class)).isTrue(); + assertThat(conversionService.convert("TRUE", Boolean.class)).isTrue(); + assertThat(conversionService.convert("ON", Boolean.class)).isTrue(); + assertThat(conversionService.convert("YES", Boolean.class)).isTrue(); } @Test void stringToBooleanFalse() { - assertThat(conversionService.convert("false", Boolean.class)).isEqualTo(false); - assertThat(conversionService.convert("off", Boolean.class)).isEqualTo(false); - assertThat(conversionService.convert("no", Boolean.class)).isEqualTo(false); - assertThat(conversionService.convert("0", Boolean.class)).isEqualTo(false); - assertThat(conversionService.convert("FALSE", Boolean.class)).isEqualTo(false); - assertThat(conversionService.convert("OFF", Boolean.class)).isEqualTo(false); - assertThat(conversionService.convert("NO", Boolean.class)).isEqualTo(false); + assertThat(conversionService.convert("false", Boolean.class)).isFalse(); + assertThat(conversionService.convert("off", Boolean.class)).isFalse(); + assertThat(conversionService.convert("no", Boolean.class)).isFalse(); + assertThat(conversionService.convert("0", Boolean.class)).isFalse(); + assertThat(conversionService.convert("FALSE", Boolean.class)).isFalse(); + assertThat(conversionService.convert("OFF", Boolean.class)).isFalse(); + assertThat(conversionService.convert("NO", Boolean.class)).isFalse(); } @Test void stringToBooleanEmptyString() { - assertThat(conversionService.convert("", Boolean.class)).isEqualTo(null); + assertThat(conversionService.convert("", Boolean.class)).isNull(); } @Test @@ -219,7 +219,7 @@ void stringToNumber() { @Test void stringToNumberEmptyString() { - assertThat(conversionService.convert("", Number.class)).isEqualTo(null); + assertThat(conversionService.convert("", Number.class)).isNull(); } @Test @@ -234,7 +234,7 @@ void stringToEnumWithSubclass() { @Test void stringToEnumEmptyString() { - assertThat(conversionService.convert("", Foo.class)).isEqualTo(null); + assertThat(conversionService.convert("", Foo.class)).isNull(); } @Test @@ -254,7 +254,7 @@ void integerToEnumWithSubclass() { @Test void integerToEnumNull() { - assertThat(conversionService.convert(null, Foo.class)).isEqualTo(null); + assertThat(conversionService.convert(null, Foo.class)).isNull(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index 304dcb15374b..1dbc0a23a2f4 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,7 +109,7 @@ void convert() { @Test void convertNullSource() { - assertThat(conversionService.convert(null, Integer.class)).isEqualTo(null); + assertThat(conversionService.convert(null, Integer.class)).isNull(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index 1a7bed2d053a..11f90d5b8cf5 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -79,7 +79,7 @@ void collectionsOperations() { PropertySource ps1 = new MapPropertySource("ps1", map1); ps1.getSource(); List> propertySources = new ArrayList<>(); - assertThat(propertySources.add(ps1)).isEqualTo(true); + assertThat(propertySources.add(ps1)).isTrue(); assertThat(propertySources.contains(ps1)).isTrue(); assertThat(propertySources.contains(PropertySource.named("ps1"))).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java index daca3a701318..5dac076f21c1 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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 @@ void setUp() { @Test void none() { - assertThat(ps.containsProperty("a.key")).isEqualTo(false); + assertThat(ps.containsProperty("a.key")).isFalse(); assertThat(ps.getProperty("a.key")).isNull(); } @@ -58,7 +58,7 @@ void none() { void normalWithoutPeriod() { envMap.put("akey", "avalue"); - assertThat(ps.containsProperty("akey")).isEqualTo(true); + assertThat(ps.containsProperty("akey")).isTrue(); assertThat(ps.getProperty("akey")).isEqualTo("avalue"); } @@ -66,7 +66,7 @@ void normalWithoutPeriod() { void normalWithPeriod() { envMap.put("a.key", "a.value"); - assertThat(ps.containsProperty("a.key")).isEqualTo(true); + assertThat(ps.containsProperty("a.key")).isTrue(); assertThat(ps.getProperty("a.key")).isEqualTo("a.value"); } @@ -74,8 +74,8 @@ void normalWithPeriod() { void withUnderscore() { envMap.put("a_key", "a_value"); - assertThat(ps.containsProperty("a_key")).isEqualTo(true); - assertThat(ps.containsProperty("a.key")).isEqualTo(true); + assertThat(ps.containsProperty("a_key")).isTrue(); + assertThat(ps.containsProperty("a.key")).isTrue(); assertThat(ps.getProperty("a_key")).isEqualTo("a_value"); assertThat( ps.getProperty("a.key")).isEqualTo("a_value"); @@ -97,30 +97,30 @@ void withUppercase() { envMap.put("A_DOT.KEY", "a_dot_value"); envMap.put("A_HYPHEN-KEY", "a_hyphen_value"); - assertThat(ps.containsProperty("A_KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("a_key")).isEqualTo(true); - assertThat(ps.containsProperty("a.key")).isEqualTo(true); - assertThat(ps.containsProperty("a-key")).isEqualTo(true); - assertThat(ps.containsProperty("A_LONG_KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.LONG.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-LONG-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.LONG-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-LONG.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A_long_KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.long.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-long-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.long-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-long.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A_DOT.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-DOT.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A_dot.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A-dot.KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A_HYPHEN-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.HYPHEN-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A_hyphen-KEY")).isEqualTo(true); - assertThat(ps.containsProperty("A.hyphen-KEY")).isEqualTo(true); + assertThat(ps.containsProperty("A_KEY")).isTrue(); + assertThat(ps.containsProperty("A.KEY")).isTrue(); + assertThat(ps.containsProperty("A-KEY")).isTrue(); + assertThat(ps.containsProperty("a_key")).isTrue(); + assertThat(ps.containsProperty("a.key")).isTrue(); + assertThat(ps.containsProperty("a-key")).isTrue(); + assertThat(ps.containsProperty("A_LONG_KEY")).isTrue(); + assertThat(ps.containsProperty("A.LONG.KEY")).isTrue(); + assertThat(ps.containsProperty("A-LONG-KEY")).isTrue(); + assertThat(ps.containsProperty("A.LONG-KEY")).isTrue(); + assertThat(ps.containsProperty("A-LONG.KEY")).isTrue(); + assertThat(ps.containsProperty("A_long_KEY")).isTrue(); + assertThat(ps.containsProperty("A.long.KEY")).isTrue(); + assertThat(ps.containsProperty("A-long-KEY")).isTrue(); + assertThat(ps.containsProperty("A.long-KEY")).isTrue(); + assertThat(ps.containsProperty("A-long.KEY")).isTrue(); + assertThat(ps.containsProperty("A_DOT.KEY")).isTrue(); + assertThat(ps.containsProperty("A-DOT.KEY")).isTrue(); + assertThat(ps.containsProperty("A_dot.KEY")).isTrue(); + assertThat(ps.containsProperty("A-dot.KEY")).isTrue(); + assertThat(ps.containsProperty("A_HYPHEN-KEY")).isTrue(); + assertThat(ps.containsProperty("A.HYPHEN-KEY")).isTrue(); + assertThat(ps.containsProperty("A_hyphen-KEY")).isTrue(); + assertThat(ps.containsProperty("A.hyphen-KEY")).isTrue(); assertThat(ps.getProperty("A_KEY")).isEqualTo("a_value"); assertThat(ps.getProperty("A.KEY")).isEqualTo("a_value"); @@ -170,7 +170,7 @@ protected boolean isSecurityManagerPresent() { } }; - assertThat(ps.containsProperty("A_KEY")).isEqualTo(true); + assertThat(ps.containsProperty("A_KEY")).isTrue(); assertThat(ps.getProperty("A_KEY")).isEqualTo("a_value"); } diff --git a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java index 59761c1d628d..be5e54e7e970 100644 --- a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,37 +124,37 @@ void getPathForDir() { @Test void fileExists() { PathResource resource = new PathResource(TEST_FILE); - assertThat(resource.exists()).isEqualTo(true); + assertThat(resource.exists()).isTrue(); } @Test void dirExists() { PathResource resource = new PathResource(TEST_DIR); - assertThat(resource.exists()).isEqualTo(true); + assertThat(resource.exists()).isTrue(); } @Test void fileDoesNotExist() { PathResource resource = new PathResource(NON_EXISTING_FILE); - assertThat(resource.exists()).isEqualTo(false); + assertThat(resource.exists()).isFalse(); } @Test void fileIsReadable() { PathResource resource = new PathResource(TEST_FILE); - assertThat(resource.isReadable()).isEqualTo(true); + assertThat(resource.isReadable()).isTrue(); } @Test void doesNotExistIsNotReadable() { PathResource resource = new PathResource(NON_EXISTING_FILE); - assertThat(resource.isReadable()).isEqualTo(false); + assertThat(resource.isReadable()).isFalse(); } @Test void directoryIsNotReadable() { PathResource resource = new PathResource(TEST_DIR); - assertThat(resource.isReadable()).isEqualTo(false); + assertThat(resource.isReadable()).isFalse(); } @Test @@ -256,13 +256,13 @@ void description() { @Test void fileIsWritable() { PathResource resource = new PathResource(TEST_FILE); - assertThat(resource.isWritable()).isEqualTo(true); + assertThat(resource.isWritable()).isTrue(); } @Test void directoryIsNotWritable() { PathResource resource = new PathResource(TEST_DIR); - assertThat(resource.isWritable()).isEqualTo(false); + assertThat(resource.isWritable()).isFalse(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index f1342883bca0..b52d23405343 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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 @@ private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata, boolean a assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), false)).isNull(); assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), true)).isNull(); assertThat(metadata.getAnnotatedMethods(DirectAnnotation.class.getName()).size()).isEqualTo(0); - assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isEqualTo(false); + assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isFalse(); assertThat(metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName())).isNull(); } diff --git a/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java b/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java index 7a42db56fe28..a96f21b0d3f1 100644 --- a/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -28,8 +28,8 @@ class PatternMatchUtilsTests { @Test void trivial() { - assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isEqualTo(false); - assertThat(PatternMatchUtils.simpleMatch("1", null)).isEqualTo(false); + assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isFalse(); + assertThat(PatternMatchUtils.simpleMatch("1", null)).isFalse(); doTest("*", "123", true); doTest("123", "123", true); } diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java index 73c679ae960e..eaa318b59e9a 100644 --- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java @@ -37,18 +37,18 @@ class StringUtilsTests { @Test void hasTextBlank() { String blank = " "; - assertThat(StringUtils.hasText(blank)).isEqualTo(false); + assertThat(StringUtils.hasText(blank)).isFalse(); } @Test void hasTextNullEmpty() { - assertThat(StringUtils.hasText(null)).isEqualTo(false); - assertThat(StringUtils.hasText("")).isEqualTo(false); + assertThat(StringUtils.hasText(null)).isFalse(); + assertThat(StringUtils.hasText("")).isFalse(); } @Test void hasTextValid() { - assertThat(StringUtils.hasText("t")).isEqualTo(true); + assertThat(StringUtils.hasText("t")).isTrue(); } @Test @@ -68,7 +68,7 @@ void containsWhitespace() { @Test void trimWhitespace() { - assertThat(StringUtils.trimWhitespace(null)).isEqualTo(null); + assertThat(StringUtils.trimWhitespace(null)).isNull(); assertThat(StringUtils.trimWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimWhitespace(" ")).isEqualTo(""); assertThat(StringUtils.trimWhitespace("\t")).isEqualTo(""); @@ -83,7 +83,7 @@ void trimWhitespace() { @Test void trimAllWhitespace() { - assertThat(StringUtils.trimAllWhitespace(null)).isEqualTo(null); + assertThat(StringUtils.trimAllWhitespace(null)).isNull(); assertThat(StringUtils.trimAllWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimAllWhitespace(" ")).isEqualTo(""); assertThat(StringUtils.trimAllWhitespace("\t")).isEqualTo(""); @@ -98,7 +98,7 @@ void trimAllWhitespace() { @Test void trimLeadingWhitespace() { - assertThat(StringUtils.trimLeadingWhitespace(null)).isEqualTo(null); + assertThat(StringUtils.trimLeadingWhitespace(null)).isNull(); assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimLeadingWhitespace(" ")).isEqualTo(""); assertThat(StringUtils.trimLeadingWhitespace("\t")).isEqualTo(""); @@ -113,7 +113,7 @@ void trimLeadingWhitespace() { @Test void trimTrailingWhitespace() { - assertThat(StringUtils.trimTrailingWhitespace(null)).isEqualTo(null); + assertThat(StringUtils.trimTrailingWhitespace(null)).isNull(); assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimTrailingWhitespace(" ")).isEqualTo(""); assertThat(StringUtils.trimTrailingWhitespace("\t")).isEqualTo(""); @@ -128,7 +128,7 @@ void trimTrailingWhitespace() { @Test void trimLeadingCharacter() { - assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isEqualTo(null); + assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isNull(); assertThat(StringUtils.trimLeadingCharacter("", ' ')).isEqualTo(""); assertThat(StringUtils.trimLeadingCharacter(" ", ' ')).isEqualTo(""); assertThat(StringUtils.trimLeadingCharacter("\t", ' ')).isEqualTo("\t"); @@ -141,7 +141,7 @@ void trimLeadingCharacter() { @Test void trimTrailingCharacter() { - assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isEqualTo(null); + assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isNull(); assertThat(StringUtils.trimTrailingCharacter("", ' ')).isEqualTo(""); assertThat(StringUtils.trimTrailingCharacter(" ", ' ')).isEqualTo(""); assertThat(StringUtils.trimTrailingCharacter("\t", ' ')).isEqualTo("\t"); @@ -340,7 +340,7 @@ void uncapitalize() { @Test void getFilename() { - assertThat(StringUtils.getFilename(null)).isEqualTo(null); + assertThat(StringUtils.getFilename(null)).isNull(); assertThat(StringUtils.getFilename("")).isEqualTo(""); assertThat(StringUtils.getFilename("myfile")).isEqualTo("myfile"); assertThat(StringUtils.getFilename("mypath/myfile")).isEqualTo("myfile"); @@ -352,11 +352,11 @@ void getFilename() { @Test void getFilenameExtension() { - assertThat(StringUtils.getFilenameExtension(null)).isEqualTo(null); - assertThat(StringUtils.getFilenameExtension("")).isEqualTo(null); - assertThat(StringUtils.getFilenameExtension("myfile")).isEqualTo(null); - assertThat(StringUtils.getFilenameExtension("myPath/myfile")).isEqualTo(null); - assertThat(StringUtils.getFilenameExtension("/home/user/.m2/settings/myfile")).isEqualTo(null); + assertThat(StringUtils.getFilenameExtension(null)).isNull(); + assertThat(StringUtils.getFilenameExtension("")).isNull(); + assertThat(StringUtils.getFilenameExtension("myfile")).isNull(); + assertThat(StringUtils.getFilenameExtension("myPath/myfile")).isNull(); + assertThat(StringUtils.getFilenameExtension("/home/user/.m2/settings/myfile")).isNull(); assertThat(StringUtils.getFilenameExtension("myfile.")).isEqualTo(""); assertThat(StringUtils.getFilenameExtension("myPath/myfile.")).isEqualTo(""); assertThat(StringUtils.getFilenameExtension("myfile.txt")).isEqualTo("txt"); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java index a789b20560e6..bb318afa1f1d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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,7 +64,7 @@ public void testLocalVariables() { state.setLocalVariable("foo", null); value = state.lookupLocalVariable("foo"); - assertThat(value).isEqualTo(null); + assertThat(value).isNull(); } @Test @@ -101,7 +101,7 @@ public void testNoVariableInterference() { @Test public void testLocalVariableNestedScopes() { ExpressionState state = getState(); - assertThat(state.lookupLocalVariable("foo")).isEqualTo(null); + assertThat(state.lookupLocalVariable("foo")).isNull(); state.setLocalVariable("foo",12); assertThat(state.lookupLocalVariable("foo")).isEqualTo(12); @@ -134,7 +134,7 @@ public void testRootContextObject() { ((StandardEvaluationContext) state.getEvaluationContext()).setRootObject(null); - assertThat(state.getRootContextObject().getValue()).isEqualTo(null); + assertThat(state.getRootContextObject().getValue()).isNull(); } @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java index 69bfa4fb4f4c..6afcf60d1f18 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -150,7 +150,7 @@ void setPropertyContainingMapAutoGrow() { assertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.Map"); assertThat(expression.getValue(this)).isEqualTo(property); expression = parser.parseExpression("parameterizedMap['9']"); - assertThat(expression.getValue(this)).isEqualTo(null); + assertThat(expression.getValue(this)).isNull(); expression.setValue(this, "37"); assertThat(expression.getValue(this)).isEqualTo(37); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java index 49fa8c182c44..60087a172958 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.within; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; /** * Checks SpelCompiler behavior. This should cover compilation all compiled node types. @@ -198,9 +199,9 @@ void typeReference() { @Test void operatorInstanceOf() { expression = parse("'xyz' instanceof T(String)"); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); expression = parse("'xyz' instanceof T(Integer)"); assertThat(expression.getValue()).isEqualTo(false); @@ -209,21 +210,21 @@ void operatorInstanceOf() { List list = new ArrayList<>(); expression = parse("#root instanceof T(java.util.List)"); - assertThat(expression.getValue(list)).isEqualTo(true); + assertThat(expression.getValue(list)).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue(list)).isEqualTo(true); + assertThat(expression.getValue(list)).asInstanceOf(BOOLEAN).isTrue(); List[] arrayOfLists = new List[] {new ArrayList()}; expression = parse("#root instanceof T(java.util.List[])"); - assertThat(expression.getValue(arrayOfLists)).isEqualTo(true); + assertThat(expression.getValue(arrayOfLists)).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue(arrayOfLists)).isEqualTo(true); + assertThat(expression.getValue(arrayOfLists)).asInstanceOf(BOOLEAN).isTrue(); int[] intArray = new int[] {1,2,3}; expression = parse("#root instanceof T(int[])"); - assertThat(expression.getValue(intArray)).isEqualTo(true); + assertThat(expression.getValue(intArray)).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue(intArray)).isEqualTo(true); + assertThat(expression.getValue(intArray)).asInstanceOf(BOOLEAN).isTrue(); String root = null; expression = parse("#root instanceof T(Integer)"); @@ -239,18 +240,18 @@ void operatorInstanceOf() { root = "howdy!"; expression = parse("#root instanceof T(java.lang.Object)"); - assertThat(expression.getValue(root)).isEqualTo(true); + assertThat(expression.getValue(root)).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue(root)).isEqualTo(true); + assertThat(expression.getValue(root)).asInstanceOf(BOOLEAN).isTrue(); } @Test void operatorInstanceOf_SPR14250() throws Exception { // primitive left operand - should get boxed, return true expression = parse("3 instanceof T(Integer)"); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); // primitive left operand - should get boxed, return false expression = parse("3 instanceof T(String)"); @@ -266,9 +267,9 @@ void operatorInstanceOf_SPR14250() throws Exception { // double slot left operand - should get boxed, return true expression = parse("3.0d instanceof T(Double)"); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); // Only when the right hand operand is a direct type reference // will it be compilable. @@ -646,9 +647,9 @@ public void operatorNot() throws Exception { assertThat(expression.getValue()).isEqualTo(false); expression = parse("!false"); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue()).isEqualTo(true); + assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue(); boolean b = true; expression = parse("!#root"); @@ -658,9 +659,9 @@ public void operatorNot() throws Exception { b = false; expression = parse("!#root"); - assertThat(expression.getValue(b)).isEqualTo(true); + assertThat(expression.getValue(b)).asInstanceOf(BOOLEAN).isTrue(); assertCanCompile(expression); - assertThat(expression.getValue(b)).isEqualTo(true); + assertThat(expression.getValue(b)).asInstanceOf(BOOLEAN).isTrue(); } @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java index c230151d562f..5046f58189aa 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelCompilerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -28,6 +28,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; /** * Tests for the {@link SpelCompiler}. @@ -69,10 +70,10 @@ void defaultMethodInvocation() { context.setVariable("user", new User()); expression = parser.parseExpression("#root.isEditable(#user)"); assertThat(SpelCompiler.compile(expression)).isFalse(); - assertThat(expression.getValue(context)).isEqualTo(true); + assertThat(expression.getValue(context)).asInstanceOf(BOOLEAN).isTrue(); assertThat(SpelCompiler.compile(expression)).isTrue(); SpelCompilationCoverageTests.assertIsCompiled(expression); - assertThat(expression.getValue(context)).isEqualTo(true); + assertThat(expression.getValue(context)).asInstanceOf(BOOLEAN).isTrue(); } diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java index d0986f527dcd..0bd41eb7ee27 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -189,7 +189,7 @@ protected void testJmsListenerRepeatable(ApplicationContext context) { simpleFactory.getListenerContainer("first").getEndpoint(); assertThat(first.getId()).isEqualTo("first"); assertThat(first.getDestination()).isEqualTo("myQueue"); - assertThat(first.getConcurrency()).isEqualTo(null); + assertThat(first.getConcurrency()).isNull(); MethodJmsListenerEndpoint second = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainer("second").getEndpoint(); diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java index 865a0edc08fe..30c054b57158 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -179,14 +179,14 @@ private void assertDefaultJmsConfig(AbstractMessageListenerContainer container) assertThat(container.getConnectionFactory()).isEqualTo(this.connectionFactory); assertThat(container.getDestinationResolver()).isEqualTo(this.destinationResolver); assertThat(container.getMessageConverter()).isEqualTo(this.messageConverter); - assertThat(container.isSessionTransacted()).isEqualTo(true); + assertThat(container.isSessionTransacted()).isTrue(); assertThat(container.getSessionAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE); - assertThat(container.isPubSubDomain()).isEqualTo(true); - assertThat(container.isReplyPubSubDomain()).isEqualTo(true); + assertThat(container.isPubSubDomain()).isTrue(); + assertThat(container.isReplyPubSubDomain()).isTrue(); assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000)); - assertThat(container.isSubscriptionDurable()).isEqualTo(true); + assertThat(container.isSubscriptionDurable()).isTrue(); assertThat(container.getClientId()).isEqualTo("client-1234"); - assertThat(container.isAutoStartup()).isEqualTo(false); + assertThat(container.isAutoStartup()).isFalse(); } private void setDefaultJcaConfig(DefaultJcaListenerContainerFactory factory) { @@ -206,9 +206,9 @@ private void assertDefaultJcaConfig(JmsMessageEndpointManager container) { JmsActivationSpecConfig config = container.getActivationSpecConfig(); assertThat(config).isNotNull(); assertThat(config.getAcknowledgeMode()).isEqualTo(Session.DUPS_OK_ACKNOWLEDGE); - assertThat(config.isPubSubDomain()).isEqualTo(true); + assertThat(config.isPubSubDomain()).isTrue(); assertThat(container.getReplyQosSettings()).isEqualTo(new QosSettings(1, 7, 5000)); - assertThat(config.isSubscriptionDurable()).isEqualTo(true); + assertThat(config.isSubscriptionDurable()).isTrue(); assertThat(config.getClientId()).isEqualTo("client-1234"); } diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java index 43b9a1a6ca58..3453a23ad375 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -145,8 +145,8 @@ public void testJmsContainerFactoryConfiguration() { assertThat(container.getConnectionFactory()).as("explicit connection factory not set").isEqualTo(context.getBean(EXPLICIT_CONNECTION_FACTORY)); assertThat(container.getDestinationResolver()).as("explicit destination resolver not set").isEqualTo(context.getBean("testDestinationResolver")); assertThat(container.getMessageConverter()).as("explicit message converter not set").isEqualTo(context.getBean("testMessageConverter")); - assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isEqualTo(true); - assertThat(container.isSubscriptionDurable()).as("Wrong durable flag").isEqualTo(true); + assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isTrue(); + assertThat(container.isSubscriptionDurable()).as("Wrong durable flag").isTrue(); assertThat(container.getCacheLevel()).as("wrong cache").isEqualTo(DefaultMessageListenerContainer.CACHE_CONNECTION); assertThat(container.getConcurrentConsumers()).as("wrong concurrency").isEqualTo(3); assertThat(container.getMaxConcurrentConsumers()).as("wrong concurrency").isEqualTo(5); @@ -166,7 +166,7 @@ public void testJcaContainerFactoryConfiguration() { factory.createListenerContainer(createDummyEndpoint()); assertThat(container.getResourceAdapter()).as("explicit resource adapter not set").isEqualTo(context.getBean("testResourceAdapter")); assertThat(container.getActivationSpecConfig().getMessageConverter()).as("explicit message converter not set").isEqualTo(context.getBean("testMessageConverter")); - assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isEqualTo(true); + assertThat(container.isPubSubDomain()).as("Wrong pub/sub").isTrue(); assertThat(container.getActivationSpecConfig().getMaxConcurrency()).as("wrong concurrency").isEqualTo(5); assertThat(container.getActivationSpecConfig().getPrefetchSize()).as("Wrong prefetch").isEqualTo(50); assertThat(container.getPhase()).as("Wrong phase").isEqualTo(77); @@ -248,20 +248,20 @@ public void testResponseDestination() { .getBean("listener1", DefaultMessageListenerContainer.class); DefaultMessageListenerContainer listener2 = this.context .getBean("listener2", DefaultMessageListenerContainer.class); - assertThat(listener1.isPubSubDomain()).as("Wrong destination type on listener1").isEqualTo(true); - assertThat(listener2.isPubSubDomain()).as("Wrong destination type on listener2").isEqualTo(true); - assertThat(listener1.isReplyPubSubDomain()).as("Wrong response destination type on listener1").isEqualTo(false); - assertThat(listener2.isReplyPubSubDomain()).as("Wrong response destination type on listener2").isEqualTo(false); + assertThat(listener1.isPubSubDomain()).as("Wrong destination type on listener1").isTrue(); + assertThat(listener2.isPubSubDomain()).as("Wrong destination type on listener2").isTrue(); + assertThat(listener1.isReplyPubSubDomain()).as("Wrong response destination type on listener1").isFalse(); + assertThat(listener2.isReplyPubSubDomain()).as("Wrong response destination type on listener2").isFalse(); // JCA JmsMessageEndpointManager listener3 = this.context .getBean("listener3", JmsMessageEndpointManager.class); JmsMessageEndpointManager listener4 = this.context .getBean("listener4", JmsMessageEndpointManager.class); - assertThat(listener3.isPubSubDomain()).as("Wrong destination type on listener3").isEqualTo(true); - assertThat(listener4.isPubSubDomain()).as("Wrong destination type on listener4").isEqualTo(true); - assertThat(listener3.isReplyPubSubDomain()).as("Wrong response destination type on listener3").isEqualTo(false); - assertThat(listener4.isReplyPubSubDomain()).as("Wrong response destination type on listener4").isEqualTo(false); + assertThat(listener3.isPubSubDomain()).as("Wrong destination type on listener3").isTrue(); + assertThat(listener4.isPubSubDomain()).as("Wrong destination type on listener4").isTrue(); + assertThat(listener3.isReplyPubSubDomain()).as("Wrong response destination type on listener3").isFalse(); + assertThat(listener4.isReplyPubSubDomain()).as("Wrong response destination type on listener4").isFalse(); } @Test diff --git a/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java b/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java index 4e74d2dc4090..05de6e473e87 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -65,6 +65,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -570,7 +571,7 @@ public void resolveJmsMessageHeaderAccessor(JmsMessageHeaderAccessor headers) { this.invocations.put("resolveJmsMessageHeaderAccessor", true); assertThat(headers).as("MessageHeaders not injected").isNotNull(); assertThat(headers.getPriority()).as("Missing JMS message priority header").isEqualTo(Integer.valueOf(9)); - assertThat(headers.getHeader("customBoolean")).as("Missing custom header").isEqualTo(true); + assertThat(headers.getHeader("customBoolean")).as("Missing custom header").asInstanceOf(BOOLEAN).isTrue(); } public void resolveObjectPayload(MyBean bean) { diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java index 4a83e858a337..aea9053261f2 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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 @@ public void applyBackOff() { DefaultMessageListenerContainer container = createContainer(createFailingContainerFactory()); container.setBackOff(backOff); container.start(); - assertThat(container.isRunning()).isEqualTo(true); + assertThat(container.isRunning()).isTrue(); container.refreshConnectionUntilSuccessful(); - assertThat(container.isRunning()).isEqualTo(false); + assertThat(container.isRunning()).isFalse(); verify(backOff).start(); verify(execution).nextBackOff(); } @@ -73,7 +73,7 @@ public void applyBackOffRetry() { container.start(); container.refreshConnectionUntilSuccessful(); - assertThat(container.isRunning()).isEqualTo(false); + assertThat(container.isRunning()).isFalse(); verify(backOff).start(); verify(execution, times(2)).nextBackOff(); } @@ -90,7 +90,7 @@ public void recoverResetBackOff() { container.start(); container.refreshConnectionUntilSuccessful(); - assertThat(container.isRunning()).isEqualTo(true); + assertThat(container.isRunning()).isTrue(); verify(backOff).start(); verify(execution, times(1)).nextBackOff(); // only on attempt as the second one lead to a recovery } diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java index 22239b5af92b..7b872388b10d 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -34,8 +34,8 @@ public void isPubSubDomainWithQueue() { JmsActivationSpecConfig config = new JmsActivationSpecConfig(); config.setPubSubDomain(false); endpoint.setActivationSpecConfig(config); - assertThat(endpoint.isPubSubDomain()).isEqualTo(false); - assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(false); + assertThat(endpoint.isPubSubDomain()).isFalse(); + assertThat(endpoint.isReplyPubSubDomain()).isFalse(); } @Test @@ -44,8 +44,8 @@ public void isPubSubDomainWithTopic() { JmsActivationSpecConfig config = new JmsActivationSpecConfig(); config.setPubSubDomain(true); endpoint.setActivationSpecConfig(config); - assertThat(endpoint.isPubSubDomain()).isEqualTo(true); - assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(true); + assertThat(endpoint.isPubSubDomain()).isTrue(); + assertThat(endpoint.isReplyPubSubDomain()).isTrue(); } @Test @@ -55,8 +55,8 @@ public void pubSubDomainCustomForReply() { config.setPubSubDomain(true); config.setReplyPubSubDomain(false); endpoint.setActivationSpecConfig(config); - assertThat(endpoint.isPubSubDomain()).isEqualTo(true); - assertThat(endpoint.isReplyPubSubDomain()).isEqualTo(false); + assertThat(endpoint.isPubSubDomain()).isTrue(); + assertThat(endpoint.isReplyPubSubDomain()).isFalse(); } @Test diff --git a/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java b/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java index 2255f34ea5d7..2a0b17907a86 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -65,7 +65,7 @@ public void validateJmsHeaders() throws JMSException { assertThat(headerAccessor.getMessageId()).isEqualTo("abcd-1234"); assertThat(headerAccessor.getPriority()).isEqualTo(Integer.valueOf(9)); assertThat(headerAccessor.getReplyTo()).isEqualTo(replyTo); - assertThat(headerAccessor.getRedelivered()).isEqualTo(true); + assertThat(headerAccessor.getRedelivered()).isTrue(); assertThat(headerAccessor.getType()).isEqualTo("type"); assertThat(headerAccessor.getTimestamp()).isEqualTo(4567); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java index ca454849a212..b31e95942bef 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -422,7 +422,7 @@ public void customPathMatcher() { DefaultUserDestinationResolver resolver = context.getBean(DefaultUserDestinationResolver.class); assertThat(resolver).isNotNull(); - assertThat(resolver.isRemoveLeadingSlash()).isEqualTo(false); + assertThat(resolver.isRemoveLeadingSlash()).isFalse(); } @Test diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java index dd8bd71219bc..730769bc7cf5 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -98,8 +98,8 @@ public void sendWithExecutor() { @Test public void subscribeTwice() { - assertThat(this.channel.subscribe(this.handler)).isEqualTo(true); - assertThat(this.channel.subscribe(this.handler)).isEqualTo(false); + assertThat(this.channel.subscribe(this.handler)).isTrue(); + assertThat(this.channel.subscribe(this.handler)).isFalse(); this.channel.send(this.message); verify(this.handler, times(1)).handleMessage(this.message); } @@ -107,8 +107,8 @@ public void subscribeTwice() { @Test public void unsubscribeTwice() { this.channel.subscribe(this.handler); - assertThat(this.channel.unsubscribe(this.handler)).isEqualTo(true); - assertThat(this.channel.unsubscribe(this.handler)).isEqualTo(false); + assertThat(this.channel.unsubscribe(this.handler)).isTrue(); + assertThat(this.channel.unsubscribe(this.handler)).isFalse(); this.channel.send(this.message); verify(this.handler, never()).handleMessage(this.message); } diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index a0e88fef2689..097064f9f69e 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -322,8 +322,8 @@ public javax.xml.bind.Unmarshaller createUnmarshaller() { verify(unmarshaller).unmarshal(sourceCaptor.capture()); SAXSource result = sourceCaptor.getValue(); - assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(true); - assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(false); + assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isTrue(); + assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isFalse(); // 2. external-general-entities and dtd support enabled @@ -335,8 +335,8 @@ public javax.xml.bind.Unmarshaller createUnmarshaller() { verify(unmarshaller).unmarshal(sourceCaptor.capture()); result = sourceCaptor.getValue(); - assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(false); - assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(true); + assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isFalse(); + assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isTrue(); } @Test // SPR-10806 @@ -356,8 +356,8 @@ public javax.xml.bind.Unmarshaller createUnmarshaller() { verify(unmarshaller).unmarshal(sourceCaptor.capture()); SAXSource result = sourceCaptor.getValue(); - assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(true); - assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(false); + assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isTrue(); + assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isFalse(); // 2. external-general-entities and dtd support enabled @@ -369,8 +369,8 @@ public javax.xml.bind.Unmarshaller createUnmarshaller() { verify(unmarshaller).unmarshal(sourceCaptor.capture()); result = sourceCaptor.getValue(); - assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isEqualTo(false); - assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isEqualTo(true); + assertThat(result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl")).isFalse(); + assertThat(result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")).isTrue(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java index 7cba9a363509..12309c5e2610 100644 --- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -149,7 +149,7 @@ public void beforeTestMethodAnnotationWithFailingAsyncEventListener() throws Exc testContextManager.beforeTestMethod(testInstance, method); - assertThat(countDownLatch.await(2, TimeUnit.SECONDS)).isEqualTo(true); + assertThat(countDownLatch.await(2, TimeUnit.SECONDS)).isTrue(); verify(listener, only()).beforeTestMethod(testContext); assertThat(TrackingAsyncUncaughtExceptionHandler.asyncException.getMessage()) diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/RegisterExtensionSpringExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/RegisterExtensionSpringExtensionTests.java index ea9c627f8f58..7c3783db041e 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/RegisterExtensionSpringExtensionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/RegisterExtensionSpringExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -175,7 +175,7 @@ void valueParameterFromPropertyPlaceholder(@Value("${enigma}") Integer enigmaPar @Test void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) { assertThat(defaultValue).as("Default value should have been injected via @Value by Spring").isNotNull(); - assertThat(defaultValue).as("default value").isEqualTo(false); + assertThat(defaultValue).as("default value").isFalse(); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionTests.java index 73e9acdd98fc..ee67fa14c9b6 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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,7 +169,7 @@ void valueParameterFromPropertyPlaceholder(@Value("${enigma}") Integer enigmaPar @Test void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) { assertThat(defaultValue).as("Default value should have been injected via @Value by Spring").isNotNull(); - assertThat(defaultValue).as("default value").isEqualTo(false); + assertThat(defaultValue).as("default value").isFalse(); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java index cdc504961dbd..680ed0bf3737 100644 --- a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -155,7 +155,7 @@ private static void assertSetFieldAndGetFieldBehavior(Person person) { assertThat(person.getName()).as("name (protected field)").isEqualTo("Tom"); assertThat(person.getAge()).as("age (private field)").isEqualTo(42); assertThat(person.getEyeColor()).as("eye color (package private field)").isEqualTo("blue"); - assertThat(person.likesPets()).as("'likes pets' flag (package private boolean field)").isEqualTo(true); + assertThat(person.likesPets()).as("'likes pets' flag (package private boolean field)").isTrue(); assertThat(person.getFavoriteNumber()).as("'favorite number' (package field)").isEqualTo(PI); } @@ -167,7 +167,7 @@ private static void assertSetFieldAndGetFieldBehaviorForProxy(Person proxy, Pers assertThat(target.getName()).as("name (protected field)").isEqualTo("Tom"); assertThat(target.getAge()).as("age (private field)").isEqualTo(42); assertThat(target.getEyeColor()).as("eye color (package private field)").isEqualTo("blue"); - assertThat(target.likesPets()).as("'likes pets' flag (package private boolean field)").isEqualTo(true); + assertThat(target.likesPets()).as("'likes pets' flag (package private boolean field)").isTrue(); assertThat(target.getFavoriteNumber()).as("'favorite number' (package field)").isEqualTo(PI); } @@ -260,7 +260,7 @@ void invokeSetterMethodAndInvokeGetterMethodWithExplicitMethodNames() throws Exc assertThat(person.getName()).as("name (private method)").isEqualTo("Jerry"); assertThat(person.getAge()).as("age (protected method)").isEqualTo(33); assertThat(person.getEyeColor()).as("eye color (package private method)").isEqualTo("green"); - assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isEqualTo(false); + assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isFalse(); assertThat(person.getFavoriteNumber()).as("'favorite number' (protected method for a Number)").isEqualTo(Integer.valueOf(42)); assertThat(invokeGetterMethod(person, "getId")).isEqualTo(Long.valueOf(1)); @@ -284,7 +284,7 @@ void invokeSetterMethodAndInvokeGetterMethodWithJavaBeanPropertyNames() throws E assertThat(person.getName()).as("name (private method)").isEqualTo("Tom"); assertThat(person.getAge()).as("age (protected method)").isEqualTo(42); assertThat(person.getEyeColor()).as("eye color (package private method)").isEqualTo("blue"); - assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isEqualTo(true); + assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isTrue(); assertThat(person.getFavoriteNumber()).as("'favorite number' (protected method for a Number)").isEqualTo(PI); assertThat(invokeGetterMethod(person, "id")).isEqualTo(Long.valueOf(99)); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java index 96ebbb4ed529..5c5f5afdfaac 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -851,7 +851,7 @@ public void buildRequestSessionFalseWithExistingSession() throws Exception { public void buildRequestSessionIsNew() throws Exception { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); - assertThat(actualRequest.getSession().isNew()).isEqualTo(true); + assertThat(actualRequest.getSession().isNew()).isTrue(); } @Test @@ -861,7 +861,7 @@ public void buildRequestSessionIsNewFalse() throws Exception { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); - assertThat(actualRequest.getSession().isNew()).isEqualTo(false); + assertThat(actualRequest.getSession().isNew()).isFalse(); } @Test @@ -873,7 +873,7 @@ public void buildRequestSessionInvalidate() throws Exception { HttpSession sessionToRemove = actualRequest.getSession(); sessionToRemove.invalidate(); - assertThat(sessions.containsKey(sessionToRemove.getId())).isEqualTo(false); + assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse(); assertSingleSessionCookie("JSESSIONID=" + sessionToRemove.getId() + "; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/test; Domain=example.com"); @@ -882,8 +882,8 @@ public void buildRequestSessionInvalidate() throws Exception { actualRequest = requestBuilder.buildRequest(servletContext); - assertThat(actualRequest.getSession().isNew()).isEqualTo(true); - assertThat(sessions.containsKey(sessionToRemove.getId())).isEqualTo(false); + assertThat(actualRequest.getSession().isNew()).isTrue(); + assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse(); } // --- setContextPath diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java index d5390e33cb0a..dccc388e454b 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public void serializable() throws Exception { .getUserTransaction() == ut2).as("UserTransaction looked up on client").isTrue(); assertThat(serializedJtatm .getTransactionManager()).as("TransactionManager didn't survive").isNull(); - assertThat(serializedJtatm.isRollbackOnCommitFailure()).isEqualTo(true); + assertThat(serializedJtatm.isRollbackOnCommitFailure()).isTrue(); } } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java index daac29918891..27a42f96f7b6 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -323,7 +323,7 @@ void checkNotModifiedTimestampConditionalPut(String method) { assertThat(request.checkNotModified(oneMinuteAgo)).isFalse(); assertThat(servletResponse.getStatus()).isEqualTo(200); - assertThat(servletResponse.getHeader("Last-Modified")).isEqualTo(null); + assertThat(servletResponse.getHeader("Last-Modified")).isNull(); } @ParameterizedHttpMethodTest @@ -337,7 +337,7 @@ void checkNotModifiedTimestampConditionalPutConflict(String method) { assertThat(request.checkNotModified(currentEpoch)).isTrue(); assertThat(servletResponse.getStatus()).isEqualTo(412); - assertThat(servletResponse.getHeader("Last-Modified")).isEqualTo(null); + assertThat(servletResponse.getHeader("Last-Modified")).isNull(); } private void setUpRequest(String method) { diff --git a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java index e37bb54c025b..2bf081bb11c3 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -287,8 +287,8 @@ private void doTestBinding(MockCommonsMultipartResolver resolver, MockHttpServle MultipartHttpServletRequest request) throws UnsupportedEncodingException { MultipartTestBean1 mtb1 = new MultipartTestBean1(); - assertThat(mtb1.getField1()).isEqualTo(null); - assertThat(mtb1.getField2()).isEqualTo(null); + assertThat(mtb1.getField1()).isNull(); + assertThat(mtb1.getField2()).isNull(); ServletRequestDataBinder binder = new ServletRequestDataBinder(mtb1, "mybean"); binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); binder.bind(request); @@ -301,8 +301,8 @@ private void doTestBinding(MockCommonsMultipartResolver resolver, MockHttpServle assertThat(new String(mtb1.getField2())).isEqualTo(new String(file2.getBytes())); MultipartTestBean2 mtb2 = new MultipartTestBean2(); - assertThat(mtb2.getField1()).isEqualTo(null); - assertThat(mtb2.getField2()).isEqualTo(null); + assertThat(mtb2.getField1()).isNull(); + assertThat(mtb2.getField2()).isNull(); binder = new ServletRequestDataBinder(mtb2, "mybean"); binder.registerCustomEditor(String.class, "field1", new StringMultipartFileEditor()); binder.registerCustomEditor(String.class, "field2", new StringMultipartFileEditor("UTF-16")); diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index d6d971c4ed5a..2c2138d7ad27 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -1066,7 +1066,7 @@ void testDeepClone() { assertThat(result1.getPath()).isEqualTo("/p1/%s/%s", vars.get("ps1"), vars.get("ps2")); assertThat(result1.getQuery()).isEqualTo("q1"); assertThat(result1.getFragment()).isEqualTo("f1"); - assertThat(result1.getSchemeSpecificPart()).isEqualTo(null); + assertThat(result1.getSchemeSpecificPart()).isNull(); UriComponents result2 = builder2.build(); assertThat(result2.getScheme()).isEqualTo("http"); @@ -1075,7 +1075,7 @@ void testDeepClone() { assertThat(result2.getPath()).isEqualTo("/p1/%s/%s", vars.get("ps1"), vars.get("ps2")); assertThat(result2.getQuery()).isEqualTo("q1"); assertThat(result2.getFragment()).isEqualTo("f1"); - assertThat(result1.getSchemeSpecificPart()).isEqualTo(null); + assertThat(result1.getSchemeSpecificPart()).isNull(); } @Test // gh-26466 diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java index a3f632a5e6ec..92cbe9a4f9a8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public void customizedMapping() { assertThat(config.getAllowedMethods()).isEqualTo(Collections.singletonList("DELETE")); assertThat(config.getAllowedHeaders()).isEqualTo(Arrays.asList("header1", "header2")); assertThat(config.getExposedHeaders()).isEqualTo(Arrays.asList("header3", "header4")); - assertThat(config.getAllowCredentials()).isEqualTo(false); + assertThat(config.getAllowCredentials()).isFalse(); assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(3600)); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java index 79d34e2750e9..9e08ded149dd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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,8 +57,8 @@ public void createEmpty() { PathPattern emptyPattern = (new PathPatternParser()).parse(""); assertThat(info.getPatternsCondition().getPatterns()).isEqualTo(Collections.singleton(emptyPattern)); assertThat(info.getMethodsCondition().getMethods().size()).isEqualTo(0); - assertThat(info.getConsumesCondition().isEmpty()).isEqualTo(true); - assertThat(info.getProducesCondition().isEmpty()).isEqualTo(true); + assertThat(info.getConsumesCondition().isEmpty()).isTrue(); + assertThat(info.getProducesCondition().isEmpty()).isTrue(); assertThat(info.getParamsCondition()).isNotNull(); assertThat(info.getHeadersCondition()).isNotNull(); assertThat(info.getCustomCondition()).isNull(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java index 9d8700850682..de3fb9d8b638 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -162,7 +162,7 @@ void preFlightRequestWithAmbiguousMapping(HttpServer httpServer) throws Exceptio assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("*"); assertThat(entity.getHeaders().getAccessControlAllowMethods()).containsExactly(HttpMethod.GET, HttpMethod.POST); - assertThat(entity.getHeaders().getAccessControlAllowCredentials()).isEqualTo(false); + assertThat(entity.getHeaders().getAccessControlAllowCredentials()).isFalse(); assertThat(entity.getHeaders().get(HttpHeaders.VARY)) .containsExactly(HttpHeaders.ORIGIN, HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java index 6648d729432c..e583e4abbd2d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; import static org.junit.jupiter.api.condition.JRE.JAVA_15; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -99,7 +100,7 @@ public void detectScriptTemplateConfigWithEngine() { assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template"); assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render"); assertThat(accessor.getPropertyValue("defaultCharset")).isEqualTo(StandardCharsets.ISO_8859_1); - assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true); + assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isTrue(); } @Test @@ -222,7 +223,7 @@ public void engineSupplierWithSharedEngine() { assertThat(engine2).isNotNull(); assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template"); assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render"); - assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true); + assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isTrue(); } @SuppressWarnings("unchecked") @@ -241,7 +242,7 @@ public void engineSupplierWithNonSharedEngine() { assertThat(engine2).isNotNull(); assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template"); assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render"); - assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(false); + assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isFalse(); } private interface InvocableScriptEngine extends ScriptEngine, Invocable { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java index 4acfaf6cffb6..d76ee7bf8ae5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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,6 +50,7 @@ import org.springframework.web.util.UrlPathHelper; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; /** * Test fixture for the configuration in mvc-config-annotation-driven.xml. @@ -73,7 +74,7 @@ public void testMessageCodesResolver() { ((ConfigurableWebBindingInitializer) initializer).getMessageCodesResolver(); assertThat(resolver).isNotNull(); assertThat(resolver.getClass()).isEqualTo(TestMessageCodesResolver.class); - assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(false); + assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 1a1c4fcff38f..2787bad0ecdb 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -151,6 +151,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; /** * Tests loading actual MVC namespace configuration. @@ -212,7 +213,7 @@ public void testDefaultConfig() throws Exception { RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class); assertThat(adapter).isNotNull(); - assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(false); + assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse(); List> converters = adapter.getMessageConverters(); assertThat(converters.size() > 0).isTrue(); @@ -327,7 +328,7 @@ private void doTestCustomValidator(String xml) throws Exception { RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class); assertThat(adapter).isNotNull(); - assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(true); + assertThat(new DirectFieldAccessor(adapter).getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isTrue(); // default web binding initializer behavior test MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java index 105496ec02c8..9b64d9c26df4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -65,7 +65,7 @@ public void customizedMapping() { assertThat(config.getAllowedMethods()).isEqualTo(Collections.singletonList("DELETE")); assertThat(config.getAllowedHeaders()).isEqualTo(Arrays.asList("header1", "header2")); assertThat(config.getExposedHeaders()).isEqualTo(Arrays.asList("header3", "header4")); - assertThat(config.getAllowCredentials()).isEqualTo(false); + assertThat(config.getAllowCredentials()).isFalse(); assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(3600)); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java index 5a5daeaadf37..9460e848ffe5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -245,9 +245,9 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) { webMvcConfig.mvcResourceUrlProvider()); assertThat(annotationsMapping).isNotNull(); - assertThat(annotationsMapping.useRegisteredSuffixPatternMatch()).isEqualTo(true); - assertThat(annotationsMapping.useSuffixPatternMatch()).isEqualTo(true); - assertThat(annotationsMapping.useTrailingSlashMatch()).isEqualTo(false); + assertThat(annotationsMapping.useRegisteredSuffixPatternMatch()).isTrue(); + assertThat(annotationsMapping.useSuffixPatternMatch()).isTrue(); + assertThat(annotationsMapping.useTrailingSlashMatch()).isFalse(); configAssertion.accept(annotationsMapping.getUrlPathHelper(), annotationsMapping.getPathMatcher()); SimpleUrlHandlerMapping mapping = (SimpleUrlHandlerMapping) webMvcConfig.viewControllerHandlerMapping( diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java index 929cf231ea6a..bcc0fe568d91 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -89,6 +89,7 @@ import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; import static com.fasterxml.jackson.databind.MapperFeature.DEFAULT_VIEW_INCLUSION; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; import static org.mockito.Mockito.mock; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.http.MediaType.APPLICATION_XML; @@ -241,7 +242,7 @@ public void requestMappingHandlerAdapter() throws Exception { (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertThat(deferredResultInterceptors.length).isEqualTo(1); - assertThat(fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")).isEqualTo(false); + assertThat(fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")).asInstanceOf(BOOLEAN).isFalse(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java index 185ca9d3f695..4e522264fcab 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -158,7 +158,7 @@ public void testSetAndResolveLocale() { Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME); assertThat(cookie).isNotNull(); assertThat(cookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME); - assertThat(cookie.getDomain()).isEqualTo(null); + assertThat(cookie.getDomain()).isNull(); assertThat(cookie.getPath()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_PATH); assertThat(cookie.getSecure()).isFalse(); @@ -244,7 +244,7 @@ public void testSetAndResolveLocaleWithCountry() { Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME); assertThat(cookie).isNotNull(); assertThat(cookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME); - assertThat(cookie.getDomain()).isEqualTo(null); + assertThat(cookie.getDomain()).isNull(); assertThat(cookie.getPath()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_PATH); assertThat(cookie.getSecure()).isFalse(); assertThat(cookie.getValue()).isEqualTo("de-AT"); @@ -270,7 +270,7 @@ public void testSetAndResolveLocaleWithCountryAsLegacyJava() { Cookie cookie = response.getCookie(CookieLocaleResolver.DEFAULT_COOKIE_NAME); assertThat(cookie).isNotNull(); assertThat(cookie.getName()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_NAME); - assertThat(cookie.getDomain()).isEqualTo(null); + assertThat(cookie.getDomain()).isNull(); assertThat(cookie.getPath()).isEqualTo(CookieLocaleResolver.DEFAULT_COOKIE_PATH); assertThat(cookie.getSecure()).isFalse(); assertThat(cookie.getValue()).isEqualTo("de_AT"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java index 11a435d25d9c..985ed0456894 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -63,8 +63,8 @@ void createEmpty(RequestMappingInfo.Builder infoBuilder) { assertThat(info.getMethodsCondition().getMethods().size()).isEqualTo(0); assertThat(info.getParamsCondition()).isNotNull(); assertThat(info.getHeadersCondition()).isNotNull(); - assertThat(info.getConsumesCondition().isEmpty()).isEqualTo(true); - assertThat(info.getProducesCondition().isEmpty()).isEqualTo(true); + assertThat(info.getConsumesCondition().isEmpty()).isTrue(); + assertThat(info.getProducesCondition().isEmpty()).isTrue(); assertThat(info.getCustomCondition()).isNull(); RequestMappingInfo anotherInfo = infoBuilder.build(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java index 51ee2085843f..9371009aadc5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -82,7 +82,7 @@ public void noUriTemplateVars() throws Exception { WebDataBinder binder = new ExtendedServletRequestDataBinder(target, ""); ((ServletRequestDataBinder) binder).bind(request); - assertThat(target.getName()).isEqualTo(null); + assertThat(target.getName()).isNull(); assertThat(target.getAge()).isEqualTo(0); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java index c6307a8dd137..906df78d0228 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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 @@ public void handleRedirectAttributesWithoutRedirect() throws Exception { handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest); ModelMap model = mavContainer.getModel(); - assertThat(mavContainer.getView()).isEqualTo(null); + assertThat(mavContainer.getView()).isNull(); assertThat(mavContainer.getModel().isEmpty()).isTrue(); assertThat(model).as("RedirectAttributes should not be used if controller doesn't redirect").isNotSameAs(redirectAttributes); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index 4ccdca2f66f9..32ecd653d704 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -247,7 +247,7 @@ public void modelAttributePackageNameAdvice() throws Exception { assertThat(mav.getModel().get("attr1")).isEqualTo("lAttr1"); assertThat(mav.getModel().get("attr2")).isEqualTo("gAttr2"); - assertThat(mav.getModel().get("attr3")).isEqualTo(null); + assertThat(mav.getModel().get("attr3")).isNull(); } // SPR-10859 diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java index d44dae46ac89..4860edbd045b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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 @@ public class MappingJackson2JsonViewTests { @Test public void isExposePathVars() { - assertThat(view.isExposePathVariables()).as("Must not expose path variables").isEqualTo(false); + assertThat(view.isExposePathVariables()).as("Must not expose path variables").isFalse(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java index 3e35cf26cb09..d546737cb80d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -47,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; import static org.junit.jupiter.api.condition.JRE.JAVA_15; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; @@ -113,7 +114,7 @@ public void detectScriptTemplateConfigWithEngine() { assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render"); assertThat(accessor.getPropertyValue("contentType")).isEqualTo(MediaType.TEXT_PLAIN_VALUE); assertThat(accessor.getPropertyValue("charset")).isEqualTo(StandardCharsets.ISO_8859_1); - assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true); + assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isTrue(); } @Test @@ -301,7 +302,7 @@ public void engineSupplierWithSharedEngine() { assertThat(engine2).isNotNull(); assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template"); assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render"); - assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(true); + assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isTrue(); } @Test // gh-23258 @@ -319,7 +320,7 @@ public void engineSupplierWithNonSharedEngine() { assertThat(engine2).isNotNull(); assertThat(accessor.getPropertyValue("renderObject")).isEqualTo("Template"); assertThat(accessor.getPropertyValue("renderFunction")).isEqualTo("render"); - assertThat(accessor.getPropertyValue("sharedEngine")).isEqualTo(false); + assertThat(accessor.getPropertyValue("sharedEngine")).asInstanceOf(BOOLEAN).isFalse(); } private interface InvocableScriptEngine extends ScriptEngine, Invocable { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java index 1ac1a7858616..797ff6379279 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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 MappingJackson2XmlViewTests { @Test public void isExposePathVars() { - assertThat(view.isExposePathVariables()).as("Must not expose path variables").isEqualTo(false); + assertThat(view.isExposePathVariables()).as("Must not expose path variables").isFalse(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java index 8a03c1028ca7..73b28604b646 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -66,12 +66,12 @@ public void getContentType() { @Test public void isExposePathVars() { - assertThat(view.isExposePathVariables()).as("Must not expose path variables").isEqualTo(false); + assertThat(view.isExposePathVariables()).as("Must not expose path variables").isFalse(); } @Test public void isExposePathVarsDefaultConstructor() { - assertThat(new MarshallingView().isExposePathVariables()).as("Must not expose path variables").isEqualTo(false); + assertThat(new MarshallingView().isExposePathVariables()).as("Must not expose path variables").isFalse(); } @Test diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index fda305a34f54..fdaea640baea 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,6 +91,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; /** * Test fixture for {@link MessageBrokerBeanDefinitionParser}. @@ -128,7 +129,7 @@ public void simpleBroker() throws Exception { WebSocketSession session = new TestWebSocketSession("id"); wsHttpRequestHandler.getWebSocketHandler().afterConnectionEstablished(session); - assertThat(session.getAttributes().get("decorated")).isEqualTo(true); + assertThat(session.getAttributes().get("decorated")).asInstanceOf(BOOLEAN).isTrue(); WebSocketHandler wsHandler = wsHttpRequestHandler.getWebSocketHandler(); assertThat(wsHandler).isInstanceOf(ExceptionWebSocketHandlerDecorator.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java index fe61f0b8ba12..c56ae0f5c539 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,6 +60,7 @@ import org.springframework.web.socket.server.support.WebSocketHttpRequestHandler; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; import static org.mockito.Mockito.mock; /** @@ -190,7 +191,7 @@ void webSocketHandlerDecorator() throws Exception { WebSocketSession session = new TestWebSocketSession("id"); handler.afterConnectionEstablished(session); - assertThat(session.getAttributes().get("decorated")).isEqualTo(true); + assertThat(session.getAttributes().get("decorated")).asInstanceOf(BOOLEAN).isTrue(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java index e5095a6aa125..5968fb591ee1 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -119,7 +119,7 @@ public void handleFrameMessageWhenNotOpen() throws Exception { public void handleFrameMessageWithBadData() throws Exception { this.session.handleFrame(SockJsFrame.openFrame().getContent()); this.session.handleFrame("a['bad data"); - assertThat(this.session.isOpen()).isEqualTo(false); + assertThat(this.session.isOpen()).isFalse(); assertThat(this.session.disconnectStatus).isEqualTo(CloseStatus.BAD_DATA); verify(this.handler).afterConnectionEstablished(this.session); verifyNoMoreInteractions(this.handler); @@ -133,7 +133,7 @@ public void handleFrameMessageWithWebSocketHandlerException() throws Exception { willThrow(new IllegalStateException("Fake error")).given(this.handler) .handleMessage(this.session, new TextMessage("bar")); this.session.handleFrame(SockJsFrame.messageFrame(CODEC, "foo", "bar").getContent()); - assertThat(this.session.isOpen()).isEqualTo(true); + assertThat(this.session.isOpen()).isTrue(); verify(this.handler).afterConnectionEstablished(this.session); verify(this.handler).handleMessage(this.session, new TextMessage("foo")); verify(this.handler).handleMessage(this.session, new TextMessage("bar")); @@ -144,7 +144,7 @@ public void handleFrameMessageWithWebSocketHandlerException() throws Exception { public void handleFrameClose() throws Exception { this.session.handleFrame(SockJsFrame.openFrame().getContent()); this.session.handleFrame(SockJsFrame.closeFrame(1007, "").getContent()); - assertThat(this.session.isOpen()).isEqualTo(false); + assertThat(this.session.isOpen()).isFalse(); assertThat(this.session.disconnectStatus).isEqualTo(new CloseStatus(1007, "")); verify(this.handler).afterConnectionEstablished(this.session); verifyNoMoreInteractions(this.handler); @@ -162,7 +162,7 @@ public void handleTransportError() throws Exception { public void afterTransportClosed() throws Exception { this.session.handleFrame(SockJsFrame.openFrame().getContent()); this.session.afterTransportClosed(CloseStatus.SERVER_ERROR); - assertThat(this.session.isOpen()).isEqualTo(false); + assertThat(this.session.isOpen()).isFalse(); verify(this.handler).afterConnectionEstablished(this.session); verify(this.handler).afterConnectionClosed(this.session, CloseStatus.SERVER_ERROR); verifyNoMoreInteractions(this.handler); @@ -172,7 +172,7 @@ public void afterTransportClosed() throws Exception { public void close() throws Exception { this.session.handleFrame(SockJsFrame.openFrame().getContent()); this.session.close(); - assertThat(this.session.isOpen()).isEqualTo(false); + assertThat(this.session.isOpen()).isFalse(); assertThat(this.session.disconnectStatus).isEqualTo(CloseStatus.NORMAL); verify(this.handler).afterConnectionEstablished(this.session); verifyNoMoreInteractions(this.handler);