Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -69,8 +69,15 @@ abstract class AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
@Test
void runAndTestHttpEndpoint() {
assertThat(this.port).isNotEqualTo(8080).isNotZero();
WebTestClient.bindToServer().baseUrl("http://localhost:" + this.port).responseTimeout(Duration.ofMinutes(5))
.build().get().uri("/").exchange().expectBody(String.class).isEqualTo("Hello World");
WebTestClient.bindToServer()
.baseUrl("http://localhost:" + this.port)
.responseTimeout(Duration.ofMinutes(5))
.build()
.get()
.uri("/")
.exchange()
.expectBody(String.class)
.isEqualTo("Hello World");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -37,13 +37,13 @@ class AnnotatedClassFinderTests {
@Test
void findFromClassWhenSourceIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.finder.findFromClass((Class<?>) null))
.withMessageContaining("Source must not be null");
.withMessageContaining("Source must not be null");
}
@Test
void findFromPackageWhenSourceIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.finder.findFromPackage((String) null))
.withMessageContaining("Source must not be null");
.withMessageContaining("Source must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class FilteredClassLoaderTests {
try (FilteredClassLoader classLoader = new FilteredClassLoader(
FilteredClassLoaderTests.class.getPackage().getName())) {
assertThatExceptionOfType(ClassNotFoundException.class)
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
}
}
@@ -52,7 +52,7 @@ class FilteredClassLoaderTests {
void loadClassWhenFilteredOnClassShouldThrowClassNotFound() throws Exception {
try (FilteredClassLoader classLoader = new FilteredClassLoader(FilteredClassLoaderTests.class)) {
assertThatExceptionOfType(ClassNotFoundException.class)
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
.isThrownBy(() -> Class.forName(getClass().getName(), false, classLoader));
}
}
@@ -117,7 +117,7 @@ class FilteredClassLoaderTests {
Class<FilteredClassLoaderTests> hiddenClass = FilteredClassLoaderTests.class;
try (FilteredClassLoader classLoader = new FilteredClassLoader(hiddenClass)) {
assertThatIllegalArgumentException()
.isThrownBy(() -> classLoader.publicDefineClass(hiddenClass.getName(), new byte[] {}, null));
.isThrownBy(() -> classLoader.publicDefineClass(hiddenClass.getName(), new byte[] {}, null));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ class ImportsContextCustomizerFactoryIntegrationTests {
@Test
void testItselfIsNotABean() {
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(getClass()));
.isThrownBy(() -> this.context.getBean(getClass()));
}
@Component

View File

@@ -77,8 +77,8 @@ class ImportsContextCustomizerFactoryTests {
@Test
void getContextCustomizerWhenClassHasBeanMethodsShouldThrowException() {
assertThatIllegalStateException()
.isThrownBy(() -> this.factory.createContextCustomizer(TestWithImportAndBeanMethod.class, null))
.withMessageContaining("Test classes cannot include @Bean methods");
.isThrownBy(() -> this.factory.createContextCustomizer(TestWithImportAndBeanMethod.class, null))
.withMessageContaining("Test classes cannot include @Bean methods");
}
@Test
@@ -93,7 +93,7 @@ class ImportsContextCustomizerFactoryTests {
@Test
void selfAnnotatingAnnotationDoesNotCauseStackOverflow() {
assertThat(this.factory.createContextCustomizer(TestWithImportAndSelfAnnotatingAnnotation.class, null))
.isNotNull();
.isNotNull();
}
static class TestWithNoImport {

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -47,37 +47,37 @@ class ImportsContextCustomizerTests {
@Test
void importSelectorsCouldUseAnyAnnotations() {
assertThat(new ImportsContextCustomizer(FirstImportSelectorAnnotatedClass.class))
.isNotEqualTo(new ImportsContextCustomizer(SecondImportSelectorAnnotatedClass.class));
.isNotEqualTo(new ImportsContextCustomizer(SecondImportSelectorAnnotatedClass.class));
}
@Test
void determinableImportSelector() {
assertThat(new ImportsContextCustomizer(FirstDeterminableImportSelectorAnnotatedClass.class))
.isEqualTo(new ImportsContextCustomizer(SecondDeterminableImportSelectorAnnotatedClass.class));
.isEqualTo(new ImportsContextCustomizer(SecondDeterminableImportSelectorAnnotatedClass.class));
}
@Test
void customizersForTestClassesWithDifferentKotlinMetadataAreEqual() {
assertThat(new ImportsContextCustomizer(FirstKotlinAnnotatedTestClass.class))
.isEqualTo(new ImportsContextCustomizer(SecondKotlinAnnotatedTestClass.class));
.isEqualTo(new ImportsContextCustomizer(SecondKotlinAnnotatedTestClass.class));
}
@Test
void customizersForTestClassesWithDifferentSpockFrameworkAnnotationsAreEqual() {
assertThat(new ImportsContextCustomizer(FirstSpockFrameworkAnnotatedTestClass.class))
.isEqualTo(new ImportsContextCustomizer(SecondSpockFrameworkAnnotatedTestClass.class));
.isEqualTo(new ImportsContextCustomizer(SecondSpockFrameworkAnnotatedTestClass.class));
}
@Test
void customizersForTestClassesWithDifferentSpockLangAnnotationsAreEqual() {
assertThat(new ImportsContextCustomizer(FirstSpockLangAnnotatedTestClass.class))
.isEqualTo(new ImportsContextCustomizer(SecondSpockLangAnnotatedTestClass.class));
.isEqualTo(new ImportsContextCustomizer(SecondSpockLangAnnotatedTestClass.class));
}
@Test
void customizersForTestClassesWithDifferentJUnitAnnotationsAreEqual() {
assertThat(new ImportsContextCustomizer(FirstJUnitAnnotatedTestClass.class))
.isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
.isEqualTo(new ImportsContextCustomizer(SecondJUnitAnnotatedTestClass.class));
}
@Import(TestImportSelector.class)

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -59,8 +59,9 @@ class SpringBootContextLoaderAotTests {
TestContextAotGenerator generator = new TestContextAotGenerator(generatedFiles);
Class<?> testClass = ExampleTest.class;
generator.processAheadOfTime(Stream.of(testClass));
TestCompiler.forSystem().with(CompilerFiles.from(generatedFiles))
.compile(ThrowingConsumer.of((compiled) -> assertCompiledTest(testClass)));
TestCompiler.forSystem()
.with(CompilerFiles.from(generatedFiles))
.compile(ThrowingConsumer.of((compiled) -> assertCompiledTest(testClass)));
}
private void assertCompiledTest(Class<?> testClass) throws Exception {
@@ -71,9 +72,9 @@ class SpringBootContextLoaderAotTests {
TestContextBootstrapper testContextBootstrapper = BootstrapUtils.resolveTestContextBootstrapper(testClass);
MergedContextConfiguration mergedConfig = testContextBootstrapper.buildMergedContextConfiguration();
ApplicationContextInitializer<ConfigurableApplicationContext> contextInitializer = aotContextInitializers
.getContextInitializer(testClass);
.getContextInitializer(testClass);
ConfigurableApplicationContext context = (ConfigurableApplicationContext) ((AotContextLoader) mergedConfig
.getContextLoader()).loadContextForAotRuntime(mergedConfig, contextInitializer);
.getContextLoader()).loadContextForAotRuntime(mergedConfig, contextInitializer);
assertThat(context).isExactlyInstanceOf(GenericApplicationContext.class);
String[] beanNames = context.getBeanNamesForType(ExampleBean.class);
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition(beanNames[0]);

View File

@@ -142,7 +142,7 @@ class SpringBootContextLoaderTests {
@Test
void testPropertyValuesShouldTakePrecedenceWhenInlinedPropertiesPresentAndProfilesActive() {
TestContext context = new ExposedTestContextManager(ActiveProfileWithInlinedProperties.class)
.getExposedTestContext();
.getExposedTestContext();
StandardEnvironment environment = (StandardEnvironment) context.getApplicationContext().getEnvironment();
TestPropertyValues.of("key=thisValue").applyTo(environment);
assertThat(environment.getProperty("key")).isEqualTo("thisValue");
@@ -153,9 +153,11 @@ class SpringBootContextLoaderTests {
void propertySourceOrdering() {
TestContext context = new ExposedTestContextManager(PropertySourceOrdering.class).getExposedTestContext();
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getApplicationContext()
.getEnvironment();
List<String> names = environment.getPropertySources().stream().map(PropertySource::getName)
.collect(Collectors.toCollection(ArrayList::new));
.getEnvironment();
List<String> names = environment.getPropertySources()
.stream()
.map(PropertySource::getName)
.collect(Collectors.toCollection(ArrayList::new));
String last = names.remove(names.size() - 1);
assertThat(names).containsExactly("configurationProperties", "Inlined Test Properties", "commandLineArgs",
"servletConfigInitParams", "servletContextInitParams", "systemProperties", "systemEnvironment",
@@ -166,29 +168,30 @@ class SpringBootContextLoaderTests {
@Test
void whenEnvironmentChangesWebApplicationTypeToNoneThenContextTypeChangesAccordingly() {
TestContext context = new ExposedTestContextManager(ChangingWebApplicationTypeToNone.class)
.getExposedTestContext();
.getExposedTestContext();
assertThat(context.getApplicationContext()).isNotInstanceOf(WebApplicationContext.class);
}
@Test
void whenEnvironmentChangesWebApplicationTypeToReactiveThenContextTypeChangesAccordingly() {
TestContext context = new ExposedTestContextManager(ChangingWebApplicationTypeToReactive.class)
.getExposedTestContext();
.getExposedTestContext();
assertThat(context.getApplicationContext()).isInstanceOf(GenericReactiveWebApplicationContext.class);
}
@Test
void whenUseMainMethodAlwaysAndMainMethodThrowsException() {
TestContext testContext = new ExposedTestContextManager(UseMainMethodAlwaysAndMainMethodThrowsException.class)
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext).havingCause()
.withMessageContaining("ThrownFromMain");
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext)
.havingCause()
.withMessageContaining("ThrownFromMain");
}
@Test
void whenUseMainMethodWhenAvailableAndNoMainMethod() {
TestContext testContext = new ExposedTestContextManager(UseMainMethodWhenAvailableAndNoMainMethod.class)
.getExposedTestContext();
.getExposedTestContext();
ApplicationContext applicationContext = testContext.getApplicationContext();
assertThat(applicationContext.getEnvironment().getActiveProfiles()).isEmpty();
}
@@ -196,7 +199,7 @@ class SpringBootContextLoaderTests {
@Test
void whenUseMainMethodWhenAvailableAndMainMethod() {
TestContext testContext = new ExposedTestContextManager(UseMainMethodWhenAvailableAndMainMethod.class)
.getExposedTestContext();
.getExposedTestContext();
ApplicationContext applicationContext = testContext.getApplicationContext();
assertThat(applicationContext.getEnvironment().getActiveProfiles()).contains("frommain");
}
@@ -211,35 +214,36 @@ class SpringBootContextLoaderTests {
@Test
void whenUseMainMethodWithBeanThrowingException() {
TestContext testContext = new ExposedTestContextManager(UseMainMethodWithBeanThrowingException.class)
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext).havingCause()
.satisfies((exception) -> {
assertThat(exception).isInstanceOf(BeanCreationException.class);
assertThat(exception)
.isSameAs(ContextLoaderApplicationContextFailureProcessor.contextLoadException);
});
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext)
.havingCause()
.satisfies((exception) -> {
assertThat(exception).isInstanceOf(BeanCreationException.class);
assertThat(exception).isSameAs(ContextLoaderApplicationContextFailureProcessor.contextLoadException);
});
assertThat(ContextLoaderApplicationContextFailureProcessor.failedContext).isNotNull();
}
@Test
void whenNoMainMethodWithBeanThrowingException() {
TestContext testContext = new ExposedTestContextManager(NoMainMethodWithBeanThrowingException.class)
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext).havingCause()
.satisfies((exception) -> {
assertThat(exception).isInstanceOf(BeanCreationException.class);
assertThat(exception)
.isSameAs(ContextLoaderApplicationContextFailureProcessor.contextLoadException);
});
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext)
.havingCause()
.satisfies((exception) -> {
assertThat(exception).isInstanceOf(BeanCreationException.class);
assertThat(exception).isSameAs(ContextLoaderApplicationContextFailureProcessor.contextLoadException);
});
assertThat(ContextLoaderApplicationContextFailureProcessor.failedContext).isNotNull();
}
@Test
void whenUseMainMethodWithContextHierarchyThrowsException() {
TestContext testContext = new ExposedTestContextManager(UseMainMethodWithContextHierarchy.class)
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext).havingCause()
.withMessage("UseMainMethod.ALWAYS cannot be used with @ContextHierarchy tests");
.getExposedTestContext();
assertThatIllegalStateException().isThrownBy(testContext::getApplicationContext)
.havingCause()
.withMessage("UseMainMethod.ALWAYS cannot be used with @ContextHierarchy tests");
}
private String[] getActiveProfiles(Class<?> testClass) {

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ class SpringBootTestWebEnvironmentMockTests {
@Test
void validateWebApplicationContextIsSet() {
WebApplicationContext fromServletContext = WebApplicationContextUtils
.getWebApplicationContext(this.servletContext);
.getWebApplicationContext(this.servletContext);
assertThat(fromServletContext).isSameAs(this.context);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ class SpringBootTestWebEnvironmentRandomPortTests extends AbstractSpringBootTest
@Test
void testRestTemplateShouldUseBuilder() {
assertThat(getRestTemplate().getRestTemplate().getMessageConverters())
.hasAtLeastOneElementOfType(MyConverter.class);
.hasAtLeastOneElementOfType(MyConverter.class);
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ class SpringBootTestWithClassesIntegrationTests {
void injectsOnlyConfig() {
assertThat(this.context.getBean(Config.class)).isNotNull();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ class SpringBootTestWithContextConfigurationIntegrationTests {
void injectsOnlyConfig() {
assertThat(this.context.getBean(Config.class)).isNotNull();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
.isThrownBy(() -> this.context.getBean(AdditionalConfig.class));
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ class SpringBootTestWithTestPropertySourceTests {
@Test
void propertyFromPropertySourcePropertiesOverridesPropertyFromPropertySourceLocations() {
assertThat(this.config.propertySourceInlinedOverridesPropertySourceLocation)
.isEqualTo("property-source-inlined");
.isEqualTo("property-source-inlined");
}
@Test

View File

@@ -34,14 +34,14 @@ class TestConfigurationTests {
@Test
void proxyBeanMethodsIsEnabledByDefault() {
AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(DefaultTestConfiguration.class, Configuration.class);
.getMergedAnnotationAttributes(DefaultTestConfiguration.class, Configuration.class);
assertThat(attributes).containsEntry("proxyBeanMethods", true);
}
@Test
void proxyBeanMethodsCanBeDisabled() {
AnnotationAttributes attributes = AnnotatedElementUtils
.getMergedAnnotationAttributes(NoBeanMethodProxyingTestConfiguration.class, Configuration.class);
.getMergedAnnotationAttributes(NoBeanMethodProxyingTestConfiguration.class, Configuration.class);
assertThat(attributes).containsEntry("proxyBeanMethods", false);
}

View File

@@ -64,37 +64,38 @@ class ApplicationContextAssertProviderTests {
void getWhenTypeIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(
() -> ApplicationContextAssertProvider.get(null, ApplicationContext.class, this.mockContextSupplier))
.withMessageContaining("Type must not be null");
.withMessageContaining("Type must not be null");
}
@Test
void getWhenTypeIsClassShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(
() -> ApplicationContextAssertProvider.get(null, ApplicationContext.class, this.mockContextSupplier))
.withMessageContaining("Type must not be null");
.withMessageContaining("Type must not be null");
}
@Test
void getWhenContextTypeIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContextClass.class,
ApplicationContext.class, this.mockContextSupplier))
.withMessageContaining("Type must be an interface");
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContextClass.class,
ApplicationContext.class, this.mockContextSupplier))
.withMessageContaining("Type must be an interface");
}
@Test
void getWhenContextTypeIsClassShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> ApplicationContextAssertProvider
.get(TestAssertProviderApplicationContext.class, null, this.mockContextSupplier))
.withMessageContaining("ContextType must not be null");
assertThatIllegalArgumentException()
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class, null,
this.mockContextSupplier))
.withMessageContaining("ContextType must not be null");
}
@Test
void getWhenSupplierIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class,
StaticApplicationContext.class, this.mockContextSupplier))
.withMessageContaining("ContextType must be an interface");
.isThrownBy(() -> ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class,
StaticApplicationContext.class, this.mockContextSupplier))
.withMessageContaining("ContextType must be an interface");
}
@Test
@@ -109,8 +110,9 @@ class ApplicationContextAssertProviderTests {
void getWhenContextFailsShouldReturnProxyThatThrowsExceptions() {
ApplicationContextAssertProvider<ApplicationContext> context = get(this.startupFailureSupplier);
assertThat((Object) context).isNotNull();
assertThatIllegalStateException().isThrownBy(() -> context.getBean("foo")).withCause(this.startupFailure)
.withMessageContaining("failed to start");
assertThatIllegalStateException().isThrownBy(() -> context.getBean("foo"))
.withCause(this.startupFailure)
.withMessageContaining("failed to start");
}
@Test
@@ -123,7 +125,8 @@ class ApplicationContextAssertProviderTests {
void getSourceContextWhenContextFailsShouldThrowException() {
ApplicationContextAssertProvider<ApplicationContext> context = get(this.startupFailureSupplier);
assertThatIllegalStateException().isThrownBy(context::getSourceApplicationContext)
.withCause(this.startupFailure).withMessageContaining("failed to start");
.withCause(this.startupFailure)
.withMessageContaining("failed to start");
}
@Test
@@ -136,8 +139,9 @@ class ApplicationContextAssertProviderTests {
void getSourceContextOfTypeWhenContextFailsToStartShouldThrowException() {
ApplicationContextAssertProvider<ApplicationContext> context = get(this.startupFailureSupplier);
assertThatIllegalStateException()
.isThrownBy(() -> context.getSourceApplicationContext(ApplicationContext.class))
.withCause(this.startupFailure).withMessageContaining("failed to start");
.isThrownBy(() -> context.getSourceApplicationContext(ApplicationContext.class))
.withCause(this.startupFailure)
.withMessageContaining("failed to start");
}
@Test
@@ -172,7 +176,7 @@ class ApplicationContextAssertProviderTests {
void toStringWhenContextStartsShouldReturnSimpleString() {
ApplicationContextAssertProvider<ApplicationContext> context = get(this.mockContextSupplier);
assertThat(context.toString()).startsWith("Started application [ConfigurableApplicationContext.MockitoMock")
.endsWith("id = [null], applicationName = [null], beanDefinitionCount = 0]");
.endsWith("id = [null], applicationName = [null], beanDefinitionCount = 0]");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ class ApplicationContextAssertTests {
@Test
void createWhenApplicationContextIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ApplicationContextAssert<>(null, null))
.withMessageContaining("ApplicationContext must not be null");
.withMessageContaining("ApplicationContext must not be null");
}
@Test
@@ -84,15 +84,15 @@ class ApplicationContextAssertTests {
@Test
void hasBeanWhenHasNoBeanShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).hasBean("foo"))
.withMessageContaining("no such bean");
.isThrownBy(() -> assertThat(getAssert(this.context)).hasBean("foo"))
.withMessageContaining("no such bean");
}
@Test
void hasBeanWhenNotStartedShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasBean("foo"))
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasBean("foo"))
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -104,8 +104,8 @@ class ApplicationContextAssertTests {
@Test
void hasSingleBeanWhenHasNoBeansShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
.withMessageContaining("to have a single bean of type");
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
.withMessageContaining("to have a single bean of type");
}
@Test
@@ -113,16 +113,16 @@ class ApplicationContextAssertTests {
this.context.registerSingleton("foo", Foo.class);
this.context.registerSingleton("bar", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
.withMessageContaining("but found:");
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
.withMessageContaining("but found:");
}
@Test
void hasSingleBeanWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasSingleBean(Foo.class))
.withMessageContaining("to have a single bean of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasSingleBean(Foo.class))
.withMessageContaining("to have a single bean of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -130,8 +130,8 @@ class ApplicationContextAssertTests {
this.parent.registerSingleton("foo", Foo.class);
this.context.registerSingleton("bar", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
.withMessageContaining("but found:");
.isThrownBy(() -> assertThat(getAssert(this.context)).hasSingleBean(Foo.class))
.withMessageContaining("but found:");
}
@Test
@@ -150,24 +150,24 @@ class ApplicationContextAssertTests {
void doesNotHaveBeanOfTypeWhenHasBeanOfTypeShouldFail() {
this.context.registerSingleton("foo", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
.withMessageContaining("but found");
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
.withMessageContaining("but found");
}
@Test
void doesNotHaveBeanOfTypeWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean(Foo.class))
.withMessageContaining("not to have any beans of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean(Foo.class))
.withMessageContaining("not to have any beans of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
void doesNotHaveBeanOfTypeWhenInParentShouldFail() {
this.parent.registerSingleton("foo", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
.withMessageContaining("but found");
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean(Foo.class))
.withMessageContaining("but found");
}
@Test
@@ -185,15 +185,16 @@ class ApplicationContextAssertTests {
void doesNotHaveBeanOfNameWhenHasBeanOfTypeShouldFail() {
this.context.registerSingleton("foo", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean("foo"))
.withMessageContaining("but found");
.isThrownBy(() -> assertThat(getAssert(this.context)).doesNotHaveBean("foo"))
.withMessageContaining("but found");
}
@Test
void doesNotHaveBeanOfNameWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
.withMessageContaining("not to have any beans of name").withMessageContaining("failed to start");
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
.withMessageContaining("not to have any beans of name")
.withMessageContaining("failed to start");
}
@Test
@@ -211,9 +212,9 @@ class ApplicationContextAssertTests {
@Test
void getBeanNamesWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
.withMessageContaining("not to have any beans of name")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).doesNotHaveBean("foo"))
.withMessageContaining("not to have any beans of name")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -232,8 +233,8 @@ class ApplicationContextAssertTests {
this.context.registerSingleton("foo", Foo.class);
this.context.registerSingleton("bar", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
.withMessageContaining("but found");
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
.withMessageContaining("but found");
}
@Test
@@ -246,9 +247,9 @@ class ApplicationContextAssertTests {
@Test
void getBeanOfTypeWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean(Foo.class))
.withMessageContaining("to contain bean of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean(Foo.class))
.withMessageContaining("to contain bean of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -268,8 +269,8 @@ class ApplicationContextAssertTests {
this.parent.registerSingleton("foo", Foo.class);
this.context.registerSingleton("bar", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
.withMessageContaining("but found");
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean(Foo.class))
.withMessageContaining("but found");
}
@Test
@@ -293,9 +294,9 @@ class ApplicationContextAssertTests {
@Test
void getBeanOfNameWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo"))
.withMessageContaining("to contain a bean of name")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo"))
.withMessageContaining("to contain a bean of name")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -313,16 +314,16 @@ class ApplicationContextAssertTests {
void getBeanOfNameAndTypeWhenHasNoBeanOfNameButDifferentTypeShouldFail() {
this.context.registerSingleton("foo", Foo.class);
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean("foo", String.class))
.withMessageContaining("of type");
.isThrownBy(() -> assertThat(getAssert(this.context)).getBean("foo", String.class))
.withMessageContaining("of type");
}
@Test
void getBeanOfNameAndTypeWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo", Foo.class))
.withMessageContaining("to contain a bean of name")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBean("foo", Foo.class))
.withMessageContaining("to contain a bean of name")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -340,9 +341,9 @@ class ApplicationContextAssertTests {
@Test
void getBeansWhenFailedToStartShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBeans(Foo.class))
.withMessageContaining("to get beans of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).getBeans(Foo.class))
.withMessageContaining("to get beans of type")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test
@@ -367,8 +368,8 @@ class ApplicationContextAssertTests {
@Test
void getFailureWhenDidNotFailShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).getFailure())
.withMessageContaining("context started");
.isThrownBy(() -> assertThat(getAssert(this.context)).getFailure())
.withMessageContaining("context started");
}
@Test
@@ -379,16 +380,16 @@ class ApplicationContextAssertTests {
@Test
void hasFailedWhenNotFailedShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.context)).hasFailed())
.withMessageContaining("to have failed");
.isThrownBy(() -> assertThat(getAssert(this.context)).hasFailed())
.withMessageContaining("to have failed");
}
@Test
void hasNotFailedWhenFailedShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasNotFailed())
.withMessageContaining("to have not failed")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
.isThrownBy(() -> assertThat(getAssert(this.failure)).hasNotFailed())
.withMessageContaining("to have not failed")
.withMessageContaining(String.format("but context failed to start:%n java.lang.RuntimeException"));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ class AssertableApplicationContextTests {
@Test
void getShouldReturnProxy() {
AssertableApplicationContext context = AssertableApplicationContext
.get(() -> mock(ConfigurableApplicationContext.class));
.get(() -> mock(ConfigurableApplicationContext.class));
assertThat(context).isInstanceOf(ConfigurableApplicationContext.class);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ class AssertableReactiveWebApplicationContextTests {
@Test
void getShouldReturnProxy() {
AssertableReactiveWebApplicationContext context = AssertableReactiveWebApplicationContext
.get(() -> mock(ConfigurableReactiveWebApplicationContext.class));
.get(() -> mock(ConfigurableReactiveWebApplicationContext.class));
assertThat(context).isInstanceOf(ConfigurableReactiveWebApplicationContext.class);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ class AssertableWebApplicationContextTests {
@Test
void getShouldReturnProxy() {
AssertableWebApplicationContext context = AssertableWebApplicationContext
.get(() -> mock(ConfigurableWebApplicationContext.class));
.get(() -> mock(ConfigurableWebApplicationContext.class));
assertThat(context).isInstanceOf(ConfigurableWebApplicationContext.class);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,10 +43,10 @@ class SpringBootTestContextBootstrapperTests {
@Test
void springBootTestWithANonMockWebEnvironmentAndWebAppConfigurationFailsFast() {
assertThatIllegalStateException()
.isThrownBy(() -> buildTestContext(SpringBootTestNonMockWebEnvironmentAndWebAppConfiguration.class))
.withMessageContaining("@WebAppConfiguration should only be used with "
+ "@SpringBootTest when @SpringBootTest is configured with a mock web "
+ "environment. Please remove @WebAppConfiguration or reconfigure @SpringBootTest.");
.isThrownBy(() -> buildTestContext(SpringBootTestNonMockWebEnvironmentAndWebAppConfiguration.class))
.withMessageContaining("@WebAppConfiguration should only be used with "
+ "@SpringBootTest when @SpringBootTest is configured with a mock web "
+ "environment. Please remove @WebAppConfiguration or reconfigure @SpringBootTest.");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ class TestTypeExcludeFilterTests {
@Test
void matchesJUnit4TestClass() throws Exception {
assertThat(this.filter.match(getMetadataReader(TestTypeExcludeFilterTests.class), this.metadataReaderFactory))
.isTrue();
.isTrue();
}
@Test
@@ -53,13 +53,13 @@ class TestTypeExcludeFilterTests {
@Test
void matchesJUnitJupiterRepeatedTestClass() throws Exception {
assertThat(this.filter.match(getMetadataReader(JupiterRepeatedTestExample.class), this.metadataReaderFactory))
.isTrue();
.isTrue();
}
@Test
void matchesJUnitJupiterTestFactoryClass() throws Exception {
assertThat(this.filter.match(getMetadataReader(JupiterTestFactoryExample.class), this.metadataReaderFactory))
.isTrue();
.isTrue();
}
@Test
@@ -70,19 +70,22 @@ class TestTypeExcludeFilterTests {
@Test
void matchesNestedConfigurationClassWithoutTestMethodsIfItHasRunWith() throws Exception {
assertThat(this.filter.match(getMetadataReader(AbstractTestWithConfigAndRunWith.Config.class),
this.metadataReaderFactory)).isTrue();
this.metadataReaderFactory))
.isTrue();
}
@Test
void matchesNestedConfigurationClassWithoutTestMethodsIfItHasExtendWith() throws Exception {
assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndExtendWith.Config.class),
this.metadataReaderFactory)).isTrue();
this.metadataReaderFactory))
.isTrue();
}
@Test
void matchesNestedConfigurationClassWithoutTestMethodsIfItHasTestable() throws Exception {
assertThat(this.filter.match(getMetadataReader(AbstractJupiterTestWithConfigAndTestable.Config.class),
this.metadataReaderFactory)).isTrue();
this.metadataReaderFactory))
.isTrue();
}
@Test
@@ -98,7 +101,8 @@ class TestTypeExcludeFilterTests {
@Test
void matchesNestedConfigurationClassWithoutTestNgAnnotation() throws Exception {
assertThat(this.filter.match(getMetadataReader(AbstractTestNgTestWithConfig.Config.class),
this.metadataReaderFactory)).isTrue();
this.metadataReaderFactory))
.isTrue();
}
private MetadataReader getMetadataReader(Class<?> source) throws IOException {

View File

@@ -73,7 +73,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
String key = "test." + UUID.randomUUID();
assertThat(System.getProperties()).doesNotContainKey(key);
get().withSystemProperties(key + "=value")
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "value"));
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "value"));
assertThat(System.getProperties()).doesNotContainKey(key);
}
@@ -81,8 +81,9 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
void runWithSystemPropertiesWhenContextFailsShouldRemoveProperties() {
String key = "test." + UUID.randomUUID();
assertThat(System.getProperties()).doesNotContainKey(key);
get().withSystemProperties(key + "=value").withUserConfiguration(FailingConfig.class)
.run((context) -> assertThat(context).hasFailed());
get().withSystemProperties(key + "=value")
.withUserConfiguration(FailingConfig.class)
.run((context) -> assertThat(context).hasFailed());
assertThat(System.getProperties()).doesNotContainKey(key);
}
@@ -93,7 +94,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
try {
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
get().withSystemProperties(key + "=newValue")
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "newValue"));
.run((context) -> assertThat(System.getProperties()).containsEntry(key, "newValue"));
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
}
finally {
@@ -108,7 +109,7 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
try {
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
get().withSystemProperties(key + "=")
.run((context) -> assertThat(System.getProperties()).doesNotContainKey(key));
.run((context) -> assertThat(System.getProperties()).doesNotContainKey(key));
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
}
finally {
@@ -150,8 +151,9 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
@Test
void runWithMultipleConfigurationsShouldRegisterAllConfigurations() {
get().withUserConfiguration(FooConfig.class).withConfiguration(UserConfigurations.of(BarConfig.class))
.run((context) -> assertThat(context).hasBean("foo").hasBean("bar"));
get().withUserConfiguration(FooConfig.class)
.withConfiguration(UserConfigurations.of(BarConfig.class))
.run((context) -> assertThat(context).hasBean("foo").hasBean("bar"));
}
@Test
@@ -162,30 +164,32 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
@Test
void runWithClassLoaderShouldSetClassLoaderOnContext() {
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
.run((context) -> assertThatExceptionOfType(ClassNotFoundException.class)
.isThrownBy(() -> ClassUtils.forName(Gson.class.getName(), context.getClassLoader())));
.run((context) -> assertThatExceptionOfType(ClassNotFoundException.class)
.isThrownBy(() -> ClassUtils.forName(Gson.class.getName(), context.getClassLoader())));
}
@Test
void runWithClassLoaderShouldSetClassLoaderOnConditionContext() {
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
.withUserConfiguration(ConditionalConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ConditionalConfig.class));
.withUserConfiguration(ConditionalConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ConditionalConfig.class));
}
@Test
void consecutiveRunWithFilteredClassLoaderShouldHaveBeanWithLazyProperties() {
get().withClassLoader(new FilteredClassLoader(Gson.class)).withUserConfiguration(LazyConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
get().withClassLoader(new FilteredClassLoader(Gson.class))
.withUserConfiguration(LazyConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
get().withClassLoader(new FilteredClassLoader(Gson.class)).withUserConfiguration(LazyConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
get().withClassLoader(new FilteredClassLoader(Gson.class))
.withUserConfiguration(LazyConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ExampleBeanWithLazyProperties.class));
}
@Test
void thrownRuleWorksWithCheckedException() {
get().run((context) -> assertThatIOException().isThrownBy(() -> throwCheckedException("Expected message"))
.withMessageContaining("Expected message"));
.withMessageContaining("Expected message"));
}
@Test
@@ -193,57 +197,62 @@ abstract class AbstractApplicationContextRunnerTests<T extends AbstractApplicati
get().withUserConfiguration(FooConfig.class).withBean("foo", Integer.class, () -> 42).run((context) -> {
assertThat(context).hasFailed();
assertThat(context.getStartupFailure()).isInstanceOf(BeanDefinitionStoreException.class)
.hasMessageContaining("Invalid bean definition with name 'foo'")
.hasMessageContaining("@Bean definition illegally overridden by existing bean definition");
.hasMessageContaining("Invalid bean definition with name 'foo'")
.hasMessageContaining("@Bean definition illegally overridden by existing bean definition");
});
}
@Test
void runDisablesCircularReferencesByDefault() {
get().withUserConfiguration(ExampleConsumerConfiguration.class, ExampleProducerConfiguration.class)
.run((context) -> {
assertThat(context).hasFailed();
assertThat(context).getFailure().hasRootCauseInstanceOf(BeanCurrentlyInCreationException.class);
});
.run((context) -> {
assertThat(context).hasFailed();
assertThat(context).getFailure().hasRootCauseInstanceOf(BeanCurrentlyInCreationException.class);
});
}
@Test
void circularReferencesCanBeAllowed() {
get().withAllowCircularReferences(true)
.withUserConfiguration(ExampleConsumerConfiguration.class, ExampleProducerConfiguration.class)
.run((context) -> assertThat(context).hasNotFailed());
.withUserConfiguration(ExampleConsumerConfiguration.class, ExampleProducerConfiguration.class)
.run((context) -> assertThat(context).hasNotFailed());
}
@Test
void runWithUserBeanShouldBeRegisteredInOrder() {
get().withAllowBeanDefinitionOverriding(true).withBean(String.class, () -> "one")
.withBean(String.class, () -> "two").withBean(String.class, () -> "three").run((context) -> {
assertThat(context).hasBean("string");
assertThat(context.getBean("string")).isEqualTo("three");
});
get().withAllowBeanDefinitionOverriding(true)
.withBean(String.class, () -> "one")
.withBean(String.class, () -> "two")
.withBean(String.class, () -> "three")
.run((context) -> {
assertThat(context).hasBean("string");
assertThat(context.getBean("string")).isEqualTo("three");
});
}
@Test
void runWithConfigurationsAndUserBeanShouldRegisterUserBeanLast() {
get().withAllowBeanDefinitionOverriding(true).withUserConfiguration(FooConfig.class)
.withBean("foo", String.class, () -> "overridden").run((context) -> {
assertThat(context).hasBean("foo");
assertThat(context.getBean("foo")).isEqualTo("overridden");
});
get().withAllowBeanDefinitionOverriding(true)
.withUserConfiguration(FooConfig.class)
.withBean("foo", String.class, () -> "overridden")
.run((context) -> {
assertThat(context).hasBean("foo");
assertThat(context.getBean("foo")).isEqualTo("overridden");
});
}
@Test
void changesMadeByInitializersShouldBeVisibleToRegisteredClasses() {
get().withInitializer((context) -> context.getEnvironment().setActiveProfiles("test"))
.withUserConfiguration(ProfileConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ProfileConfig.class));
.withUserConfiguration(ProfileConfig.class)
.run((context) -> assertThat(context).hasSingleBean(ProfileConfig.class));
}
@Test
void prepareDoesNotRefreshContext() {
get().withUserConfiguration(FooConfig.class).prepare((context) -> {
assertThatIllegalStateException().isThrownBy(() -> context.getBean(String.class))
.withMessageContaining("not been refreshed");
.withMessageContaining("not been refreshed");
context.getSourceApplicationContext().refresh();
assertThat(context.getBean(String.class)).isEqualTo("foo");
});

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ class ContextConsumerTests {
ContextConsumer<ApplicationContext> firstConsumer = (context) -> assertThat(predicate.test(42)).isFalse();
ContextConsumer<ApplicationContext> secondConsumer = (context) -> assertThat(predicate.test(24)).isFalse();
assertThatThrownBy(() -> firstConsumer.andThen(secondConsumer).accept(mock(ApplicationContext.class)))
.isInstanceOf(AssertionError.class);
.isInstanceOf(AssertionError.class);
then(predicate).should().test(42);
then(predicate).shouldHaveNoMoreInteractions();
}
@@ -70,7 +70,7 @@ class ContextConsumerTests {
ContextConsumer<?> consumer = (context) -> {
};
assertThatIllegalArgumentException().isThrownBy(() -> consumer.andThen(null))
.withMessage("After must not be null");
.withMessage("After must not be null");
}
}

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -43,17 +43,18 @@ class HttpGraphQlTesterContextCustomizerTests {
@Test
void whenContextIsNotABeanDefinitionRegistryHttpGraphQlTesterIsRegistered() {
new ApplicationContextRunner(HttpGraphQlTesterContextCustomizerTests.TestApplicationContext::new)
.withInitializer(this::applyHttpGraphQlTesterContextCustomizer)
.run((context) -> assertThat(context).hasSingleBean(HttpGraphQlTester.class));
.withInitializer(this::applyHttpGraphQlTesterContextCustomizer)
.run((context) -> assertThat(context).hasSingleBean(HttpGraphQlTester.class));
}
@Test
void whenUsingAotGeneratedArtifactsHttpGraphQlTesterIsNotRegistered() {
new ApplicationContextRunner().withSystemProperties("spring.aot.enabled:true")
.withInitializer(this::applyHttpGraphQlTesterContextCustomizer).run((context) -> {
assertThat(context).doesNotHaveBean(HttpGraphQlTesterRegistrar.class);
assertThat(context).doesNotHaveBean(HttpGraphQlTester.class);
});
.withInitializer(this::applyHttpGraphQlTesterContextCustomizer)
.run((context) -> {
assertThat(context).doesNotHaveBean(HttpGraphQlTesterRegistrar.class);
assertThat(context).doesNotHaveBean(HttpGraphQlTester.class);
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -91,14 +91,14 @@ abstract class AbstractJsonMarshalTesterTests {
@Test
void createWhenResourceLoadClassIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> createTester(null, ResolvableType.forClass(ExampleObject.class)))
.withMessageContaining("ResourceLoadClass must not be null");
.isThrownBy(() -> createTester(null, ResolvableType.forClass(ExampleObject.class)))
.withMessageContaining("ResourceLoadClass must not be null");
}
@Test
void createWhenTypeIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> createTester(getClass(), null))
.withMessageContaining("Type must not be null");
.withMessageContaining("Type must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ class BasicJsonTesterTests {
@Test
void createWhenResourceLoadClassIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new BasicJsonTester(null))
.withMessageContaining("ResourceLoadClass must not be null");
.withMessageContaining("ResourceLoadClass must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,8 @@ class DuplicateJsonObjectContextCustomizerFactoryTests {
@Test
void warningForMultipleVersions() {
new DuplicateJsonObjectContextCustomizerFactory().createContextCustomizer(null, null).customizeContext(null,
null);
new DuplicateJsonObjectContextCustomizerFactory().createContextCustomizer(null, null)
.customizeContext(null, null);
assertThat(this.output).contains("Found multiple occurrences of org.json.JSONObject on the class path:");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ class GsonTesterIntegrationTests {
void stringLiteral() throws Exception {
String stringWithSpecialCharacters = "myString";
assertThat(this.stringJson.write(stringWithSpecialCharacters)).extractingJsonPathStringValue("@")
.isEqualTo(stringWithSpecialCharacters);
.isEqualTo(stringWithSpecialCharacters);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,14 +37,14 @@ class GsonTesterTests extends AbstractJsonMarshalTesterTests {
@Test
void initFieldsWhenTestIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> GsonTester.initFields(null, new GsonBuilder().create()))
.withMessageContaining("TestInstance must not be null");
.withMessageContaining("TestInstance must not be null");
}
@Test
void initFieldsWhenMarshallerIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> GsonTester.initFields(new InitFieldsTestClass(), (Gson) null))
.withMessageContaining("Marshaller must not be null");
.isThrownBy(() -> GsonTester.initFields(new InitFieldsTestClass(), (Gson) null))
.withMessageContaining("Marshaller must not be null");
}
@Test

View File

@@ -81,7 +81,7 @@ class JacksonTesterIntegrationTests {
JacksonTester.initFields(this, new ObjectMapper());
String stringWithSpecialCharacters = "myString";
assertThat(this.stringJson.write(stringWithSpecialCharacters)).extractingJsonPathStringValue("@")
.isEqualTo(stringWithSpecialCharacters);
.isEqualTo(stringWithSpecialCharacters);
}
@Test
@@ -95,7 +95,7 @@ class JacksonTesterIntegrationTests {
// restores the symmetry. See gh-15727
String stringWithSpecialCharacters = "\u0006\u007F";
assertThat(this.stringJson.write(stringWithSpecialCharacters)).extractingJsonPathStringValue("@")
.isEqualTo(stringWithSpecialCharacters);
.isEqualTo(stringWithSpecialCharacters);
}
@Test
@@ -105,7 +105,7 @@ class JacksonTesterIntegrationTests {
object.setName("Spring");
object.setAge(123);
JsonContent<ExampleObjectWithView> content = this.jsonWithView.forView(ExampleObjectWithView.TestView.class)
.write(object);
.write(object);
assertThat(content).extractingJsonPathStringValue("@.name").isEqualTo("Spring");
assertThat(content).doesNotHaveJsonPathValue("age");
}
@@ -115,7 +115,7 @@ class JacksonTesterIntegrationTests {
JacksonTester.initFields(this, JsonMapper.builder().disable(MapperFeature.DEFAULT_VIEW_INCLUSION).build());
ByteArrayResource resource = new ByteArrayResource(JSON.getBytes());
ObjectContent<ExampleObjectWithView> content = this.jsonWithView.forView(ExampleObjectWithView.TestView.class)
.read(resource);
.read(resource);
assertThat(content.getObject().getName()).isEqualTo("Spring");
assertThat(content.getObject().getAge()).isZero();
}
@@ -125,7 +125,7 @@ class JacksonTesterIntegrationTests {
JacksonTester.initFields(this, JsonMapper.builder().disable(MapperFeature.DEFAULT_VIEW_INCLUSION).build());
Reader reader = new StringReader(JSON);
ObjectContent<ExampleObjectWithView> content = this.jsonWithView.forView(ExampleObjectWithView.TestView.class)
.read(reader);
.read(reader);
assertThat(content.getObject().getName()).isEqualTo("Spring");
assertThat(content.getObject().getAge()).isZero();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,14 +36,14 @@ class JacksonTesterTests extends AbstractJsonMarshalTesterTests {
@Test
void initFieldsWhenTestIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> JacksonTester.initFields(null, new ObjectMapper()))
.withMessageContaining("TestInstance must not be null");
.withMessageContaining("TestInstance must not be null");
}
@Test
void initFieldsWhenMarshallerIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> JacksonTester.initFields(new InitFieldsTestClass(), (ObjectMapper) null))
.withMessageContaining("Marshaller must not be null");
.isThrownBy(() -> JacksonTester.initFields(new InitFieldsTestClass(), (ObjectMapper) null))
.withMessageContaining("Marshaller must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ class JsonContentAssertTests {
@Test
void isEqualToWhenStringIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT));
}
@Test
@@ -96,7 +96,7 @@ class JsonContentAssertTests {
@Test
void isEqualToWhenResourcePathIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo("different.json"));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo("different.json"));
}
@Test
@@ -107,7 +107,7 @@ class JsonContentAssertTests {
@Test
void isEqualToWhenBytesAreNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes()));
}
@Test
@@ -118,7 +118,7 @@ class JsonContentAssertTests {
@Test
void isEqualToWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
}
@Test
@@ -129,7 +129,7 @@ class JsonContentAssertTests {
@Test
void isEqualToWhenInputStreamIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createInputStream(DIFFERENT)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createInputStream(DIFFERENT)));
}
@Test
@@ -140,7 +140,7 @@ class JsonContentAssertTests {
@Test
void isEqualToWhenResourceIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createResource(DIFFERENT)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createResource(DIFFERENT)));
}
@Test
@@ -151,13 +151,13 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenNullActualShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(null)).isEqualToJson(SOURCE));
.isThrownBy(() -> assertThat(forJson(null)).isEqualToJson(SOURCE));
}
@Test
void isEqualToJsonWhenStringIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT));
}
@Test
@@ -168,7 +168,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json"));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json"));
}
@Test
@@ -179,7 +179,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass()));
}
@Test
@@ -190,7 +190,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenBytesAreNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes()));
}
@Test
@@ -201,7 +201,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
}
@Test
@@ -212,7 +212,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenInputStreamIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT)));
}
@Test
@@ -223,7 +223,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourceIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT)));
}
@Test
@@ -234,7 +234,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenStringIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME));
}
@Test
@@ -245,7 +245,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json"));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json"));
}
@Test
@@ -256,7 +256,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json", getClass()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json", getClass()));
}
@Test
@@ -267,7 +267,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenBytesAreNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME.getBytes()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME.getBytes()));
}
@Test
@@ -278,7 +278,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME)));
}
@Test
@@ -289,7 +289,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenInputStreamIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createInputStream(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createInputStream(LENIENT_SAME)));
}
@Test
@@ -300,7 +300,7 @@ class JsonContentAssertTests {
@Test
void isStrictlyEqualToJsonWhenResourceIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createResource(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createResource(LENIENT_SAME)));
}
@Test
@@ -311,7 +311,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenStringIsNotMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, JSONCompareMode.LENIENT));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, JSONCompareMode.LENIENT));
}
@Test
@@ -322,7 +322,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", JSONCompareMode.LENIENT));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", JSONCompareMode.LENIENT));
}
@Test
@@ -343,8 +343,8 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenBytesAreNotMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), JSONCompareMode.LENIENT));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), JSONCompareMode.LENIENT));
}
@Test
@@ -388,7 +388,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR));
}
@Test
@@ -399,7 +399,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", COMPARATOR));
}
@Test
@@ -410,7 +410,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(), COMPARATOR));
}
@Test
@@ -421,7 +421,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), COMPARATOR));
}
@Test
@@ -432,7 +432,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR));
}
@Test
@@ -443,7 +443,7 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT), COMPARATOR));
}
@Test
@@ -454,13 +454,13 @@ class JsonContentAssertTests {
@Test
void isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT), COMPARATOR));
}
@Test
void isNotEqualToWhenStringIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME));
}
@Test
@@ -476,7 +476,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToWhenResourcePathIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json"));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json"));
}
@Test
@@ -487,7 +487,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToWhenBytesAreMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes()));
}
@Test
@@ -498,7 +498,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
}
@Test
@@ -509,7 +509,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToWhenInputStreamIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME)));
}
@Test
@@ -520,7 +520,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToWhenResourceIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME)));
}
@Test
@@ -531,7 +531,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenStringIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME));
}
@Test
@@ -547,7 +547,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourcePathIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json"));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json"));
}
@Test
@@ -558,7 +558,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass()));
}
@Test
@@ -569,7 +569,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenBytesAreMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes()));
}
@Test
@@ -580,7 +580,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)));
}
@Test
@@ -591,7 +591,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenInputStreamIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME)));
}
@Test
@@ -602,7 +602,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourceIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME)));
}
@Test
@@ -613,7 +613,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE));
}
@Test
@@ -624,7 +624,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json"));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json"));
}
@Test
@@ -635,7 +635,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass()));
}
@Test
@@ -646,7 +646,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes()));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes()));
}
@Test
@@ -657,7 +657,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)));
}
@Test
@@ -668,7 +668,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenInputStreamIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE)));
}
@Test
@@ -679,7 +679,7 @@ class JsonContentAssertTests {
@Test
void isNotStrictlyEqualToJsonWhenResourceIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE)));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE)));
}
@Test
@@ -690,7 +690,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT));
}
@Test
@@ -712,7 +712,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson("lenient-same.json", getClass(), JSONCompareMode.LENIENT));
.isNotEqualToJson("lenient-same.json", getClass(), JSONCompareMode.LENIENT));
}
@Test
@@ -745,7 +745,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenInputStreamIsMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createInputStream(LENIENT_SAME), JSONCompareMode.LENIENT));
.isNotEqualToJson(createInputStream(LENIENT_SAME), JSONCompareMode.LENIENT));
}
@Test
@@ -756,7 +756,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourceIsMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> assertThat(forJson(SOURCE))
.isNotEqualToJson(createResource(LENIENT_SAME), JSONCompareMode.LENIENT));
.isNotEqualToJson(createResource(LENIENT_SAME), JSONCompareMode.LENIENT));
}
@Test
@@ -767,7 +767,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, COMPARATOR));
}
@Test
@@ -778,7 +778,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", COMPARATOR));
}
@Test
@@ -800,7 +800,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR));
}
@Test
@@ -811,7 +811,7 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
}
@Test
@@ -832,8 +832,8 @@ class JsonContentAssertTests {
@Test
void isNotEqualToJsonWhenResourceIsMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME), COMPARATOR));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME), COMPARATOR));
}
@Test
@@ -855,8 +855,8 @@ class JsonContentAssertTests {
void hasJsonPathForNotPresent() {
String expression = "missing";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPath(expression))
.withMessageContaining("No JSON path \"" + expression + "\" found");
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPath(expression))
.withMessageContaining("No JSON path \"" + expression + "\" found");
}
@Test
@@ -878,16 +878,16 @@ class JsonContentAssertTests {
void hasJsonPathValueForANullValue() {
String expression = "nullname";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
.withMessageContaining("No value at JSON path \"" + expression + "\"");
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
.withMessageContaining("No value at JSON path \"" + expression + "\"");
}
@Test
void hasJsonPathValueForMissingValue() {
String expression = "missing";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
.withMessageContaining("No value at JSON path \"" + expression + "\"");
.isThrownBy(() -> assertThat(forJson(NULLS)).hasJsonPathValue(expression))
.withMessageContaining("No value at JSON path \"" + expression + "\"");
}
@Test
@@ -899,8 +899,8 @@ class JsonContentAssertTests {
void hasJsonPathValueForIndefinitePathWithEmptyResults() {
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasJsonPathValue(expression))
.withMessageContaining("No value at JSON path \"" + expression + "\"");
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasJsonPathValue(expression))
.withMessageContaining("No value at JSON path \"" + expression + "\"");
}
@Test
@@ -912,16 +912,16 @@ class JsonContentAssertTests {
void doesNotHaveJsonPathForNull() {
String expression = "nullname";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
}
@Test
void doesNotHaveJsonPathForPresent() {
String expression = "valuename";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
.isThrownBy(() -> assertThat(forJson(NULLS)).doesNotHaveJsonPath(expression))
.withMessageContaining("Expecting no JSON path \"" + expression + "\"");
}
@Test
@@ -933,25 +933,25 @@ class JsonContentAssertTests {
void doesNotHaveJsonPathValueForAnEmptyArray() {
String expression = "$.emptyArray";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: []");
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: []");
}
@Test
void doesNotHaveJsonPathValueForAnEmptyMap() {
String expression = "$.emptyMap";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: {}");
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveJsonPathValue(expression))
.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: {}");
}
@Test
void doesNotHaveJsonPathValueForIndefinitePathWithResults() {
String expression = "$.familyMembers[?(@.name == 'Bart')]";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveJsonPathValue(expression))
.withMessageContaining(
"Expected no value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveJsonPathValue(expression))
.withMessageContaining(
"Expected no value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
}
@Test
@@ -988,17 +988,17 @@ class JsonContentAssertTests {
void hasEmptyJsonPathValueForIndefinitePathWithResults() {
String expression = "$.familyMembers[?(@.name == 'Bart')]";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasEmptyJsonPathValue(expression))
.withMessageContaining(
"Expected an empty value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).hasEmptyJsonPathValue(expression))
.withMessageContaining(
"Expected an empty value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
}
@Test
void hasEmptyJsonPathValueForWhitespace() {
String expression = "$.whitespace";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).hasEmptyJsonPathValue(expression))
.withMessageContaining("Expected an empty value at JSON path \"" + expression + "\" but found: ' '");
.isThrownBy(() -> assertThat(forJson(TYPES)).hasEmptyJsonPathValue(expression))
.withMessageContaining("Expected an empty value at JSON path \"" + expression + "\" but found: ' '");
}
@Test
@@ -1035,32 +1035,32 @@ class JsonContentAssertTests {
void doesNotHaveEmptyJsonPathValueForIndefinitePathWithEmptyResults() {
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
.isThrownBy(() -> assertThat(forJson(SIMPSONS)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
}
@Test
void doesNotHaveEmptyJsonPathValueForAnEmptyString() {
String expression = "$.emptyString";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: ''");
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: ''");
}
@Test
void doesNotHaveEmptyJsonPathValueForForAnEmptyArray() {
String expression = "$.emptyArray";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
}
@Test
void doesNotHaveEmptyJsonPathValueForAnEmptyMap() {
String expression = "$.emptyMap";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: {}");
.isThrownBy(() -> assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue(expression))
.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: {}");
}
@Test
@@ -1077,8 +1077,8 @@ class JsonContentAssertTests {
void hasJsonPathStringValueForNonString() {
String expression = "$.bool";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathStringValue(expression))
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: true");
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathStringValue(expression))
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: true");
}
@Test
@@ -1090,8 +1090,8 @@ class JsonContentAssertTests {
void hasJsonPathNumberValueForNonNumber() {
String expression = "$.bool";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathNumberValue(expression))
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: true");
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathNumberValue(expression))
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: true");
}
@Test
@@ -1103,8 +1103,8 @@ class JsonContentAssertTests {
void hasJsonPathBooleanValueForNonBoolean() {
String expression = "$.num";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathBooleanValue(expression))
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 5");
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathBooleanValue(expression))
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 5");
}
@Test
@@ -1121,8 +1121,8 @@ class JsonContentAssertTests {
void hasJsonPathArrayValueForNonArray() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathArrayValue(expression))
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathArrayValue(expression))
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
}
@Test
@@ -1139,8 +1139,8 @@ class JsonContentAssertTests {
void hasJsonPathMapValueForNonMap() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathMapValue(expression))
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
.isThrownBy(() -> assertThat(forJson(TYPES)).hasJsonPathMapValue(expression))
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
}
@Test
@@ -1172,8 +1172,8 @@ class JsonContentAssertTests {
void extractingJsonPathStringValueForWrongType() {
String expression = "$.num";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathStringValue(expression))
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: 5");
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathStringValue(expression))
.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: 5");
}
@Test
@@ -1190,8 +1190,8 @@ class JsonContentAssertTests {
void extractingJsonPathNumberValueForWrongType() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathNumberValue(expression))
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: 'foo'");
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathNumberValue(expression))
.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: 'foo'");
}
@Test
@@ -1208,8 +1208,8 @@ class JsonContentAssertTests {
void extractingJsonPathBooleanValueForWrongType() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathBooleanValue(expression))
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 'foo'");
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathBooleanValue(expression))
.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 'foo'");
}
@Test
@@ -1231,8 +1231,8 @@ class JsonContentAssertTests {
void extractingJsonPathArrayValueForWrongType() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathArrayValue(expression))
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathArrayValue(expression))
.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
}
@Test
@@ -1254,8 +1254,8 @@ class JsonContentAssertTests {
void extractingJsonPathMapValueForWrongType() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathMapValue(expression))
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
.isThrownBy(() -> assertThat(forJson(TYPES)).extractingJsonPathMapValue(expression))
.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,23 +38,23 @@ class JsonContentTests {
@Test
void createWhenResourceLoadClassIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(
() -> new JsonContent<ExampleObject>(null, TYPE, JSON, Configuration.defaultConfiguration()))
.withMessageContaining("ResourceLoadClass must not be null");
.isThrownBy(() -> new JsonContent<ExampleObject>(null, TYPE, JSON, Configuration.defaultConfiguration()))
.withMessageContaining("ResourceLoadClass must not be null");
}
@Test
void createWhenJsonIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(
() -> new JsonContent<ExampleObject>(getClass(), TYPE, null, Configuration.defaultConfiguration()))
.withMessageContaining("JSON must not be null");
assertThatIllegalArgumentException()
.isThrownBy(
() -> new JsonContent<ExampleObject>(getClass(), TYPE, null, Configuration.defaultConfiguration()))
.withMessageContaining("JSON must not be null");
}
@Test
void createWhenConfigurationIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new JsonContent<ExampleObject>(getClass(), TYPE, JSON, null))
.withMessageContaining("Configuration must not be null");
.isThrownBy(() -> new JsonContent<ExampleObject>(getClass(), TYPE, JSON, null))
.withMessageContaining("Configuration must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -37,14 +37,14 @@ class JsonbTesterTests extends AbstractJsonMarshalTesterTests {
@Test
void initFieldsWhenTestIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> JsonbTester.initFields(null, JsonbBuilder.create()))
.withMessageContaining("TestInstance must not be null");
.withMessageContaining("TestInstance must not be null");
}
@Test
void initFieldsWhenMarshallerIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> JsonbTester.initFields(new InitFieldsTestClass(), (Jsonb) null))
.withMessageContaining("Marshaller must not be null");
.isThrownBy(() -> JsonbTester.initFields(new InitFieldsTestClass(), (Jsonb) null))
.withMessageContaining("Marshaller must not be null");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ class ObjectContentAssertTests {
@Test
void isEqualToWhenObjectsAreDifferentShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT));
.isThrownBy(() -> assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ class ObjectContentTests {
@Test
void createWhenObjectIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new ObjectContent<ExampleObject>(TYPE, null))
.withMessageContaining("Object must not be null");
.withMessageContaining("Object must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ class DefinitionsParserTests {
MockDefinition fieldDefinition = getMockDefinition(1);
assertThat(fieldDefinition.getTypeToMock().resolve()).isEqualTo(ExampleServiceCaller.class);
QualifierDefinition qualifier = QualifierDefinition
.forElement(ReflectionUtils.findField(MockBeanOnClassAndField.class, "caller"));
.forElement(ReflectionUtils.findField(MockBeanOnClassAndField.class, "caller"));
assertThat(fieldDefinition.getQualifier()).isNotNull().isEqualTo(qualifier);
}
@@ -94,7 +94,7 @@ class DefinitionsParserTests {
@Test
void parseMockBeanMissingClassToMock() {
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(MockBeanMissingClassToMock.class))
.withMessageContaining("Unable to deduce type to mock");
.withMessageContaining("Unable to deduce type to mock");
}
@Test
@@ -108,7 +108,7 @@ class DefinitionsParserTests {
@Test
void parseMockBeanMultipleClassesWithName() {
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(MockBeanMultipleClassesWithName.class))
.withMessageContaining("The name attribute can only be used when mocking a single class");
.withMessageContaining("The name attribute can only be used when mocking a single class");
}
@Test
@@ -146,7 +146,7 @@ class DefinitionsParserTests {
assertThat(classDefinition.getTypeToSpy().resolve()).isEqualTo(RealExampleService.class);
SpyDefinition fieldDefinition = getSpyDefinition(1);
QualifierDefinition qualifier = QualifierDefinition
.forElement(ReflectionUtils.findField(SpyBeanOnClassAndField.class, "caller"));
.forElement(ReflectionUtils.findField(SpyBeanOnClassAndField.class, "caller"));
assertThat(fieldDefinition.getQualifier()).isNotNull().isEqualTo(qualifier);
assertThat(fieldDefinition.getTypeToSpy().resolve()).isEqualTo(ExampleServiceCaller.class);
}
@@ -161,7 +161,7 @@ class DefinitionsParserTests {
@Test
void parseSpyBeanMissingClassToMock() {
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(SpyBeanMissingClassToMock.class))
.withMessageContaining("Unable to deduce type to spy");
.withMessageContaining("Unable to deduce type to spy");
}
@Test
@@ -175,7 +175,7 @@ class DefinitionsParserTests {
@Test
void parseSpyBeanMultipleClassesWithName() {
assertThatIllegalStateException().isThrownBy(() -> this.parser.parse(SpyBeanMultipleClassesWithName.class))
.withMessageContaining("The name attribute can only be used when spying a single class");
.withMessageContaining("The name attribute can only be used when spying a single class");
}
private MockDefinition getMockDefinition(int index) {

View File

@@ -54,7 +54,7 @@ class MockBeanContextCachingTests {
@SuppressWarnings("unchecked")
void clearCache() {
Map<MergedContextConfiguration, ApplicationContext> contexts = (Map<MergedContextConfiguration, ApplicationContext>) ReflectionTestUtils
.getField(this.contextCache, "contextMap");
.getField(this.contextCache, "contextMap");
for (ApplicationContext context : contexts.values()) {
if (context instanceof ConfigurableApplicationContext configurableContext) {
configurableContext.close();

View File

@@ -41,8 +41,8 @@ class MockDefinitionTests {
@Test
void classToMockMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new MockDefinition(null, null, null, null, false, null, null))
.withMessageContaining("TypeToMock must not be null");
.isThrownBy(() -> new MockDefinition(null, null, null, null, false, null, null))
.withMessageContaining("TypeToMock must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -58,8 +58,8 @@ class MockitoPostProcessorTests {
MockitoPostProcessor.register(context);
context.register(MultipleBeans.class);
assertThatIllegalStateException().isThrownBy(context::refresh)
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
+ " expected a single matching bean to replace but found [example1, example2]");
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
+ " expected a single matching bean to replace but found [example1, example2]");
}
@Test
@@ -68,8 +68,8 @@ class MockitoPostProcessorTests {
MockitoPostProcessor.register(context);
context.register(MultipleQualifiedBeans.class);
assertThatIllegalStateException().isThrownBy(context::refresh)
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
+ " expected a single matching bean to replace but found [example1, example3]");
.withMessageContaining("Unable to register mock bean " + ExampleService.class.getName()
+ " expected a single matching bean to replace but found [example1, example3]");
}
@Test
@@ -94,7 +94,7 @@ class MockitoPostProcessorTests {
assertThat(Mockito.mockingDetails(context.getBean(ExampleService.class)).isMock()).isTrue();
assertThat(Mockito.mockingDetails(context.getBean("examplePrimary", ExampleService.class)).isMock()).isTrue();
assertThat(Mockito.mockingDetails(context.getBean("exampleQualified", ExampleService.class)).isMock())
.isFalse();
.isFalse();
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ class MockitoTestExecutionListenerTests {
TestContext mockTestContext = mockTestContext(instance);
given(mockTestContext.getApplicationContext()).willReturn(this.applicationContext);
given(mockTestContext.getAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE))
.willReturn(Boolean.TRUE);
.willReturn(Boolean.TRUE);
this.listener.beforeTestMethod(mockTestContext);
then(this.postProcessor).should().inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean");

View File

@@ -65,14 +65,14 @@ class QualifierDefinitionTests {
@Test
void forElementWhenElementIsFieldWithNoQualifiersShouldReturnNull() {
QualifierDefinition definition = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "noQualifier"));
.forElement(ReflectionUtils.findField(ConfigA.class, "noQualifier"));
assertThat(definition).isNull();
}
@Test
void forElementWhenElementIsFieldWithQualifierShouldReturnDefinition() {
QualifierDefinition definition = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
assertThat(definition).isNotNull();
}
@@ -97,26 +97,29 @@ class QualifierDefinitionTests {
@Test
void hashCodeAndEqualsShouldWorkOnDifferentClasses() {
QualifierDefinition directQualifier1 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
QualifierDefinition directQualifier2 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigB.class, "directQualifier"));
.forElement(ReflectionUtils.findField(ConfigB.class, "directQualifier"));
QualifierDefinition differentDirectQualifier1 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "differentDirectQualifier"));
.forElement(ReflectionUtils.findField(ConfigA.class, "differentDirectQualifier"));
QualifierDefinition differentDirectQualifier2 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigB.class, "differentDirectQualifier"));
.forElement(ReflectionUtils.findField(ConfigB.class, "differentDirectQualifier"));
QualifierDefinition customQualifier1 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "customQualifier"));
.forElement(ReflectionUtils.findField(ConfigA.class, "customQualifier"));
QualifierDefinition customQualifier2 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigB.class, "customQualifier"));
.forElement(ReflectionUtils.findField(ConfigB.class, "customQualifier"));
assertThat(directQualifier1).hasSameHashCodeAs(directQualifier2);
assertThat(differentDirectQualifier1).hasSameHashCodeAs(differentDirectQualifier2);
assertThat(customQualifier1).hasSameHashCodeAs(customQualifier2);
assertThat(differentDirectQualifier1).isEqualTo(differentDirectQualifier1).isEqualTo(differentDirectQualifier2)
.isNotEqualTo(directQualifier2);
assertThat(directQualifier1).isEqualTo(directQualifier1).isEqualTo(directQualifier2)
.isNotEqualTo(differentDirectQualifier1);
assertThat(customQualifier1).isEqualTo(customQualifier1).isEqualTo(customQualifier2)
.isNotEqualTo(differentDirectQualifier1);
assertThat(differentDirectQualifier1).isEqualTo(differentDirectQualifier1)
.isEqualTo(differentDirectQualifier2)
.isNotEqualTo(directQualifier2);
assertThat(directQualifier1).isEqualTo(directQualifier1)
.isEqualTo(directQualifier2)
.isNotEqualTo(differentDirectQualifier1);
assertThat(customQualifier1).isEqualTo(customQualifier1)
.isEqualTo(customQualifier2)
.isNotEqualTo(differentDirectQualifier1);
}
@Configuration(proxyBeanMethods = false)

View File

@@ -42,7 +42,7 @@ class SpyDefinitionTests {
@Test
void classToSpyMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(() -> new SpyDefinition(null, null, null, true, null))
.withMessageContaining("TypeToSpy must not be null");
.withMessageContaining("TypeToSpy must not be null");
}
@Test
@@ -81,14 +81,14 @@ class SpyDefinitionTests {
void createSpyWhenNullInstanceShouldThrowException() {
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE, MockReset.BEFORE, true, null);
assertThatIllegalArgumentException().isThrownBy(() -> definition.createSpy(null))
.withMessageContaining("Instance must not be null");
.withMessageContaining("Instance must not be null");
}
@Test
void createSpyWhenWrongInstanceShouldThrowException() {
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE, MockReset.BEFORE, true, null);
assertThatIllegalArgumentException().isThrownBy(() -> definition.createSpy(new ExampleServiceCaller(null)))
.withMessageContaining("must be an instance of");
.withMessageContaining("must be an instance of");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -103,7 +103,7 @@ class TestPropertyValuesTests {
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment, Type.SYSTEM_ENVIRONMENT);
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
assertThat(this.environment.getPropertySources()
.contains("test-" + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)).isTrue();
.contains("test-" + StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)).isTrue();
}
@Test
@@ -118,7 +118,7 @@ class TestPropertyValuesTests {
TestPropertyValues.of("foo.bar=baz", "hello.world=hi").applyTo(this.environment, Type.MAP, "other");
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment, Type.SYSTEM_ENVIRONMENT, "other");
assertThat(this.environment.getPropertySources().get("other"))
.isInstanceOf(SystemEnvironmentPropertySource.class);
.isInstanceOf(SystemEnvironmentPropertySource.class);
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
assertThat(this.environment.getProperty("hello.world")).isNull();
}
@@ -133,8 +133,10 @@ class TestPropertyValuesTests {
@Test
void andShouldChainAndAddSingleKeyValue() {
TestPropertyValues.of("foo.bar=baz").and("hello.world=hi").and("bling.blah=bing").applyTo(this.environment,
Type.MAP);
TestPropertyValues.of("foo.bar=baz")
.and("hello.world=hi")
.and("bling.blah=bing")
.applyTo(this.environment, Type.MAP);
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("baz");
assertThat(this.environment.getProperty("hello.world")).isEqualTo("hi");
assertThat(this.environment.getProperty("bling.blah")).isEqualTo("bing");
@@ -151,7 +153,7 @@ class TestPropertyValuesTests {
@Test
void applyToSystemPropertiesWithRunnableShouldSetSystemProperties() {
TestPropertyValues.of("foo=bar")
.applyToSystemProperties(() -> assertThat(System.getProperty("foo")).isEqualTo("bar"));
.applyToSystemProperties(() -> assertThat(System.getProperty("foo")).isEqualTo("bar"));
}
@Test

View File

@@ -115,7 +115,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
// is null in app properties
addTestPropertySource("0", null);
this.propertySources
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8080")));
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8080")));
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEmpty();
@@ -125,7 +125,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
void postProcessWhenTestServerPortIsZeroAndManagementPortIsNotNullAndDifferentInProduction() {
addTestPropertySource("0", null);
this.propertySources
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8081")));
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "8081")));
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
@@ -135,7 +135,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
void postProcessWhenTestServerPortIsZeroAndManagementPortMinusOne() {
addTestPropertySource("0", null);
this.propertySources
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "-1")));
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "-1")));
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("-1");
@@ -145,7 +145,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
void postProcessWhenTestServerPortIsZeroAndManagementPortIsAnInteger() {
addTestPropertySource("0", null);
this.propertySources
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", 8081)));
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", 8081)));
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
@@ -155,10 +155,10 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
void postProcessWhenManagementServerPortPlaceholderPresentShouldResolvePlaceholder() {
addTestPropertySource("0", null);
MapPropertySource testPropertySource = (MapPropertySource) this.propertySources
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
testPropertySource.getSource().put("port", "9090");
this.propertySources
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
this.postProcessor.postProcessEnvironment(this.environment, null);
assertThat(this.environment.getProperty("server.port")).isEqualTo("0");
assertThat(this.environment.getProperty("management.server.port")).isEqualTo("0");
@@ -168,17 +168,17 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
void postProcessWhenManagementServerPortPlaceholderAbsentShouldFail() {
addTestPropertySource("0", null);
this.propertySources
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
assertThatIllegalArgumentException()
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
}
@Test
void postProcessWhenServerPortPlaceholderPresentShouldResolvePlaceholder() {
addTestPropertySource("0", null);
MapPropertySource testPropertySource = (MapPropertySource) this.propertySources
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
.get(TestPropertySourceUtils.INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
testPropertySource.getSource().put("port", "8080");
Map<String, Object> source = new HashMap<>();
source.put("server.port", "${port}");
@@ -197,8 +197,8 @@ class SpringBootTestRandomPortEnvironmentPostProcessorTests {
source.put("management.server.port", "9090");
this.propertySources.addLast(new MapPropertySource("other", source));
assertThatIllegalArgumentException()
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
}
private void addTestPropertySource(String serverPort, String managementPort) {

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -43,21 +43,21 @@ class LocalHostUriTemplateHandlerTests {
@Test
void createWhenEnvironmentIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostUriTemplateHandler(null))
.withMessageContaining("Environment must not be null");
.withMessageContaining("Environment must not be null");
}
@Test
void createWhenSchemeIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), null))
.withMessageContaining("Scheme must not be null");
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), null))
.withMessageContaining("Scheme must not be null");
}
@Test
void createWhenHandlerIsNullShouldThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), "http", null))
.withMessageContaining("Handler must not be null");
.isThrownBy(() -> new LocalHostUriTemplateHandler(new MockEnvironment(), "http", null))
.withMessageContaining("Handler must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -53,22 +53,22 @@ class MockServerRestTemplateCustomizerTests {
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer();
customizer.customize(new RestTemplate());
assertThat(customizer.getServer()).extracting("expectationManager")
.isInstanceOf(SimpleRequestExpectationManager.class);
.isInstanceOf(SimpleRequestExpectationManager.class);
}
@Test
void createWhenExpectationManagerClassIsNullShouldThrowException() {
Class<? extends RequestExpectationManager> expectationManager = null;
assertThatIllegalArgumentException().isThrownBy(() -> new MockServerRestTemplateCustomizer(expectationManager))
.withMessageContaining("ExpectationManager must not be null");
.withMessageContaining("ExpectationManager must not be null");
}
@Test
void createWhenExpectationManagerSupplierIsNullShouldThrowException() {
Supplier<? extends RequestExpectationManager> expectationManagerSupplier = null;
assertThatIllegalArgumentException()
.isThrownBy(() -> new MockServerRestTemplateCustomizer(expectationManagerSupplier))
.withMessageContaining("ExpectationManagerSupplier must not be null");
.isThrownBy(() -> new MockServerRestTemplateCustomizer(expectationManagerSupplier))
.withMessageContaining("ExpectationManagerSupplier must not be null");
}
@Test
@@ -77,7 +77,7 @@ class MockServerRestTemplateCustomizerTests {
UnorderedRequestExpectationManager.class);
customizer.customize(new RestTemplate());
assertThat(customizer.getServer()).extracting("expectationManager")
.isInstanceOf(UnorderedRequestExpectationManager.class);
.isInstanceOf(UnorderedRequestExpectationManager.class);
}
@Test
@@ -86,7 +86,7 @@ class MockServerRestTemplateCustomizerTests {
UnorderedRequestExpectationManager::new);
customizer.customize(new RestTemplate());
assertThat(customizer.getServer()).extracting("expectationManager")
.isInstanceOf(UnorderedRequestExpectationManager.class);
.isInstanceOf(UnorderedRequestExpectationManager.class);
}
@Test
@@ -95,7 +95,7 @@ class MockServerRestTemplateCustomizerTests {
UnorderedRequestExpectationManager.class);
customizer.customize(new RestTemplateBuilder().rootUri("https://example.com").build());
assertThat(customizer.getServer()).extracting("expectationManager")
.isInstanceOf(RootUriRequestExpectationManager.class);
.isInstanceOf(RootUriRequestExpectationManager.class);
}
@Test
@@ -103,7 +103,7 @@ class MockServerRestTemplateCustomizerTests {
this.customizer.setDetectRootUri(false);
this.customizer.customize(new RestTemplateBuilder().rootUri("https://example.com").build());
assertThat(this.customizer.getServer()).extracting("expectationManager")
.isInstanceOf(SimpleRequestExpectationManager.class);
.isInstanceOf(SimpleRequestExpectationManager.class);
}
@@ -118,8 +118,8 @@ class MockServerRestTemplateCustomizerTests {
@Test
void getServerWhenNoServersAreBoundShouldThrowException() {
assertThatIllegalStateException().isThrownBy(this.customizer::getServer)
.withMessageContaining("Unable to return a single MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has not been bound to a RestTemplate");
.withMessageContaining("Unable to return a single MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has not been bound to a RestTemplate");
}
@Test
@@ -127,8 +127,8 @@ class MockServerRestTemplateCustomizerTests {
this.customizer.customize(new RestTemplate());
this.customizer.customize(new RestTemplate());
assertThatIllegalStateException().isThrownBy(this.customizer::getServer)
.withMessageContaining("Unable to return a single MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has been bound to more than one RestTemplate");
.withMessageContaining("Unable to return a single MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has been bound to more than one RestTemplate");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,8 @@ class NoTestRestTemplateBeanChecker implements ImportSelector, BeanFactoryAware
@Override
public void setBeanFactory(BeanFactory beanFactory) {
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
TestRestTemplate.class)).isEmpty();
TestRestTemplate.class))
.isEmpty();
}
@Override

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -71,13 +71,13 @@ class RootUriRequestExpectationManagerTests {
@Test
void createWhenRootUriIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new RootUriRequestExpectationManager(null, this.delegate))
.withMessageContaining("RootUri must not be null");
.withMessageContaining("RootUri must not be null");
}
@Test
void createWhenExpectationManagerIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new RootUriRequestExpectationManager(this.uri, null))
.withMessageContaining("ExpectationManager must not be null");
.withMessageContaining("ExpectationManager must not be null");
}
@Test
@@ -112,9 +112,9 @@ class RootUriRequestExpectationManagerTests {
ClientHttpRequest request = mock(ClientHttpRequest.class);
given(request.getURI()).willReturn(new URI(this.uri + "/hello"));
given(this.delegate.validateRequest(any(ClientHttpRequest.class)))
.willThrow(new AssertionError("Request URI expected:</hello> was:<https://example.com/bad>"));
.willThrow(new AssertionError("Request URI expected:</hello> was:<https://example.com/bad>"));
assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.manager.validateRequest(request))
.withMessageContaining("Request URI expected:<https://example.com/hello>");
.withMessageContaining("Request URI expected:<https://example.com/hello>");
}
@Test
@@ -168,8 +168,8 @@ class RootUriRequestExpectationManagerTests {
MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
server.expect(requestTo("/hello")).andRespond(withSuccess());
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> restTemplate.getForEntity("https://spring.io/hello", String.class))
.withMessageContaining("expected:<https://example.com/hello> but was:<https://spring.io/hello>");
.isThrownBy(() -> restTemplate.getForEntity("https://spring.io/hello", String.class))
.withMessageContaining("expected:<https://example.com/hello> but was:<https://spring.io/hello>");
}
}

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -42,17 +42,18 @@ class TestRestTemplateContextCustomizerTests {
@Test
void whenContextIsNotABeanDefinitionRegistryTestRestTemplateIsRegistered() {
new ApplicationContextRunner(TestApplicationContext::new)
.withInitializer(this::applyTestRestTemplateContextCustomizer)
.run((context) -> assertThat(context).hasSingleBean(TestRestTemplate.class));
.withInitializer(this::applyTestRestTemplateContextCustomizer)
.run((context) -> assertThat(context).hasSingleBean(TestRestTemplate.class));
}
@Test
void whenUsingAotGeneratedArtifactsTestRestTemplateIsNotRegistered() {
new ApplicationContextRunner().withSystemProperties("spring.aot.enabled:true")
.withInitializer(this::applyTestRestTemplateContextCustomizer).run((context) -> {
assertThat(context).doesNotHaveBean(TestRestTemplateRegistrar.class);
assertThat(context).doesNotHaveBean(TestRestTemplate.class);
});
.withInitializer(this::applyTestRestTemplateContextCustomizer)
.run((context) -> {
assertThat(context).doesNotHaveBean(TestRestTemplateRegistrar.class);
assertThat(context).doesNotHaveBean(TestRestTemplate.class);
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })

View File

@@ -81,7 +81,7 @@ class TestRestTemplateTests {
void simple() {
// The Apache client is on the classpath so we get the fully-fledged factory
assertThat(new TestRestTemplate().getRestTemplate().getRequestFactory())
.isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
.isInstanceOf(HttpComponentsClientHttpRequestFactory.class);
}
@Test
@@ -89,7 +89,7 @@ class TestRestTemplateTests {
RestTemplateBuilder builder = new RestTemplateBuilder().requestFactory(OkHttp3ClientHttpRequestFactory.class);
TestRestTemplate testRestTemplate = new TestRestTemplate(builder);
assertThat(testRestTemplate.getRestTemplate().getRequestFactory())
.isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
.isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
}
@Test
@@ -133,7 +133,8 @@ class TestRestTemplateTests {
void options() {
TestRestTemplate template = new TestRestTemplate(HttpClientOption.ENABLE_REDIRECTS);
CustomHttpComponentsClientHttpRequestFactory factory = (CustomHttpComponentsClientHttpRequestFactory) template
.getRestTemplate().getRequestFactory();
.getRestTemplate()
.getRequestFactory();
RequestConfig config = factory.createRequestConfig();
assertThat(config.isRedirectsEnabled()).isTrue();
}
@@ -154,7 +155,8 @@ class TestRestTemplateTests {
method.getParameterTypes());
assertThat(equivalent).as("Method %s not found", method).isNotNull();
assertThat(Modifier.isPublic(equivalent.getModifiers()))
.as("Method %s should have been public", equivalent).isTrue();
.as("Method %s should have been public", equivalent)
.isTrue();
try {
equivalent.invoke(restTemplate, mockArguments(method.getParameterTypes()));
}
@@ -269,14 +271,14 @@ class TestRestTemplateTests {
@Test
void exchangeWithRequestEntityAndClassHandlesRelativeUris() throws IOException {
verifyRelativeUriHandling((testRestTemplate, relativeUri) -> testRestTemplate
.exchange(new RequestEntity<String>(HttpMethod.GET, relativeUri), String.class));
.exchange(new RequestEntity<String>(HttpMethod.GET, relativeUri), String.class));
}
@Test
void exchangeWithRequestEntityAndParameterizedTypeReferenceHandlesRelativeUris() throws IOException {
verifyRelativeUriHandling((testRestTemplate, relativeUri) -> testRestTemplate.exchange(
new RequestEntity<String>(HttpMethod.GET, relativeUri), new ParameterizedTypeReference<String>() {
}));
verifyRelativeUriHandling((testRestTemplate, relativeUri) -> testRestTemplate
.exchange(new RequestEntity<String>(HttpMethod.GET, relativeUri), new ParameterizedTypeReference<String>() {
}));
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ class LocalHostWebClientTests {
@Test
void createWhenEnvironmentIsNullWillThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostWebClient(null))
.withMessageContaining("Environment must not be null");
.withMessageContaining("Environment must not be null");
}
@Test

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -64,20 +64,20 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
@Test
void createWhenEnvironmentIsNullWillThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null))
.withMessageContaining("Environment must not be null");
.withMessageContaining("Environment must not be null");
}
@Test
void createWithJavascriptFlagWhenEnvironmentIsNullWillThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, true))
.withMessageContaining("Environment must not be null");
.withMessageContaining("Environment must not be null");
}
@Test
void createWithBrowserVersionWhenEnvironmentIsNullWillThrowException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, BrowserVersion.CHROME))
.withMessageContaining("Environment must not be null");
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, BrowserVersion.CHROME))
.withMessageContaining("Environment must not be null");
}
@Test
@@ -86,8 +86,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
given(capabilities.getBrowserName()).willReturn("htmlunit");
given(capabilities.getBrowserVersion()).willReturn("chrome");
assertThatIllegalArgumentException()
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, capabilities))
.withMessageContaining("Environment must not be null");
.isThrownBy(() -> new LocalHostWebConnectionHtmlUnitDriver(null, capabilities))
.withMessageContaining("Environment must not be null");
}
@Test
@@ -95,8 +95,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
MockEnvironment environment = new MockEnvironment();
LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment);
driver.get("/test");
then(this.webClient).should().getPage(any(TopLevelWindow.class),
requestToUrl(new URL("http://localhost:8080/test")));
then(this.webClient).should()
.getPage(any(TopLevelWindow.class), requestToUrl(new URL("http://localhost:8080/test")));
}
@Test
@@ -105,8 +105,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
environment.setProperty("local.server.port", "8181");
LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment);
driver.get("/test");
then(this.webClient).should().getPage(any(TopLevelWindow.class),
requestToUrl(new URL("http://localhost:8181/test")));
then(this.webClient).should()
.getPage(any(TopLevelWindow.class), requestToUrl(new URL("http://localhost:8181/test")));
}
private WebRequest requestToUrl(URL url) {

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,8 @@ class NoWebTestClientBeanChecker implements ImportSelector, BeanFactoryAware {
@Override
public void setBeanFactory(BeanFactory beanFactory) {
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
WebTestClient.class)).isEmpty();
WebTestClient.class))
.isEmpty();
}
@Override

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -43,17 +43,18 @@ class WebTestClientContextCustomizerTests {
@Test
void whenContextIsNotABeanDefinitionRegistryWebTestClientIsRegistered() {
new ApplicationContextRunner(TestApplicationContext::new)
.withInitializer(this::applyWebTestClientContextCustomizer)
.run((context) -> assertThat(context).hasSingleBean(WebTestClient.class));
.withInitializer(this::applyWebTestClientContextCustomizer)
.run((context) -> assertThat(context).hasSingleBean(WebTestClient.class));
}
@Test
void whenUsingAotGeneratedArtifactsWebTestClientIsNotRegistered() {
new ApplicationContextRunner().withSystemProperties("spring.aot.enabled:true")
.withInitializer(this::applyWebTestClientContextCustomizer).run((context) -> {
assertThat(context).doesNotHaveBean(WebTestClientRegistrar.class);
assertThat(context).doesNotHaveBean(WebTestClient.class);
});
.withInitializer(this::applyWebTestClientContextCustomizer)
.run((context) -> {
assertThat(context).doesNotHaveBean(WebTestClientRegistrar.class);
assertThat(context).doesNotHaveBean(WebTestClient.class);
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })