Skip to content

Commit

Permalink
Merge branch '5.3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jan 10, 2022
2 parents 4ebc53a + df263d0 commit d57bc17
Show file tree
Hide file tree
Showing 72 changed files with 334 additions and 322 deletions.
@@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down
@@ -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.
Expand Down Expand Up @@ -46,15 +46,15 @@ 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
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
Expand Down
@@ -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.
Expand Down Expand Up @@ -426,7 +426,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");
Expand Down Expand Up @@ -2599,8 +2599,8 @@ public boolean postProcessAfterInstantiation(Object bean, String beanName) throw
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
Expand Down
@@ -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.
Expand Down Expand Up @@ -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");
}

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

Expand Down Expand Up @@ -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${");
Expand Down
@@ -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.
Expand Down Expand Up @@ -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");
}

Expand Down
@@ -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.
Expand Down Expand Up @@ -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();
}
Expand All @@ -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");
}

Expand Down
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
@@ -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.
Expand Down Expand Up @@ -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);
Expand Down
@@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
@@ -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.
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -894,15 +894,15 @@ 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
assertThat(rod.getSpouse1()).isEqualTo(kerry);
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
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
@@ -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.
Expand Down Expand Up @@ -46,7 +46,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);
}
Expand All @@ -55,7 +55,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);
}
Expand All @@ -64,15 +64,15 @@ 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);
}

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

Expand Down
@@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
@@ -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.
Expand All @@ -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}.
Expand All @@ -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();
Expand Down

0 comments on commit d57bc17

Please sign in to comment.