Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ public class ClassWithComplexConstructor {
|
||||
|
||||
@Autowired
|
||||
public ClassWithComplexConstructor(Dependency dependency) {
|
||||
Assert.notNull(dependency);
|
||||
Assert.notNull(dependency, "No Dependency bean injected");
|
||||
this.dependency = dependency;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ public class ClassWithComplexConstructor {
|
||||
}
|
||||
|
||||
public void method() {
|
||||
Assert.isTrue(this.selfReference != this && AopUtils.isCglibProxy(this.selfReference));
|
||||
Assert.state(this.selfReference != this && AopUtils.isCglibProxy(this.selfReference),
|
||||
"Self reference must be a CGLIB proxy");
|
||||
this.dependency.method();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -1250,7 +1250,7 @@ public class ConfigurationClassPostProcessorTests {
|
||||
|
||||
@PostConstruct
|
||||
public void validate() {
|
||||
Assert.notNull(provider);
|
||||
Assert.notNull(provider, "No ServiceBeanProvider injected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1291,7 +1291,7 @@ public class ConfigurationClassPostProcessorTests {
|
||||
|
||||
@PostConstruct
|
||||
public void validate() {
|
||||
Assert.notNull(provider);
|
||||
Assert.notNull(provider, "No ServiceBeanProvider injected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1403,7 +1403,7 @@ public class ConfigurationClassPostProcessorTests {
|
||||
static class DependingFoo {
|
||||
|
||||
DependingFoo(BarArgument bar) {
|
||||
Assert.notNull(bar);
|
||||
Assert.notNull(bar, "No BarArgument injected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,7 +72,8 @@ public class Service implements ApplicationContextAware, MessageSourceAware, Dis
|
||||
Thread thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Assert.isTrue(applicationContext.getBean("messageSource") instanceof StaticMessageSource);
|
||||
Assert.state(applicationContext.getBean("messageSource") instanceof StaticMessageSource,
|
||||
"Invalid MessageSource bean");
|
||||
try {
|
||||
applicationContext.getBean("service2");
|
||||
// Should have thrown BeanCreationNotAllowedException
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -355,6 +355,7 @@ public class DateTimeFormattingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testBindInstantFromJavaUtilDate() throws Exception {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("instant", new Date(109, 9, 31, 12, 0));
|
||||
|
||||
@@ -240,7 +240,7 @@ public class SpringValidatorAdapterTests {
|
||||
else {
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(message)
|
||||
.addNode(field)
|
||||
.addPropertyNode(field)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user