Polish tests

pull/36455/head
Moritz Halbritter 1 year ago
parent 4ea3c75331
commit 7bb337aeb1

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -132,7 +132,7 @@ class SonatypeServiceTests {
.andRespond(withSuccess()); .andRespond(withSuccess());
this.service.publish(getReleaseInfo(), artifactsRoot); this.service.publish(getReleaseInfo(), artifactsRoot);
this.server.verify(); this.server.verify();
assertThat(uploadRequestsMatcher.candidates).hasSize(0); assertThat(uploadRequestsMatcher.candidates).isEmpty();
} }
} }
@ -184,7 +184,7 @@ class SonatypeServiceTests {
.isThrownBy(() -> this.service.publish(getReleaseInfo(), artifactsRoot)) .isThrownBy(() -> this.service.publish(getReleaseInfo(), artifactsRoot))
.withMessage("Close failed"); .withMessage("Close failed");
this.server.verify(); this.server.verify();
assertThat(uploadRequestsMatcher.candidates).hasSize(0); assertThat(uploadRequestsMatcher.candidates).isEmpty();
} }
} }

@ -51,13 +51,11 @@ class ReactiveCloudFoundrySecurityServiceTests {
private MockWebServer server; private MockWebServer server;
private WebClient.Builder builder;
@BeforeEach @BeforeEach
void setup() { void setup() {
this.server = new MockWebServer(); this.server = new MockWebServer();
this.builder = WebClient.builder().baseUrl(this.server.url("/").toString()); WebClient.Builder builder = WebClient.builder().baseUrl(this.server.url("/").toString());
this.securityService = new ReactiveCloudFoundrySecurityService(this.builder, CLOUD_CONTROLLER, false); this.securityService = new ReactiveCloudFoundrySecurityService(builder, CLOUD_CONTROLLER, false);
} }
@AfterEach @AfterEach
@ -183,7 +181,7 @@ class ReactiveCloudFoundrySecurityServiceTests {
response.setHeader("Content-Type", "application/json"); response.setHeader("Content-Type", "application/json");
}); });
StepVerifier.create(this.securityService.fetchTokenKeys()) StepVerifier.create(this.securityService.fetchTokenKeys())
.consumeNextWith((tokenKeys) -> assertThat(tokenKeys).hasSize(0)) .consumeNextWith((tokenKeys) -> assertThat(tokenKeys).isEmpty())
.expectComplete() .expectComplete()
.verify(); .verify();
expectRequest((request) -> assertThat(request.getPath()).isEqualTo("/my-cloud-controller.com/info")); expectRequest((request) -> assertThat(request.getPath()).isEqualTo("/my-cloud-controller.com/info"));

@ -33,6 +33,7 @@ import org.junit.jupiter.params.provider.EnumSource.Mode;
import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.DatabaseDriver;
import org.springframework.boot.sql.init.DatabaseInitializationSettings; import org.springframework.boot.sql.init.DatabaseInitializationSettings;
import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
@ -76,7 +77,7 @@ class BatchDataSourceScriptDatabaseInitializerTests {
DatabaseInitializationSettings settings = BatchDataSourceScriptDatabaseInitializer.getSettings(dataSource, DatabaseInitializationSettings settings = BatchDataSourceScriptDatabaseInitializer.getSettings(dataSource,
properties.getJdbc()); properties.getJdbc());
List<String> schemaLocations = settings.getSchemaLocations(); List<String> schemaLocations = settings.getSchemaLocations();
assertThat(schemaLocations) assertThat(schemaLocations).isNotEmpty()
.allSatisfy((location) -> assertThat(resourceLoader.getResource(location).exists()).isTrue()); .allSatisfy((location) -> assertThat(resourceLoader.getResource(location).exists()).isTrue());
} }
@ -85,7 +86,7 @@ class BatchDataSourceScriptDatabaseInitializerTests {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
List<String> schemaNames = Stream List<String> schemaNames = Stream
.of(resolver.getResources("classpath:org/springframework/batch/core/schema-*.sql")) .of(resolver.getResources("classpath:org/springframework/batch/core/schema-*.sql"))
.map((resource) -> resource.getFilename()) .map(Resource::getFilename)
.filter((resourceName) -> !resourceName.contains("-drop-")) .filter((resourceName) -> !resourceName.contains("-drop-"))
.toList(); .toList();
assertThat(schemaNames).containsExactlyInAnyOrder("schema-derby.sql", "schema-sqlserver.sql", assertThat(schemaNames).containsExactlyInAnyOrder("schema-derby.sql", "schema-sqlserver.sql",

@ -164,7 +164,7 @@ class ConditionEvaluationReportTests {
void springBootConditionPopulatesReport() { void springBootConditionPopulatesReport() {
ConditionEvaluationReport report = ConditionEvaluationReport ConditionEvaluationReport report = ConditionEvaluationReport
.get(new AnnotationConfigApplicationContext(Config.class).getBeanFactory()); .get(new AnnotationConfigApplicationContext(Config.class).getBeanFactory());
assertThat(report.getConditionAndOutcomesBySource().size()).isNotZero(); assertThat(report.getConditionAndOutcomesBySource()).isNotEmpty();
} }
@Test @Test

@ -155,7 +155,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(FactoryBeanConfiguration.class, ConditionalOnFactoryBean.class, .withUserConfiguration(FactoryBeanConfiguration.class, ConditionalOnFactoryBean.class,
PropertyPlaceholderAutoConfiguration.class) PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -163,7 +163,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(ComponentScannedFactoryBeanBeanMethodConfiguration.class, .withUserConfiguration(ComponentScannedFactoryBeanBeanMethodConfiguration.class,
ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ScanBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ScanBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -171,7 +171,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(ComponentScannedFactoryBeanBeanMethodWithArgumentsConfiguration.class, .withUserConfiguration(ComponentScannedFactoryBeanBeanMethodWithArgumentsConfiguration.class,
ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ScanBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ScanBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -180,7 +180,7 @@ class ConditionalOnMissingBeanTests {
.withUserConfiguration(FactoryBeanWithBeanMethodArgumentsConfiguration.class, .withUserConfiguration(FactoryBeanWithBeanMethodArgumentsConfiguration.class,
ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
.withPropertyValues("theValue=foo") .withPropertyValues("theValue=foo")
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -188,7 +188,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(ConcreteFactoryBeanConfiguration.class, ConditionalOnFactoryBean.class, .withUserConfiguration(ConcreteFactoryBeanConfiguration.class, ConditionalOnFactoryBean.class,
PropertyPlaceholderAutoConfiguration.class) PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -205,7 +205,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(RegisteredFactoryBeanConfiguration.class, ConditionalOnFactoryBean.class, .withUserConfiguration(RegisteredFactoryBeanConfiguration.class, ConditionalOnFactoryBean.class,
PropertyPlaceholderAutoConfiguration.class) PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -213,7 +213,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(NonspecificFactoryBeanClassAttributeConfiguration.class, .withUserConfiguration(NonspecificFactoryBeanClassAttributeConfiguration.class,
ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -221,7 +221,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(NonspecificFactoryBeanStringAttributeConfiguration.class, .withUserConfiguration(NonspecificFactoryBeanStringAttributeConfiguration.class,
ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class) ConditionalOnFactoryBean.class, PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test
@ -229,7 +229,7 @@ class ConditionalOnMissingBeanTests {
this.contextRunner this.contextRunner
.withUserConfiguration(FactoryBeanXmlConfiguration.class, ConditionalOnFactoryBean.class, .withUserConfiguration(FactoryBeanXmlConfiguration.class, ConditionalOnFactoryBean.class,
PropertyPlaceholderAutoConfiguration.class) PropertyPlaceholderAutoConfiguration.class)
.run((context) -> assertThat(context.getBean(ExampleBean.class).toString()).isEqualTo("fromFactory")); .run((context) -> assertThat(context.getBean(ExampleBean.class)).hasToString("fromFactory"));
} }
@Test @Test

@ -119,7 +119,7 @@ class ProjectInfoAutoConfigurationTests {
@Test @Test
void buildPropertiesCustomInvalidLocation() { void buildPropertiesCustomInvalidLocation() {
this.contextRunner.withPropertyValues("spring.info.build.location=classpath:/org/acme/no-build-info.properties") this.contextRunner.withPropertyValues("spring.info.build.location=classpath:/org/acme/no-build-info.properties")
.run((context) -> assertThat(context.getBeansOfType(BuildProperties.class)).hasSize(0)); .run((context) -> assertThat(context.getBeansOfType(BuildProperties.class)).isEmpty());
} }
@Test @Test

@ -60,8 +60,8 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
@Test @Test
void contextLoads() { void contextLoads() {
ResponseEntity<String> response = this.restTemplate.getForEntity("/rest/message", String.class); ResponseEntity<String> response = this.restTemplate.getForEntity("/rest/message", String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).isEqualTo("{\"subject\":\"Jersey\"}"); assertThat("{\"subject\":\"Jersey\"}").isEqualTo(response.getBody());
} }
@MinimalWebConfiguration @MinimalWebConfiguration

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 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.
@ -62,7 +62,7 @@ class JerseyAutoConfigurationObjectMapperProviderTests {
@Test @Test
void responseIsSerializedUsingAutoConfiguredObjectMapper() { void responseIsSerializedUsingAutoConfiguredObjectMapper() {
ResponseEntity<String> response = this.restTemplate.getForEntity("/rest/message", String.class); ResponseEntity<String> response = this.restTemplate.getForEntity("/rest/message", String.class);
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).isEqualTo("{\"subject\":\"Jersey\"}"); assertThat(response.getBody()).isEqualTo("{\"subject\":\"Jersey\"}");
} }

@ -62,7 +62,7 @@ class ActiveMQPropertiesTests {
ActiveMQConnectionFactory factory = createFactory(this.properties) ActiveMQConnectionFactory factory = createFactory(this.properties)
.createConnectionFactory(ActiveMQConnectionFactory.class); .createConnectionFactory(ActiveMQConnectionFactory.class);
assertThat(factory.isTrustAllPackages()).isFalse(); assertThat(factory.isTrustAllPackages()).isFalse();
assertThat(factory.getTrustedPackages().size()).isEqualTo(1); assertThat(factory.getTrustedPackages()).hasSize(1);
assertThat(factory.getTrustedPackages().get(0)).isEqualTo("trusted.package"); assertThat(factory.getTrustedPackages().get(0)).isEqualTo("trusted.package");
} }

@ -235,7 +235,7 @@ class WebMvcAutoConfigurationTests {
@Test @Test
void resourceHandlerMappingDisabled() { void resourceHandlerMappingDisabled() {
this.contextRunner.withPropertyValues("spring.web.resources.add-mappings:false") this.contextRunner.withPropertyValues("spring.web.resources.add-mappings:false")
.run((context) -> assertThat(getResourceMappingLocations(context)).hasSize(0)); .run((context) -> assertThat(getResourceMappingLocations(context)).isEmpty());
} }
@Test @Test

@ -48,7 +48,7 @@ class ChangeableUrlsTests {
@Test @Test
void directoryUrl() throws Exception { void directoryUrl() throws Exception {
URL url = makeUrl("myproject"); URL url = makeUrl("myproject");
assertThat(ChangeableUrls.fromUrls(url).size()).isOne(); assertThat(ChangeableUrls.fromUrls(url)).hasSize(1);
} }
@Test @Test

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2021 the original author or authors. * Copyright 2012-2023 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.
@ -36,7 +36,6 @@ import org.springframework.core.Ordered;
import org.springframework.test.util.ReflectionTestUtils; 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.hamcrest.Matchers.nullValue;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
@ -103,7 +102,7 @@ class RestartApplicationListenerTests {
SpringApplication application = new SpringApplication(); SpringApplication application = new SpringApplication();
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class); ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
listener.onApplicationEvent(new ApplicationStartingEvent(bootstrapContext, application, ARGS)); listener.onApplicationEvent(new ApplicationStartingEvent(bootstrapContext, application, ARGS));
assertThat(Restarter.getInstance()).isNotEqualTo(nullValue()); assertThat(Restarter.getInstance()).isNotNull();
assertThat(Restarter.getInstance().isFinished()).isFalse(); assertThat(Restarter.getInstance().isFinished()).isFalse();
listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context)); listener.onApplicationEvent(new ApplicationPreparedEvent(application, ARGS, context));
if (failed) { if (failed) {

@ -106,7 +106,7 @@ class DockerComposeFileTests {
FileCopyUtils.copy(new byte[0], file); FileCopyUtils.copy(new byte[0], file);
DockerComposeFile composeFile = DockerComposeFile.of(file); DockerComposeFile composeFile = DockerComposeFile.of(file);
assertThat(composeFile).isNotNull(); assertThat(composeFile).isNotNull();
assertThat(composeFile.toString()).isEqualTo(file.getCanonicalPath()); assertThat(composeFile).hasToString(file.getCanonicalPath());
} }
@Test @Test

@ -42,7 +42,7 @@ class CassandraDockerComposeConnectionDetailsFactoryIntegrationTests extends Abs
void runCreatesConnectionDetails() { void runCreatesConnectionDetails() {
CassandraConnectionDetails connectionDetails = run(CassandraConnectionDetails.class); CassandraConnectionDetails connectionDetails = run(CassandraConnectionDetails.class);
List<Node> contactPoints = connectionDetails.getContactPoints(); List<Node> contactPoints = connectionDetails.getContactPoints();
assertThat(contactPoints.size()).isEqualTo(1); assertThat(contactPoints).hasSize(1);
Node node = contactPoints.get(0); Node node = contactPoints.get(0);
assertThat(node.host()).isNotNull(); assertThat(node.host()).isNotNull();
assertThat(node.port()).isGreaterThan(0); assertThat(node.port()).isGreaterThan(0);

@ -52,7 +52,7 @@ class ImageArchiveManifestTests extends AbstractJsonTests {
String content = "[{\"Layers\": []}]"; String content = "[{\"Layers\": []}]";
ImageArchiveManifest manifest = new ImageArchiveManifest(getObjectMapper().readTree(content)); ImageArchiveManifest manifest = new ImageArchiveManifest(getObjectMapper().readTree(content));
assertThat(manifest.getEntries()).hasSize(1); assertThat(manifest.getEntries()).hasSize(1);
assertThat(manifest.getEntries().get(0).getLayers()).hasSize(0); assertThat(manifest.getEntries().get(0).getLayers()).isEmpty();
} }
@Test @Test

@ -111,15 +111,16 @@ class PropertyDescriptorResolverTests {
void propertiesWithDeducedConstructorBinding() { void propertiesWithDeducedConstructorBinding() {
process(ImmutableDeducedConstructorBindingProperties.class, process(ImmutableDeducedConstructorBindingProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag"))); propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag")));
process(ImmutableDeducedConstructorBindingProperties.class, properties((stream) -> assertThat(stream) process(ImmutableDeducedConstructorBindingProperties.class,
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); properties((stream) -> assertThat(stream).isNotEmpty()
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor)));
} }
@Test @Test
void propertiesWithConstructorWithConstructorBinding() { void propertiesWithConstructorWithConstructorBinding() {
process(ImmutableSimpleProperties.class, propertyNames( process(ImmutableSimpleProperties.class, propertyNames(
(stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator", "counter"))); (stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator", "counter")));
process(ImmutableSimpleProperties.class, properties((stream) -> assertThat(stream) process(ImmutableSimpleProperties.class, properties((stream) -> assertThat(stream).isNotEmpty()
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor)));
} }
@ -127,14 +128,14 @@ class PropertyDescriptorResolverTests {
void propertiesWithConstructorAndClassConstructorBinding() { void propertiesWithConstructorAndClassConstructorBinding() {
process(ImmutableClassConstructorBindingProperties.class, process(ImmutableClassConstructorBindingProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); propertyNames((stream) -> assertThat(stream).containsExactly("name", "description")));
process(ImmutableClassConstructorBindingProperties.class, properties((stream) -> assertThat(stream) process(ImmutableClassConstructorBindingProperties.class, properties((stream) -> assertThat(stream).isNotEmpty()
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor)));
} }
@Test @Test
void propertiesWithAutowiredConstructor() { void propertiesWithAutowiredConstructor() {
process(AutowiredProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("theName"))); process(AutowiredProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("theName")));
process(AutowiredProperties.class, properties((stream) -> assertThat(stream) process(AutowiredProperties.class, properties((stream) -> assertThat(stream).isNotEmpty()
.allMatch((predicate) -> predicate instanceof JavaBeanPropertyDescriptor))); .allMatch((predicate) -> predicate instanceof JavaBeanPropertyDescriptor)));
} }
@ -142,7 +143,7 @@ class PropertyDescriptorResolverTests {
void propertiesWithMultiConstructor() { void propertiesWithMultiConstructor() {
process(ImmutableMultiConstructorProperties.class, process(ImmutableMultiConstructorProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); propertyNames((stream) -> assertThat(stream).containsExactly("name", "description")));
process(ImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream) process(ImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream).isNotEmpty()
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor)));
} }

@ -488,7 +488,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
void jarWhenLayersDisabledShouldNotContainLayersIndex() throws IOException { void jarWhenLayersDisabledShouldNotContainLayersIndex() throws IOException {
List<String> entryNames = getEntryNames( List<String> entryNames = getEntryNames(
createLayeredJar((configuration) -> configuration.getEnabled().set(false))); createLayeredJar((configuration) -> configuration.getEnabled().set(false)));
assertThat(entryNames).doesNotContain(this.indexPath + "layers.idx"); assertThat(entryNames).isNotEmpty().doesNotContain(this.indexPath + "layers.idx");
} }
@Test @Test
@ -605,7 +605,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
void whenArchiveIsLayeredAndIncludeLayerToolsIsFalseThenLayerToolsAreNotAddedToTheJar() throws IOException { void whenArchiveIsLayeredAndIncludeLayerToolsIsFalseThenLayerToolsAreNotAddedToTheJar() throws IOException {
List<String> entryNames = getEntryNames( List<String> entryNames = getEntryNames(
createLayeredJar((configuration) -> configuration.getIncludeLayerTools().set(false))); createLayeredJar((configuration) -> configuration.getIncludeLayerTools().set(false)));
assertThat(entryNames) assertThat(entryNames).isNotEmpty()
.doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar"); .doesNotContain(this.indexPath + "layers/dependencies/lib/spring-boot-jarmode-layertools.jar");
} }

@ -220,7 +220,7 @@ class JarFileTests {
@Test @Test
void size() throws Exception { void size() throws Exception {
try (ZipFile zip = new ZipFile(this.rootJarFile)) { try (ZipFile zip = new ZipFile(this.rootJarFile)) {
assertThat(this.jarFile.size()).isEqualTo(zip.size()); assertThat(this.jarFile).hasSize(zip.size());
} }
} }

@ -108,7 +108,7 @@ class ConfigDataEnvironmentPostProcessorTests {
TestConfigDataEnvironmentUpdateListener listener = new TestConfigDataEnvironmentUpdateListener(); TestConfigDataEnvironmentUpdateListener listener = new TestConfigDataEnvironmentUpdateListener();
ConfigDataEnvironmentPostProcessor.applyTo(this.environment, null, null, Collections.singleton("dev"), ConfigDataEnvironmentPostProcessor.applyTo(this.environment, null, null, Collections.singleton("dev"),
listener); listener);
assertThat(this.environment.getPropertySources().size()).isGreaterThan(before); assertThat(this.environment.getPropertySources()).hasSizeGreaterThan(before);
assertThat(this.environment.getActiveProfiles()).containsExactly("dev"); assertThat(this.environment.getActiveProfiles()).containsExactly("dev");
assertThat(listener.getAddedPropertySources()).isNotEmpty(); assertThat(listener.getAddedPropertySources()).isNotEmpty();
assertThat(listener.getProfiles().getActive()).containsExactly("dev"); assertThat(listener.getProfiles().getActive()).containsExactly("dev");

@ -54,7 +54,7 @@ class ConfigurationPropertySourcesTests {
sources.addLast(new MapPropertySource("config", Collections.singletonMap("server.port", "4568"))); sources.addLast(new MapPropertySource("config", Collections.singletonMap("server.port", "4568")));
int size = sources.size(); int size = sources.size();
ConfigurationPropertySources.attach(environment); ConfigurationPropertySources.attach(environment);
assertThat(sources.size()).isEqualTo(size + 1); assertThat(sources).hasSize(size + 1);
PropertyResolver resolver = new PropertySourcesPropertyResolver(sources); PropertyResolver resolver = new PropertySourcesPropertyResolver(sources);
assertThat(resolver.getProperty("server.port")).isEqualTo("1234"); assertThat(resolver.getProperty("server.port")).isEqualTo("1234");
} }

@ -62,14 +62,14 @@ class SampleOAuth2AuthorizationServerApplicationTests {
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
OidcProviderConfiguration config = OidcProviderConfiguration.withClaims(entity.getBody()).build(); OidcProviderConfiguration config = OidcProviderConfiguration.withClaims(entity.getBody()).build();
assertThat(config.getIssuer().toString()).isEqualTo("https://provider.com"); assertThat(config.getIssuer()).hasToString("https://provider.com");
assertThat(config.getAuthorizationEndpoint().toString()).isEqualTo("https://provider.com/authorize"); assertThat(config.getAuthorizationEndpoint()).hasToString("https://provider.com/authorize");
assertThat(config.getTokenEndpoint().toString()).isEqualTo("https://provider.com/token"); assertThat(config.getTokenEndpoint()).hasToString("https://provider.com/token");
assertThat(config.getJwkSetUrl().toString()).isEqualTo("https://provider.com/jwks"); assertThat(config.getJwkSetUrl()).hasToString("https://provider.com/jwks");
assertThat(config.getTokenRevocationEndpoint().toString()).isEqualTo("https://provider.com/revoke"); assertThat(config.getTokenRevocationEndpoint()).hasToString("https://provider.com/revoke");
assertThat(config.getEndSessionEndpoint().toString()).isEqualTo("https://provider.com/logout"); assertThat(config.getEndSessionEndpoint()).hasToString("https://provider.com/logout");
assertThat(config.getTokenIntrospectionEndpoint().toString()).isEqualTo("https://provider.com/introspect"); assertThat(config.getTokenIntrospectionEndpoint()).hasToString("https://provider.com/introspect");
assertThat(config.getUserInfoEndpoint().toString()).isEqualTo("https://provider.com/user"); assertThat(config.getUserInfoEndpoint()).hasToString("https://provider.com/user");
// OIDC Client Registration is disabled by default // OIDC Client Registration is disabled by default
assertThat(config.getClientRegistrationEndpoint()).isNull(); assertThat(config.getClientRegistrationEndpoint()).isNull();
} }
@ -82,12 +82,12 @@ class SampleOAuth2AuthorizationServerApplicationTests {
OAuth2AuthorizationServerMetadata config = OAuth2AuthorizationServerMetadata.withClaims(entity.getBody()) OAuth2AuthorizationServerMetadata config = OAuth2AuthorizationServerMetadata.withClaims(entity.getBody())
.build(); .build();
assertThat(config.getIssuer().toString()).isEqualTo("https://provider.com"); assertThat(config.getIssuer()).hasToString("https://provider.com");
assertThat(config.getAuthorizationEndpoint().toString()).isEqualTo("https://provider.com/authorize"); assertThat(config.getAuthorizationEndpoint()).hasToString("https://provider.com/authorize");
assertThat(config.getTokenEndpoint().toString()).isEqualTo("https://provider.com/token"); assertThat(config.getTokenEndpoint()).hasToString("https://provider.com/token");
assertThat(config.getJwkSetUrl().toString()).isEqualTo("https://provider.com/jwks"); assertThat(config.getJwkSetUrl()).hasToString("https://provider.com/jwks");
assertThat(config.getTokenRevocationEndpoint().toString()).isEqualTo("https://provider.com/revoke"); assertThat(config.getTokenRevocationEndpoint()).hasToString("https://provider.com/revoke");
assertThat(config.getTokenIntrospectionEndpoint().toString()).isEqualTo("https://provider.com/introspect"); assertThat(config.getTokenIntrospectionEndpoint()).hasToString("https://provider.com/introspect");
// OIDC Client Registration is disabled by default // OIDC Client Registration is disabled by default
assertThat(config.getClientRegistrationEndpoint()).isNull(); assertThat(config.getClientRegistrationEndpoint()).isNull();
} }

Loading…
Cancel
Save