Change relevant Assert calls to throw IllegalStateException
Change certain Assert class from `assert...` to `assertState` so that a more appropriate `IllegalStateException` is thrown. Fixes gh-43779
This commit is contained in:
parent
29baaf32e6
commit
f08188d5cf
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -69,7 +69,7 @@ public class AvailabilityStateHealthIndicator extends AbstractHealthIndicator {
|
||||||
if (!this.statusMappings.containsKey(null) && Enum.class.isAssignableFrom(stateType)) {
|
if (!this.statusMappings.containsKey(null) && Enum.class.isAssignableFrom(stateType)) {
|
||||||
EnumSet elements = EnumSet.allOf((Class) stateType);
|
EnumSet elements = EnumSet.allOf((Class) stateType);
|
||||||
for (Object element : elements) {
|
for (Object element : elements) {
|
||||||
Assert.isTrue(this.statusMappings.containsKey(element),
|
Assert.state(this.statusMappings.containsKey(element),
|
||||||
() -> "StatusMappings does not include " + element);
|
() -> "StatusMappings does not include " + element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -209,7 +209,7 @@ public class HeapDumpWebEndpoint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File dumpHeap(Boolean live) throws IOException, InterruptedException {
|
public File dumpHeap(Boolean live) throws IOException, InterruptedException {
|
||||||
Assert.isNull(live, "OpenJ9DiagnosticsMXBean does not support live parameter when dumping the heap");
|
Assert.state(live == null, "OpenJ9DiagnosticsMXBean does not support live parameter when dumping the heap");
|
||||||
return new File(
|
return new File(
|
||||||
(String) ReflectionUtils.invokeMethod(this.dumpHeapMethod, this.diagnosticMXBean, "heap", null));
|
(String) ReflectionUtils.invokeMethod(this.dumpHeapMethod, this.diagnosticMXBean, "heap", null));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.boot.availability.LivenessState;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -67,7 +68,7 @@ class AvailabilityStateHealthIndicatorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createWhenStatusMappingDoesNotCoverAllEnumsThrowsException() {
|
void createWhenStatusMappingDoesNotCoverAllEnumsThrowsException() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> new AvailabilityStateHealthIndicator(this.applicationAvailability, LivenessState.class,
|
.isThrownBy(() -> new AvailabilityStateHealthIndicator(this.applicationAvailability, LivenessState.class,
|
||||||
(statusMappings) -> statusMappings.add(LivenessState.CORRECT, Status.UP)))
|
(statusMappings) -> statusMappings.add(LivenessState.CORRECT, Status.UP)))
|
||||||
.withMessage("StatusMappings does not include BROKEN");
|
.withMessage("StatusMappings does not include BROKEN");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -57,6 +57,7 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -170,7 +171,7 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector,
|
||||||
protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {
|
protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {
|
||||||
String name = getAnnotationClass().getName();
|
String name = getAnnotationClass().getName();
|
||||||
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(name, true));
|
AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(name, true));
|
||||||
Assert.notNull(attributes, () -> "No auto-configuration attributes found. Is " + metadata.getClassName()
|
Assert.state(attributes != null, () -> "No auto-configuration attributes found. Is " + metadata.getClassName()
|
||||||
+ " annotated with " + ClassUtils.getShortName(name) + "?");
|
+ " annotated with " + ClassUtils.getShortName(name) + "?");
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +196,7 @@ public class AutoConfigurationImportSelector implements DeferredImportSelector,
|
||||||
ImportCandidates importCandidates = ImportCandidates.load(this.autoConfigurationAnnotation,
|
ImportCandidates importCandidates = ImportCandidates.load(this.autoConfigurationAnnotation,
|
||||||
getBeanClassLoader());
|
getBeanClassLoader());
|
||||||
List<String> configurations = importCandidates.getCandidates();
|
List<String> configurations = importCandidates.getCandidates();
|
||||||
Assert.notEmpty(configurations,
|
Assert.state(!CollectionUtils.isEmpty(configurations),
|
||||||
"No auto configuration classes found in " + "META-INF/spring/"
|
"No auto configuration classes found in " + "META-INF/spring/"
|
||||||
+ this.autoConfigurationAnnotation.getName() + ".imports. If you "
|
+ this.autoConfigurationAnnotation.getName() + ".imports. If you "
|
||||||
+ "are using a custom packaging, make sure that file is correct.");
|
+ "are using a custom packaging, make sure that file is correct.");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -112,10 +112,10 @@ public class JobLauncherApplicationRunner
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
Assert.isTrue(this.jobs.size() <= 1 || StringUtils.hasText(this.jobName),
|
Assert.state(this.jobs.size() <= 1 || StringUtils.hasText(this.jobName),
|
||||||
"Job name must be specified in case of multiple jobs");
|
"Job name must be specified in case of multiple jobs");
|
||||||
if (StringUtils.hasText(this.jobName)) {
|
if (StringUtils.hasText(this.jobName)) {
|
||||||
Assert.isTrue(isLocalJob(this.jobName) || isRegisteredJob(this.jobName),
|
Assert.state(isLocalJob(this.jobName) || isRegisteredJob(this.jobName),
|
||||||
() -> "No job found with name '" + this.jobName + "'");
|
() -> "No job found with name '" + this.jobName + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -102,7 +102,7 @@ public class CacheAutoConfiguration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
Assert.notNull(this.cacheManager.getIfAvailable(),
|
Assert.state(this.cacheManager.getIfAvailable() != null,
|
||||||
() -> "No cache manager could be auto-configured, check your configuration (caching type is '"
|
() -> "No cache manager could be auto-configured, check your configuration (caching type is '"
|
||||||
+ this.cacheProperties.getType() + "')");
|
+ this.cacheProperties.getType() + "')");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -250,8 +250,8 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat
|
||||||
ConfigurableListableBeanFactory beanFactory = spec.getContext().getBeanFactory();
|
ConfigurableListableBeanFactory beanFactory = spec.getContext().getBeanFactory();
|
||||||
if (spec.getStrategy() == SearchStrategy.ANCESTORS) {
|
if (spec.getStrategy() == SearchStrategy.ANCESTORS) {
|
||||||
BeanFactory parent = beanFactory.getParentBeanFactory();
|
BeanFactory parent = beanFactory.getParentBeanFactory();
|
||||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, parent,
|
Assert.state(parent instanceof ConfigurableListableBeanFactory,
|
||||||
"Unable to use SearchStrategy.ANCESTORS");
|
"Unable to use SearchStrategy.ANCESTORS without ConfigurableListableBeanFactory");
|
||||||
beanFactory = (ConfigurableListableBeanFactory) parent;
|
beanFactory = (ConfigurableListableBeanFactory) parent;
|
||||||
}
|
}
|
||||||
return beanFactory;
|
return beanFactory;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -45,7 +45,7 @@ class OnResourceCondition extends SpringBootCondition {
|
||||||
ResourceLoader loader = context.getResourceLoader();
|
ResourceLoader loader = context.getResourceLoader();
|
||||||
List<String> locations = new ArrayList<>();
|
List<String> locations = new ArrayList<>();
|
||||||
collectValues(locations, attributes.get("resources"));
|
collectValues(locations, attributes.get("resources"));
|
||||||
Assert.isTrue(!locations.isEmpty(),
|
Assert.state(!locations.isEmpty(),
|
||||||
"@ConditionalOnResource annotations must specify at least one resource location");
|
"@ConditionalOnResource annotations must specify at least one resource location");
|
||||||
List<String> missing = new ArrayList<>();
|
List<String> missing = new ArrayList<>();
|
||||||
for (String location : locations) {
|
for (String location : locations) {
|
||||||
|
|
|
||||||
|
|
@ -583,7 +583,7 @@ public class FlywayAutoConfiguration {
|
||||||
Extension(FluentConfiguration configuration, Class<E> type, String name) {
|
Extension(FluentConfiguration configuration, Class<E> type, String name) {
|
||||||
this.extension = SingletonSupplier.of(() -> {
|
this.extension = SingletonSupplier.of(() -> {
|
||||||
E extension = configuration.getPluginRegister().getPlugin(type);
|
E extension = configuration.getPluginRegister().getPlugin(type);
|
||||||
Assert.notNull(extension, () -> "Flyway %s extension missing".formatted(name));
|
Assert.state(extension != null, () -> "Flyway %s extension missing".formatted(name));
|
||||||
return extension;
|
return extension;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -52,7 +52,7 @@ public class HazelcastProperties {
|
||||||
if (this.config == null) {
|
if (this.config == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Assert.isTrue(this.config.exists(),
|
Assert.state(this.config.exists(),
|
||||||
() -> "Hazelcast configuration does not exist '" + this.config.getDescription() + "'");
|
() -> "Hazelcast configuration does not exist '" + this.config.getDescription() + "'");
|
||||||
return this.config;
|
return this.config;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ public class JacksonAutoConfiguration {
|
||||||
// Find the field (this way we automatically support new constants
|
// Find the field (this way we automatically support new constants
|
||||||
// that may be added by Jackson in the future)
|
// that may be added by Jackson in the future)
|
||||||
Field field = findPropertyNamingStrategyField(fieldName);
|
Field field = findPropertyNamingStrategyField(fieldName);
|
||||||
Assert.notNull(field, () -> "Constant named '" + fieldName + "' not found");
|
Assert.state(field != null, () -> "Constant named '" + fieldName + "' not found");
|
||||||
try {
|
try {
|
||||||
builder.propertyNamingStrategy((PropertyNamingStrategy) field.get(null));
|
builder.propertyNamingStrategy((PropertyNamingStrategy) field.get(null));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -96,7 +96,8 @@ public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
|
||||||
try {
|
try {
|
||||||
Class<?> dataSourceClass = ClassUtils.forName(className, this.classLoader);
|
Class<?> dataSourceClass = ClassUtils.forName(className, this.classLoader);
|
||||||
Object instance = BeanUtils.instantiateClass(dataSourceClass);
|
Object instance = BeanUtils.instantiateClass(dataSourceClass);
|
||||||
Assert.isInstanceOf(XADataSource.class, instance);
|
Assert.state(instance instanceof XADataSource,
|
||||||
|
() -> "DataSource class " + className + " is not an XADataSource");
|
||||||
return (XADataSource) instance;
|
return (XADataSource) instance;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -175,8 +175,8 @@ class Saml2RelyingPartyRegistrationConfiguration {
|
||||||
try (InputStream inputStream = location.getInputStream()) {
|
try (InputStream inputStream = location.getInputStream()) {
|
||||||
PemContent pemContent = PemContent.load(inputStream);
|
PemContent pemContent = PemContent.load(inputStream);
|
||||||
PrivateKey privateKey = pemContent.getPrivateKey();
|
PrivateKey privateKey = pemContent.getPrivateKey();
|
||||||
Assert.isInstanceOf(RSAPrivateKey.class, privateKey,
|
Assert.state(privateKey instanceof RSAPrivateKey,
|
||||||
"PrivateKey in resource '" + location + "' must be an RSAPrivateKey");
|
() -> "PrivateKey in resource '" + location + "' must be an RSAPrivateKey");
|
||||||
return (RSAPrivateKey) privateKey;
|
return (RSAPrivateKey) privateKey;
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -53,7 +53,7 @@ class CertificateMatcher {
|
||||||
Assert.notNull(privateKey, "Private key must not be null");
|
Assert.notNull(privateKey, "Private key must not be null");
|
||||||
this.privateKey = privateKey;
|
this.privateKey = privateKey;
|
||||||
this.signature = createSignature(privateKey);
|
this.signature = createSignature(privateKey);
|
||||||
Assert.notNull(this.signature, "Failed to create signature");
|
Assert.state(this.signature != null, "Failed to create signature");
|
||||||
this.generatedSignature = sign(this.signature, privateKey);
|
this.generatedSignature = sign(this.signature, privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -127,7 +127,7 @@ public final class PropertiesSslBundle implements SslBundle {
|
||||||
if (properties.isVerifyKeys()) {
|
if (properties.isVerifyKeys()) {
|
||||||
CertificateMatcher certificateMatcher = new CertificateMatcher(pemSslStore.privateKey());
|
CertificateMatcher certificateMatcher = new CertificateMatcher(pemSslStore.privateKey());
|
||||||
Assert.state(certificateMatcher.matchesAny(pemSslStore.certificates()),
|
Assert.state(certificateMatcher.matchesAny(pemSslStore.certificates()),
|
||||||
"Private key in %s matches none of the certificates in the chain".formatted(propertyName));
|
() -> "Private key in %s matches none of the certificates in the chain".formatted(propertyName));
|
||||||
}
|
}
|
||||||
return pemSslStore;
|
return pemSslStore;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -91,7 +91,7 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -484,7 +484,7 @@ class BatchAutoConfigurationTests {
|
||||||
JobLauncherApplicationRunner runner = createInstance();
|
JobLauncherApplicationRunner runner = createInstance();
|
||||||
runner.setJobs(Arrays.asList(mockJob("one"), mockJob("two")));
|
runner.setJobs(Arrays.asList(mockJob("one"), mockJob("two")));
|
||||||
runner.setJobName("three");
|
runner.setJobName("three");
|
||||||
assertThatIllegalArgumentException().isThrownBy(runner::afterPropertiesSet)
|
assertThatIllegalStateException().isThrownBy(runner::afterPropertiesSet)
|
||||||
.withMessage("No job found with name 'three'");
|
.withMessage("No job found with name 'three'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -492,7 +492,7 @@ class BatchAutoConfigurationTests {
|
||||||
void whenTheUserDefinesAJobNameThatDoesNotExistWithRegisteredJobFailsFast() {
|
void whenTheUserDefinesAJobNameThatDoesNotExistWithRegisteredJobFailsFast() {
|
||||||
JobLauncherApplicationRunner runner = createInstance("one", "two");
|
JobLauncherApplicationRunner runner = createInstance("one", "two");
|
||||||
runner.setJobName("three");
|
runner.setJobName("three");
|
||||||
assertThatIllegalArgumentException().isThrownBy(runner::afterPropertiesSet)
|
assertThatIllegalStateException().isThrownBy(runner::afterPropertiesSet)
|
||||||
.withMessage("No job found with name 'three'");
|
.withMessage("No job found with name 'three'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -272,7 +272,7 @@ public class Restarter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Throwable doStart() throws Exception {
|
private Throwable doStart() throws Exception {
|
||||||
Assert.notNull(this.mainClassName, "Unable to find the main class to restart");
|
Assert.state(this.mainClassName != null, "Unable to find the main class to restart");
|
||||||
URL[] urls = this.urls.toArray(new URL[0]);
|
URL[] urls = this.urls.toArray(new URL[0]);
|
||||||
ClassLoaderFiles updatedFiles = new ClassLoaderFiles(this.classLoaderFiles);
|
ClassLoaderFiles updatedFiles = new ClassLoaderFiles(this.classLoaderFiles);
|
||||||
ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, urls, updatedFiles);
|
ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, urls, updatedFiles);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -97,7 +97,8 @@ class DefaultConnectionPorts implements ConnectionPorts {
|
||||||
@Override
|
@Override
|
||||||
public int get(int containerPort) {
|
public int get(int containerPort) {
|
||||||
Integer hostPort = this.portMappings.get(containerPort);
|
Integer hostPort = this.portMappings.get(containerPort);
|
||||||
Assert.state(hostPort != null, "No host port mapping found for container port %s".formatted(containerPort));
|
Assert.state(hostPort != null,
|
||||||
|
() -> "No host port mapping found for container port %s".formatted(containerPort));
|
||||||
return hostPort;
|
return hostPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -102,7 +102,7 @@ class DefaultDockerCompose implements DockerCompose {
|
||||||
Map<String, DockerCliInspectResponse> inspected = inspect(runningPsResponses);
|
Map<String, DockerCliInspectResponse> inspected = inspect(runningPsResponses);
|
||||||
for (DockerCliComposePsResponse psResponse : runningPsResponses) {
|
for (DockerCliComposePsResponse psResponse : runningPsResponses) {
|
||||||
DockerCliInspectResponse inspectResponse = inspectContainer(psResponse.id(), inspected);
|
DockerCliInspectResponse inspectResponse = inspectContainer(psResponse.id(), inspected);
|
||||||
Assert.notNull(inspectResponse, () -> "Failed to inspect container '%s'".formatted(psResponse.id()));
|
Assert.state(inspectResponse != null, () -> "Failed to inspect container '%s'".formatted(psResponse.id()));
|
||||||
result.add(new DefaultRunningService(this.hostname, dockerComposeFile, psResponse, inspectResponse));
|
result.add(new DefaultRunningService(this.hostname, dockerComposeFile, psResponse, inspectResponse));
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(result);
|
return Collections.unmodifiableList(result);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -47,7 +47,7 @@ public final class DockerComposeFile {
|
||||||
private final List<File> files;
|
private final List<File> files;
|
||||||
|
|
||||||
private DockerComposeFile(List<File> files) {
|
private DockerComposeFile(List<File> files) {
|
||||||
Assert.state(!files.isEmpty(), "Files must not be empty");
|
Assert.isTrue(!files.isEmpty(), "'files' must not be empty");
|
||||||
this.files = files.stream().map(DockerComposeFile::toCanonicalFile).toList();
|
this.files = files.stream().map(DockerComposeFile::toCanonicalFile).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ public final class DockerComposeFile {
|
||||||
if (!base.exists()) {
|
if (!base.exists()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Assert.isTrue(base.isDirectory(), () -> "'%s' is not a directory".formatted(base));
|
Assert.state(base.isDirectory(), () -> "'%s' is not a directory".formatted(base));
|
||||||
Path basePath = base.toPath();
|
Path basePath = base.toPath();
|
||||||
for (String candidate : SEARCH_ORDER) {
|
for (String candidate : SEARCH_ORDER) {
|
||||||
Path resolved = basePath.resolve(candidate);
|
Path resolved = basePath.resolve(candidate);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,6 +27,7 @@ import org.springframework.util.FileCopyUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link DockerComposeFile}.
|
* Tests for {@link DockerComposeFile}.
|
||||||
|
|
@ -104,7 +105,7 @@ class DockerComposeFileTests {
|
||||||
@Test
|
@Test
|
||||||
void findWhenWorkingDirectoryIsNotDirectoryThrowsException() throws Exception {
|
void findWhenWorkingDirectoryIsNotDirectoryThrowsException() throws Exception {
|
||||||
File file = createTempFile("iamafile");
|
File file = createTempFile("iamafile");
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> DockerComposeFile.find(file))
|
assertThatIllegalStateException().isThrownBy(() -> DockerComposeFile.find(file))
|
||||||
.withMessageEndingWith("is not a directory");
|
.withMessageEndingWith("is not a directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -65,7 +65,7 @@ class BuilderBuildpack implements Buildpack {
|
||||||
.of(unambiguous ? reference.getSubReference(PREFIX) : reference.toString());
|
.of(unambiguous ? reference.getSubReference(PREFIX) : reference.toString());
|
||||||
BuildpackMetadata buildpackMetadata = findBuildpackMetadata(context, builderReference);
|
BuildpackMetadata buildpackMetadata = findBuildpackMetadata(context, builderReference);
|
||||||
if (unambiguous) {
|
if (unambiguous) {
|
||||||
Assert.isTrue(buildpackMetadata != null, () -> "Buildpack '" + reference + "' not found in builder");
|
Assert.state(buildpackMetadata != null, () -> "Buildpack '" + reference + "' not found in builder");
|
||||||
}
|
}
|
||||||
return (buildpackMetadata != null) ? new BuilderBuildpack(buildpackMetadata) : null;
|
return (buildpackMetadata != null) ? new BuilderBuildpack(buildpackMetadata) : null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -158,7 +158,7 @@ class BuilderMetadata extends MappedObject {
|
||||||
static BuilderMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
|
static BuilderMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
|
||||||
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
||||||
String json = imageConfig.getLabels().get(LABEL_NAME);
|
String json = imageConfig.getLabels().get(LABEL_NAME);
|
||||||
Assert.notNull(json, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
|
Assert.state(json != null, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
|
||||||
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");
|
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");
|
||||||
return fromJson(json);
|
return fromJson(json);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -77,7 +77,7 @@ final class BuildpackLayersMetadata extends MappedObject {
|
||||||
static BuildpackLayersMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
|
static BuildpackLayersMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
|
||||||
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
||||||
String json = imageConfig.getLabels().get(LABEL_NAME);
|
String json = imageConfig.getLabels().get(LABEL_NAME);
|
||||||
Assert.notNull(json, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
|
Assert.state(json != null, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
|
||||||
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");
|
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");
|
||||||
return fromJson(json);
|
return fromJson(json);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -94,7 +94,7 @@ final class BuildpackMetadata extends MappedObject {
|
||||||
static BuildpackMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
|
static BuildpackMetadata fromImageConfig(ImageConfig imageConfig) throws IOException {
|
||||||
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
||||||
String json = imageConfig.getLabels().get(LABEL_NAME);
|
String json = imageConfig.getLabels().get(LABEL_NAME);
|
||||||
Assert.notNull(json, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
|
Assert.state(json != null, () -> "No '" + LABEL_NAME + "' label found in image config labels '"
|
||||||
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");
|
+ StringUtils.collectionToCommaDelimitedString(imageConfig.getLabels().keySet()) + "'");
|
||||||
return fromJson(json);
|
return fromJson(json);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -56,7 +56,7 @@ final class DirectoryBuildpack implements Buildpack {
|
||||||
|
|
||||||
private BuildpackCoordinates findBuildpackCoordinates(Path path) {
|
private BuildpackCoordinates findBuildpackCoordinates(Path path) {
|
||||||
Path buildpackToml = path.resolve("buildpack.toml");
|
Path buildpackToml = path.resolve("buildpack.toml");
|
||||||
Assert.isTrue(Files.exists(buildpackToml),
|
Assert.state(Files.exists(buildpackToml),
|
||||||
() -> "Buildpack descriptor 'buildpack.toml' is required in buildpack '" + path + "'");
|
() -> "Buildpack descriptor 'buildpack.toml' is required in buildpack '" + path + "'");
|
||||||
try {
|
try {
|
||||||
try (InputStream inputStream = Files.newInputStream(buildpackToml)) {
|
try (InputStream inputStream = Files.newInputStream(buildpackToml)) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -127,7 +127,8 @@ class ExportedImageTar implements Closeable {
|
||||||
entry = tar.getNextEntry();
|
entry = tar.getNextEntry();
|
||||||
}
|
}
|
||||||
Assert.state(index != null || manifest != null,
|
Assert.state(index != null || manifest != null,
|
||||||
"Exported image '%s' does not contain 'index.json' or 'manifest.json'".formatted(reference));
|
() -> "Exported image '%s' does not contain 'index.json' or 'manifest.json'"
|
||||||
|
.formatted(reference));
|
||||||
return (index != null) ? new IndexLayerArchiveFactory(tarFile, index)
|
return (index != null) ? new IndexLayerArchiveFactory(tarFile, index)
|
||||||
: new ManifestLayerArchiveFactory(tarFile, manifest);
|
: new ManifestLayerArchiveFactory(tarFile, manifest);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -445,7 +445,7 @@ final class PemPrivateKeyParser {
|
||||||
public static final String PBES2_ALGORITHM = "PBES2";
|
public static final String PBES2_ALGORITHM = "PBES2";
|
||||||
|
|
||||||
static PKCS8EncodedKeySpec decrypt(byte[] bytes, String password) {
|
static PKCS8EncodedKeySpec decrypt(byte[] bytes, String password) {
|
||||||
Assert.notNull(password, "Password is required for an encrypted private key");
|
Assert.state(password != null, "Password is required for an encrypted private key");
|
||||||
try {
|
try {
|
||||||
EncryptedPrivateKeyInfo keyInfo = new EncryptedPrivateKeyInfo(bytes);
|
EncryptedPrivateKeyInfo keyInfo = new EncryptedPrivateKeyInfo(bytes);
|
||||||
AlgorithmParameters algorithmParameters = keyInfo.getAlgParameters();
|
AlgorithmParameters algorithmParameters = keyInfo.getAlgParameters();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -35,6 +35,7 @@ import org.springframework.boot.buildpack.platform.docker.configuration.DockerHo
|
||||||
import org.springframework.boot.buildpack.platform.docker.configuration.ResolvedDockerHost;
|
import org.springframework.boot.buildpack.platform.docker.configuration.ResolvedDockerHost;
|
||||||
import org.springframework.boot.buildpack.platform.docker.ssl.SslContextFactory;
|
import org.springframework.boot.buildpack.platform.docker.ssl.SslContextFactory;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link HttpClientTransport} that talks to a remote Docker.
|
* {@link HttpClientTransport} that talks to a remote Docker.
|
||||||
|
|
@ -85,8 +86,8 @@ final class RemoteHttpClientTransport extends HttpClientTransport {
|
||||||
|
|
||||||
private static TlsSocketStrategy getTlsSocketStrategy(DockerHost host, SslContextFactory sslContextFactory) {
|
private static TlsSocketStrategy getTlsSocketStrategy(DockerHost host, SslContextFactory sslContextFactory) {
|
||||||
String directory = host.getCertificatePath();
|
String directory = host.getCertificatePath();
|
||||||
Assert.hasText(directory,
|
Assert.state(StringUtils.hasText(directory),
|
||||||
() -> "Docker host TLS verification requires trust material location to be specified with certificate path");
|
"Docker host TLS verification requires trust material location to be specified with certificate path");
|
||||||
SSLContext sslContext = sslContextFactory.forDirectory(directory);
|
SSLContext sslContext = sslContextFactory.forDirectory(directory);
|
||||||
return new DefaultClientTlsStrategy(sslContext);
|
return new DefaultClientTlsStrategy(sslContext);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,7 +27,7 @@ import org.springframework.boot.buildpack.platform.docker.type.Layer;
|
||||||
import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
|
import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||||
@Test
|
@Test
|
||||||
void resolveWhenFullyQualifiedBuildpackWithVersionNotInBuilderThrowsException() {
|
void resolveWhenFullyQualifiedBuildpackWithVersionNotInBuilderThrowsException() {
|
||||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack1@1.2.3");
|
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack1@1.2.3");
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderBuildpack.resolve(this.resolverContext, reference))
|
assertThatIllegalStateException().isThrownBy(() -> BuilderBuildpack.resolve(this.resolverContext, reference))
|
||||||
.withMessageContaining("'urn:cnb:builder:example/buildpack1@1.2.3'")
|
.withMessageContaining("'urn:cnb:builder:example/buildpack1@1.2.3'")
|
||||||
.withMessageContaining("not found in builder");
|
.withMessageContaining("not found in builder");
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,7 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||||
@Test
|
@Test
|
||||||
void resolveWhenFullyQualifiedBuildpackWithoutVersionNotInBuilderThrowsException() {
|
void resolveWhenFullyQualifiedBuildpackWithoutVersionNotInBuilderThrowsException() {
|
||||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack1");
|
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack1");
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderBuildpack.resolve(this.resolverContext, reference))
|
assertThatIllegalStateException().isThrownBy(() -> BuilderBuildpack.resolve(this.resolverContext, reference))
|
||||||
.withMessageContaining("'urn:cnb:builder:example/buildpack1'")
|
.withMessageContaining("'urn:cnb:builder:example/buildpack1'")
|
||||||
.withMessageContaining("not found in builder");
|
.withMessageContaining("not found in builder");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.assertj.core.api.Assertions.tuple;
|
import static org.assertj.core.api.Assertions.tuple;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -105,7 +106,7 @@ class BuilderMetadataTests extends AbstractJsonTests {
|
||||||
ImageConfig imageConfig = mock(ImageConfig.class);
|
ImageConfig imageConfig = mock(ImageConfig.class);
|
||||||
given(image.getConfig()).willReturn(imageConfig);
|
given(image.getConfig()).willReturn(imageConfig);
|
||||||
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderMetadata.fromImage(image))
|
assertThatIllegalStateException().isThrownBy(() -> BuilderMetadata.fromImage(image))
|
||||||
.withMessage("No 'io.buildpacks.builder.metadata' label found in image config labels 'alpha'");
|
.withMessage("No 'io.buildpacks.builder.metadata' label found in image config labels 'alpha'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -517,7 +517,7 @@ class BuilderTests {
|
||||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack@1.2.3");
|
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack@1.2.3");
|
||||||
BuildRequest request = getTestRequest().withBuildpacks(reference);
|
BuildRequest request = getTestRequest().withBuildpacks(reference);
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> builder.build(request))
|
assertThatIllegalStateException().isThrownBy(() -> builder.build(request))
|
||||||
.withMessageContaining("'urn:cnb:builder:example/buildpack@1.2.3'")
|
.withMessageContaining("'urn:cnb:builder:example/buildpack@1.2.3'")
|
||||||
.withMessageContaining("not found in builder");
|
.withMessageContaining("not found in builder");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,6 +27,7 @@ import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -70,7 +71,7 @@ class BuildpackLayersMetadataTests extends AbstractJsonTests {
|
||||||
ImageConfig imageConfig = mock(ImageConfig.class);
|
ImageConfig imageConfig = mock(ImageConfig.class);
|
||||||
given(image.getConfig()).willReturn(imageConfig);
|
given(image.getConfig()).willReturn(imageConfig);
|
||||||
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(image))
|
assertThatIllegalStateException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(image))
|
||||||
.withMessage("No 'io.buildpacks.buildpack.layers' label found in image config labels 'alpha'");
|
.withMessage("No 'io.buildpacks.buildpack.layers' label found in image config labels 'alpha'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,6 +27,7 @@ import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -64,7 +65,7 @@ class BuildpackMetadataTests extends AbstractJsonTests {
|
||||||
ImageConfig imageConfig = mock(ImageConfig.class);
|
ImageConfig imageConfig = mock(ImageConfig.class);
|
||||||
given(image.getConfig()).willReturn(imageConfig);
|
given(image.getConfig()).willReturn(imageConfig);
|
||||||
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackMetadata.fromImage(image))
|
assertThatIllegalStateException().isThrownBy(() -> BuildpackMetadata.fromImage(image))
|
||||||
.withMessage("No 'io.buildpacks.buildpackage.metadata' label found in image config labels 'alpha'");
|
.withMessage("No 'io.buildpacks.buildpackage.metadata' label found in image config labels 'alpha'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -37,7 +37,7 @@ import org.junit.jupiter.api.condition.OS;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.assertj.core.api.Assertions.tuple;
|
import static org.assertj.core.api.Assertions.tuple;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -89,8 +89,7 @@ class DirectoryBuildpackTests {
|
||||||
void resolveWhenDirectoryWithoutBuildpackTomlThrowsException() throws Exception {
|
void resolveWhenDirectoryWithoutBuildpackTomlThrowsException() throws Exception {
|
||||||
Files.createDirectories(this.buildpackDir.toPath());
|
Files.createDirectories(this.buildpackDir.toPath());
|
||||||
BuildpackReference reference = BuildpackReference.of(this.buildpackDir.toString());
|
BuildpackReference reference = BuildpackReference.of(this.buildpackDir.toString());
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalStateException().isThrownBy(() -> DirectoryBuildpack.resolve(this.resolverContext, reference))
|
||||||
.isThrownBy(() -> DirectoryBuildpack.resolve(this.resolverContext, reference))
|
|
||||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||||
.withMessageContaining(this.buildpackDir.getAbsolutePath());
|
.withMessageContaining(this.buildpackDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -43,6 +43,7 @@ import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.assertj.core.api.Assertions.fail;
|
import static org.assertj.core.api.Assertions.fail;
|
||||||
import static org.assertj.core.api.Assertions.tuple;
|
import static org.assertj.core.api.Assertions.tuple;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
|
@ -156,7 +157,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
||||||
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
|
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
|
||||||
given(resolverContext.fetchImage(any(), any())).willReturn(image);
|
given(resolverContext.fetchImage(any(), any())).willReturn(image);
|
||||||
BuildpackReference reference = BuildpackReference.of("docker://example/buildpack1:latest");
|
BuildpackReference reference = BuildpackReference.of("docker://example/buildpack1:latest");
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
|
assertThatIllegalStateException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
|
||||||
.withMessageContaining("No 'io.buildpacks.buildpackage.metadata' label found");
|
.withMessageContaining("No 'io.buildpacks.buildpackage.metadata' label found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,7 +28,7 @@ import org.springframework.boot.buildpack.platform.docker.configuration.Resolved
|
||||||
import org.springframework.boot.buildpack.platform.docker.ssl.SslContextFactory;
|
import org.springframework.boot.buildpack.platform.docker.ssl.SslContextFactory;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ class RemoteHttpClientTransportTests {
|
||||||
void createIfPossibleWhenTlsVerifyWithMissingCertPathThrowsException() {
|
void createIfPossibleWhenTlsVerifyWithMissingCertPathThrowsException() {
|
||||||
ResolvedDockerHost dockerHost = ResolvedDockerHost
|
ResolvedDockerHost dockerHost = ResolvedDockerHost
|
||||||
.from(DockerHostConfiguration.forAddress("tcp://192.168.1.2:2376", true, null));
|
.from(DockerHostConfiguration.forAddress("tcp://192.168.1.2:2376", true, null));
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> RemoteHttpClientTransport.createIfPossible(dockerHost))
|
assertThatIllegalStateException().isThrownBy(() -> RemoteHttpClientTransport.createIfPossible(dockerHost))
|
||||||
.withMessageContaining("Docker host TLS verification requires trust material");
|
.withMessageContaining("Docker host TLS verification requires trust material");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -220,7 +220,7 @@ public class InitCommand extends OptionParsingCommand {
|
||||||
|
|
||||||
protected ProjectGenerationRequest createProjectGenerationRequest(OptionSet options) {
|
protected ProjectGenerationRequest createProjectGenerationRequest(OptionSet options) {
|
||||||
List<?> nonOptionArguments = new ArrayList<Object>(options.nonOptionArguments());
|
List<?> nonOptionArguments = new ArrayList<Object>(options.nonOptionArguments());
|
||||||
Assert.isTrue(nonOptionArguments.size() <= 1, "Only the target location may be specified");
|
Assert.state(nonOptionArguments.size() <= 1, "Only the target location may be specified");
|
||||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||||
request.setServiceUrl(options.valueOf(this.target));
|
request.setServiceUrl(options.valueOf(this.target));
|
||||||
if (options.has(this.bootVersion)) {
|
if (options.has(this.bootVersion)) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -128,13 +128,13 @@ class IndexedJarStructure implements JarStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toStructureDependency(String libEntryName) {
|
private String toStructureDependency(String libEntryName) {
|
||||||
Assert.state(libEntryName.startsWith(this.libLocation), "Invalid library location " + libEntryName);
|
Assert.state(libEntryName.startsWith(this.libLocation), () -> "Invalid library location " + libEntryName);
|
||||||
return libEntryName.substring(this.libLocation.length());
|
return libEntryName.substring(this.libLocation.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getMandatoryAttribute(Manifest manifest, String attribute) {
|
private static String getMandatoryAttribute(Manifest manifest, String attribute) {
|
||||||
String value = manifest.getMainAttributes().getValue(attribute);
|
String value = manifest.getMainAttributes().getValue(attribute);
|
||||||
Assert.state(value != null, "Manifest attribute '" + attribute + "' is mandatory");
|
Assert.state(value != null, () -> "Manifest attribute '" + attribute + "' is mandatory");
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -60,7 +60,7 @@ class IndexedLayers implements Layers {
|
||||||
this.layers.put(line.substring(3, line.length() - 2), contents);
|
this.layers.put(line.substring(3, line.length() - 2), contents);
|
||||||
}
|
}
|
||||||
else if (line.startsWith(" - ")) {
|
else if (line.startsWith(" - ")) {
|
||||||
Assert.notNull(contents, "Contents must not be null. Check if the index file is malformed!");
|
Assert.state(contents != null, "Contents must not be null. Check if the index file is malformed!");
|
||||||
contents.add(line.substring(5, line.length() - 1));
|
contents.add(line.substring(5, line.length() - 1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -154,7 +154,7 @@ class PropertyMigration {
|
||||||
ConfigurationPropertyName oldName = property.getName();
|
ConfigurationPropertyName oldName = property.getName();
|
||||||
ConfigurationPropertyName oldPrefix = ConfigurationPropertyName.of(metadata.getId());
|
ConfigurationPropertyName oldPrefix = ConfigurationPropertyName.of(metadata.getId());
|
||||||
Assert.state(oldPrefix.isAncestorOf(oldName),
|
Assert.state(oldPrefix.isAncestorOf(oldName),
|
||||||
String.format("'%s' is not an ancestor of '%s'", oldPrefix, oldName));
|
() -> "'%s' is not an ancestor of '%s'".formatted(oldPrefix, oldName));
|
||||||
ConfigurationPropertyName newPrefix = ConfigurationPropertyName.of(replacement.getId());
|
ConfigurationPropertyName newPrefix = ConfigurationPropertyName.of(replacement.getId());
|
||||||
return newPrefix.append(oldName.subName(oldPrefix.getNumberOfElements()));
|
return newPrefix.append(oldName.subName(oldPrefix.getNumberOfElements()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -69,7 +69,7 @@ class DisabledIfProcessUnavailableCondition implements ExecutionCondition {
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||||
try {
|
try {
|
||||||
Process process = processBuilder.start();
|
Process process = processBuilder.start();
|
||||||
Assert.isTrue(process.waitFor(30, TimeUnit.SECONDS), "Process did not exit within 30 seconds");
|
Assert.state(process.waitFor(30, TimeUnit.SECONDS), "Process did not exit within 30 seconds");
|
||||||
Assert.state(process.exitValue() == 0, () -> "Process exited with %d".formatted(process.exitValue()));
|
Assert.state(process.exitValue() == 0, () -> "Process exited with %d".formatted(process.exitValue()));
|
||||||
process.destroy();
|
process.destroy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -410,7 +410,7 @@ public class SpringApplication {
|
||||||
if (!AotDetector.useGeneratedArtifacts()) {
|
if (!AotDetector.useGeneratedArtifacts()) {
|
||||||
// Load the sources
|
// Load the sources
|
||||||
Set<Object> sources = getAllSources();
|
Set<Object> sources = getAllSources();
|
||||||
Assert.notEmpty(sources, "Sources must not be empty");
|
Assert.state(!ObjectUtils.isEmpty(sources), "No sources defined");
|
||||||
load(context, sources.toArray(new Object[0]));
|
load(context, sources.toArray(new Object[0]));
|
||||||
}
|
}
|
||||||
listeners.contextLoaded(context);
|
listeners.contextLoaded(context);
|
||||||
|
|
@ -608,7 +608,7 @@ public class SpringApplication {
|
||||||
for (ApplicationContextInitializer initializer : getInitializers()) {
|
for (ApplicationContextInitializer initializer : getInitializers()) {
|
||||||
Class<?> requiredType = GenericTypeResolver.resolveTypeArgument(initializer.getClass(),
|
Class<?> requiredType = GenericTypeResolver.resolveTypeArgument(initializer.getClass(),
|
||||||
ApplicationContextInitializer.class);
|
ApplicationContextInitializer.class);
|
||||||
Assert.isInstanceOf(requiredType, context, "Unable to call initializer.");
|
Assert.state(requiredType.isInstance(context), "Unable to call initializer");
|
||||||
initializer.initialize(context);
|
initializer.initialize(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class SpringApplicationAotProcessor extends ContextAotProcessor {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
int requiredArgs = 6;
|
int requiredArgs = 6;
|
||||||
Assert.isTrue(args.length >= requiredArgs, () -> "Usage: " + SpringApplicationAotProcessor.class.getName()
|
Assert.state(args.length >= requiredArgs, () -> "Usage: " + SpringApplicationAotProcessor.class.getName()
|
||||||
+ " <applicationMainClass> <sourceOutput> <resourceOutput> <classOutput> <groupId> <artifactId> <originalArgs...>");
|
+ " <applicationMainClass> <sourceOutput> <resourceOutput> <classOutput> <groupId> <artifactId> <originalArgs...>");
|
||||||
Class<?> application = Class.forName(args[0]);
|
Class<?> application = Class.forName(args[0]);
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
|
|
@ -110,7 +110,7 @@ public class SpringApplicationAotProcessor extends ContextAotProcessor {
|
||||||
}
|
}
|
||||||
catch (AbandonedRunException ex) {
|
catch (AbandonedRunException ex) {
|
||||||
ApplicationContext context = ex.getApplicationContext();
|
ApplicationContext context = ex.getApplicationContext();
|
||||||
Assert.isInstanceOf(GenericApplicationContext.class, context,
|
Assert.state(context instanceof GenericApplicationContext,
|
||||||
() -> "AOT processing requires a GenericApplicationContext but got a "
|
() -> "AOT processing requires a GenericApplicationContext but got a "
|
||||||
+ context.getClass().getName());
|
+ context.getClass().getName());
|
||||||
return (GenericApplicationContext) context;
|
return (GenericApplicationContext) context;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -60,7 +60,7 @@ public class ConfigTreeConfigDataLocationResolver implements ConfigDataLocationR
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ConfigTreeConfigDataResource> resolve(String location) throws IOException {
|
private List<ConfigTreeConfigDataResource> resolve(String location) throws IOException {
|
||||||
Assert.isTrue(location.endsWith("/"),
|
Assert.state(location.endsWith("/"),
|
||||||
() -> String.format("Config tree location '%s' must end with '/'", location));
|
() -> String.format("Config tree location '%s' must end with '/'", location));
|
||||||
if (!this.resourceLoader.isPattern(location)) {
|
if (!this.resourceLoader.isPattern(location)) {
|
||||||
return Collections.singletonList(new ConfigTreeConfigDataResource(location));
|
return Collections.singletonList(new ConfigTreeConfigDataResource(location));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -91,7 +91,7 @@ public class BufferingApplicationStartup implements ApplicationStartup {
|
||||||
* already.
|
* already.
|
||||||
*/
|
*/
|
||||||
public void startRecording() {
|
public void startRecording() {
|
||||||
Assert.state(this.events.isEmpty(), "Cannot restart recording once steps have been buffered.");
|
Assert.state(this.events.isEmpty(), "Cannot restart recording once steps have been buffered");
|
||||||
this.startTime = this.clock.instant();
|
this.startTime = this.clock.instant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -264,7 +264,7 @@ public enum PeriodStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int intValue(Period value) {
|
private int intValue(Period value) {
|
||||||
Assert.notNull(this.intValue, () -> "intValue cannot be extracted from " + name());
|
Assert.state(this.intValue != null, () -> "intValue cannot be extracted from " + name());
|
||||||
return this.intValue.apply(value);
|
return this.intValue.apply(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -195,11 +195,11 @@ public class RandomValuePropertySource extends PropertySource<Random> {
|
||||||
String[] tokens = StringUtils.commaDelimitedListToStringArray(value);
|
String[] tokens = StringUtils.commaDelimitedListToStringArray(value);
|
||||||
T min = parse.apply(tokens[0]);
|
T min = parse.apply(tokens[0]);
|
||||||
if (tokens.length == 1) {
|
if (tokens.length == 1) {
|
||||||
Assert.isTrue(min.compareTo(zero) > 0, "Bound must be positive.");
|
Assert.state(min.compareTo(zero) > 0, "Bound must be positive.");
|
||||||
return new Range<>(value, zero, min);
|
return new Range<>(value, zero, min);
|
||||||
}
|
}
|
||||||
T max = parse.apply(tokens[1]);
|
T max = parse.apply(tokens[1]);
|
||||||
Assert.isTrue(min.compareTo(max) < 0, "Lower bound must be less than upper bound.");
|
Assert.state(min.compareTo(max) < 0, "Lower bound must be less than upper bound.");
|
||||||
return new Range<>(value, min, max);
|
return new Range<>(value, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -61,9 +61,9 @@ public class HikariCheckpointRestoreLifecycle implements Lifecycle {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Field closeConnectionExecutor = ReflectionUtils.findField(HikariPool.class, "closeConnectionExecutor");
|
Field closeConnectionExecutor = ReflectionUtils.findField(HikariPool.class, "closeConnectionExecutor");
|
||||||
Assert.notNull(closeConnectionExecutor, "Unable to locate closeConnectionExecutor for HikariPool");
|
Assert.state(closeConnectionExecutor != null, "Unable to locate closeConnectionExecutor for HikariPool");
|
||||||
Assert.isAssignable(ThreadPoolExecutor.class, closeConnectionExecutor.getType(),
|
Assert.state(ThreadPoolExecutor.class.isAssignableFrom(closeConnectionExecutor.getType()),
|
||||||
"Expected ThreadPoolExecutor for closeConnectionExecutor but found %s"
|
() -> "Expected ThreadPoolExecutor for closeConnectionExecutor but found %s"
|
||||||
.formatted(closeConnectionExecutor.getType()));
|
.formatted(closeConnectionExecutor.getType()));
|
||||||
ReflectionUtils.makeAccessible(closeConnectionExecutor);
|
ReflectionUtils.makeAccessible(closeConnectionExecutor);
|
||||||
CLOSE_CONNECTION_EXECUTOR = closeConnectionExecutor;
|
CLOSE_CONNECTION_EXECUTOR = closeConnectionExecutor;
|
||||||
|
|
@ -104,7 +104,7 @@ public class HikariCheckpointRestoreLifecycle implements Lifecycle {
|
||||||
this.hasOpenConnections = (pool) -> {
|
this.hasOpenConnections = (pool) -> {
|
||||||
ThreadPoolExecutor closeConnectionExecutor = (ThreadPoolExecutor) ReflectionUtils
|
ThreadPoolExecutor closeConnectionExecutor = (ThreadPoolExecutor) ReflectionUtils
|
||||||
.getField(CLOSE_CONNECTION_EXECUTOR, pool);
|
.getField(CLOSE_CONNECTION_EXECUTOR, pool);
|
||||||
Assert.notNull(closeConnectionExecutor, "CloseConnectionExecutor was null");
|
Assert.state(closeConnectionExecutor != null, "'closeConnectionExecutor' was null");
|
||||||
return closeConnectionExecutor.getActiveCount() > 0;
|
return closeConnectionExecutor.getActiveCount() > 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -184,7 +184,7 @@ class JsonValueWriter {
|
||||||
|
|
||||||
<E> void writeElement(E element) {
|
<E> void writeElement(E element) {
|
||||||
ActiveSeries activeSeries = this.activeSeries.peek();
|
ActiveSeries activeSeries = this.activeSeries.peek();
|
||||||
Assert.notNull(activeSeries, "No series has been started");
|
Assert.state(activeSeries != null, "No series has been started");
|
||||||
this.path = activeSeries.updatePath(this.path);
|
this.path = activeSeries.updatePath(this.path);
|
||||||
activeSeries.incrementIndexAndAddCommaIfRequired();
|
activeSeries.incrementIndexAndAddCommaIfRequired();
|
||||||
write(element);
|
write(element);
|
||||||
|
|
@ -223,7 +223,7 @@ class JsonValueWriter {
|
||||||
if (!isFilteredPath()) {
|
if (!isFilteredPath()) {
|
||||||
String processedName = processName(name.toString());
|
String processedName = processName(name.toString());
|
||||||
ActiveSeries activeSeries = this.activeSeries.peek();
|
ActiveSeries activeSeries = this.activeSeries.peek();
|
||||||
Assert.notNull(activeSeries, "No series has been started");
|
Assert.state(activeSeries != null, "No series has been started");
|
||||||
activeSeries.incrementIndexAndAddCommaIfRequired();
|
activeSeries.incrementIndexAndAddCommaIfRequired();
|
||||||
Assert.state(activeSeries.addName(processedName),
|
Assert.state(activeSeries.addName(processedName),
|
||||||
() -> "The name '" + processedName + "' has already been written");
|
() -> "The name '" + processedName + "' has already been written");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -190,7 +190,7 @@ public final class LoggerConfiguration {
|
||||||
* @throws IllegalStateException if this is a {@link #isCustom() custom} level
|
* @throws IllegalStateException if this is a {@link #isCustom() custom} level
|
||||||
*/
|
*/
|
||||||
public LogLevel getLevel() {
|
public LogLevel getLevel() {
|
||||||
Assert.state(this.logLevel != null, "Unable to provide LogLevel for '" + this.name + "'");
|
Assert.state(this.logLevel != null, () -> "Unable to provide LogLevel for '" + this.name + "'");
|
||||||
return this.logLevel;
|
return this.logLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -409,7 +409,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
|
||||||
|
|
||||||
private LoggerContext getLoggerContext() {
|
private LoggerContext getLoggerContext() {
|
||||||
ILoggerFactory factory = getLoggerFactory();
|
ILoggerFactory factory = getLoggerFactory();
|
||||||
Assert.isInstanceOf(LoggerContext.class, factory,
|
Assert.state(factory instanceof LoggerContext,
|
||||||
() -> String.format(
|
() -> String.format(
|
||||||
"LoggerFactory is not a Logback LoggerContext but Logback is on "
|
"LoggerFactory is not a Logback LoggerContext but Logback is on "
|
||||||
+ "the classpath. Either remove Logback or the competing "
|
+ "the classpath. Either remove Logback or the competing "
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -147,7 +147,7 @@ public class StructuredLogFormatterFactory<E> {
|
||||||
private void checkTypeArgument(Object formatter) {
|
private void checkTypeArgument(Object formatter) {
|
||||||
Class<?> typeArgument = GenericTypeResolver.resolveTypeArgument(formatter.getClass(),
|
Class<?> typeArgument = GenericTypeResolver.resolveTypeArgument(formatter.getClass(),
|
||||||
StructuredLogFormatter.class);
|
StructuredLogFormatter.class);
|
||||||
Assert.isTrue(this.logEventType.equals(typeArgument),
|
Assert.state(this.logEventType.equals(typeArgument),
|
||||||
() -> "Type argument of %s must be %s but was %s".formatted(formatter.getClass().getName(),
|
() -> "Type argument of %s must be %s but was %s".formatted(formatter.getClass().getName(),
|
||||||
this.logEventType.getName(), (typeArgument != null) ? typeArgument.getName() : "null"));
|
this.logEventType.getName(), (typeArgument != null) ? typeArgument.getName() : "null"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -99,7 +99,7 @@ public enum EmbeddedDatabaseConnection {
|
||||||
*/
|
*/
|
||||||
public static boolean isEmbedded(ConnectionFactory connectionFactory) {
|
public static boolean isEmbedded(ConnectionFactory connectionFactory) {
|
||||||
OptionsCapableConnectionFactory optionsCapable = OptionsCapableConnectionFactory.unwrapFrom(connectionFactory);
|
OptionsCapableConnectionFactory optionsCapable = OptionsCapableConnectionFactory.unwrapFrom(connectionFactory);
|
||||||
Assert.notNull(optionsCapable,
|
Assert.state(optionsCapable != null,
|
||||||
() -> "Cannot determine database's type as ConnectionFactory is not options-capable. To be "
|
() -> "Cannot determine database's type as ConnectionFactory is not options-capable. To be "
|
||||||
+ "options-capable, a ConnectionFactory should be created with "
|
+ "options-capable, a ConnectionFactory should be created with "
|
||||||
+ ConnectionFactoryBuilder.class.getName());
|
+ ConnectionFactoryBuilder.class.getName());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -445,7 +445,7 @@ final class PemPrivateKeyParser {
|
||||||
public static final String PBES2_ALGORITHM = "PBES2";
|
public static final String PBES2_ALGORITHM = "PBES2";
|
||||||
|
|
||||||
static PKCS8EncodedKeySpec decrypt(byte[] bytes, String password) {
|
static PKCS8EncodedKeySpec decrypt(byte[] bytes, String password) {
|
||||||
Assert.notNull(password, "Password is required for an encrypted private key");
|
Assert.state(password != null, "Password is required for an encrypted private key");
|
||||||
try {
|
try {
|
||||||
EncryptedPrivateKeyInfo keyInfo = new EncryptedPrivateKeyInfo(bytes);
|
EncryptedPrivateKeyInfo keyInfo = new EncryptedPrivateKeyInfo(bytes);
|
||||||
AlgorithmParameters algorithmParameters = keyInfo.getAlgParameters();
|
AlgorithmParameters algorithmParameters = keyInfo.getAlgParameters();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -29,6 +29,7 @@ import java.util.function.Supplier;
|
||||||
import org.springframework.boot.ssl.SslStoreBundle;
|
import org.springframework.boot.ssl.SslStoreBundle;
|
||||||
import org.springframework.core.style.ToStringCreator;
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.util.function.SingletonSupplier;
|
import org.springframework.util.function.SingletonSupplier;
|
||||||
|
|
||||||
|
|
@ -89,7 +90,7 @@ public class PemSslStoreBundle implements SslStoreBundle {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<X509Certificate> certificates = pemSslStore.certificates();
|
List<X509Certificate> certificates = pemSslStore.certificates();
|
||||||
Assert.notEmpty(certificates, "Certificates must not be empty");
|
Assert.state(!ObjectUtils.isEmpty(certificates), "Certificates must not be empty");
|
||||||
String alias = (pemSslStore.alias() != null) ? pemSslStore.alias() : DEFAULT_ALIAS;
|
String alias = (pemSslStore.alias() != null) ? pemSslStore.alias() : DEFAULT_ALIAS;
|
||||||
KeyStore store = createKeyStore(pemSslStore.type());
|
KeyStore store = createKeyStore(pemSslStore.type());
|
||||||
PrivateKey privateKey = pemSslStore.privateKey();
|
PrivateKey privateKey = pemSslStore.privateKey();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -182,7 +182,7 @@ public class Instantiator<T> {
|
||||||
public <A> A getArg(Class<A> type) {
|
public <A> A getArg(Class<A> type) {
|
||||||
Assert.notNull(type, "'type' must not be null");
|
Assert.notNull(type, "'type' must not be null");
|
||||||
Function<Class<?>, Object> parameter = getAvailableParameter(type);
|
Function<Class<?>, Object> parameter = getAvailableParameter(type);
|
||||||
Assert.isTrue(parameter != null, "Unknown argument type " + type.getName());
|
Assert.state(parameter != null, "Unknown argument type " + type.getName());
|
||||||
return (A) parameter.apply(this.type);
|
return (A) parameter.apply(this.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ public class Instantiator<T> {
|
||||||
private T instantiate(TypeSupplier typeSupplier) {
|
private T instantiate(TypeSupplier typeSupplier) {
|
||||||
try {
|
try {
|
||||||
Class<?> type = typeSupplier.get();
|
Class<?> type = typeSupplier.get();
|
||||||
Assert.isAssignable(this.type, type);
|
Assert.state(this.type.isAssignableFrom(type), () -> type + " is not assignable to " + this.type);
|
||||||
return instantiate(type);
|
return instantiate(type);
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -162,7 +162,7 @@ public class NettyWebServer implements WebServer {
|
||||||
}
|
}
|
||||||
if (this.resourceFactory != null) {
|
if (this.resourceFactory != null) {
|
||||||
LoopResources resources = this.resourceFactory.getLoopResources();
|
LoopResources resources = this.resourceFactory.getLoopResources();
|
||||||
Assert.notNull(resources, "No LoopResources: is ReactorResourceFactory not initialized yet?");
|
Assert.state(resources != null, "No LoopResources: is ReactorResourceFactory not initialized yet?");
|
||||||
server = server.runOn(resources);
|
server = server.runOn(resources);
|
||||||
}
|
}
|
||||||
if (this.lifecycleTimeout != null) {
|
if (this.lifecycleTimeout != null) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -175,7 +175,7 @@ public class UndertowWebServer implements WebServer {
|
||||||
this.closeables.add(closeable);
|
this.closeables.add(closeable);
|
||||||
}
|
}
|
||||||
if (handler instanceof GracefulShutdownHandler shutdownHandler) {
|
if (handler instanceof GracefulShutdownHandler shutdownHandler) {
|
||||||
Assert.isNull(this.gracefulShutdown, "Only a single GracefulShutdownHandler can be defined");
|
Assert.state(this.gracefulShutdown == null, "Only a single GracefulShutdownHandler can be defined");
|
||||||
this.gracefulShutdown = shutdownHandler;
|
this.gracefulShutdown = shutdownHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -95,8 +95,9 @@ public class DelegatingFilterProxyRegistrationBean extends AbstractFilterRegistr
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebApplicationContext getWebApplicationContext() {
|
private WebApplicationContext getWebApplicationContext() {
|
||||||
Assert.notNull(this.applicationContext, "ApplicationContext be injected");
|
Assert.state(this.applicationContext != null, "ApplicationContext has not been injected");
|
||||||
Assert.isInstanceOf(WebApplicationContext.class, this.applicationContext);
|
Assert.state(this.applicationContext instanceof WebApplicationContext,
|
||||||
|
"Injected ApplicationContext is not a WebApplicationContext");
|
||||||
return (WebApplicationContext) this.applicationContext;
|
return (WebApplicationContext) this.applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -52,7 +52,7 @@ abstract class ServletComponentHandler {
|
||||||
String[] value = (String[]) attributes.get("value");
|
String[] value = (String[]) attributes.get("value");
|
||||||
String[] urlPatterns = (String[]) attributes.get("urlPatterns");
|
String[] urlPatterns = (String[]) attributes.get("urlPatterns");
|
||||||
if (urlPatterns.length > 0) {
|
if (urlPatterns.length > 0) {
|
||||||
Assert.state(value.length == 0, "The urlPatterns and value attributes are mutually exclusive.");
|
Assert.state(value.length == 0, "The urlPatterns and value attributes are mutually exclusive");
|
||||||
return urlPatterns;
|
return urlPatterns;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -168,7 +168,7 @@ public class ServletRegistrationBean<T extends Servlet> extends DynamicRegistrat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getDescription() {
|
protected String getDescription() {
|
||||||
Assert.notNull(this.servlet, "Servlet must not be null");
|
Assert.state(this.servlet != null, "Unable to return description for null servlet");
|
||||||
return "servlet " + getServletName();
|
return "servlet " + getServletName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -30,7 +30,7 @@ import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link SpringApplication} main method.
|
* Tests for {@link SpringApplication} main method.
|
||||||
|
|
@ -45,7 +45,7 @@ class SimpleMainTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void emptyApplicationContext() {
|
void emptyApplicationContext() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> SpringApplication.main(getArgs()));
|
assertThatIllegalStateException().isThrownBy(() -> SpringApplication.main(getArgs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -26,7 +26,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.aot.AbstractAotProcessor.Settings;
|
import org.springframework.context.aot.AbstractAotProcessor.Settings;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -84,8 +83,7 @@ class SpringApplicationAotProcessorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invokeMainWithMissingArguments() {
|
void invokeMainWithMissingArguments() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalStateException().isThrownBy(() -> SpringApplicationAotProcessor.main(new String[] { "Test" }))
|
||||||
.isThrownBy(() -> SpringApplicationAotProcessor.main(new String[] { "Test" }))
|
|
||||||
.withMessageContaining("Usage:");
|
.withMessageContaining("Usage:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -213,8 +213,8 @@ class SpringApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void sourcesMustNotBeEmpty() {
|
void sourcesMustNotBeEmpty() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> new SpringApplication().run())
|
assertThatIllegalStateException().isThrownBy(() -> new SpringApplication().run())
|
||||||
.withMessageContaining("Sources must not be empty");
|
.withMessageContaining("No sources defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -88,7 +88,7 @@ class BufferingApplicationStartupTests {
|
||||||
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(2);
|
BufferingApplicationStartup applicationStartup = new BufferingApplicationStartup(2);
|
||||||
applicationStartup.start("first").end();
|
applicationStartup.start("first").end();
|
||||||
assertThatIllegalStateException().isThrownBy(applicationStartup::startRecording)
|
assertThatIllegalStateException().isThrownBy(applicationStartup::startRecording)
|
||||||
.withMessage("Cannot restart recording once steps have been buffered.");
|
.withMessage("Cannot restart recording once steps have been buffered");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,7 +28,7 @@ import org.springframework.core.env.SystemEnvironmentPropertySource;
|
||||||
import org.springframework.mock.env.MockEnvironment;
|
import org.springframework.mock.env.MockEnvironment;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ class RandomValuePropertySourceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void intRangeWhenLowerBoundEqualsUpperBoundShouldFailWithIllegalArgumentException() {
|
void intRangeWhenLowerBoundEqualsUpperBoundShouldFailWithIllegalArgumentException() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.source.getProperty("random.int[4,4]"))
|
assertThatIllegalStateException().isThrownBy(() -> this.source.getProperty("random.int[4,4]"))
|
||||||
.withMessage("Lower bound must be less than upper bound.");
|
.withMessage("Lower bound must be less than upper bound.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,13 +95,13 @@ class RandomValuePropertySourceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void intMaxZero() {
|
void intMaxZero() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.source.getProperty("random.int(0)"))
|
assertThatIllegalStateException().isThrownBy(() -> this.source.getProperty("random.int(0)"))
|
||||||
.withMessage("Bound must be positive.");
|
.withMessage("Bound must be positive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void intNegativeBound() {
|
void intNegativeBound() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.source.getProperty("random.int(-5)"))
|
assertThatIllegalStateException().isThrownBy(() -> this.source.getProperty("random.int(-5)"))
|
||||||
.withMessage("Bound must be positive.");
|
.withMessage("Bound must be positive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ class RandomValuePropertySourceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void longRangeWhenLowerBoundEqualsUpperBoundShouldFailWithIllegalArgumentException() {
|
void longRangeWhenLowerBoundEqualsUpperBoundShouldFailWithIllegalArgumentException() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.source.getProperty("random.long[4,4]"))
|
assertThatIllegalStateException().isThrownBy(() -> this.source.getProperty("random.long[4,4]"))
|
||||||
.withMessage("Lower bound must be less than upper bound.");
|
.withMessage("Lower bound must be less than upper bound.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,13 +138,13 @@ class RandomValuePropertySourceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void longMaxZero() {
|
void longMaxZero() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.source.getProperty("random.long(0)"))
|
assertThatIllegalStateException().isThrownBy(() -> this.source.getProperty("random.long(0)"))
|
||||||
.withMessage("Bound must be positive.");
|
.withMessage("Bound must be positive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void longNegativeBound() {
|
void longNegativeBound() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.source.getProperty("random.long(-5)"))
|
assertThatIllegalStateException().isThrownBy(() -> this.source.getProperty("random.long(-5)"))
|
||||||
.withMessage("Bound must be positive.");
|
.withMessage("Bound must be positive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -33,6 +33,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link StructuredLogLayout}.
|
* Tests for {@link StructuredLogLayout}.
|
||||||
|
|
@ -93,14 +94,14 @@ class StructuredLoggingLayoutTests extends AbstractStructuredLoggingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCheckTypeArgument() {
|
void shouldCheckTypeArgument() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(
|
assertThatIllegalStateException().isThrownBy(
|
||||||
() -> newBuilder().setFormat(CustomLog4j2StructuredLoggingFormatterWrongType.class.getName()).build())
|
() -> newBuilder().setFormat(CustomLog4j2StructuredLoggingFormatterWrongType.class.getName()).build())
|
||||||
.withMessageContaining("must be org.apache.logging.log4j.core.LogEvent but was java.lang.String");
|
.withMessageContaining("must be org.apache.logging.log4j.core.LogEvent but was java.lang.String");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCheckTypeArgumentWithRawType() {
|
void shouldCheckTypeArgumentWithRawType() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(
|
.isThrownBy(
|
||||||
() -> newBuilder().setFormat(CustomLog4j2StructuredLoggingFormatterRawType.class.getName()).build())
|
() -> newBuilder().setFormat(CustomLog4j2StructuredLoggingFormatterRawType.class.getName()).build())
|
||||||
.withMessageContaining("must be org.apache.logging.log4j.core.LogEvent but was null");
|
.withMessageContaining("must be org.apache.logging.log4j.core.LogEvent but was null");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -35,6 +35,7 @@ import org.springframework.mock.env.MockEnvironment;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link StructuredLogEncoder}.
|
* Tests for {@link StructuredLogEncoder}.
|
||||||
|
|
@ -113,7 +114,7 @@ class StructuredLogEncoderTests extends AbstractStructuredLoggingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCheckTypeArgument() {
|
void shouldCheckTypeArgument() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
assertThatIllegalStateException().isThrownBy(() -> {
|
||||||
this.encoder.setFormat(CustomLogbackStructuredLoggingFormatterWrongType.class.getName());
|
this.encoder.setFormat(CustomLogbackStructuredLoggingFormatterWrongType.class.getName());
|
||||||
this.encoder.start();
|
this.encoder.start();
|
||||||
}).withMessageContaining("must be ch.qos.logback.classic.spi.ILoggingEvent but was java.lang.String");
|
}).withMessageContaining("must be ch.qos.logback.classic.spi.ILoggingEvent but was java.lang.String");
|
||||||
|
|
@ -121,7 +122,7 @@ class StructuredLogEncoderTests extends AbstractStructuredLoggingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCheckTypeArgumentWithRawType() {
|
void shouldCheckTypeArgumentWithRawType() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> {
|
assertThatIllegalStateException().isThrownBy(() -> {
|
||||||
this.encoder.setFormat(CustomLogbackStructuredLoggingFormatterRawType.class.getName());
|
this.encoder.setFormat(CustomLogbackStructuredLoggingFormatterRawType.class.getName());
|
||||||
this.encoder.start();
|
this.encoder.start();
|
||||||
}).withMessageContaining("must be ch.qos.logback.classic.spi.ILoggingEvent but was null");
|
}).withMessageContaining("must be ch.qos.logback.classic.spi.ILoggingEvent but was null");
|
||||||
|
|
@ -133,8 +134,8 @@ class StructuredLogEncoderTests extends AbstractStructuredLoggingTests {
|
||||||
this.encoder.setFormat("does-not-exist");
|
this.encoder.setFormat("does-not-exist");
|
||||||
this.encoder.start();
|
this.encoder.start();
|
||||||
})
|
})
|
||||||
.withMessageContaining(
|
.withMessageContaining("Unknown format 'does-not-exist'. Values can be a valid fully-qualified "
|
||||||
"Unknown format 'does-not-exist'. Values can be a valid fully-qualified class name or one of the common formats: [ecs, gelf, logstash]");
|
+ "class name or one of the common formats: [ecs, gelf, logstash]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String encode(LoggingEvent event) {
|
private String encode(LoggingEvent event) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -31,6 +31,7 @@ import org.springframework.mock.env.MockEnvironment;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -83,7 +84,7 @@ class StructuredLogFormatterFactoryTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getUsingClassNameWhenHasGenericMismatch() {
|
void getUsingClassNameWhenHasGenericMismatch() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> this.factory.get(DifferentFormatter.class.getName()))
|
assertThatIllegalStateException().isThrownBy(() -> this.factory.get(DifferentFormatter.class.getName()))
|
||||||
.withMessage("Type argument of org.springframework.boot.logging.structured."
|
.withMessage("Type argument of org.springframework.boot.logging.structured."
|
||||||
+ "StructuredLogFormatterFactoryTests$DifferentFormatter "
|
+ "StructuredLogFormatterFactoryTests$DifferentFormatter "
|
||||||
+ "must be org.springframework.boot.logging.structured."
|
+ "must be org.springframework.boot.logging.structured."
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -29,7 +29,7 @@ import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link EmbeddedDatabaseConnection}.
|
* Tests for {@link EmbeddedDatabaseConnection}.
|
||||||
|
|
@ -85,7 +85,7 @@ class EmbeddedDatabaseConnectionTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenConnectionFactoryIsNotOptionsCapableThenIsEmbeddedThrows() {
|
void whenConnectionFactoryIsNotOptionsCapableThenIsEmbeddedThrows() {
|
||||||
assertThatIllegalArgumentException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> EmbeddedDatabaseConnection
|
.isThrownBy(() -> EmbeddedDatabaseConnection
|
||||||
.isEmbedded(ConnectionFactories.get("r2dbc:pool:h2:mem:///" + UUID.randomUUID())))
|
.isEmbedded(ConnectionFactories.get("r2dbc:pool:h2:mem:///" + UUID.randomUUID())))
|
||||||
.withMessage("Cannot determine database's type as ConnectionFactory is not options-capable. To be "
|
.withMessage("Cannot determine database's type as ConnectionFactory is not options-capable. To be "
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -140,7 +140,7 @@ class InstantiatorTests {
|
||||||
@Test
|
@Test
|
||||||
void getArgWhenUnknownThrowsException() {
|
void getArgWhenUnknownThrowsException() {
|
||||||
Instantiator<?> instantiator = createInstantiator(WithMultipleConstructors.class);
|
Instantiator<?> instantiator = createInstantiator(WithMultipleConstructors.class);
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> instantiator.getArg(InputStream.class))
|
assertThatIllegalStateException().isThrownBy(() -> instantiator.getArg(InputStream.class))
|
||||||
.withMessageStartingWith("Unknown argument type");
|
.withMessageStartingWith("Unknown argument type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -135,8 +135,8 @@ class ServletRegistrationBeanTests {
|
||||||
@Test
|
@Test
|
||||||
void setServletMustNotBeNull() {
|
void setServletMustNotBeNull() {
|
||||||
ServletRegistrationBean<MockServlet> bean = new ServletRegistrationBean<>();
|
ServletRegistrationBean<MockServlet> bean = new ServletRegistrationBean<>();
|
||||||
assertThatIllegalArgumentException().isThrownBy(() -> bean.onStartup(this.servletContext))
|
assertThatIllegalStateException().isThrownBy(() -> bean.onStartup(this.servletContext))
|
||||||
.withMessageContaining("Servlet must not be null");
|
.withMessageContaining("Unable to return description for null servlet");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -130,7 +130,7 @@ class WebFilterHandlerTests {
|
||||||
void urlPatternsDeclaredTwice() {
|
void urlPatternsDeclaredTwice() {
|
||||||
assertThatIllegalStateException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> handleBeanDefinitionForClass(UrlPatternsDeclaredTwiceFilter.class))
|
.isThrownBy(() -> handleBeanDefinitionForClass(UrlPatternsDeclaredTwiceFilter.class))
|
||||||
.withMessageContaining("The urlPatterns and value attributes are mutually exclusive.");
|
.withMessageContaining("The urlPatterns and value attributes are mutually exclusive");
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnnotatedBeanDefinition createBeanDefinition(Class<?> filterClass) throws IOException {
|
private AnnotatedBeanDefinition createBeanDefinition(Class<?> filterClass) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -105,7 +105,7 @@ class WebServletHandlerTests {
|
||||||
void urlPatternsDeclaredTwice() {
|
void urlPatternsDeclaredTwice() {
|
||||||
assertThatIllegalStateException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> handleBeanDefinitionForClass(UrlPatternsDeclaredTwiceServlet.class))
|
.isThrownBy(() -> handleBeanDefinitionForClass(UrlPatternsDeclaredTwiceServlet.class))
|
||||||
.withMessageContaining("The urlPatterns and value attributes are mutually exclusive.");
|
.withMessageContaining("The urlPatterns and value attributes are mutually exclusive");
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnnotatedBeanDefinition createBeanDefinition(Class<?> servletClass) throws IOException {
|
private AnnotatedBeanDefinition createBeanDefinition(Class<?> servletClass) throws IOException {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -40,7 +40,7 @@ public class GradleBuildInjectionExtension implements BeforeEachCallback {
|
||||||
this.gradleBuild = new GradleBuild();
|
this.gradleBuild = new GradleBuild();
|
||||||
this.gradleBuild.gradleVersion(GradleVersions.minimumCompatible());
|
this.gradleBuild.gradleVersion(GradleVersions.minimumCompatible());
|
||||||
String bootVersion = System.getProperty("springBootVersion");
|
String bootVersion = System.getProperty("springBootVersion");
|
||||||
Assert.notNull(bootVersion, "Property 'springBootVersion' must be set in build environment");
|
Assert.state(bootVersion != null, "Property 'springBootVersion' must be set in build environment");
|
||||||
this.gradleBuild.bootVersion(bootVersion);
|
this.gradleBuild.bootVersion(bootVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue