diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 4edeefd6537..a31f0b0f1d0 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -133,10 +133,6 @@ gradlePlugin { id = "org.springframework.boot.integration-test" implementationClass = "org.springframework.boot.build.test.IntegrationTestPlugin" } - systemTestPlugin { - id = "org.springframework.boot.system-test" - implementationClass = "org.springframework.boot.build.test.SystemTestPlugin" - } mavenPluginPlugin { id = "org.springframework.boot.maven-plugin" implementationClass = "org.springframework.boot.build.mavenplugin.MavenPluginPlugin" @@ -153,10 +149,22 @@ gradlePlugin { id = "org.springframework.boot.starter" implementationClass = "org.springframework.boot.build.starters.StarterPlugin" } + systemTestPlugin { + id = "org.springframework.boot.system-test" + implementationClass = "org.springframework.boot.build.test.SystemTestPlugin" + } + testAutoConfigurationPlugin { + id = "org.springframework.boot.test-auto-configuration" + implementationClass = "org.springframework.boot.build.test.autoconfigure.TestAutoConfigurationPlugin" + } testFailuresPlugin { id = "org.springframework.boot.test-failures" implementationClass = "org.springframework.boot.build.testing.TestFailuresPlugin" } + testSlicePlugin { + id = "org.springframework.boot.test-slice" + implementationClass = "org.springframework.boot.build.test.autoconfigure.TestSlicePlugin" + } } } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationClass.java b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationClass.java index 762db1eaaac..170fe6b69ee 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationClass.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationClass.java @@ -19,6 +19,7 @@ package org.springframework.boot.build.autoconfigure; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collections; @@ -54,8 +55,8 @@ public record AutoConfigurationClass(String name, List before, List before, List { public static final String CHECK_ADDITIONAL_SPRING_CONFIGURATION_METADATA_TASK_NAME = "checkAdditionalSpringConfigurationMetadata"; /** - * Name of the {@link CheckAdditionalSpringConfigurationMetadata} task. + * Name of the {@link CheckSpringConfigurationMetadata} task. */ public static final String CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME = "checkSpringConfigurationMetadata"; diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/CheckAutoConfigureImports.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/CheckAutoConfigureImports.java new file mode 100644 index 00000000000..acb54de73b3 --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/CheckAutoConfigureImports.java @@ -0,0 +1,233 @@ +/* + * Copyright 2025-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.test.autoconfigure; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.function.Consumer; +import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; + +import org.gradle.api.DefaultTask; +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.file.FileCollection; +import org.gradle.api.file.FileTree; +import org.gradle.api.tasks.Classpath; +import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; +import org.gradle.api.tasks.SkipWhenEmpty; +import org.gradle.api.tasks.TaskAction; +import org.gradle.api.tasks.VerificationException; +import org.gradle.language.base.plugins.LifecycleBasePlugin; + +import org.springframework.boot.build.autoconfigure.AutoConfigurationClass; + +/** + * Task to check the contents of a project's + * {@code META-INF/spring/*.AutoConfigure*.imports} files. + * + * @author Andy Wilkinson + */ +public abstract class CheckAutoConfigureImports extends DefaultTask { + + private FileCollection sourceFiles = getProject().getObjects().fileCollection(); + + private FileCollection classpath = getProject().getObjects().fileCollection(); + + public CheckAutoConfigureImports() { + getOutputDirectory().convention(getProject().getLayout().getBuildDirectory().dir(getName())); + setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); + } + + @InputFiles + @SkipWhenEmpty + @PathSensitive(PathSensitivity.RELATIVE) + public FileTree getSource() { + return this.sourceFiles.getAsFileTree() + .matching((filter) -> filter.include("META-INF/spring/*.AutoConfigure*.imports")); + } + + public void setSource(Object source) { + this.sourceFiles = getProject().getObjects().fileCollection().from(source); + } + + @Classpath + public FileCollection getClasspath() { + return this.classpath; + } + + public void setClasspath(Object classpath) { + this.classpath = getProject().getObjects().fileCollection().from(classpath); + } + + @OutputDirectory + public abstract DirectoryProperty getOutputDirectory(); + + @TaskAction + void execute() { + Map> allProblems = new TreeMap<>(); + for (AutoConfigureImports autoConfigureImports : loadImports()) { + List problems = new ArrayList<>(); + if (!find(autoConfigureImports.annotationName)) { + problems.add("Annotation '%s' was not found".formatted(autoConfigureImports.annotationName)); + } + for (String imported : autoConfigureImports.imports) { + String importedClassName = imported; + if (importedClassName.startsWith("optional:")) { + importedClassName = importedClassName.substring("optional:".length()); + } + boolean found = find(importedClassName, (input) -> { + if (!correctlyAnnotated(input)) { + problems.add("Imported auto-configuration '%s' is not annotated with @AutoConfiguration" + .formatted(imported)); + } + }); + if (!found) { + problems.add("Imported auto-configuration '%s' was not found".formatted(importedClassName)); + } + + } + List sortedValues = new ArrayList<>(autoConfigureImports.imports); + Collections.sort(sortedValues, (i1, i2) -> { + boolean imported1 = i1.startsWith("optional:"); + boolean imported2 = i2.startsWith("optional:"); + int comparison = Boolean.compare(imported1, imported2); + if (comparison != 0) { + return comparison; + } + return i1.compareTo(i2); + }); + if (!sortedValues.equals(autoConfigureImports.imports)) { + File sortedOutputFile = getOutputDirectory().file("sorted-" + autoConfigureImports.fileName) + .get() + .getAsFile(); + writeString(sortedOutputFile, sortedValues.stream().collect(Collectors.joining(System.lineSeparator())) + + System.lineSeparator()); + problems.add( + "Entries should be required then optional, each sorted alphabetically (expected content written to '%s')" + .formatted(sortedOutputFile.getAbsolutePath())); + } + if (!problems.isEmpty()) { + allProblems.computeIfAbsent(autoConfigureImports.fileName, (unused) -> new ArrayList<>()) + .addAll(problems); + } + } + File outputFile = getOutputDirectory().file("failure-report.txt").get().getAsFile(); + writeReport(allProblems, outputFile); + if (!allProblems.isEmpty()) { + throw new VerificationException( + "AutoConfigure….imports checks failed. See '%s' for details".formatted(outputFile)); + } + } + + private List loadImports() { + return getSource().getFiles().stream().map((file) -> { + String fileName = file.getName(); + String annotationName = fileName.substring(0, fileName.length() - ".imports".length()); + return new AutoConfigureImports(annotationName, loadImports(file), fileName); + }).toList(); + } + + private List loadImports(File importsFile) { + try { + return Files.readAllLines(importsFile.toPath()); + } + catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + private boolean find(String className) { + return find(className, (input) -> { + }); + } + + private boolean find(String className, Consumer handler) { + for (File root : this.classpath.getFiles()) { + String classFilePath = className.replace(".", "/") + ".class"; + if (root.isDirectory()) { + File classFile = new File(root, classFilePath); + if (classFile.isFile()) { + try (InputStream input = new FileInputStream(classFile)) { + handler.accept(input); + } + catch (IOException ex) { + throw new UncheckedIOException(ex); + } + return true; + } + } + else { + try (JarFile jar = new JarFile(root)) { + ZipEntry entry = jar.getEntry(classFilePath); + if (entry != null) { + try (InputStream input = jar.getInputStream(entry)) { + handler.accept(input); + } + return true; + } + } + catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + } + return false; + } + + private boolean correctlyAnnotated(InputStream classFile) { + return AutoConfigurationClass.of(classFile) != null; + } + + private void writeReport(Map> allProblems, File outputFile) { + outputFile.getParentFile().mkdirs(); + StringBuilder report = new StringBuilder(); + if (!allProblems.isEmpty()) { + allProblems.forEach((fileName, problems) -> { + report.append("Found problems in '%s':%n".formatted(fileName)); + problems.forEach((problem) -> report.append(" - %s%n".formatted(problem))); + }); + } + writeString(outputFile, report.toString()); + } + + private void writeString(File file, String content) { + try { + Files.writeString(file.toPath(), content); + } + catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + record AutoConfigureImports(String annotationName, List imports, String fileName) { + + } + +} diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java index 3ff45c126a8..9ecfaa1bb27 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java @@ -17,17 +17,14 @@ package org.springframework.boot.build.test.autoconfigure; import java.io.File; -import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; -import java.io.Reader; +import java.util.ArrayList; import java.util.Collections; -import java.util.Enumeration; -import java.util.Properties; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; import org.gradle.api.DefaultTask; import org.gradle.api.Task; @@ -38,9 +35,9 @@ import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.PathSensitive; import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; +import tools.jackson.databind.json.JsonMapper; -import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; +import org.springframework.boot.build.test.autoconfigure.TestSliceMetadata.TestSlice; /** * {@link Task} used to document test slices. @@ -49,16 +46,16 @@ import org.springframework.util.StringUtils; */ public abstract class DocumentTestSlices extends DefaultTask { - private FileCollection testSlices; + private FileCollection testSliceMetadata; @InputFiles @PathSensitive(PathSensitivity.RELATIVE) public FileCollection getTestSlices() { - return this.testSlices; + return this.testSliceMetadata; } public void setTestSlices(FileCollection testSlices) { - this.testSlices = testSlices; + this.testSliceMetadata = testSlices; } @OutputFile @@ -66,61 +63,42 @@ public abstract class DocumentTestSlices extends DefaultTask { @TaskAction void documentTestSlices() throws IOException { - Set testSlices = readTestSlices(); + Map> testSlices = readTestSlices(); writeTable(testSlices); } - @SuppressWarnings("unchecked") - private Set readTestSlices() throws IOException { - Set testSlices = new TreeSet<>(); - for (File metadataFile : this.testSlices) { - Properties metadata = new Properties(); - try (Reader reader = new FileReader(metadataFile)) { - metadata.load(reader); - } - for (String name : Collections.list((Enumeration) metadata.propertyNames())) { - testSlices.add(new TestSlice(name, - new TreeSet<>(StringUtils.commaDelimitedListToSet(metadata.getProperty(name))))); - } + private Map> readTestSlices() { + Map> testSlices = new TreeMap<>(); + for (File metadataFile : this.testSliceMetadata) { + JsonMapper mapper = JsonMapper.builder().build(); + TestSliceMetadata metadata = mapper.readValue(metadataFile, TestSliceMetadata.class); + List slices = new ArrayList<>(metadata.testSlices()); + Collections.sort(slices, (s1, s2) -> s1.annotation().compareTo(s2.annotation())); + testSlices.put(metadata.module(), slices); } return testSlices; } - private void writeTable(Set testSlices) throws IOException { + private void writeTable(Map> testSlicesByModule) throws IOException { File outputFile = getOutputFile().getAsFile().get(); outputFile.getParentFile().mkdirs(); try (PrintWriter writer = new PrintWriter(new FileWriter(outputFile))) { - writer.println("[cols=\"d,a\"]"); + writer.println("[cols=\"d,d,a\"]"); writer.println("|==="); - writer.println("| Test slice | Imported auto-configuration"); - for (TestSlice testSlice : testSlices) { - writer.println(); - writer.printf("| `@%s`%n", testSlice.className); - writer.println("| "); - for (String importedAutoConfiguration : testSlice.importedAutoConfigurations) { - writer.printf("`%s`%n", importedAutoConfiguration); - } - } + writer.println("|Module | Test slice | Imported auto-configuration"); + testSlicesByModule.forEach((module, testSlices) -> { + testSlices.forEach((testSlice) -> { + writer.println(); + writer.printf("| `%s`%n", module); + writer.printf("| javadoc:%s[format=annotation]%n", testSlice.annotation()); + writer.println("| "); + for (String importedAutoConfiguration : testSlice.importedAutoConfigurations()) { + writer.printf("`%s`%n", importedAutoConfiguration); + } + }); + }); writer.println("|==="); } } - private static final class TestSlice implements Comparable { - - private final String className; - - private final SortedSet importedAutoConfigurations; - - private TestSlice(String className, SortedSet importedAutoConfigurations) { - this.className = ClassUtils.getShortName(className); - this.importedAutoConfigurations = importedAutoConfigurations; - } - - @Override - public int compareTo(TestSlice other) { - return this.className.compareTo(other.className); - } - - } - } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/GenerateTestSliceMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/GenerateTestSliceMetadata.java new file mode 100644 index 00000000000..bf18f932b47 --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/GenerateTestSliceMetadata.java @@ -0,0 +1,238 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.test.autoconfigure; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.io.UncheckedIOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +import javax.inject.Inject; + +import org.gradle.api.DefaultTask; +import org.gradle.api.Task; +import org.gradle.api.file.FileCollection; +import org.gradle.api.file.RegularFileProperty; +import org.gradle.api.model.ObjectFactory; +import org.gradle.api.tasks.Classpath; +import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.OutputFile; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.TaskAction; + +import org.springframework.boot.build.test.autoconfigure.TestSliceMetadata.TestSlice; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.type.AnnotationMetadata; +import org.springframework.core.type.classreading.MetadataReader; +import org.springframework.core.type.classreading.MetadataReaderFactory; +import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; +import org.springframework.util.StringUtils; + +/** + * A {@link Task} for generating metadata describing a project's test slices. + * + * @author Andy Wilkinson + */ +public abstract class GenerateTestSliceMetadata extends DefaultTask { + + private final ObjectFactory objectFactory; + + private FileCollection classpath; + + private FileCollection importsFiles; + + private FileCollection classesDirs; + + @Inject + public GenerateTestSliceMetadata(ObjectFactory objectFactory) { + this.objectFactory = objectFactory; + } + + public void setSourceSet(SourceSet sourceSet) { + this.classpath = sourceSet.getRuntimeClasspath(); + this.importsFiles = this.objectFactory.fileTree() + .from(new File(sourceSet.getOutput().getResourcesDir(), "META-INF/spring")); + this.importsFiles.filter((file) -> file.getName().endsWith(".imports")); + getSpringFactories().set(new File(sourceSet.getOutput().getResourcesDir(), "META-INF/spring.factories")); + this.classesDirs = sourceSet.getOutput().getClassesDirs(); + } + + @OutputFile + public abstract RegularFileProperty getOutputFile(); + + @InputFiles + @PathSensitive(PathSensitivity.RELATIVE) + abstract RegularFileProperty getSpringFactories(); + + @Classpath + FileCollection getClasspath() { + return this.classpath; + } + + @InputFiles + @PathSensitive(PathSensitivity.RELATIVE) + FileCollection getImportFiles() { + return this.importsFiles; + } + + @Classpath + FileCollection getClassesDirs() { + return this.classesDirs; + } + + @TaskAction + void generateTestSliceMetadata() throws IOException { + TestSliceMetadata metadata = readTestSlices(); + File outputFile = getOutputFile().getAsFile().get(); + outputFile.getParentFile().mkdirs(); + metadata.writeTo(outputFile); + } + + private TestSliceMetadata readTestSlices() throws IOException { + List testSlices = new ArrayList<>(); + try (URLClassLoader classLoader = new URLClassLoader( + StreamSupport.stream(this.classpath.spliterator(), false).map(this::toURL).toArray(URL[]::new))) { + MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(classLoader); + Properties springFactories = readSpringFactories(getSpringFactories().getAsFile().getOrNull()); + readImportsFiles(springFactories, this.importsFiles); + for (File classesDir : this.classesDirs) { + testSlices.addAll(readTestSlices(classesDir, metadataReaderFactory, springFactories)); + } + } + return new TestSliceMetadata(getProject().getName(), testSlices); + } + + /** + * Reads the given imports files and puts them in springFactories. The key is the file + * name, the value is the file contents, split by line, delimited with a comma. This + * is done to mimic the spring.factories structure. + * @param springFactories spring.factories parsed as properties + * @param importsFiles the imports files to read + */ + private void readImportsFiles(Properties springFactories, FileCollection importsFiles) { + for (File file : importsFiles.getFiles()) { + try { + List lines = removeComments(Files.readAllLines(file.toPath())); + String fileNameWithoutExtension = file.getName() + .substring(0, file.getName().length() - ".imports".length()); + springFactories.setProperty(fileNameWithoutExtension, + StringUtils.collectionToCommaDelimitedString(lines)); + } + catch (IOException ex) { + throw new UncheckedIOException("Failed to read file " + file, ex); + } + } + } + + private List removeComments(List lines) { + List result = new ArrayList<>(); + for (String line : lines) { + int commentIndex = line.indexOf('#'); + if (commentIndex > -1) { + line = line.substring(0, commentIndex); + } + line = line.trim(); + if (!line.isEmpty()) { + result.add(line); + } + } + return result; + } + + private URL toURL(File file) { + try { + return file.toURI().toURL(); + } + catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } + } + + private Properties readSpringFactories(File file) throws IOException { + Properties springFactories = new Properties(); + if (file.isFile()) { + try (Reader in = new FileReader(file)) { + springFactories.load(in); + } + } + return springFactories; + } + + private List readTestSlices(File classesDir, MetadataReaderFactory metadataReaderFactory, + Properties springFactories) throws IOException { + try (Stream classes = Files.walk(classesDir.toPath())) { + return classes.filter((path) -> path.toString().endsWith("Test.class")) + .map((path) -> getMetadataReader(path, metadataReaderFactory)) + .filter((metadataReader) -> metadataReader.getClassMetadata().isAnnotation()) + .map((metadataReader) -> readTestSlice(metadataReader, springFactories)) + .toList(); + } + + } + + private MetadataReader getMetadataReader(Path path, MetadataReaderFactory metadataReaderFactory) { + try { + return metadataReaderFactory.getMetadataReader(new FileSystemResource(path)); + } + catch (IOException ex) { + throw new RuntimeException(ex); + } + } + + private TestSlice readTestSlice(MetadataReader metadataReader, Properties springFactories) { + String annotationName = metadataReader.getClassMetadata().getClassName(); + List importedAutoConfiguration = getImportedAutoConfiguration(springFactories, + metadataReader.getAnnotationMetadata()); + return new TestSlice(annotationName, importedAutoConfiguration); + } + + private List getImportedAutoConfiguration(Properties springFactories, + AnnotationMetadata annotationMetadata) { + Stream importers = findMetaImporters(annotationMetadata); + if (annotationMetadata.isAnnotated("org.springframework.boot.autoconfigure.ImportAutoConfiguration")) { + importers = Stream.concat(importers, Stream.of(annotationMetadata.getClassName())); + } + return importers + .flatMap((importer) -> StringUtils.commaDelimitedListToSet(springFactories.getProperty(importer)).stream()) + .toList(); + } + + private Stream findMetaImporters(AnnotationMetadata annotationMetadata) { + return annotationMetadata.getAnnotationTypes() + .stream() + .filter((annotationType) -> isAutoConfigurationImporter(annotationType, annotationMetadata)); + } + + private boolean isAutoConfigurationImporter(String annotationType, AnnotationMetadata metadata) { + return metadata.getMetaAnnotationTypes(annotationType) + .contains("org.springframework.boot.autoconfigure.ImportAutoConfiguration"); + } + +} diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestAutoConfigurationPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestAutoConfigurationPlugin.java new file mode 100644 index 00000000000..1641822d21d --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestAutoConfigurationPlugin.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.test.autoconfigure; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.file.ConfigurableFileCollection; +import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.tasks.SourceSet; + +/** + * {@link Plugin} for projects that define test auto-configuration. When the + * {@link JavaPlugin} is applied it: + * + *
    + *
  • Add checks to ensure AutoConfigure*.import files and related annotations are + * correct
  • + *
+ * + * @author Andy Wilkinson + */ +public class TestAutoConfigurationPlugin implements Plugin { + + @Override + public void apply(Project target) { + target.getPlugins().withType(JavaPlugin.class, (plugin) -> { + target.getTasks().register("checkAutoConfigureImports", CheckAutoConfigureImports.class, (task) -> { + SourceSet mainSourceSet = target.getExtensions() + .getByType(JavaPluginExtension.class) + .getSourceSets() + .getByName(SourceSet.MAIN_SOURCE_SET_NAME); + task.setSource(mainSourceSet.getResources()); + ConfigurableFileCollection classpath = target.files(mainSourceSet.getRuntimeClasspath(), + target.getConfigurations().getByName(mainSourceSet.getRuntimeClasspathConfigurationName())); + task.setClasspath(classpath); + }); + }); + } + +} diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java index 3b170b19613..b89a451c698 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java @@ -17,229 +17,30 @@ package org.springframework.boot.build.test.autoconfigure; import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Reader; -import java.io.UncheckedIOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; import java.util.List; -import java.util.Properties; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; -import javax.inject.Inject; - -import org.gradle.api.DefaultTask; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.FileCollection; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskAction; - -import org.springframework.core.CollectionFactory; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.core.type.classreading.MetadataReader; -import org.springframework.core.type.classreading.MetadataReaderFactory; -import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; -import org.springframework.util.StringUtils; +import tools.jackson.databind.SerializationFeature; +import tools.jackson.databind.json.JsonMapper; /** - * A {@link Task} for generating metadata describing a project's test slices. + * Metadata describing a module's test slices. * + * @param module the module's name + * @param testSlices the module's test slices * @author Andy Wilkinson */ -public abstract class TestSliceMetadata extends DefaultTask { +record TestSliceMetadata(String module, List testSlices) { - private final ObjectFactory objectFactory; - - private FileCollection classpath; - - private FileCollection importsFiles; - - private FileCollection classesDirs; - - @Inject - public TestSliceMetadata(ObjectFactory objectFactory) { - this.objectFactory = objectFactory; - Configuration testSliceMetadata = getProject().getConfigurations().maybeCreate("testSliceMetadata"); - getProject().afterEvaluate((evaluated) -> evaluated.getArtifacts() - .add(testSliceMetadata.getName(), getOutputFile(), (artifact) -> artifact.builtBy(this))); + static TestSliceMetadata readFrom(File file) { + return JsonMapper.builder().build().readValue(file, TestSliceMetadata.class); } - public void setSourceSet(SourceSet sourceSet) { - this.classpath = sourceSet.getRuntimeClasspath(); - this.importsFiles = this.objectFactory.fileTree() - .from(new File(sourceSet.getOutput().getResourcesDir(), "META-INF/spring")); - this.importsFiles.filter((file) -> file.getName().endsWith(".imports")); - getSpringFactories().set(new File(sourceSet.getOutput().getResourcesDir(), "META-INF/spring.factories")); - this.classesDirs = sourceSet.getOutput().getClassesDirs(); + void writeTo(File file) { + JsonMapper.builder().enable(SerializationFeature.INDENT_OUTPUT).build().writeValue(file, this); } - @OutputFile - public abstract RegularFileProperty getOutputFile(); + record TestSlice(String annotation, List importedAutoConfigurations) { - @InputFile - @PathSensitive(PathSensitivity.RELATIVE) - abstract RegularFileProperty getSpringFactories(); - - @Classpath - FileCollection getClasspath() { - return this.classpath; - } - - @InputFiles - @PathSensitive(PathSensitivity.RELATIVE) - FileCollection getImportFiles() { - return this.importsFiles; - } - - @Classpath - FileCollection getClassesDirs() { - return this.classesDirs; - } - - @TaskAction - void documentTestSlices() throws IOException { - Properties testSlices = readTestSlices(); - File outputFile = getOutputFile().getAsFile().get(); - outputFile.getParentFile().mkdirs(); - try (FileWriter writer = new FileWriter(outputFile)) { - testSlices.store(writer, null); - } - } - - private Properties readTestSlices() throws IOException { - Properties testSlices = CollectionFactory.createSortedProperties(true); - try (URLClassLoader classLoader = new URLClassLoader( - StreamSupport.stream(this.classpath.spliterator(), false).map(this::toURL).toArray(URL[]::new))) { - MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(classLoader); - Properties springFactories = readSpringFactories(getSpringFactories().getAsFile().get()); - readImportsFiles(springFactories, this.importsFiles); - for (File classesDir : this.classesDirs) { - addTestSlices(testSlices, classesDir, metadataReaderFactory, springFactories); - } - } - return testSlices; - } - - /** - * Reads the given imports files and puts them in springFactories. The key is the file - * name, the value is the file contents, split by line, delimited with a comma. This - * is done to mimic the spring.factories structure. - * @param springFactories spring.factories parsed as properties - * @param importsFiles the imports files to read - */ - private void readImportsFiles(Properties springFactories, FileCollection importsFiles) { - for (File file : importsFiles.getFiles()) { - try { - List lines = removeComments(Files.readAllLines(file.toPath())); - String fileNameWithoutExtension = file.getName() - .substring(0, file.getName().length() - ".imports".length()); - springFactories.setProperty(fileNameWithoutExtension, - StringUtils.collectionToCommaDelimitedString(lines)); - } - catch (IOException ex) { - throw new UncheckedIOException("Failed to read file " + file, ex); - } - } - } - - private List removeComments(List lines) { - List result = new ArrayList<>(); - for (String line : lines) { - int commentIndex = line.indexOf('#'); - if (commentIndex > -1) { - line = line.substring(0, commentIndex); - } - line = line.trim(); - if (!line.isEmpty()) { - result.add(line); - } - } - return result; - } - - private URL toURL(File file) { - try { - return file.toURI().toURL(); - } - catch (MalformedURLException ex) { - throw new RuntimeException(ex); - } - } - - private Properties readSpringFactories(File file) throws IOException { - Properties springFactories = new Properties(); - try (Reader in = new FileReader(file)) { - springFactories.load(in); - } - return springFactories; - } - - private void addTestSlices(Properties testSlices, File classesDir, MetadataReaderFactory metadataReaderFactory, - Properties springFactories) throws IOException { - try (Stream classes = Files.walk(classesDir.toPath())) { - classes.filter((path) -> path.toString().endsWith("Test.class")) - .map((path) -> getMetadataReader(path, metadataReaderFactory)) - .filter((metadataReader) -> metadataReader.getClassMetadata().isAnnotation()) - .forEach((metadataReader) -> addTestSlice(testSlices, springFactories, metadataReader)); - } - - } - - private MetadataReader getMetadataReader(Path path, MetadataReaderFactory metadataReaderFactory) { - try { - return metadataReaderFactory.getMetadataReader(new FileSystemResource(path)); - } - catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - private void addTestSlice(Properties testSlices, Properties springFactories, MetadataReader metadataReader) { - testSlices.setProperty(metadataReader.getClassMetadata().getClassName(), - StringUtils.collectionToCommaDelimitedString( - getImportedAutoConfiguration(springFactories, metadataReader.getAnnotationMetadata()))); - } - - private SortedSet getImportedAutoConfiguration(Properties springFactories, - AnnotationMetadata annotationMetadata) { - Stream importers = findMetaImporters(annotationMetadata); - if (annotationMetadata.isAnnotated("org.springframework.boot.autoconfigure.ImportAutoConfiguration")) { - importers = Stream.concat(importers, Stream.of(annotationMetadata.getClassName())); - } - return importers - .flatMap((importer) -> StringUtils.commaDelimitedListToSet(springFactories.getProperty(importer)).stream()) - .collect(Collectors.toCollection(TreeSet::new)); - } - - private Stream findMetaImporters(AnnotationMetadata annotationMetadata) { - return annotationMetadata.getAnnotationTypes() - .stream() - .filter((annotationType) -> isAutoConfigurationImporter(annotationType, annotationMetadata)); - } - - private boolean isAutoConfigurationImporter(String annotationType, AnnotationMetadata metadata) { - return metadata.getMetaAnnotationTypes(annotationType) - .contains("org.springframework.boot.autoconfigure.ImportAutoConfiguration"); } } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSlicePlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSlicePlugin.java new file mode 100644 index 00000000000..8764a2d98b4 --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSlicePlugin.java @@ -0,0 +1,78 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.test.autoconfigure; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.attributes.Category; +import org.gradle.api.attributes.Usage; +import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.plugins.PluginContainer; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.TaskProvider; + +/** + * {@link Plugin} for projects that define one or more test slices. When applied, it: + * + *
    + *
  • Applies the {@link TestAutoConfigurationPlugin} + *
+ * Additionally, when the {@link JavaPlugin} is applied it: + * + *
    + *
  • Defines a task that produces metadata describing the test slices. The metadata is + * made available as an artifact in the {@code testSliceMetadata} configuration + *
+ * + * @author Andy Wilkinson + */ +public class TestSlicePlugin implements Plugin { + + private static final String TEST_SLICE_METADATA_CONFIGURATION_NAME = "testSliceMetadata"; + + @Override + public void apply(Project target) { + PluginContainer plugins = target.getPlugins(); + plugins.apply(TestAutoConfigurationPlugin.class); + plugins.withType(JavaPlugin.class, (plugin) -> { + TaskProvider generateTestSliceMetadata = target.getTasks() + .register("generateTestSliceMetadata", GenerateTestSliceMetadata.class, (task) -> { + SourceSet mainSourceSet = target.getExtensions() + .getByType(JavaPluginExtension.class) + .getSourceSets() + .getByName(SourceSet.MAIN_SOURCE_SET_NAME); + task.setSourceSet(mainSourceSet); + task.getOutputFile().set(target.getLayout().getBuildDirectory().file("test-slice-metadata.json")); + }); + addMetadataArtifact(target, generateTestSliceMetadata); + }); + } + + private void addMetadataArtifact(Project project, TaskProvider task) { + project.getConfigurations().consumable(TEST_SLICE_METADATA_CONFIGURATION_NAME, (configuration) -> { + configuration.attributes((attributes) -> { + attributes.attribute(Category.CATEGORY_ATTRIBUTE, + project.getObjects().named(Category.class, Category.DOCUMENTATION)); + attributes.attribute(Usage.USAGE_ATTRIBUTE, + project.getObjects().named(Usage.class, "test-slice-metadata")); + }); + }); + project.getArtifacts().add(TEST_SLICE_METADATA_CONFIGURATION_NAME, task); + } + +} diff --git a/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java b/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java new file mode 100644 index 00000000000..217fb5b2203 --- /dev/null +++ b/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.test.autoconfigure; + +import java.io.File; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import org.springframework.boot.build.test.autoconfigure.TestSliceMetadata.TestSlice; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link TestSliceMetadata}. + * + * @author Andy Wilkinson + */ +public class TestSliceMetadataTests { + + @TempDir + private File temp; + + @Test + void roundtripJson() { + TestSliceMetadata source = new TestSliceMetadata("example", + List.of(new TestSlice("ExampleOneTest", List.of("com.example.OneAutoConfiguration")), + new TestSlice("ExampleTwoTest", List.of("com.example.TwoAutoConfiguration")))); + File metadataFile = new File(this.temp, "metadata.json"); + source.writeTo(metadataFile); + TestSliceMetadata readBack = TestSliceMetadata.readFrom(metadataFile); + assertThat(source).isEqualTo(readBack); + } + +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 22731f7a60d..1d71812a2d3 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -6,7 +6,10 @@ - + + + diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/AutoConfigurationImportedCondition.java b/core/spring-boot-autoconfigure/src/testFixtures/java/org/springframework/boot/autoconfigure/AutoConfigurationImportedCondition.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/AutoConfigurationImportedCondition.java rename to core/spring-boot-autoconfigure/src/testFixtures/java/org/springframework/boot/autoconfigure/AutoConfigurationImportedCondition.java index c9c81f90168..410dfac5bb1 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/AutoConfigurationImportedCondition.java +++ b/core/spring-boot-autoconfigure/src/testFixtures/java/org/springframework/boot/autoconfigure/AutoConfigurationImportedCondition.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure; +package org.springframework.boot.autoconfigure; import org.assertj.core.api.Condition; import org.assertj.core.description.TextDescription; diff --git a/documentation/spring-boot-docs/build.gradle b/documentation/spring-boot-docs/build.gradle index 8941ea9abe7..5bf08fc7560 100644 --- a/documentation/spring-boot-docs/build.gradle +++ b/documentation/spring-boot-docs/build.gradle @@ -90,9 +90,18 @@ dependencies { implementation(project(path: ":module:spring-boot-amqp")) implementation(project(path: ":module:spring-boot-cache")) implementation(project(path: ":module:spring-boot-data-cassandra")) + implementation(project(path: ":module:spring-boot-data-cassandra-test")) + implementation(project(path: ":module:spring-boot-data-couchbase-test")) implementation(project(path: ":module:spring-boot-data-elasticsearch")) + implementation(project(path: ":module:spring-boot-data-elasticsearch-test")) + implementation(project(path: ":module:spring-boot-data-jpa-test")) + implementation(project(path: ":module:spring-boot-data-ldap-test")) + implementation(project(path: ":module:spring-boot-data-mongodb-test")) implementation(project(path: ":module:spring-boot-data-neo4j")) + implementation(project(path: ":module:spring-boot-data-neo4j-test")) + implementation(project(path: ":module:spring-boot-data-redis-test")) implementation(project(path: ":module:spring-boot-devtools")) + implementation(project(path: ":module:spring-boot-graphql-test")) implementation(project(path: ":module:spring-boot-health")) implementation(project(path: ":module:spring-boot-hibernate")) implementation(project(path: ":module:spring-boot-http-converter")) @@ -100,23 +109,31 @@ dependencies { implementation(project(path: ":module:spring-boot-integration")) implementation(project(path: ":module:spring-boot-jackson")) implementation(project(path: ":module:spring-boot-jdbc")) + implementation(project(path: ":module:spring-boot-jdbc-test")) + implementation(project(path: ":module:spring-boot-jooq-test")) implementation(project(path: ":module:spring-boot-jpa")) implementation(project(path: ":module:spring-boot-jms")) implementation(project(path: ":module:spring-boot-jsonb")) + implementation(project(path: ":module:spring-boot-json-test")) implementation(project(path: ":module:spring-boot-ldap")) implementation(project(path: ":module:spring-boot-micrometer-metrics")) implementation(project(path: ":module:spring-boot-persistence")) implementation(project(path: ":module:spring-boot-r2dbc")) + implementation(project(path: ":module:spring-boot-restdocs")) implementation(project(path: ":module:spring-boot-reactor-netty")) implementation(project(path: ":module:spring-boot-restclient")) + implementation(project(path: ":module:spring-boot-restclient-test")) implementation(project(path: ":module:spring-boot-security")) implementation(project(path: ":module:spring-boot-test-autoconfigure")) implementation(project(path: ":module:spring-boot-tomcat")) implementation(project(path: ":module:spring-boot-web-server-test")) implementation(project(path: ":module:spring-boot-webclient")) implementation(project(path: ":module:spring-boot-webflux")) + implementation(project(path: ":module:spring-boot-webflux-test")) implementation(project(path: ":module:spring-boot-webmvc")) + implementation(project(path: ":module:spring-boot-webmvc-test")) implementation(project(path: ":module:spring-boot-webservices")) + implementation(project(path: ":module:spring-boot-webservices-test")) implementation("ch.qos.logback:logback-classic") implementation("com.redis:testcontainers-redis") implementation("com.zaxxer:HikariCP") @@ -254,8 +271,15 @@ project.rootProject.gradle.projectsEvaluated { } } +aggregates { + testSliceMetadata { + category = Category.DOCUMENTATION + usage = "test-slice-metadata" + } +} + tasks.register("documentTestSlices", org.springframework.boot.build.test.autoconfigure.DocumentTestSlices) { - testSlices = configurations.testSlices + testSlices = aggregates.testSliceMetadata.files outputFile = layout.buildDirectory.file("generated/docs/test-auto-configuration/documented-slices.adoc") } diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/testing.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/testing.adoc index 1223b882621..c26bc9aa981 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/testing.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/testing.adoc @@ -14,7 +14,7 @@ For example, the test in the snippet below will run with an authenticated user t include-code::MySecurityTests[] -Spring Security provides comprehensive integration with Spring MVC Test, and this can also be used when testing controllers using the javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] slice and javadoc:org.springframework.test.web.servlet.MockMvc[]. +Spring Security provides comprehensive integration with Spring MVC Test, and this can also be used when testing controllers using the javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] slice and javadoc:org.springframework.test.web.servlet.MockMvc[]. For additional details on Spring Security's testing support, see Spring Security's {url-spring-security-docs}/servlet/test/index.html[reference documentation]. @@ -30,7 +30,7 @@ Consider this example: include-code::MyConfiguration[] -For a javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] for an application with the above javadoc:org.springframework.context.annotation.Configuration[format=annotation] class, you might expect to have the javadoc:org.springframework.security.web.SecurityFilterChain[] bean in the application context so that you can test if your controller endpoints are secured properly. +For a javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] for an application with the above javadoc:org.springframework.context.annotation.Configuration[format=annotation] class, you might expect to have the javadoc:org.springframework.security.web.SecurityFilterChain[] bean in the application context so that you can test if your controller endpoints are secured properly. However, `MyConfiguration` is not picked up by @WebMvcTest's component scanning filter because it doesn't match any of the types specified by the filter. You can include the configuration explicitly by annotating the test class with `@Import(MyConfiguration.class)`. This will load all the beans in `MyConfiguration` including the javadoc:com.zaxxer.hikari.HikariDataSource[] bean which isn't required when testing the web tier. diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/io/caching.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/io/caching.adoc index c2092e8b07b..ed699445617 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/io/caching.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/io/caching.adoc @@ -267,7 +267,7 @@ This is similar to the way the "real" cache providers behave if you use an undec When javadoc:org.springframework.cache.annotation.EnableCaching[format=annotation] is present in your configuration, a suitable cache configuration is expected as well. If you have a custom ` org.springframework.cache.CacheManager`, consider defining it in a separate javadoc:org.springframework.context.annotation.Configuration[format=annotation] class so that you can override it if necessary. -None uses a no-op implementation that is useful in tests, and slice tests use that by default via javadoc:org.springframework.boot.test.autoconfigure.core.AutoConfigureCache[format=annotation]. +None uses a no-op implementation that is useful in tests, and slice tests use that by default through javadoc:org.springframework.boot.cache.test.autoconfigure.AutoConfigureCache[format=annotation] when the `spring-boot-cache-test` module is present. If you need to use a no-op cache rather than the auto-configured cache manager in a certain environment, set the cache type to `none`, as shown in the following example: diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc index 1ae13e3d1f5..a5b878d3839 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/index.adoc @@ -2,9 +2,10 @@ = Testing Spring Boot provides a number of utilities and annotations to help when testing your application. -Test support is provided by two modules: `spring-boot-test` contains core items, and `spring-boot-test-autoconfigure` supports auto-configuration for tests. -Most developers use the `spring-boot-starter-test` starter, which imports both Spring Boot test modules as well as JUnit Jupiter, AssertJ, Hamcrest, and a number of other useful libraries. +Test support is provided by two general-purpose modules – `spring-boot-test` contains core items and `spring-boot-test-autoconfigure` supports auto-configuration for tests – and several focused `-test` modules that provide testing support for a particular feature. + +Most developers use the `spring-boot-starter-test` starter, which imports both general-purpose Spring Boot test modules as well as JUnit Jupiter, AssertJ, Hamcrest, and a number of other useful libraries, and the focused `-test` modules that are applicable to their particular application. [TIP] ==== diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc index d3fea3ccb40..b3ea0bbcbc6 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc @@ -18,7 +18,7 @@ You can use the `webEnvironment` attribute of javadoc:org.springframework.boot.t * `MOCK`(Default) : Loads a web javadoc:org.springframework.context.ApplicationContext[] and provides a mock web environment. Embedded servers are not started when using this annotation. If a web environment is not available on your classpath, this mode transparently falls back to creating a regular non-web javadoc:org.springframework.context.ApplicationContext[]. -It can be used in conjunction with xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[`@AutoConfigureMockMvc` or javadoc:org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient[format=annotation]] for mock-based testing of your web application. +It can be used in conjunction with xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[`@AutoConfigureMockMvc` or javadoc:org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient[format=annotation]] for mock-based testing of your web application. * `RANDOM_PORT`: Loads a javadoc:org.springframework.boot.web.context.WebServerApplicationContext[] and provides a real web environment. Embedded servers are started and listen on a random port. * `DEFINED_PORT`: Loads a javadoc:org.springframework.boot.web.context.WebServerApplicationContext[] and provides a real web environment. @@ -151,7 +151,7 @@ The following example showcases the available integrations: include-code::MyMockMvcTests[] -TIP: If you want to focus only on the web layer and not start a complete javadoc:org.springframework.context.ApplicationContext[], consider xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.spring-mvc-tests[using javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] instead]. +TIP: If you want to focus only on the web layer and not start a complete javadoc:org.springframework.context.ApplicationContext[], consider xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.spring-mvc-tests[using javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] instead]. With Spring WebFlux endpoints, you can use {url-spring-framework-docs}/testing/webtestclient.html[`WebTestClient`] as shown in the following example: @@ -180,10 +180,10 @@ For convenience, tests that need to make REST calls to the started server can ad include-code::MyRandomPortWebTestClientTests[] -TIP: javadoc:org.springframework.test.web.reactive.server.WebTestClient[] can also used with a xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[mock environment], removing the need for a running server, by annotating your test class with javadoc:org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient[format=annotation]. +TIP: javadoc:org.springframework.test.web.reactive.server.WebTestClient[] can also used with a xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[mock environment], removing the need for a running server, by annotating your test class with javadoc:org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient[format=annotation] from `spring-boot-webflux-test`. This setup requires `spring-webflux` on the classpath. -If you can not or will not add webflux, Spring Boot also provides a javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] facility: +If you can not or will not add webflux, the `spring-boot-web-server-test` modules provides a javadoc:org.springframework.boot.web.server.test.client.TestRestTemplate[] facility: include-code::MyRandomPortTestRestTemplateTests[] @@ -210,7 +210,7 @@ include-code::MyJmxTests[] [[testing.spring-boot-applications.observations]] == Using Observations -If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation], it auto-configures an javadoc:io.micrometer.observation.ObservationRegistry[]. +If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing[format=annotation] from `spring-boot-micrometer-tracing-test` or with javadoc:org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics[format=annotation] from `spring-boot-micrometer-metrics-test`, it auto-configures an javadoc:io.micrometer.observation.ObservationRegistry[]. @@ -219,10 +219,10 @@ If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-a Regardless of your classpath, meter registries, except the in-memory backed, are not auto-configured when using javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]. -If you need to export metrics to a different backend as part of an integration test, annotate it with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation]. +If you need to export metrics to a different backend as part of an integration test, annotate it with javadoc:org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics[format=annotation]. -If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation], it auto-configures an in-memory javadoc:io.micrometer.core.instrument.MeterRegistry[]. -Data exporting in sliced tests is not supported with the javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation] annotation. +If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics[format=annotation], it auto-configures an in-memory javadoc:io.micrometer.core.instrument.MeterRegistry[]. +Data exporting in sliced tests is not supported with the javadoc:org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics[format=annotation] annotation. @@ -231,12 +231,12 @@ Data exporting in sliced tests is not supported with the javadoc:org.springframe Regardless of your classpath, tracing components which are reporting data are not auto-configured when using javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]. -If you need those components as part of an integration test, annotate the test with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation]. +If you need those components as part of an integration test, annotate the test with javadoc:org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing[format=annotation]. If you have created your own reporting components (e.g. a custom javadoc:io.opentelemetry.sdk.trace.export.SpanExporter[] or `brave.handler.SpanHandler`) and you don't want them to be active in tests, you can use the javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracingExport[format=annotation] annotation to disable them. -If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation], it auto-configures a no-op javadoc:io.micrometer.tracing.Tracer[]. -Data exporting in sliced tests is not supported with the javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation] annotation. +If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing[format=annotation] , it auto-configures a no-op javadoc:io.micrometer.tracing.Tracer[]. +Data exporting in sliced tests is not supported with the javadoc:org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing[format=annotation] annotation. @@ -260,7 +260,7 @@ Spring Boot's auto-configuration system works well for applications but can some It often helps to load only the parts of the configuration that are required to test a "`slice`" of your application. For example, you might want to test that Spring MVC controllers are mapping URLs correctly, and you do not want to involve database calls in those tests, or you might want to test JPA entities, and you are not interested in the web layer when those tests run. -The `spring-boot-test-autoconfigure` module includes a number of annotations that can be used to automatically configure such "`slices`". +When combined with `spring-boot-test-autoconfigure`, Spring Boot's xref:reference:testing/test-modules.adoc[test modules] include a number of annotations that can be used to automatically configure such "`slices`". Each of them works in a similar way, providing a `@...Test` annotation that loads the javadoc:org.springframework.context.ApplicationContext[] and one or more `@AutoConfigure...` annotations that can be used to customize auto-configuration settings. NOTE: Each slice restricts component scan to appropriate components and loads a very restricted set of auto-configuration classes. @@ -278,26 +278,26 @@ You can use this combination if you are not interested in "`slicing`" your appli [[testing.spring-boot-applications.json-tests]] == Auto-configured JSON Tests -To test that object JSON serialization and deserialization is working as expected, you can use the javadoc:org.springframework.boot.test.autoconfigure.json.JsonTest[format=annotation] annotation. -javadoc:org.springframework.boot.test.autoconfigure.json.JsonTest[format=annotation] auto-configures the available supported JSON mapper, which can be one of the following libraries: +To test that object JSON serialization and deserialization is working as expected, you can use the javadoc:org.springframework.boot.json.test.autoconfigure.JsonTest[format=annotation] annotation from the `spring-boot-json-test` module. +javadoc:org.springframework.boot.json.test.autoconfigure.JsonTest[format=annotation] auto-configures the available supported JSON mapper, which can be one of the following libraries: * Jackson javadoc:tools.jackson.databind.JsonMapper[], any javadoc:org.springframework.boot.jackson.JsonComponent[format=annotation] beans and any Jackson javadoc:tools.jackson.databind.JacksonModule[] * `Gson` * `Jsonb` -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.json.JsonTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.json.test.autoconfigure.JsonTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -If you need to configure elements of the auto-configuration, you can use the javadoc:org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters[format=annotation] annotation. +If you need to configure elements of the auto-configuration, you can use the javadoc:org.springframework.boot.json.test.autoconfigure.AutoConfigureJsonTesters[format=annotation] annotation. Spring Boot includes AssertJ-based helpers that work with the JSONAssert and JsonPath libraries to check that JSON appears as expected. The javadoc:org.springframework.boot.test.json.JacksonTester[], javadoc:org.springframework.boot.test.json.GsonTester[], javadoc:org.springframework.boot.test.json.JsonbTester[], and javadoc:org.springframework.boot.test.json.BasicJsonTester[] classes can be used for Jackson, Gson, Jsonb, and Strings respectively. -Any helper fields on the test class can be javadoc:org.springframework.beans.factory.annotation.Autowired[format=annotation] when using javadoc:org.springframework.boot.test.autoconfigure.json.JsonTest[format=annotation]. +Any helper fields on the test class can be javadoc:org.springframework.beans.factory.annotation.Autowired[format=annotation] when using javadoc:org.springframework.boot.json.test.autoconfigure.JsonTest[format=annotation]. The following example shows a test class for Jackson: include-code::MyJsonTests[] NOTE: JSON helper classes can also be used directly in standard unit tests. -To do so, call the `initFields` method of the helper in your javadoc:org.junit.jupiter.api.BeforeEach[format=annotation] method if you do not use javadoc:org.springframework.boot.test.autoconfigure.json.JsonTest[format=annotation]. +To do so, call the `initFields` method of the helper in your javadoc:org.junit.jupiter.api.BeforeEach[format=annotation] method if you do not use javadoc:org.springframework.boot.json.test.autoconfigure.JsonTest[format=annotation]. If you use Spring Boot's AssertJ-based helpers to assert on a number value at a given JSON path, you might not be able to use `isEqualTo` depending on the type. Instead, you can use AssertJ's `satisfies` to assert that the value matches the given condition. @@ -310,27 +310,27 @@ include-code::MyJsonAssertJTests[tag=*] [[testing.spring-boot-applications.spring-mvc-tests]] == Auto-configured Spring MVC Tests -To test whether Spring MVC controllers are working as expected, use the javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] annotation. -javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] auto-configures the Spring MVC infrastructure and limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.web.bind.annotation.ControllerAdvice[format=annotation], javadoc:org.springframework.boot.jackson.JsonComponent[format=annotation], javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[], javadoc:jakarta.servlet.Filter[], javadoc:org.springframework.web.servlet.HandlerInterceptor[], javadoc:org.springframework.web.servlet.config.annotation.WebMvcConfigurer[], javadoc:org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations[], and javadoc:org.springframework.web.method.support.HandlerMethodArgumentResolver[]. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] annotation is used. +To test whether Spring MVC controllers are working as expected, use the javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] annotation from the `spring-boot-webmvc-test` module. +javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] auto-configures the Spring MVC infrastructure and limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.web.bind.annotation.ControllerAdvice[format=annotation], javadoc:org.springframework.boot.jackson.JsonComponent[format=annotation], javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[], javadoc:jakarta.servlet.Filter[], javadoc:org.springframework.web.servlet.HandlerInterceptor[], javadoc:org.springframework.web.servlet.config.annotation.WebMvcConfigurer[], javadoc:org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations[], and javadoc:org.springframework.web.method.support.HandlerMethodArgumentResolver[]. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. TIP: If you need to register extra components, such as a javadoc:tools.jackson.databind.JacksonModule[], you can import additional configuration classes by using javadoc:org.springframework.context.annotation.Import[format=annotation] on your test. -Often, javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] is limited to a single controller and is used in combination with javadoc:org.springframework.test.context.bean.override.mockito.MockitoBean[format=annotation] to provide mock implementations for required collaborators. +Often, javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] is limited to a single controller and is used in combination with javadoc:org.springframework.test.context.bean.override.mockito.MockitoBean[format=annotation] to provide mock implementations for required collaborators. -javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] also auto-configures javadoc:org.springframework.test.web.servlet.MockMvc[]. +javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] also auto-configures javadoc:org.springframework.test.web.servlet.MockMvc[]. Mock MVC offers a powerful way to quickly test MVC controllers without needing to start a full HTTP server. If AssertJ is available, the AssertJ support provided by javadoc:org.springframework.test.web.servlet.assertj.MockMvcTester[] is auto-configured as well. -TIP: You can also auto-configure javadoc:org.springframework.test.web.servlet.MockMvc[] and javadoc:org.springframework.test.web.servlet.assertj.MockMvcTester[] in a non-`@WebMvcTest` (such as javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]) by annotating it with javadoc:org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc[format=annotation]. +TIP: You can also auto-configure javadoc:org.springframework.test.web.servlet.MockMvc[] and javadoc:org.springframework.test.web.servlet.assertj.MockMvcTester[] in a non-`@WebMvcTest` (such as javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]) by annotating it with javadoc:org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc[format=annotation]. The following example uses javadoc:org.springframework.test.web.servlet.assertj.MockMvcTester[]: include-code::MyControllerTests[] -TIP: If you need to configure elements of the auto-configuration (for example, when servlet filters should be applied) you can use attributes in the javadoc:org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc[format=annotation] annotation. +TIP: If you need to configure elements of the auto-configuration (for example, when servlet filters should be applied) you can use attributes in the javadoc:org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc[format=annotation] annotation. If you use HtmlUnit and Selenium, auto-configuration also provides an HtmlUnit javadoc:org.springframework.web.reactive.function.client.WebClient[] bean and/or a Selenium javadoc:org.openqa.selenium.WebDriver[] bean. The following example uses HtmlUnit: @@ -341,9 +341,9 @@ NOTE: By default, Spring Boot puts javadoc:org.openqa.selenium.WebDriver[] beans If you do not want this behavior, you can add `@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)` to your javadoc:org.openqa.selenium.WebDriver[] javadoc:org.springframework.context.annotation.Bean[format=annotation] definition. WARNING: The `webDriver` scope created by Spring Boot will replace any user defined scope of the same name. -If you define your own `webDriver` scope you may find it stops working when you use javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation]. +If you define your own `webDriver` scope you may find it stops working when you use javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation]. -If you have Spring Security on the classpath, javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation] will also scan javadoc:org.springframework.security.config.annotation.web.WebSecurityConfigurer[] beans. +If you have Spring Security on the classpath, javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation] will also scan javadoc:org.springframework.security.config.annotation.web.WebSecurityConfigurer[] beans. Instead of disabling security completely for such tests, you can use Spring Security's test support. More details on how to use Spring Security's javadoc:org.springframework.test.web.servlet.MockMvc[] support can be found in this xref:how-to:testing.adoc#howto.testing.with-spring-security[] "`How-to Guides`" section. @@ -354,30 +354,30 @@ TIP: Sometimes writing Spring MVC tests is not enough; Spring Boot can help you [[testing.spring-boot-applications.spring-webflux-tests]] == Auto-configured Spring WebFlux Tests -To test that {url-spring-framework-docs}/web-reactive.html[Spring WebFlux] controllers are working as expected, you can use the javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] annotation. -javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] auto-configures the Spring WebFlux infrastructure and limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.web.bind.annotation.ControllerAdvice[format=annotation], javadoc:org.springframework.boot.jackson.JsonComponent[format=annotation], javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[] and javadoc:org.springframework.web.reactive.config.WebFluxConfigurer[]. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] annotation is used. +To test that {url-spring-framework-docs}/web-reactive.html[Spring WebFlux] controllers are working as expected, you can use the javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] annotation from the `spring-boot-webflux-test` module. +javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] auto-configures the Spring WebFlux infrastructure and limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.web.bind.annotation.ControllerAdvice[format=annotation], javadoc:org.springframework.boot.jackson.JsonComponent[format=annotation], javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[] and javadoc:org.springframework.web.reactive.config.WebFluxConfigurer[]. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. TIP: If you need to register extra components, such as a javadoc:tools.jackson.databind.JacksonModule[], you can import additional configuration classes using javadoc:org.springframework.context.annotation.Import[format=annotation] on your test. -Often, javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] is limited to a single controller and used in combination with the javadoc:org.springframework.test.context.bean.override.mockito.MockitoBean[format=annotation] annotation to provide mock implementations for required collaborators. +Often, javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] is limited to a single controller and used in combination with the javadoc:org.springframework.test.context.bean.override.mockito.MockitoBean[format=annotation] annotation to provide mock implementations for required collaborators. -javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] also auto-configures {url-spring-framework-docs}/testing/webtestclient.html[`WebTestClient`], which offers a powerful way to quickly test WebFlux controllers without needing to start a full HTTP server. +javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] also auto-configures {url-spring-framework-docs}/testing/webtestclient.html[`WebTestClient`], which offers a powerful way to quickly test WebFlux controllers without needing to start a full HTTP server. -TIP: You can also auto-configure javadoc:org.springframework.test.web.reactive.server.WebTestClient[] in a non-`@WebFluxTest` (such as javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]) by annotating it with javadoc:org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient[format=annotation]. -The following example shows a class that uses both javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] and a javadoc:org.springframework.test.web.reactive.server.WebTestClient[]: +TIP: You can also auto-configure javadoc:org.springframework.test.web.reactive.server.WebTestClient[] in a non-`@WebFluxTest` (such as javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]) by annotating it with javadoc:org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient[format=annotation]. +The following example shows a class that uses both javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] and a javadoc:org.springframework.test.web.reactive.server.WebTestClient[]: include-code::MyControllerTests[] TIP: This setup is only supported by WebFlux applications as using javadoc:org.springframework.test.web.reactive.server.WebTestClient[] in a mocked web application only works with WebFlux at the moment. -NOTE: javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] cannot detect routes registered through the functional web framework. +NOTE: javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] cannot detect routes registered through the functional web framework. For testing javadoc:org.springframework.web.reactive.function.server.RouterFunction[] beans in the context, consider importing your javadoc:org.springframework.web.reactive.function.server.RouterFunction[] yourself by using javadoc:org.springframework.context.annotation.Import[format=annotation] or by using javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]. -NOTE: javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] cannot detect custom security configuration registered as a javadoc:org.springframework.context.annotation.Bean[format=annotation] of type javadoc:org.springframework.security.web.server.SecurityWebFilterChain[]. +NOTE: javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] cannot detect custom security configuration registered as a javadoc:org.springframework.context.annotation.Bean[format=annotation] of type javadoc:org.springframework.security.web.server.SecurityWebFilterChain[]. To include that in your test, you will need to import the configuration that registers the bean by using javadoc:org.springframework.context.annotation.Import[format=annotation] or by using javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation]. TIP: Sometimes writing Spring WebFlux tests is not enough; Spring Boot can help you run xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-running-server[full end-to-end tests with an actual server]. @@ -424,21 +424,21 @@ There are javadoc:org.springframework.graphql.test.tester.GraphQlTester[] varian * the javadoc:org.springframework.graphql.test.tester.ExecutionGraphQlServiceTester[] performs tests on the server side, without a client nor a transport * the javadoc:org.springframework.graphql.test.tester.HttpGraphQlTester[] performs tests with a client that connects to a server, with or without a live server -Spring Boot helps you to test your {url-spring-graphql-docs}/controllers.html[Spring GraphQL Controllers] with the javadoc:org.springframework.boot.test.autoconfigure.graphql.GraphQlTest[format=annotation] annotation. -javadoc:org.springframework.boot.test.autoconfigure.graphql.GraphQlTest[format=annotation] auto-configures the Spring GraphQL infrastructure, without any transport nor server being involved. +Spring Boot helps you to test your {url-spring-graphql-docs}/controllers.html[Spring GraphQL Controllers] with the javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] annotation from the `spring-boot-graphql-test` module. +javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] auto-configures the Spring GraphQL infrastructure, without any transport nor server being involved. This limits scanned beans to javadoc:org.springframework.stereotype.Controller[format=annotation], javadoc:org.springframework.graphql.execution.RuntimeWiringConfigurer[], javadoc:org.springframework.boot.jackson.JsonComponent[], javadoc:org.springframework.core.convert.converter.Converter[], javadoc:org.springframework.core.convert.converter.GenericConverter[], javadoc:org.springframework.graphql.execution.DataFetcherExceptionResolver[], javadoc:graphql.execution.instrumentation.Instrumentation[] and javadoc:org.springframework.boot.graphql.autoconfigure.GraphQlSourceBuilderCustomizer[]. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.graphql.GraphQlTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.graphql.GraphQlTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -Often, javadoc:org.springframework.boot.test.autoconfigure.graphql.GraphQlTest[format=annotation] is limited to a set of controllers and used in combination with the javadoc:org.springframework.test.context.bean.override.mockito.MockitoBean[format=annotation] annotation to provide mock implementations for required collaborators. +Often, javadoc:org.springframework.boot.graphql.test.autoconfigure.GraphQlTest[format=annotation] is limited to a set of controllers and used in combination with the javadoc:org.springframework.test.context.bean.override.mockito.MockitoBean[format=annotation] annotation to provide mock implementations for required collaborators. include-code::GreetingControllerTests[] javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] tests are full integration tests and involve the entire application. When using a random or defined port, a live server is configured and an javadoc:org.springframework.graphql.test.tester.HttpGraphQlTester[] bean is contributed automatically so you can use it to test your server. -When a MOCK environment is configured, you can also request an javadoc:org.springframework.graphql.test.tester.HttpGraphQlTester[] bean by annotating your test class with javadoc:org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester[format=annotation]: +When a MOCK environment is configured, you can also request an javadoc:org.springframework.graphql.test.tester.HttpGraphQlTester[] bean by annotating your test class with javadoc:org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester[format=annotation] from the `spring-boot-graphql-test` module: include-code::GraphQlIntegrationTests[] @@ -447,13 +447,13 @@ include-code::GraphQlIntegrationTests[] [[testing.spring-boot-applications.autoconfigured-spring-data-cassandra]] == Auto-configured Data Cassandra Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest[format=annotation] to test Cassandra applications. +You can use javadoc:org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest[format=annotation] from the `spring-boot-data-cassandra-test` module to test Data Cassandra applications. By default, it configures a javadoc:org.springframework.data.cassandra.core.CassandraTemplate[], scans for javadoc:org.springframework.data.cassandra.core.mapping.Table[format=annotation] classes, and configures Spring Data Cassandra repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using Cassandra with Spring Boot, see xref:data/nosql.adoc#data.nosql.cassandra[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. The following example shows a typical setup for using Cassandra tests in Spring Boot: @@ -464,13 +464,13 @@ include-code::MyDataCassandraTests[] [[testing.spring-boot-applications.autoconfigured-spring-data-couchbase]] == Auto-configured Data Couchbase Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest[format=annotation] to test Couchbase applications. +You can use javadoc:org.springframework.boot.data.couchbase.test.autoconfigure.DataCouchbaseTest[format=annotation] from the `spring-boot-data-couchbase-test` module to test Data Couchbase applications. By default, it configures a javadoc:org.springframework.data.couchbase.core.CouchbaseTemplate[] or javadoc:org.springframework.data.couchbase.core.ReactiveCouchbaseTemplate[], scans for javadoc:org.springframework.data.couchbase.core.mapping.Document[format=annotation] classes, and configures Spring Data Couchbase repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.couchbase.test.autoconfigure.DataCouchbaseTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using Couchbase with Spring Boot, see xref:data/nosql.adoc#data.nosql.couchbase[], earlier in this chapter.) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.couchbase.test.autoconfigure.DataCouchbaseTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. The following example shows a typical setup for using Couchbase tests in Spring Boot: @@ -481,13 +481,13 @@ include-code::MyDataCouchbaseTests[] [[testing.spring-boot-applications.autoconfigured-spring-data-elasticsearch]] == Auto-configured Data Elasticsearch Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest[format=annotation] to test Elasticsearch applications. +You can use javadoc:org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest[format=annotation] from the `spring-boot-data-elasticsearch-test` module to test Data Elasticsearch applications. By default, it configures an javadoc:org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate[], scans for javadoc:org.springframework.data.elasticsearch.annotations.Document[format=annotation] classes, and configures Spring Data Elasticsearch repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using Elasticsearch with Spring Boot, see xref:data/nosql.adoc#data.nosql.elasticsearch[], earlier in this chapter.) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. The following example shows a typical setup for using Elasticsearch tests in Spring Boot: @@ -498,16 +498,16 @@ include-code::MyDataElasticsearchTests[] [[testing.spring-boot-applications.autoconfigured-spring-data-jpa]] == Auto-configured Data JPA Tests -You can use the javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation] annotation to test JPA applications. +You can use the javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation] annotation from the `spring-boot-data-jpa-test` module to test Data JPA applications. By default, it scans for javadoc:jakarta.persistence.Entity[format=annotation] classes and configures Spring Data JPA repositories. If an embedded database is available on the classpath, it configures one as well. SQL queries are logged by default by setting the `spring.jpa.show-sql` property to `true`. This can be disabled using the `showSql` attribute of the annotation. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. By default, data JPA tests are transactional and roll back at the end of each test. See the {url-spring-framework-docs}/testing/testcontext-framework/tx.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. @@ -515,18 +515,18 @@ If that is not what you want, you can disable transaction management for a test include-code::MyNonTransactionalTests[] -Data JPA tests may also inject a javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager[] bean, which provides an alternative to the standard JPA javadoc:jakarta.persistence.EntityManager[] that is specifically designed for tests. +Data JPA tests may also inject a javadoc:org.springframework.boot.jpa.test.autoconfigure.TestEntityManager[] bean, which provides an alternative to the standard JPA javadoc:jakarta.persistence.EntityManager[] that is specifically designed for tests. -TIP: javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager[] can also be auto-configured to any of your Spring-based test class by adding javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager[format=annotation]. +TIP: javadoc:org.springframework.boot.jpa.test.autoconfigure.TestEntityManager[] can also be auto-configured to any of your Spring-based test class by adding javadoc:org.springframework.boot.jpa.test.autoconfigure.AutoConfigureTestEntityManager[format=annotation]. When doing so, make sure that your test is running in a transaction, for instance by adding javadoc:org.springframework.transaction.annotation.Transactional[format=annotation] on your test class or method. A javadoc:org.springframework.jdbc.core.JdbcTemplate[] is also available if you need that. -The following example shows the javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation] annotation in use: +The following example shows the javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation] annotation in use: include-code::withoutdb/MyRepositoryTests[] In-memory embedded databases generally work well for tests, since they are fast and do not require any installation. -If, however, you prefer to run tests against a real database you can use the javadoc:org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase[format=annotation] annotation, as shown in the following example: +If, however, you prefer to run tests against a real database you can use the javadoc:org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase[format=annotation] annotation, as shown in the following example: include-code::withdb/MyRepositoryTests[] @@ -535,12 +535,12 @@ include-code::withdb/MyRepositoryTests[] [[testing.spring-boot-applications.autoconfigured-jdbc]] == Auto-configured JDBC Tests -javadoc:org.springframework.boot.test.autoconfigure.jdbc.JdbcTest[format=annotation] is similar to javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation] but is for tests that only require a javadoc:javax.sql.DataSource[] and do not use Spring Data JDBC. +javadoc:org.springframework.boot.jdbc.test.autoconfigure.JdbcTest[format=annotation] from the `spring-boot-jdbc-test` module is similar to javadoc:org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest[format=annotation] but is for tests that only require a javadoc:javax.sql.DataSource[] and do not use Spring Data JDBC. By default, it configures an in-memory embedded database and a javadoc:org.springframework.jdbc.core.JdbcTemplate[]. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.jdbc.JdbcTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.jdbc.test.autoconfigure.JdbcTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.jdbc.JdbcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.jdbc.test.autoconfigure.JdbcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. By default, JDBC tests are transactional and roll back at the end of each test. See the {url-spring-framework-docs}/testing/testcontext-framework/tx.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. @@ -548,7 +548,7 @@ If that is not what you want, you can disable transaction management for a test include-code::MyTransactionalTests[] -If you prefer your test to run against a real database, you can use the javadoc:org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase[format=annotation] annotation in the same way as for javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation]. +If you prefer your test to run against a real database, you can use the javadoc:org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase[format=annotation] annotation in the same way as for javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation]. (See xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-spring-data-jpa[].) @@ -556,18 +556,18 @@ If you prefer your test to run against a real database, you can use the javadoc: [[testing.spring-boot-applications.autoconfigured-spring-data-jdbc]] == Auto-configured Data JDBC Tests -javadoc:org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest[format=annotation] is similar to javadoc:org.springframework.boot.test.autoconfigure.jdbc.JdbcTest[format=annotation] but is for tests that use Spring Data JDBC repositories. +javadoc:org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest[format=annotation] from the `spring-boot-data-jdbc-test` module is similar to javadoc:org.springframework.boot.jdbc.test.autoconfigure.JdbcTest[format=annotation] but is for tests that use Spring Data JDBC repositories. By default, it configures an in-memory embedded database, a javadoc:org.springframework.jdbc.core.JdbcTemplate[], and Spring Data JDBC repositories. -Only javadoc:org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration[] subclasses are scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest[format=annotation] annotation is used, regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned. +Only javadoc:org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration[] subclasses are scanned when the javadoc:org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest[format=annotation] annotation is used, regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. By default, Data JDBC tests are transactional and roll back at the end of each test. See the {url-spring-framework-docs}/testing/testcontext-framework/tx.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole test class as xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-jdbc[shown in the JDBC example]. -If you prefer your test to run against a real database, you can use the javadoc:org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase[format=annotation] annotation in the same way as for javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation]. +If you prefer your test to run against a real database, you can use the javadoc:org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase[format=annotation] annotation in the same way as for javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation]. (See xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-spring-data-jpa[].) @@ -575,16 +575,16 @@ If you prefer your test to run against a real database, you can use the javadoc: [[testing.spring-boot-applications.autoconfigured-spring-data-r2dbc]] == Auto-configured Data R2DBC Tests -javadoc:org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest[format=annotation] is similar to javadoc:org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest[format=annotation] but is for tests that use Spring Data R2DBC repositories. +javadoc:org.springframework.boot.data.r2dbc.test.autoconfigure.DataR2dbcTest[format=annotation] from the `spring-boot-data-r2dbc-test` module is similar to javadoc:org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest[format=annotation] but is for tests that use Spring Data R2DBC repositories. By default, it configures an in-memory embedded database, an javadoc:org.springframework.data.r2dbc.core.R2dbcEntityTemplate[], and Spring Data R2DBC repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.r2dbc.test.autoconfigure.DataR2dbcTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.data.r2dbc.test.autoconfigure.DataR2dbcTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. By default, Data R2DBC tests are not transactional. -If you prefer your test to run against a real database, you can use the javadoc:org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase[format=annotation] annotation in the same way as for javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation]. +If you prefer your test to run against a real database, you can use the javadoc:org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase[format=annotation] annotation in the same way as for javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation]. (See xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-spring-data-jpa[].) @@ -592,17 +592,17 @@ If you prefer your test to run against a real database, you can use the javadoc: [[testing.spring-boot-applications.autoconfigured-jooq]] == Auto-configured jOOQ Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.jooq.JooqTest[format=annotation] in a similar fashion as javadoc:org.springframework.boot.test.autoconfigure.jdbc.JdbcTest[format=annotation] but for jOOQ-related tests. +You can use javadoc:org.springframework.boot.jooq.test.autoconfigure.JooqTest[format=annotation] from `spring-boot-jooq-test` in a similar fashion as javadoc:org.springframework.boot.jdbc.test.autoconfigure.JdbcTest[format=annotation] but for jOOQ-related tests. As jOOQ relies heavily on a Java-based schema that corresponds with the database schema, the existing javadoc:javax.sql.DataSource[] is used. -If you want to replace it with an in-memory database, you can use javadoc:org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase[format=annotation] to override those settings. +If you want to replace it with an in-memory database, you can use javadoc:org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase[format=annotation] to override those settings. (For more about using jOOQ with Spring Boot, see xref:data/sql.adoc#data.sql.jooq[].) -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.jooq.JooqTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.jooq.test.autoconfigure.JooqTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.test.autoconfigure.jooq.JooqTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configurations that are enabled by javadoc:org.springframework.boot.jooq.test.autoconfigure.JooqTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -javadoc:org.springframework.boot.test.autoconfigure.jooq.JooqTest[format=annotation] configures a javadoc:org.jooq.DSLContext[]. -The following example shows the javadoc:org.springframework.boot.test.autoconfigure.jooq.JooqTest[format=annotation] annotation in use: +javadoc:org.springframework.boot.jooq.test.autoconfigure.JooqTest[format=annotation] configures a javadoc:org.jooq.DSLContext[]. +The following example shows the javadoc:org.springframework.boot.jooq.test.autoconfigure.JooqTest[format=annotation] annotation in use: include-code::MyJooqTests[] @@ -614,15 +614,15 @@ If that is not what you want, you can disable transaction management for a test [[testing.spring-boot-applications.autoconfigured-spring-data-mongodb]] == Auto-configured Data MongoDB Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest[format=annotation] to test MongoDB applications. +You can use javadoc:org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest[format=annotation] from the `spring-boot-data-mongodb-test` module to test MongoDB applications. By default, it configures a javadoc:org.springframework.data.mongodb.core.MongoTemplate[], scans for javadoc:org.springframework.data.mongodb.core.mapping.Document[format=annotation] classes, and configures Spring Data MongoDB repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using MongoDB with Spring Boot, see xref:data/nosql.adoc#data.nosql.mongodb[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -The following class shows the javadoc:org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest[format=annotation] annotation in use: +The following class shows the javadoc:org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest[format=annotation] annotation in use: include-code::MyDataMongoDbTests[] @@ -631,13 +631,13 @@ include-code::MyDataMongoDbTests[] [[testing.spring-boot-applications.autoconfigured-spring-data-neo4j]] == Auto-configured Data Neo4j Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest[format=annotation] to test Neo4j applications. +You can use javadoc:org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest[format=annotation] from the `spring-boot-data-neo4j-test` module to test Neo4j applications. By default, it scans for javadoc:org.springframework.data.neo4j.core.schema.Node[format=annotation] classes, and configures Spring Data Neo4j repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using Neo4J with Spring Boot, see xref:data/nosql.adoc#data.nosql.neo4j[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. The following example shows a typical setup for using Neo4J tests in Spring Boot: @@ -650,22 +650,22 @@ If that is not what you want, you can disable transaction management for a test include-code::nopropagation/MyDataNeo4jTests[] NOTE: Transactional tests are not supported with reactive access. -If you are using this style, you must configure javadoc:org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest[format=annotation] tests as described above. +If you are using this style, you must configure javadoc:org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest[format=annotation] tests as described above. [[testing.spring-boot-applications.autoconfigured-spring-data-redis]] == Auto-configured Data Redis Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest[format=annotation] to test Redis applications. +You can use javadoc:org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest[format=annotation] from the `spring-boot-data-redis-test` module to test Data Redis applications. By default, it scans for javadoc:org.springframework.data.redis.core.RedisHash[format=annotation] classes and configures Spring Data Redis repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using Redis with Spring Boot, see xref:data/nosql.adoc#data.nosql.redis[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -The following example shows the javadoc:org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest[format=annotation] annotation in use: +The following example shows the javadoc:org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest[format=annotation] annotation in use: include-code::MyDataRedisTests[] @@ -674,15 +674,15 @@ include-code::MyDataRedisTests[] [[testing.spring-boot-applications.autoconfigured-spring-data-ldap]] == Auto-configured Data LDAP Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest[format=annotation] to test LDAP applications. +You can use javadoc:org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest[format=annotation] to test Data LDAP applications. By default, it configures an in-memory embedded LDAP (if available), configures an javadoc:org.springframework.ldap.core.LdapTemplate[], scans for javadoc:org.springframework.ldap.odm.annotations.Entry[format=annotation] classes, and configures Spring Data LDAP repositories. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. (For more about using LDAP with Spring Boot, see xref:data/nosql.adoc#data.nosql.ldap[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -The following example shows the javadoc:org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest[format=annotation] annotation in use: +The following example shows the javadoc:org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest[format=annotation] annotation in use: include-code::inmemory/MyDataLdapTests[] @@ -696,14 +696,14 @@ include-code::server/MyDataLdapTests[] [[testing.spring-boot-applications.autoconfigured-rest-client]] == Auto-configured REST Clients -You can use the javadoc:org.springframework.boot.test.autoconfigure.web.client.RestClientTest[format=annotation] annotation to test REST clients. +You can use the javadoc:org.springframework.boot.restclient.test.autoconfigure.RestClientTest[format=annotation] annotation from the `spring-boot-restclient-test` moule to test REST clients. By default, it auto-configures Jackson, GSON, and Jsonb support, configures a javadoc:org.springframework.boot.web.client.RestTemplateBuilder[] and a javadoc:org.springframework.web.client.RestClient$Builder[], and adds support for javadoc:org.springframework.test.web.client.MockRestServiceServer[]. -Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.test.autoconfigure.web.client.RestClientTest[format=annotation] annotation is used. +Regular javadoc:org.springframework.stereotype.Component[format=annotation] and javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans are not scanned when the javadoc:org.springframework.boot.restclient.test.autoconfigure.RestClientTest[format=annotation] annotation is used. javadoc:org.springframework.boot.context.properties.EnableConfigurationProperties[format=annotation] can be used to include javadoc:org.springframework.boot.context.properties.ConfigurationProperties[format=annotation] beans. -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.web.client.RestClientTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.restclient.test.autoconfigure.RestClientTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -The specific beans that you want to test should be specified by using the `value` or `components` attribute of javadoc:org.springframework.boot.test.autoconfigure.web.client.RestClientTest[format=annotation]. +The specific beans that you want to test should be specified by using the `value` or `components` attribute of javadoc:org.springframework.boot.restclient.test.autoconfigure.RestClientTest[format=annotation]. When using a javadoc:org.springframework.boot.web.client.RestTemplateBuilder[] in the beans under test and `RestTemplateBuilder.rootUri(String rootUri)` has been called when building the javadoc:org.springframework.web.client.RestTemplate[], then the root URI should be omitted from the javadoc:org.springframework.test.web.client.MockRestServiceServer[] expectations as shown in the following example: @@ -718,10 +718,10 @@ include-code::MyRestClientServiceTests[] [[testing.spring-boot-applications.autoconfigured-spring-restdocs]] == Auto-configured Spring REST Docs Tests -You can use the javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation] annotation to use {url-spring-restdocs-site}[Spring REST Docs] in your tests with Mock MVC, REST Assured, or WebTestClient. +You can use the javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation] annotation from the `spring-boot-restdocs- module to use {url-spring-restdocs-site}[Spring REST Docs] in your tests with Mock MVC, REST Assured, or WebTestClient. It removes the need for the JUnit extension in Spring REST Docs. -javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation] can be used to override the default output directory (`target/generated-snippets` if you are using Maven or `build/generated-snippets` if you are using Gradle). +javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation] can be used to override the default output directory (`target/generated-snippets` if you are using Maven or `build/generated-snippets` if you are using Gradle). It can also be used to configure the host, scheme, and port that appears in any documented URIs. @@ -729,7 +729,7 @@ It can also be used to configure the host, scheme, and port that appears in any [[testing.spring-boot-applications.autoconfigured-spring-restdocs.with-mock-mvc]] === Auto-configured Spring REST Docs Tests With Mock MVC -javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation] customizes the javadoc:org.springframework.test.web.servlet.MockMvc[] bean to use Spring REST Docs when testing servlet-based web applications. +javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation] customizes the javadoc:org.springframework.test.web.servlet.MockMvc[] bean to use Spring REST Docs when testing servlet-based web applications. You can inject it by using javadoc:org.springframework.beans.factory.annotation.Autowired[format=annotation] and use it in your tests as you normally would when using Mock MVC and Spring REST Docs, as shown in the following example: include-code::hamcrest/MyUserDocumentationTests[] @@ -740,7 +740,7 @@ include-code::assertj/MyUserDocumentationTests[] Both reuses the same javadoc:org.springframework.test.web.servlet.MockMvc[] instance behind the scenes so any configuration to it applies to both. -If you require more control over Spring REST Docs configuration than offered by the attributes of javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation], you can use a javadoc:org.springframework.boot.test.autoconfigure.restdocs.RestDocsMockMvcConfigurationCustomizer[] bean, as shown in the following example: +If you require more control over Spring REST Docs configuration than offered by the attributes of javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation], you can use a javadoc:org.springframework.boot.restdocs.test.autoconfigure.RestDocsMockMvcConfigurationCustomizer[] bean, as shown in the following example: include-code::MyRestDocsConfiguration[] @@ -755,12 +755,12 @@ include-code::MyResultHandlerConfiguration[] [[testing.spring-boot-applications.autoconfigured-spring-restdocs.with-web-test-client]] === Auto-configured Spring REST Docs Tests With WebTestClient -javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation] can also be used with javadoc:org.springframework.test.web.reactive.server.WebTestClient[] when testing reactive web applications. -You can inject it by using javadoc:org.springframework.beans.factory.annotation.Autowired[format=annotation] and use it in your tests as you normally would when using javadoc:org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest[format=annotation] and Spring REST Docs, as shown in the following example: +javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation] can also be used with javadoc:org.springframework.test.web.reactive.server.WebTestClient[] when testing reactive web applications. +You can inject it by using javadoc:org.springframework.beans.factory.annotation.Autowired[format=annotation] and use it in your tests as you normally would when using javadoc:org.springframework.boot.webflux.test.autoconfigure.WebFluxTest[format=annotation] and Spring REST Docs, as shown in the following example: include-code::MyUsersDocumentationTests[] -If you require more control over Spring REST Docs configuration than offered by the attributes of javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation], you can use a javadoc:org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer[] bean, as shown in the following example: +If you require more control over Spring REST Docs configuration than offered by the attributes of javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation], you can use a javadoc:org.springframework.boot.restdocs.test.autoconfigure.RestDocsWebTestClientConfigurationCustomizer[] bean, as shown in the following example: include-code::MyRestDocsConfiguration[] @@ -774,12 +774,12 @@ include-code::MyWebTestClientBuilderCustomizerConfiguration[] [[testing.spring-boot-applications.autoconfigured-spring-restdocs.with-rest-assured]] === Auto-configured Spring REST Docs Tests With REST Assured -javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation] makes a javadoc:io.restassured.specification.RequestSpecification[] bean, preconfigured to use Spring REST Docs, available to your tests. +javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation] makes a javadoc:io.restassured.specification.RequestSpecification[] bean, preconfigured to use Spring REST Docs, available to your tests. You can inject it by using javadoc:org.springframework.beans.factory.annotation.Autowired[format=annotation] and use it in your tests as you normally would when using REST Assured and Spring REST Docs, as shown in the following example: include-code::MyUserDocumentationTests[] -If you require more control over Spring REST Docs configuration than offered by the attributes of javadoc:org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs[format=annotation], a javadoc:org.springframework.boot.test.autoconfigure.restdocs.RestDocsRestAssuredConfigurationCustomizer[] bean can be used, as shown in the following example: +If you require more control over Spring REST Docs configuration than offered by the attributes of javadoc:org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs[format=annotation], a javadoc:org.springframework.boot.restdocs.test.autoconfigure.RestDocsRestAssuredConfigurationCustomizer[] bean can be used, as shown in the following example: include-code::MyRestDocsConfiguration[] @@ -793,14 +793,14 @@ include-code::MyRestDocsConfiguration[] [[testing.spring-boot-applications.autoconfigured-webservices.client]] === Auto-configured Spring Web Services Client Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest[format=annotation] to test applications that call web services using the Spring Web Services project. +You can use javadoc:org.springframework.boot.webservices.test.autoconfigure.client.WebServiceClientTest[format=annotation] from the `spring-boot-webservices-test` module to test applications that call web services using the Spring Web Services project. By default, it configures a javadoc:org.springframework.ws.test.client.MockWebServiceServer[] bean and automatically customizes your javadoc:org.springframework.boot.webservices.client.WebServiceTemplateBuilder[]. (For more about using Web Services with Spring Boot, see xref:io/webservices.adoc[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.webservices.test.autoconfigure.client.WebServiceClientTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -The following example shows the javadoc:org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest[format=annotation] annotation in use: +The following example shows the javadoc:org.springframework.boot.webservices.test.autoconfigure.client.WebServiceClientTest[format=annotation] annotation in use: include-code::MyWebServiceClientTests[] @@ -809,14 +809,14 @@ include-code::MyWebServiceClientTests[] [[testing.spring-boot-applications.autoconfigured-webservices.server]] === Auto-configured Spring Web Services Server Tests -You can use javadoc:org.springframework.boot.test.autoconfigure.webservices.server.WebServiceServerTest[format=annotation] to test applications that implement web services using the Spring Web Services project. +You can use javadoc:org.springframework.boot.webservices.test.autoconfigure.server.WebServiceServerTest[format=annotation] from the `spring-boot-webservices-test` module to test applications that implement web services using the Spring Web Services project. By default, it configures a javadoc:org.springframework.ws.test.server.MockWebServiceClient[] bean that can be used to call your web service endpoints. (For more about using Web Services with Spring Boot, see xref:io/webservices.adoc[].) -TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.test.autoconfigure.webservices.server.WebServiceServerTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. +TIP: A list of the auto-configuration settings that are enabled by javadoc:org.springframework.boot.webservices.test.autoconfigure.server.WebServiceServerTest[format=annotation] can be xref:appendix:test-auto-configuration/index.adoc[found in the appendix]. -The following example shows the javadoc:org.springframework.boot.test.autoconfigure.webservices.server.WebServiceServerTest[format=annotation] annotation in use: +The following example shows the javadoc:org.springframework.boot.webservices.test.autoconfigure.server.WebServiceServerTest[format=annotation] annotation in use: include-code::MyWebServiceServerTests[] @@ -834,13 +834,13 @@ NOTE: Make sure to not use the regular javadoc:org.springframework.context.annot Alternatively, additional auto-configurations can be added for any use of a slice annotation by registering them in a file stored in `META-INF/spring` as shown in the following example: -.META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.JdbcTest.imports +.META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.JdbcTest.imports [source] ---- com.example.IntegrationAutoConfiguration ---- -In this example, the `+com.example.IntegrationAutoConfiguration+` is enabled on every test annotated with javadoc:org.springframework.boot.test.autoconfigure.jdbc.JdbcTest[format=annotation]. +In this example, the `+com.example.IntegrationAutoConfiguration+` is enabled on every test annotated with javadoc:org.springframework.boot.jdbc.test.autoconfigure.JdbcTest[format=annotation]. TIP: You can use comments with `#` in this file. @@ -870,7 +870,7 @@ The latter approach lets you enable it in one of your tests, if necessary, with See xref:how-to:testing.adoc#howto.testing.slice-tests[this how-to section] for more details on when you might want to enable specific javadoc:org.springframework.context.annotation.Configuration[format=annotation] classes for slice tests. Test slices exclude javadoc:org.springframework.context.annotation.Configuration[format=annotation] classes from scanning. -For example, for a javadoc:org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest[format=annotation], the following configuration will not include the given javadoc:org.springframework.web.servlet.config.annotation.WebMvcConfigurer[] bean in the application context loaded by the test slice: +For example, for a javadoc:org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest[format=annotation], the following configuration will not include the given javadoc:org.springframework.web.servlet.config.annotation.WebMvcConfigurer[] bean in the application context loaded by the test slice: include-code::MyWebConfiguration[] @@ -885,7 +885,7 @@ Your application may resemble the following code: include-code::scan/MyApplication[] Doing so effectively overrides the default component scan directive with the side effect of scanning those two packages regardless of the slice that you chose. -For instance, a javadoc:org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest[format=annotation] seems to suddenly scan components and user configurations of your application. +For instance, a javadoc:org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest[format=annotation] seems to suddenly scan components and user configurations of your application. Again, moving the custom directive to a separate class is a good way to fix this issue. TIP: If this is not an option for you, you can create a javadoc:org.springframework.boot.SpringBootConfiguration[format=annotation] somewhere in the hierarchy of your test so that it is used instead. diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-modules.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-modules.adoc new file mode 100644 index 00000000000..53b830f842e --- /dev/null +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-modules.adoc @@ -0,0 +1,82 @@ +[[testing.test-modules]] += Test Modules + +Spring Boot offers several focused, feature-specific `-test` modules: + +[cols="1,3"] +|=== +|Module | Purpose + +|`spring-boot-cache-test` +|Testing applications that use Spring Framework's cache abstration. + +|`spring-boot-data-cassandra-test` +|Testing applications that use Spring Data Cassandra. Provides the `@DataCassandraTest` test slice. + +|`spring-boot-data-couchbase-test` +|Testing applications that use Spring Data Couchbase. Provides the `@DataCouchbaseTest` test slice. + +|`spring-boot-data-elasticsearch-test` +|Testing applications that use Spring Data Elasticsearch. Provides the `@DataElasticsearchTest` test slice. + +|`spring-boot-data-jdbc-test` +|Testing applications that use Spring Data JDBC. Provides the `@DataJdbcTest` test slice. + +|`spring-boot-data-jpa-test` +|Testing applications that use Spring Data JPA. Provides the `@DataJpaTest` test slice. + +|`spring-boot-data-ldap-test` +|Testing applications that use Spring Data LDAP. Provides the `@DataLdapTest` test slice. + +|`spring-boot-mongodb-test` +|Testing applications that use Spring Data MongoDB. Provides the `@DataMongoTest` test slice. + +|`spring-boot-data-neo4j-test` +|Testing applications that use Spring Data JPA. Provides the `@DataNeo4jTest` test slice. + +|`spring-boot-data-r2dbc-test` +|Testing applications that use Spring Data R2DBC. Provides the `@DataR2dbcTest` test slice. + +|`spring-boot-data-redis-test` +|Testing applications that use Spring Data Redis. Provides the `@DataRedisTest` test slice. + +|`spring-boot-graphql-test` +|Testing applications that use Spring GraphQL. Provides the `@GraphQlTest` test slice. + +|`spring-boot-jdbc-test` +|Testing applications that using Spring JDBC. Provides the `@JdbcTest` test slice. + +|`spring-boot-jooq-test` +|Testing applications that using jOOQ. Provides the `@JooqTest` test slice. + +|`spring-boot-jpa-test` +|Testing applications that use JPA. + +|`spring-boot-json-test` +|Testing applications that use JSON. Provides the `@JsonTest` test slice. + +|`spring-boot-micrometer-metrics-test` +|Testing applications that use Micrometer Metrics. + +|`spring-boot-micrometer-tracing-test` +|Testing applications that use Micrometer Tracing. + +|`spring-boot-restclient-test` +|Testing applications that use REST clients. Provides the `@RestClientTest` test slice. + +|`spring-boot-security-test` +|Testing applications that use Spring Security. + +|`spring-boot-web-server-test` +|Testing applications that use an embedded web server. + +|`spring-boot-webflux-test` +|Testing applications that use Spring WebFlux. Provides the `@WebFluxTest` test slice. + +|`spring-boot-webmvc-test` +|Testing applications that use Spring Web MVC. Provides the `@WebMvcTest` test slice. + +|`spring-boot-webservices-test` +|Testing applications that use Spring Web Services. Provides the `@WebServiceClientTest` and `@WebServiceServerTest` test slices. + +|=== \ No newline at end of file diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/partials/nav-reference.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/partials/nav-reference.adoc index 0c674a83143..65cf7db43f9 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/partials/nav-reference.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/partials/nav-reference.adoc @@ -57,6 +57,7 @@ *** xref:reference:messaging/websockets.adoc[] ** xref:reference:testing/index.adoc[] +*** xref:reference:testing/test-modules.adoc[] *** xref:reference:testing/test-scope-dependencies.adoc[] *** xref:reference:testing/spring-applications.adoc[] *** xref:reference:testing/spring-boot-applications.adoc[] diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.java index 15c7213d741..a302fa80a3c 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.howto.testing.withspringsecurity; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.java index caea3755369..63b1e2723c9 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.java @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.springbootapplications.additionala import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.integration.autoconfigure.IntegrationAutoConfiguration; -import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest; +import org.springframework.boot.jdbc.test.autoconfigure.JdbcTest; @JdbcTest @ImportAutoConfiguration(IntegrationAutoConfiguration.class) diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.java index 4c311fd981b..eb644f22ae2 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.java @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredjdbc; -import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest; +import org.springframework.boot.jdbc.test.autoconfigure.JdbcTest; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.java index be8a882c370..802a31b48e8 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.jooq.DSLContext; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jooq.JooqTest; +import org.springframework.boot.jooq.test.autoconfigure.JooqTest; @JooqTest class MyJooqTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.java index 5f44b78d1b7..6b57e34521c 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.client.RestClientTest; +import org.springframework.boot.restclient.test.autoconfigure.RestClientTest; import org.springframework.http.MediaType; import org.springframework.test.web.client.MockRestServiceServer; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.java index 9c598d5b272..c99d8892dad 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.client.RestClientTest; +import org.springframework.boot.restclient.test.autoconfigure.RestClientTest; import org.springframework.http.MediaType; import org.springframework.test.web.client.MockRestServiceServer; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.java index e998a927d61..84747b3f8bd 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatacassandra; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; @DataCassandraTest class MyDataCassandraTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.java index 8aa25f9bdc7..c823985ef68 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatacouchbase; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest; +import org.springframework.boot.data.couchbase.test.autoconfigure.DataCouchbaseTest; @DataCouchbaseTest class MyDataCouchbaseTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.java index 34ee71c2ffd..0068f78c6f4 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataelasticsearch; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest; @DataElasticsearchTest class MyDataElasticsearchTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.java index 0af33604515..175a12f1882 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.java @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatajpa; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.java index 8d7f6de9a29..2da6033be5d 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.java @@ -16,9 +16,9 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatajpa.withdb; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.Replace; @DataJpaTest @AutoConfigureTestDatabase(replace = Replace.NONE) diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java index cb59cee650b..5f10eca512a 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.java @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.java index 36670d97982..29fd73276a6 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataldap.inmemory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest; +import org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest; import org.springframework.ldap.core.LdapTemplate; @DataLdapTest diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.java index db2fa363a28..b753155bf98 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.java @@ -16,8 +16,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataldap.server; +import org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest; import org.springframework.boot.ldap.autoconfigure.embedded.EmbeddedLdapAutoConfiguration; -import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest; @DataLdapTest(excludeAutoConfiguration = EmbeddedLdapAutoConfiguration.class) class MyDataLdapTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.java index fb82f9c7fe1..23290010c12 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatamongodb; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; +import org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest; import org.springframework.data.mongodb.core.MongoTemplate; @DataMongoTest diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.java index dd3abf93b9a..8a361fe12d6 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.java @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataneo4j.nopropagation; -import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest; +import org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.java index 972a4e8f5ad..60c2d49e68b 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataneo4j.propagation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest; +import org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest; @DataNeo4jTest class MyDataNeo4jTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.java index 1e148df59e7..cb9c4ec2705 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.java @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataredis; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; +import org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest; @DataRedisTest class MyDataRedisTests { diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.java index 3ad30947393..442d2c9a618 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.java @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withmockmvc; -import org.springframework.boot.test.autoconfigure.restdocs.RestDocsMockMvcConfigurationCustomizer; +import org.springframework.boot.restdocs.test.autoconfigure.RestDocsMockMvcConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentationConfigurer; import org.springframework.restdocs.templates.TemplateFormats; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/assertj/MyUserDocumentationTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/assertj/MyUserDocumentationTests.java index bbf10f7ecc7..1c77ebd05a3 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/assertj/MyUserDocumentationTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/assertj/MyUserDocumentationTests.java @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/hamcrest/MyUserDocumentationTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/hamcrest/MyUserDocumentationTests.java index b8922cb6d08..4953482caea 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/hamcrest/MyUserDocumentationTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/hamcrest/MyUserDocumentationTests.java @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.java index ea672dd76db..debb703c38e 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.java @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withrestassured; -import org.springframework.boot.test.autoconfigure.restdocs.RestDocsRestAssuredConfigurationCustomizer; +import org.springframework.boot.restdocs.test.autoconfigure.RestDocsRestAssuredConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.restdocs.restassured.RestAssuredRestDocumentationConfigurer; import org.springframework.restdocs.templates.TemplateFormats; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java index 2822d1ff483..c15fa2ad557 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java @@ -20,7 +20,7 @@ import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.test.LocalServerPort; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java index fc10a73e1d2..b5ca0e18393 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withwebtestclient; -import org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer; +import org.springframework.boot.restdocs.test.autoconfigure.RestDocsWebTestClientConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.java index 80d90a9b87a..d7371f67a87 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.java @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; import org.springframework.test.web.reactive.server.WebTestClient; import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.java index bfa2c01c3d1..d91986a99ef 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest; +import org.springframework.boot.webservices.test.autoconfigure.client.WebServiceClientTest; import org.springframework.ws.test.client.MockWebServiceServer; import org.springframework.xml.transform.StringSource; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.java index 4151fcc07ca..0cb69843895 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.webservices.server.WebServiceServerTest; +import org.springframework.boot.webservices.test.autoconfigure.server.WebServiceServerTest; import org.springframework.ws.test.server.MockWebServiceClient; import org.springframework.ws.test.server.RequestCreators; import org.springframework.ws.test.server.ResponseMatchers; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.java index c39f0c2b850..5f32c9d3ff0 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.jsontests; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.JsonTest; +import org.springframework.boot.json.test.autoconfigure.JsonTest; import org.springframework.boot.test.json.JacksonTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.java index d15f0cf2087..1b829e123cd 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.jsontests; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.JsonTest; +import org.springframework.boot.json.test.autoconfigure.JsonTest; import org.springframework.boot.test.json.JacksonTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.java index ad279d3d34e..f5259e01647 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.springgraph import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester; +import org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.graphql.test.tester.HttpGraphQlTester; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.java index fd58885fe8e..9a8c1144c4f 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.docs.web.graphql.runtimewiring.GreetingController; -import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest; +import org.springframework.boot.graphql.test.autoconfigure.GraphQlTest; import org.springframework.graphql.test.tester.GraphQlTester; @GraphQlTest(GreetingController.class) diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.java index 16502861b29..dffef1529a8 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.springmvcte import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.java index 2b41d00e881..4d071732986 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.java @@ -21,7 +21,7 @@ import org.htmlunit.html.HtmlPage; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.java index f9b3f6d21db..5ab8d491569 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.springwebfl import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; import org.springframework.http.MediaType; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.reactive.server.WebTestClient; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java index 6327f3d2b71..80dfa4785c6 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.withmockenv import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java index 2b280c1e98b..6afdafa4e84 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.withmockenv import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; import org.springframework.test.web.reactive.server.WebTestClient; @SpringBootTest diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/testcontainers/serviceconnections/ssl/MyElasticsearchWithSslIntegrationTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/testcontainers/serviceconnections/ssl/MyElasticsearchWithSslIntegrationTests.java index c818150f2e6..6770256af0c 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/testcontainers/serviceconnections/ssl/MyElasticsearchWithSslIntegrationTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/testcontainers/serviceconnections/ssl/MyElasticsearchWithSslIntegrationTests.java @@ -22,7 +22,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testcontainers.service.connection.Ssl; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt index 4444272307d..10c087fbf57 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.howto.testing.withspringsecurity import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest import org.springframework.security.test.context.support.WithMockUser import org.springframework.test.web.servlet.assertj.MockMvcTester diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt index 3f7cf0ce0e1..f0e873eacaf 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.springbootapplications.additionala import org.springframework.boot.autoconfigure.ImportAutoConfiguration import org.springframework.boot.integration.autoconfigure.IntegrationAutoConfiguration -import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest +import org.springframework.boot.jdbc.test.autoconfigure.JdbcTest @JdbcTest @ImportAutoConfiguration(IntegrationAutoConfiguration::class) diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt index bf87e8951c4..37058c11989 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredjdbc -import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest +import org.springframework.boot.jdbc.test.autoconfigure.JdbcTest import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt index fc67dce3de9..9b8841c5211 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.jooq.DSLContext import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.jooq.JooqTest +import org.springframework.boot.jooq.test.autoconfigure.JooqTest @JooqTest class MyJooqTests(@Autowired val dslContext: DSLContext) { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.kt index d72b9140d9a..66b33697405 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestClientServiceTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.client.RestClientTest +import org.springframework.boot.restclient.test.autoconfigure.RestClientTest import org.springframework.http.MediaType import org.springframework.test.web.client.MockRestServiceServer import org.springframework.test.web.client.match.MockRestRequestMatchers diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.kt index aaf00ff6f3d..84719b7fadc 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredrestclient/MyRestTemplateServiceTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.client.RestClientTest +import org.springframework.boot.restclient.test.autoconfigure.RestClientTest import org.springframework.http.MediaType import org.springframework.test.web.client.MockRestServiceServer import org.springframework.test.web.client.match.MockRestRequestMatchers diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt index 74cf05af085..4feca0ae9e3 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatacassandra import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest @DataCassandraTest class MyDataCassandraTests(@Autowired val repository: SomeRepository) diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.kt index 1c34b8600f6..cec9b8a8222 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatacouchbase/MyDataCouchbaseTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatacouchbase import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest +import org.springframework.boot.data.couchbase.test.autoconfigure.DataCouchbaseTest @DataCouchbaseTest class MyDataCouchbaseTests(@Autowired val repository: SomeRepository) { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.kt index f563264ba06..4b1b09fdd07 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataelasticsearch/MyDataElasticsearchTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataelasticsearch import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest @DataElasticsearchTest class MyDataElasticsearchTests(@Autowired val repository: SomeRepository) { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt index 8b443669f27..b95a23314e5 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatajpa -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt index 35343640832..aa29eadabbb 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt @@ -16,8 +16,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatajpa.withdb -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest @DataJpaTest @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt index 21dac86bdfb..2fe538a3d5d 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest +import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager @DataJpaTest class MyRepositoryTests(@Autowired val entityManager: TestEntityManager, @Autowired val repository: UserRepository) { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt index 19edf56a919..77d92dd5e45 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataldap.inmemory import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest +import org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest import org.springframework.ldap.core.LdapTemplate @DataLdapTest diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt index 7a422880952..b797b06f0ca 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataldap.server import org.springframework.boot.ldap.autoconfigure.embedded.EmbeddedLdapAutoConfiguration -import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest +import org.springframework.boot.data.ldap.test.autoconfigure.DataLdapTest @DataLdapTest(excludeAutoConfiguration = [EmbeddedLdapAutoConfiguration::class]) class MyDataLdapTests { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.kt index 42bb5fb5c67..aceb4918fd0 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdatamongodb/MyDataMongoDbTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdatamongodb import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest +import org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest import org.springframework.data.mongodb.core.MongoTemplate @DataMongoTest diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt index 7c1402c7e3f..6d5473e45cf 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataneo4j.nopropagation -import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest +import org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest import org.springframework.transaction.annotation.Propagation import org.springframework.transaction.annotation.Transactional diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt index 1686390e1af..f467a266cc1 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataneo4j.propagation import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest +import org.springframework.boot.data.neo4j.test.autoconfigure.DataNeo4jTest @DataNeo4jTest class MyDataNeo4jTests(@Autowired val repository: SomeRepository) { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt index 21ea8dd2e61..67774ba99a5 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringdataredis import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest +import org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest @DataRedisTest class MyDataRedisTests(@Autowired val repository: SomeRepository) { diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt index 3887ad8f4ff..d6b316e53f4 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withmockmvc -import org.springframework.boot.test.autoconfigure.restdocs.RestDocsMockMvcConfigurationCustomizer +import org.springframework.boot.restdocs.test.autoconfigure.RestDocsMockMvcConfigurationCustomizer import org.springframework.boot.test.context.TestConfiguration import org.springframework.restdocs.mockmvc.MockMvcRestDocumentationConfigurer import org.springframework.restdocs.templates.TemplateFormats diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt index fc3192c6030..7bbc73c7177 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt @@ -19,8 +19,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest import org.springframework.http.MediaType import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation import org.springframework.test.web.servlet.assertj.MockMvcTester diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt index 573b3ea3e39..54890a13bba 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withrestassured -import org.springframework.boot.test.autoconfigure.restdocs.RestDocsRestAssuredConfigurationCustomizer +import org.springframework.boot.restdocs.test.autoconfigure.RestDocsRestAssuredConfigurationCustomizer import org.springframework.boot.test.context.TestConfiguration import org.springframework.restdocs.restassured.RestAssuredRestDocumentationConfigurer import org.springframework.restdocs.templates.TemplateFormats diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt index 3879a9aa1a9..369594d94d0 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt @@ -21,7 +21,7 @@ import io.restassured.specification.RequestSpecification import org.hamcrest.Matchers import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest.WebEnvironment import org.springframework.boot.web.server.test.LocalServerPort diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt index dc3b16ca2b4..bf8314364dd 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfiguredspringrestdocs.withwebtestclient -import org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer +import org.springframework.boot.restdocs.test.autoconfigure.RestDocsWebTestClientConfigurationCustomizer import org.springframework.boot.test.context.TestConfiguration import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt index 064c3206d07..5c0707dc5ce 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt @@ -18,8 +18,8 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation import org.springframework.test.web.reactive.server.WebTestClient diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt index e0c392b7e5d..db0fe7650ec 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest +import org.springframework.boot.webservices.test.autoconfigure.client.WebServiceClientTest import org.springframework.ws.test.client.MockWebServiceServer import org.springframework.ws.test.client.RequestMatchers import org.springframework.ws.test.client.ResponseCreators diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt index cdb31145e68..4ac6e9455ea 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.springbootapplications.autoconfigu import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.webservices.server.WebServiceServerTest +import org.springframework.boot.webservices.test.autoconfigure.server.WebServiceServerTest import org.springframework.ws.test.server.MockWebServiceClient import org.springframework.ws.test.server.RequestCreators import org.springframework.ws.test.server.ResponseMatchers diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt index 71935fbc091..e65d85716ca 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt @@ -21,7 +21,7 @@ import org.assertj.core.api.Assertions.within import org.assertj.core.api.ThrowingConsumer import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.json.JsonTest +import org.springframework.boot.json.test.autoconfigure.JsonTest import org.springframework.boot.test.json.JacksonTester @JsonTest diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.kt index dd64e262768..8977abc4d6a 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/jsontests/MyJsonTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.jsontests import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.json.JsonTest +import org.springframework.boot.json.test.autoconfigure.JsonTest import org.springframework.boot.test.json.JacksonTester @JsonTest diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.kt index 74eac2c769a..c6ceda46360 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GraphQlIntegrationTests.kt @@ -18,7 +18,7 @@ package org.springframework.boot.docs.testing.springbootapplications.springgraph import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester +import org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester import org.springframework.boot.test.context.SpringBootTest import org.springframework.graphql.test.tester.HttpGraphQlTester import org.springframework.http.HttpHeaders diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt index 8dd567d400c..f57e84395c2 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.springgraph import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.docs.web.graphql.runtimewiring.GreetingController -import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest +import org.springframework.boot.graphql.test.autoconfigure.GraphQlTest import org.springframework.graphql.test.tester.GraphQlTester @GraphQlTest(GreetingController::class) diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.kt index c8dfe17b76c..ba680179b75 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyControllerTests.kt @@ -20,7 +20,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest import org.springframework.http.MediaType import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.assertj.MockMvcTester diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt index 8a63476af86..f3a4b3b5044 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt @@ -22,7 +22,7 @@ import org.htmlunit.html.HtmlPage import org.junit.jupiter.api.Test import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest import org.springframework.test.context.bean.override.mockito.MockitoBean @WebMvcTest(UserVehicleController::class) diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt index 3648aec7371..b6439fd2e73 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.springwebfl import org.junit.jupiter.api.Test import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest import org.springframework.http.MediaType import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.reactive.server.WebTestClient diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt index e7696c4eb2c..2a09861c61d 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt @@ -19,7 +19,7 @@ package org.springframework.boot.docs.testing.springbootapplications.withmockenv import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt index 7abfb6803ef..decfb1ce537 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt @@ -18,8 +18,8 @@ package org.springframework.boot.docs.testing.springbootapplications.withmockenv import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient import org.springframework.boot.test.context.SpringBootTest +import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody diff --git a/module/spring-boot-cache-test/build.gradle b/module/spring-boot-cache-test/build.gradle new file mode 100644 index 00000000000..52a3fed17b9 --- /dev/null +++ b/module/spring-boot-cache-test/build.gradle @@ -0,0 +1,36 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" +} + +description = "Spring Boot Cache Test" + +dependencies { + api(project(":module:spring-boot-cache")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-test-autoconfigure")) + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java b/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java rename to module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java index b60f899b36f..7e0afe4b051 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCache.java +++ b/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCache.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.core; +package org.springframework.boot.cache.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -35,7 +35,7 @@ import org.springframework.cache.support.NoOpCacheManager; * {@link NoOpCacheManager}. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/package-info.java b/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/package-info.java new file mode 100644 index 00000000000..10f236fc696 --- /dev/null +++ b/module/spring-boot-cache-test/src/main/java/org/springframework/boot/cache/test/autoconfigure/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Auto-configuration for testing code that uses the cache abstraction. + */ +@NullMarked +package org.springframework.boot.cache.test.autoconfigure; + +import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-web-server-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-cache-test/src/main/resources/META-INF/spring-configuration-metadata.json similarity index 100% rename from module/spring-boot-web-server-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json rename to module/spring-boot-cache-test/src/main/resources/META-INF/spring-configuration-metadata.json diff --git a/module/spring-boot-cache-test/src/main/resources/META-INF/spring/org.springframework.boot.cache.test.autoconfigure.AutoConfigureCache.imports b/module/spring-boot-cache-test/src/main/resources/META-INF/spring/org.springframework.boot.cache.test.autoconfigure.AutoConfigureCache.imports new file mode 100644 index 00000000000..29caa971636 --- /dev/null +++ b/module/spring-boot-cache-test/src/main/resources/META-INF/spring/org.springframework.boot.cache.test.autoconfigure.AutoConfigureCache.imports @@ -0,0 +1 @@ +org.springframework.boot.cache.autoconfigure.CacheAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCacheIntegrationTests.java b/module/spring-boot-cache-test/src/test/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCacheIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCacheIntegrationTests.java rename to module/spring-boot-cache-test/src/test/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCacheIntegrationTests.java index cd3b1e155eb..e6b758abe9a 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCacheIntegrationTests.java +++ b/module/spring-boot-cache-test/src/test/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCacheIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.core; +package org.springframework.boot.cache.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCacheWithExistingCacheManagerIntegrationTests.java b/module/spring-boot-cache-test/src/test/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCacheWithExistingCacheManagerIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCacheWithExistingCacheManagerIntegrationTests.java rename to module/spring-boot-cache-test/src/test/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCacheWithExistingCacheManagerIntegrationTests.java index 2df1e41ca3d..5c865ec20cc 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/core/AutoConfigureCacheWithExistingCacheManagerIntegrationTests.java +++ b/module/spring-boot-cache-test/src/test/java/org/springframework/boot/cache/test/autoconfigure/AutoConfigureCacheWithExistingCacheManagerIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.core; +package org.springframework.boot.cache.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-data-cassandra-test/build.gradle b/module/spring-boot-data-cassandra-test/build.gradle new file mode 100644 index 00000000000..f2714b65a16 --- /dev/null +++ b/module/spring-boot-data-cassandra-test/build.gradle @@ -0,0 +1,48 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data Cassandra Test" + +dependencies { + api(project(":module:spring-boot-data-cassandra")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + dockerTestImplementation("org.assertj:assertj-core") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.testcontainers:cassandra") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:testcontainers") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestIntegrationTests.java b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestIntegrationTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestIntegrationTests.java rename to module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestIntegrationTests.java index bc811812d4f..ba7ed737ce0 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestIntegrationTests.java +++ b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestIntegrationTests.java @@ -27,7 +27,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.redis.ExampleService; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; @@ -38,7 +38,7 @@ import org.springframework.data.cassandra.core.CassandraTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration test for {@link DataCassandraTest @DataCassandraTest}. diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithIncludeFilterIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithIncludeFilterIntegrationTests.java index 53544b8fa5d..516165a59a5 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestWithIncludeFilterIntegrationTests.java @@ -26,6 +26,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleCassandraApplication.java b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleCassandraApplication.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleCassandraApplication.java rename to module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleCassandraApplication.java index 45e21e3a24f..9ed238be0a7 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleCassandraApplication.java +++ b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleCassandraApplication.java @@ -17,6 +17,7 @@ package org.springframework.boot.test.autoconfigure.data.cassandra; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; /** * Example {@link SpringBootApplication @SpringBootApplication} used with diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleEntity.java b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleEntity.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleEntity.java rename to module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleEntity.java index 9cdd5c8e6bb..9b05c1aa84f 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleEntity.java +++ b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleEntity.java @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.cassandra; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; import org.springframework.data.cassandra.core.mapping.PrimaryKey; import org.springframework.data.cassandra.core.mapping.Table; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleRepository.java b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleRepository.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleRepository.java rename to module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleRepository.java index 53278ad40d2..e70b4d5e13a 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleRepository.java +++ b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleRepository.java @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.cassandra; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; import org.springframework.data.cassandra.repository.CassandraRepository; /** diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleService.java b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleService.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleService.java rename to module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleService.java index 6c274205991..edb5861cdb6 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleService.java +++ b/module/spring-boot-data-cassandra-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/cassandra/ExampleService.java @@ -16,6 +16,7 @@ package org.springframework.boot.test.autoconfigure.data.cassandra; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; import org.springframework.data.cassandra.core.CassandraTemplate; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/AutoConfigureDataCassandra.java b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/AutoConfigureDataCassandra.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/AutoConfigureDataCassandra.java rename to module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/AutoConfigureDataCassandra.java index cf15c75c9a6..c409f1d844a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/AutoConfigureDataCassandra.java +++ b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/AutoConfigureDataCassandra.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.cassandra; +package org.springframework.boot.data.cassandra.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * rather than using this annotation directly. * * @author Artsiom Yudovin - * @since 2.4.0 + * @since 4.0.0 * @see DataCassandraTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java rename to module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTest.java index ccf7629710b..0deba6df2ce 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTest.java +++ b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.cassandra; +package org.springframework.boot.data.cassandra.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -49,7 +48,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * * @author Artsiom Yudovin * @author Stephane Nicoll - * @since 2.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -59,7 +58,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataCassandraTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureDataCassandra @ImportAutoConfiguration public @interface DataCassandraTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java rename to module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestContextBootstrapper.java index 30b109c7619..9539c19c765 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestContextBootstrapper.java +++ b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.cassandra; +package org.springframework.boot.data.cassandra.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTypeExcludeFilter.java b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTypeExcludeFilter.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTypeExcludeFilter.java rename to module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTypeExcludeFilter.java index 8b3499b9159..75049748847 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTypeExcludeFilter.java +++ b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.cassandra; +package org.springframework.boot.data.cassandra.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/package-info.java b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/package-info.java rename to module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/package-info.java index 8d02e031a6b..ec493d60472 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/cassandra/package-info.java +++ b/module/spring-boot-data-cassandra-test/src/main/java/org/springframework/boot/data/cassandra/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data Cassandra tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.cassandra; +package org.springframework.boot.data.cassandra.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports b/module/spring-boot-data-cassandra-test/src/main/resources/META-INF/spring/org.springframework.boot.data.cassandra.test.autoconfigure.AutoConfigureDataCassandra.imports similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports rename to module/spring-boot-data-cassandra-test/src/main/resources/META-INF/spring/org.springframework.boot.data.cassandra.test.autoconfigure.AutoConfigureDataCassandra.imports index 108562156ea..486238dc0a8 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.cassandra.AutoConfigureDataCassandra.imports +++ b/module/spring-boot-data-cassandra-test/src/main/resources/META-INF/spring/org.springframework.boot.data.cassandra.test.autoconfigure.AutoConfigureDataCassandra.imports @@ -1,8 +1,7 @@ -# AutoConfigureDataCassandra auto-configuration imports +org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration org.springframework.boot.data.cassandra.autoconfigure.CassandraDataAutoConfiguration org.springframework.boot.data.cassandra.autoconfigure.CassandraReactiveDataAutoConfiguration org.springframework.boot.data.cassandra.autoconfigure.CassandraReactiveRepositoriesAutoConfiguration org.springframework.boot.data.cassandra.autoconfigure.CassandraRepositoriesAutoConfiguration -org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-data-cassandra-test/src/test/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestApplication.java b/module/spring-boot-data-cassandra-test/src/test/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestApplication.java new file mode 100644 index 00000000000..6272722dabe --- /dev/null +++ b/module/spring-boot-data-cassandra-test/src/test/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.data.cassandra.test.autoconfigure; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Application for testing of {@link DataCassandraTest @DataCassandraTest}. + * + * @author Andy Wilkinson + */ +@SpringBootApplication +class DataCassandraTestApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java b/module/spring-boot-data-cassandra-test/src/test/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestPropertiesIntegrationTests.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java rename to module/spring-boot-data-cassandra-test/src/test/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestPropertiesIntegrationTests.java index e0ca47a86fd..1f02544854c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/cassandra/DataCassandraTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-cassandra-test/src/test/java/org/springframework/boot/data/cassandra/test/autoconfigure/DataCassandraTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.cassandra; +package org.springframework.boot.data.cassandra.test.autoconfigure; import com.datastax.oss.driver.api.core.CqlSession; import com.datastax.oss.driver.api.core.context.DriverContext; @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTestPropertiesIntegrationTests.CassandraMockConfiguration; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTestPropertiesIntegrationTests.CassandraMockConfiguration; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; diff --git a/module/spring-boot-data-commons/build.gradle b/module/spring-boot-data-commons/build.gradle index e7d300cdaba..71bb3107f86 100644 --- a/module/spring-boot-data-commons/build.gradle +++ b/module/spring-boot-data-commons/build.gradle @@ -35,6 +35,8 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-jdbc")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":test-support:spring-boot-test-support")) testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("org.springframework.data:spring-data-jdbc") diff --git a/module/spring-boot-data-commons/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-data-commons/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..7e9012b4a2b --- /dev/null +++ b/module/spring-boot-data-commons/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +org.springframework.boot.data.autoconfigure.web.SpringDataWebAutoConfiguration diff --git a/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/metrics/web/SpringDataWebAutoConfigurationTests.java b/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/web/SpringDataWebAutoConfigurationTests.java similarity index 96% rename from module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/metrics/web/SpringDataWebAutoConfigurationTests.java rename to module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/web/SpringDataWebAutoConfigurationTests.java index f0dd47a10eb..e7b6bae6b80 100644 --- a/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/metrics/web/SpringDataWebAutoConfigurationTests.java +++ b/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/web/SpringDataWebAutoConfigurationTests.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.data.autoconfigure.metrics.web; +package org.springframework.boot.data.autoconfigure.web; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.data.autoconfigure.web.SpringDataWebAutoConfiguration; -import org.springframework.boot.data.autoconfigure.web.SpringDataWebProperties; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.data.domain.PageRequest; diff --git a/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/web/SpringDataWebWebMvcTestIntegrationTests.java b/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/web/SpringDataWebWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..36803e6a8da --- /dev/null +++ b/module/spring-boot-data-commons/src/test/java/org/springframework/boot/data/autoconfigure/web/SpringDataWebWebMvcTestIntegrationTests.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.data.autoconfigure.web; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.data.autoconfigure.web.SpringDataWebWebMvcTestIntegrationTests.PageableController; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.annotation.Import; +import org.springframework.data.domain.Pageable; +import org.springframework.test.web.servlet.assertj.MockMvcTester; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration tests for Spring Data Web and {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +@Import(PageableController.class) +class SpringDataWebWebMvcTestIntegrationTests { + + @Autowired + private MockMvcTester mvc; + + @Test + void shouldSupportPageable() { + assertThat(this.mvc.get().uri("/paged").param("page", "2").param("size", "42")).hasStatusOk() + .hasBodyTextEqualTo("2:42"); + } + + @RestController + @SpringBootConfiguration + static class PageableController { + + @GetMapping("/paged") + String paged(Pageable pageable) { + return String.format("%s:%s", pageable.getPageNumber(), pageable.getPageSize()); + } + + } + +} diff --git a/module/spring-boot-data-couchbase-test/build.gradle b/module/spring-boot-data-couchbase-test/build.gradle new file mode 100644 index 00000000000..8f250811df9 --- /dev/null +++ b/module/spring-boot-data-couchbase-test/build.gradle @@ -0,0 +1,38 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data Couchbase Test" + +dependencies { + api(project(":module:spring-boot-data-couchbase")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestIntegrationTests.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestIntegrationTests.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestIntegrationTests.java index d238a3fd15d..439aee99775 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestIntegrationTests.java +++ b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestIntegrationTests.java @@ -33,7 +33,7 @@ import org.springframework.data.couchbase.core.CouchbaseTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration test for {@link DataCouchbaseTest @DataCouchbaseTest}. diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestReactiveIntegrationTests.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestReactiveIntegrationTests.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestReactiveIntegrationTests.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestReactiveIntegrationTests.java diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithIncludeFilterIntegrationTests.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestWithIncludeFilterIntegrationTests.java diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleCouchbaseApplication.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleCouchbaseApplication.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleCouchbaseApplication.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleCouchbaseApplication.java diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleDocument.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleDocument.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleDocument.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleDocument.java diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleReactiveRepository.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleReactiveRepository.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleReactiveRepository.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleReactiveRepository.java diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleRepository.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleRepository.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleRepository.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleRepository.java diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleService.java b/module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleService.java similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleService.java rename to module/spring-boot-data-couchbase-test/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/couchbase/ExampleService.java diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/AutoConfigureDataCouchbase.java b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/AutoConfigureDataCouchbase.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/AutoConfigureDataCouchbase.java rename to module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/AutoConfigureDataCouchbase.java index 031aea998be..324ba8947db 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/AutoConfigureDataCouchbase.java +++ b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/AutoConfigureDataCouchbase.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.couchbase; +package org.springframework.boot.data.couchbase.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * rather than using this annotation directly. * * @author Eddú Meléndez - * @since 2.7.0 + * @since 4.0.0 * @see DataCouchbaseTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java rename to module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTest.java index 5f56fd6d43c..2296f6dcdb1 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTest.java +++ b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.couchbase; +package org.springframework.boot.data.couchbase.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -48,7 +47,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * {@code @RunWith(SpringRunner.class)}. * * @author Eddú Meléndez - * @since 2.7.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -58,7 +57,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataCouchbaseTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureDataCouchbase @ImportAutoConfiguration public @interface DataCouchbaseTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java rename to module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestContextBootstrapper.java index 3b9fc0e5ea9..3456f56f116 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestContextBootstrapper.java +++ b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.couchbase; +package org.springframework.boot.data.couchbase.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTypeExcludeFilter.java b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTypeExcludeFilter.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTypeExcludeFilter.java rename to module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTypeExcludeFilter.java index 96063311adc..85a1386effb 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTypeExcludeFilter.java +++ b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.couchbase; +package org.springframework.boot.data.couchbase.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/package-info.java b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/package-info.java rename to module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/package-info.java index c6ce2c327d1..efed8d659a0 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/couchbase/package-info.java +++ b/module/spring-boot-data-couchbase-test/src/main/java/org/springframework/boot/data/couchbase/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data Couchbase tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.couchbase; +package org.springframework.boot.data.couchbase.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports b/module/spring-boot-data-couchbase-test/src/main/resources/META-INF/spring/org.springframework.boot.data.couchbase.test.autoconfigure.AutoConfigureDataCouchbase.imports similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports rename to module/spring-boot-data-couchbase-test/src/main/resources/META-INF/spring/org.springframework.boot.data.couchbase.test.autoconfigure.AutoConfigureDataCouchbase.imports index 3248ffc4a4b..f91e7a43b7b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.couchbase.AutoConfigureDataCouchbase.imports +++ b/module/spring-boot-data-couchbase-test/src/main/resources/META-INF/spring/org.springframework.boot.data.couchbase.test.autoconfigure.AutoConfigureDataCouchbase.imports @@ -1,9 +1,7 @@ -# AutoConfigureDataCouchbase auto-configuration imports - +org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration org.springframework.boot.couchbase.autoconfigure.CouchbaseAutoConfiguration org.springframework.boot.data.couchbase.autoconfigure.CouchbaseDataAutoConfiguration org.springframework.boot.data.couchbase.autoconfigure.CouchbaseReactiveDataAutoConfiguration org.springframework.boot.data.couchbase.autoconfigure.CouchbaseReactiveRepositoriesAutoConfiguration org.springframework.boot.data.couchbase.autoconfigure.CouchbaseRepositoriesAutoConfiguration -org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-data-couchbase-test/src/test/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestApplication.java b/module/spring-boot-data-couchbase-test/src/test/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestApplication.java new file mode 100644 index 00000000000..946aabc9260 --- /dev/null +++ b/module/spring-boot-data-couchbase-test/src/test/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.data.couchbase.test.autoconfigure; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Application for testing of {@link DataCouchbaseTest @DataCouchbaseTest}. + * + * @author Andy Wilkinson + */ +@SpringBootApplication +class DataCouchbaseTestApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java b/module/spring-boot-data-couchbase-test/src/test/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java rename to module/spring-boot-data-couchbase-test/src/test/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestPropertiesIntegrationTests.java index 8938e8c868f..ce1862e7aa2 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/couchbase/DataCouchbaseTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-couchbase-test/src/test/java/org/springframework/boot/data/couchbase/test/autoconfigure/DataCouchbaseTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.couchbase; +package org.springframework.boot.data.couchbase.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-data-couchbase/build.gradle b/module/spring-boot-data-couchbase/build.gradle index 94732958ba3..44b14afae17 100644 --- a/module/spring-boot-data-couchbase/build.gradle +++ b/module/spring-boot-data-couchbase/build.gradle @@ -19,6 +19,7 @@ plugins { id "org.springframework.boot.auto-configuration" id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" id "org.springframework.boot.optional-dependencies" } diff --git a/module/spring-boot-data-elasticsearch-test/build.gradle b/module/spring-boot-data-elasticsearch-test/build.gradle new file mode 100644 index 00000000000..a1e0061a3fe --- /dev/null +++ b/module/spring-boot-data-elasticsearch-test/build.gradle @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data Elasticsearch Test" + +dependencies { + api(project(":module:spring-boot-data-elasticsearch")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-jackson")) + optional(project(":module:spring-boot-jsonb")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + dockerTestImplementation("io.projectreactor:reactor-test") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.testcontainers:elasticsearch") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:testcontainers") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestIntegrationTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestIntegrationTests.java index edd77ff0441..9cddef69865 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import java.util.UUID; @@ -33,7 +33,7 @@ import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Sample test for {@link DataElasticsearchTest @DataElasticsearchTest}. diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestPropertiesIntegrationTests.java index f56bb451015..35e4d72b828 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java index 4d62674ab32..ccc3ab2d2c6 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestReactiveIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import java.time.Duration; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java index 3a74d0b7ef6..ad6af437757 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestWithIncludeFilterIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import java.util.UUID; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleDocument.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleDocument.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java index ae269e54db3..9cca99ae960 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleDocument.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleDocument.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleElasticsearchApplication.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleElasticsearchApplication.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleElasticsearchApplication.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleElasticsearchApplication.java index 42df0ffa989..e09743e82d9 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleElasticsearchApplication.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleElasticsearchApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleReactiveRepository.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleReactiveRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleReactiveRepository.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleReactiveRepository.java index d18c863d178..554448d9626 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleReactiveRepository.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleReactiveRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleRepository.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleRepository.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleRepository.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleRepository.java index f22bf7717ea..83ce9522a0c 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleRepository.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java rename to module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java index 7031fbb3c3a..59ff347ec7f 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java +++ b/module/spring-boot-data-elasticsearch-test/src/dockerTest/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/ExampleService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/AutoConfigureDataElasticsearch.java b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/AutoConfigureDataElasticsearch.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/AutoConfigureDataElasticsearch.java rename to module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/AutoConfigureDataElasticsearch.java index 7c95e5fdc3e..57a44797a95 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/AutoConfigureDataElasticsearch.java +++ b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/AutoConfigureDataElasticsearch.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * directly. * * @author Eddú Meléndez - * @since 2.7.0 + * @since 4.0.0 * @see DataElasticsearchTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java rename to module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTest.java index c2baffec73d..fdd4ed4340c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTest.java +++ b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -48,7 +47,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * {@code @RunWith(SpringRunner.class)}. * * @author Eddú Meléndez - * @since 2.7.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -58,7 +57,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataElasticsearchTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureDataElasticsearch @ImportAutoConfiguration public @interface DataElasticsearchTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java rename to module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestContextBootstrapper.java index f3afdc781e7..9f362023b7e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestContextBootstrapper.java +++ b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTypeExcludeFilter.java b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTypeExcludeFilter.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTypeExcludeFilter.java rename to module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTypeExcludeFilter.java index ebbd5fc02df..e5baaeac780 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTypeExcludeFilter.java +++ b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/DataElasticsearchTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/package-info.java b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/package-info.java rename to module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/package-info.java index 38dfd4e6334..e10f5fe5c55 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/package-info.java +++ b/module/spring-boot-data-elasticsearch-test/src/main/java/org/springframework/boot/data/elasticsearch/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data Elasticsearch tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.elasticsearch; +package org.springframework.boot.data.elasticsearch.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports b/module/spring-boot-data-elasticsearch-test/src/main/resources/META-INF/spring/org.springframework.boot.data.elasticsearch.test.autoconfigure.AutoConfigureDataElasticsearch.imports similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports rename to module/spring-boot-data-elasticsearch-test/src/main/resources/META-INF/spring/org.springframework.boot.data.elasticsearch.test.autoconfigure.AutoConfigureDataElasticsearch.imports index fdf9a3cfd60..c35ec73221d 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.elasticsearch.AutoConfigureDataElasticsearch.imports +++ b/module/spring-boot-data-elasticsearch-test/src/main/resources/META-INF/spring/org.springframework.boot.data.elasticsearch.test.autoconfigure.AutoConfigureDataElasticsearch.imports @@ -1,11 +1,10 @@ -# AutoConfigureDataElasticsearch auto-configuration imports -org.springframework.boot.data.elasticsearch.autoconfigure.ElasticsearchRepositoriesAutoConfiguration +org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration org.springframework.boot.data.elasticsearch.autoconfigure.ElasticsearchDataAutoConfiguration org.springframework.boot.data.elasticsearch.autoconfigure.ElasticsearchReactiveRepositoriesAutoConfiguration +org.springframework.boot.data.elasticsearch.autoconfigure.ElasticsearchRepositoriesAutoConfiguration org.springframework.boot.elasticsearch.autoconfigure.ElasticsearchClientAutoConfiguration -org.springframework.boot.elasticsearch.autoconfigure.ElasticsearchRestClientAutoConfiguration org.springframework.boot.elasticsearch.autoconfigure.ElasticsearchReactiveClientAutoConfiguration -org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration +org.springframework.boot.elasticsearch.autoconfigure.ElasticsearchRestClientAutoConfiguration org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration optional:org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-data-jdbc-test/build.gradle b/module/spring-boot-data-jdbc-test/build.gradle new file mode 100644 index 00000000000..d9534cd7d81 --- /dev/null +++ b/module/spring-boot-data-jdbc-test/build.gradle @@ -0,0 +1,42 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data JDBC Test" + +dependencies { + api(project(":module:spring-boot-data-jdbc")) + api(project(":module:spring-boot-jdbc-test")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("com.h2database:h2") + testRuntimeOnly("org.hsqldb:hsqldb") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/AutoConfigureDataJdbc.java b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/AutoConfigureDataJdbc.java similarity index 88% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/AutoConfigureDataJdbc.java rename to module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/AutoConfigureDataJdbc.java index 10fdd7a2845..7c0a4d7131a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/AutoConfigureDataJdbc.java +++ b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/AutoConfigureDataJdbc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc; /** * {@link ImportAutoConfiguration Auto-configuration imports} for typical Data JDBC tests. @@ -31,13 +32,14 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * this annotation directly. * * @author Andy Wilkinson - * @since 2.1.0 + * @since 4.0.0 * @see DataJdbcTest */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited +@AutoConfigureJdbc @ImportAutoConfiguration public @interface AutoConfigureDataJdbc { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTest.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java rename to module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTest.java index f9e8fd42a46..daf3a5e734c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTest.java +++ b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -27,10 +27,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -62,7 +61,7 @@ import org.springframework.transaction.annotation.Transactional; * {@code @RunWith(SpringRunner.class)}. * * @author Andy Wilkinson - * @since 2.1.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -73,7 +72,6 @@ import org.springframework.transaction.annotation.Transactional; @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataJdbcTypeExcludeFilter.class) @Transactional -@AutoConfigureCache @AutoConfigureDataJdbc @AutoConfigureTestDatabase @ImportAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java rename to module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestContextBootstrapper.java index eb1d0792d2a..c2eaa118347 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestContextBootstrapper.java +++ b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilter.java b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTypeExcludeFilter.java similarity index 82% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilter.java rename to module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTypeExcludeFilter.java index 0ca435fc857..c3b3dbc9636 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilter.java +++ b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import java.util.Collections; import java.util.Set; @@ -28,19 +28,19 @@ import org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration * * @author Andy Wilkinson * @author Ravi Undupitiya - * @since 2.2.1 + * @since 4.0.0 */ public final class DataJdbcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { - private static final Set> DEFAULT_INCLUDES = Collections.singleton(AbstractJdbcConfiguration.class); + private static final Set> KNOWN_INCLUDES = Collections.singleton(AbstractJdbcConfiguration.class); DataJdbcTypeExcludeFilter(Class testClass) { super(testClass); } @Override - protected Set> getDefaultIncludes() { - return DEFAULT_INCLUDES; + protected Set> getKnownIncludes() { + return KNOWN_INCLUDES; } } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/package-info.java b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/package-info.java rename to module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/package-info.java index fe0bb75b0bb..d7aef0b00f3 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/jdbc/package-info.java +++ b/module/spring-boot-data-jdbc-test/src/main/java/org/springframework/boot/data/jdbc/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data JDBC tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-data-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.data.jdbc.test.autoconfigure.AutoConfigureDataJdbc.imports b/module/spring-boot-data-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.data.jdbc.test.autoconfigure.AutoConfigureDataJdbc.imports new file mode 100644 index 00000000000..8594a630c36 --- /dev/null +++ b/module/spring-boot-data-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.data.jdbc.test.autoconfigure.AutoConfigureDataJdbc.imports @@ -0,0 +1 @@ +org.springframework.boot.data.jdbc.autoconfigure.JdbcRepositoriesAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestIntegrationTests.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestIntegrationTests.java similarity index 77% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestIntegrationTests.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestIntegrationTests.java index 926d51296d8..6d468ad7f4d 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestIntegrationTests.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import javax.sql.DataSource; @@ -22,8 +22,6 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; -import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.jdbc.core.JdbcTemplate; @@ -31,7 +29,7 @@ import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration tests for {@link DataJdbcTest @DataJdbcTest}. @@ -40,7 +38,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor */ @DataJdbcTest @TestPropertySource( - properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/test/autoconfigure/data/jdbc/schema.sql") + properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/data/jdbc/test/autoconfigure/schema.sql") class DataJdbcTestIntegrationTests { @Autowired @@ -74,16 +72,6 @@ class DataJdbcTestIntegrationTests { .isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class)); } - @Test - void flywayAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(FlywayAutoConfiguration.class)); - } - - @Test - void liquibaseAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(LiquibaseAutoConfiguration.class)); - } - @Test void serviceConnectionAutoConfigurationWasImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(ServiceConnectionAutoConfiguration.class)); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestPropertiesIntegrationTests.java index 1195734101c..8df8070d4e2 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilterTests.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTypeExcludeFilterTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilterTests.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTypeExcludeFilterTests.java index 930a428b78f..593ed567161 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/DataJdbcTypeExcludeFilterTests.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/DataJdbcTypeExcludeFilterTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import java.io.IOException; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleComponent.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleComponent.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleComponent.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleComponent.java index 299bf9c9593..136572d1d02 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleComponent.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleComponent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import org.springframework.stereotype.Component; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleDataJdbcApplication.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleDataJdbcApplication.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleDataJdbcApplication.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleDataJdbcApplication.java index 08ed06f0970..07ebe62f1ef 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleDataJdbcApplication.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleDataJdbcApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleEntity.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleEntity.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleEntity.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleEntity.java index 68c4d8ff7fe..9e51129494f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleEntity.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleEntity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.Table; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleRepository.java b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleRepository.java rename to module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleRepository.java index 90b809e8299..93bfe79e3ee 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/jdbc/ExampleRepository.java +++ b/module/spring-boot-data-jdbc-test/src/test/java/org/springframework/boot/data/jdbc/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.jdbc; +package org.springframework.boot.data.jdbc.test.autoconfigure; import org.springframework.data.repository.CrudRepository; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/jdbc/schema.sql b/module/spring-boot-data-jdbc-test/src/test/resources/org/springframework/boot/data/jdbc/test/autoconfigure/schema.sql similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/jdbc/schema.sql rename to module/spring-boot-data-jdbc-test/src/test/resources/org/springframework/boot/data/jdbc/test/autoconfigure/schema.sql diff --git a/module/spring-boot-data-jpa-test/build.gradle b/module/spring-boot-data-jpa-test/build.gradle new file mode 100644 index 00000000000..b10eed79c66 --- /dev/null +++ b/module/spring-boot-data-jpa-test/build.gradle @@ -0,0 +1,43 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data JPA Test" + +dependencies { + api(project(":module:spring-boot-data-jpa")) + api(project(":module:spring-boot-jdbc-test")) + api(project(":module:spring-boot-jpa-test")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("com.h2database:h2") + testRuntimeOnly("org.hsqldb:hsqldb") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/AutoConfigureDataJpa.java similarity index 88% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java rename to module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/AutoConfigureDataJpa.java index acc842b52b8..dfd4f7d0579 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureDataJpa.java +++ b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/AutoConfigureDataJpa.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc; /** * {@link ImportAutoConfiguration Auto-configuration imports} for typical Data JPA tests. @@ -32,13 +33,14 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * * @author Phillip Webb * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 * @see DataJpaTest */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited +@AutoConfigureJdbc @ImportAutoConfiguration public @interface AutoConfigureDataJpa { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java rename to module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java index 62dc4fcc8a8..e14dec4be81 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTest.java +++ b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -27,10 +27,11 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; +import org.springframework.boot.jpa.test.autoconfigure.AutoConfigureTestEntityManager; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan.Filter; @@ -69,11 +70,10 @@ import org.springframework.transaction.annotation.Transactional; * @author Phillip Webb * @author Artsiom Yudovin * @author Scott Frederick - * @since 1.4.0 + * @since 4.0.0 * @see AutoConfigureDataJpa * @see AutoConfigureTestDatabase * @see AutoConfigureTestEntityManager - * @see AutoConfigureCache */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -84,8 +84,8 @@ import org.springframework.transaction.annotation.Transactional; @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataJpaTypeExcludeFilter.class) @Transactional -@AutoConfigureCache @AutoConfigureDataJpa +@AutoConfigureJdbc @AutoConfigureTestDatabase @AutoConfigureTestEntityManager @ImportAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java rename to module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestContextBootstrapper.java index 6a7dd5a9893..d70a52aae9e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestContextBootstrapper.java +++ b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTypeExcludeFilter.java b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTypeExcludeFilter.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTypeExcludeFilter.java rename to module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTypeExcludeFilter.java index 652afbd71e9..e3b4a4ea211 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTypeExcludeFilter.java +++ b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; @@ -23,7 +23,7 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust * {@link TypeExcludeFilter} for {@link DataJpaTest @DataJpaTest}. * * @author Phillip Webb - * @since 2.2.1 + * @since 4.0.0 */ public final class DataJpaTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/package-info.java b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/package-info.java rename to module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/package-info.java index 5b0d4b8c8d1..bd0682e6718 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/package-info.java +++ b/module/spring-boot-data-jpa-test/src/main/java/org/springframework/boot/data/jpa/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data JPA tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-data-jpa-test/src/main/resources/META-INF/spring/org.springframework.boot.data.jpa.test.autoconfigure.AutoConfigureDataJpa.imports b/module/spring-boot-data-jpa-test/src/main/resources/META-INF/spring/org.springframework.boot.data.jpa.test.autoconfigure.AutoConfigureDataJpa.imports new file mode 100644 index 00000000000..5bfab1758cf --- /dev/null +++ b/module/spring-boot-data-jpa-test/src/main/resources/META-INF/spring/org.springframework.boot.data.jpa.test.autoconfigure.AutoConfigureDataJpa.imports @@ -0,0 +1,2 @@ +org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration +org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestAttributesIntegrationTests.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestAttributesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestAttributesIntegrationTests.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestAttributesIntegrationTests.java index e77d79df773..9fbec8b4e14 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestAttributesIntegrationTests.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestAttributesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestIntegrationTests.java similarity index 85% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestIntegrationTests.java index 9ac8c052efb..71222a447d4 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import javax.sql.DataSource; @@ -22,8 +22,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; -import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration; +import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager; import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.data.repository.config.BootstrapMode; @@ -32,7 +31,7 @@ import org.springframework.jdbc.core.simple.JdbcClient; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration tests for {@link DataJpaTest @DataJpaTest}. @@ -105,16 +104,6 @@ class DataJpaTestIntegrationTests { .isThrownBy(() -> this.applicationContext.getBean(ExampleComponent.class)); } - @Test - void flywayAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(FlywayAutoConfiguration.class)); - } - - @Test - void liquibaseAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(LiquibaseAutoConfiguration.class)); - } - @Test void serviceConnectionAutoConfigurationWasImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(ServiceConnectionAutoConfiguration.class)); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestPropertiesIntegrationTests.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestPropertiesIntegrationTests.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestPropertiesIntegrationTests.java index bf2967c81bd..a1fe3911328 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestSchemaCredentialsIntegrationTests.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestSchemaCredentialsIntegrationTests.java index 509125b4b2b..ebd25ad8cd6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/DataJpaTestSchemaCredentialsIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import javax.sql.DataSource; @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Andy Wilkinson */ @DataJpaTest(properties = { "spring.sql.init.username=alice", "spring.sql.init.password=secret", - "spring.sql.init.schema-locations=classpath:org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql" }) + "spring.sql.init.schema-locations=classpath:org/springframework/boot/data/jpa/test/autoconfigure/schema.sql" }) class DataJpaTestSchemaCredentialsIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleComponent.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleComponent.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleComponent.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleComponent.java index 24c1a11fcf8..78eb9faf496 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleComponent.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleComponent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.springframework.stereotype.Component; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleDataJpaApplication.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleDataJpaApplication.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleDataJpaApplication.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleDataJpaApplication.java index 0c4b516c79a..029843e08dc 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleDataJpaApplication.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleDataJpaApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleEntity.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleEntity.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleEntity.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleEntity.java index bd034f5546d..0b470be41d2 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleEntity.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleEntity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleRepository.java b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleRepository.java rename to module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleRepository.java index d7228d8ed12..986c6c3ca84 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/ExampleRepository.java +++ b/module/spring-boot-data-jpa-test/src/test/java/org/springframework/boot/data/jpa/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.data.jpa.test.autoconfigure; import org.springframework.data.repository.Repository; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql b/module/spring-boot-data-jpa-test/src/test/resources/org/springframework/boot/data/jpa/test/autoconfigure/schema.sql similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql rename to module/spring-boot-data-jpa-test/src/test/resources/org/springframework/boot/data/jpa/test/autoconfigure/schema.sql diff --git a/module/spring-boot-data-ldap-test/build.gradle b/module/spring-boot-data-ldap-test/build.gradle new file mode 100644 index 00000000000..83e7fc96237 --- /dev/null +++ b/module/spring-boot-data-ldap-test/build.gradle @@ -0,0 +1,48 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data LDAP Test" + +dependencies { + api(project(":module:spring-boot-data-ldap")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + dockerTestImplementation("org.assertj:assertj-core") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:testcontainers") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation("com.unboundid:unboundid-ldapsdk") + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestDockerTests.java b/module/spring-boot-data-ldap-test/src/dockerTest/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestDockerTests.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestDockerTests.java rename to module/spring-boot-data-ldap-test/src/dockerTest/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestDockerTests.java index 1e9599d48a8..36d489c9a1a 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestDockerTests.java +++ b/module/spring-boot-data-ldap-test/src/dockerTest/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestDockerTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import java.util.List; @@ -33,7 +33,7 @@ import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.query.LdapQueryBuilder; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Sample test for {@link DataLdapTest @DataLdapTest}. diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/AutoConfigureDataLdap.java b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/AutoConfigureDataLdap.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/AutoConfigureDataLdap.java rename to module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/AutoConfigureDataLdap.java index fb7e13573ac..f39b45a6478 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/AutoConfigureDataLdap.java +++ b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/AutoConfigureDataLdap.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * this annotation directly. * * @author Eddú Meléndez - * @since 2.0.0 + * @since 4.0.0 * @see DataLdapTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java rename to module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTest.java index 52edad4fc08..1cac04c6792 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTest.java +++ b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -52,7 +51,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * * @author Eddú Meléndez * @author Artsiom Yudovin - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -62,7 +61,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataLdapTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureDataLdap @ImportAutoConfiguration public @interface DataLdapTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java rename to module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestContextBootstrapper.java index 6e71c3c783f..9d11b35c0ce 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestContextBootstrapper.java +++ b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTypeExcludeFilter.java b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTypeExcludeFilter.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTypeExcludeFilter.java rename to module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTypeExcludeFilter.java index 6a554886493..8d58ffa5bc3 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTypeExcludeFilter.java +++ b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; @@ -23,7 +23,7 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust * {@link TypeExcludeFilter} for {@link DataLdapTest @DataLdapTest}. * * @author Eddú Meléndez - * @since 2.2.1 + * @since 4.0.0 */ public final class DataLdapTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/package-info.java b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/package-info.java rename to module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/package-info.java index 08244bb4d0c..3ec86390a5b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/ldap/package-info.java +++ b/module/spring-boot-data-ldap-test/src/main/java/org/springframework/boot/data/ldap/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data LDAP tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.ldap.AutoConfigureDataLdap.imports b/module/spring-boot-data-ldap-test/src/main/resources/META-INF/spring/org.springframework.boot.data.ldap.test.autoconfigure.AutoConfigureDataLdap.imports similarity index 76% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.ldap.AutoConfigureDataLdap.imports rename to module/spring-boot-data-ldap-test/src/main/resources/META-INF/spring/org.springframework.boot.data.ldap.test.autoconfigure.AutoConfigureDataLdap.imports index 940387e7d10..291311980bc 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.ldap.AutoConfigureDataLdap.imports +++ b/module/spring-boot-data-ldap-test/src/main/resources/META-INF/spring/org.springframework.boot.data.ldap.test.autoconfigure.AutoConfigureDataLdap.imports @@ -1,5 +1,4 @@ -# AutoConfigureDataLdap auto-configuration imports org.springframework.boot.data.ldap.autoconfigure.LdapRepositoriesAutoConfiguration org.springframework.boot.ldap.autoconfigure.LdapAutoConfiguration org.springframework.boot.ldap.autoconfigure.embedded.EmbeddedLdapAutoConfiguration -optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration \ No newline at end of file +optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestIntegrationTests.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestIntegrationTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestIntegrationTests.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestIntegrationTests.java index efd66379fdf..d163c44f566 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestIntegrationTests.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import java.util.Optional; @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; */ @DataLdapTest @TestPropertySource(properties = { "spring.ldap.embedded.base-dn=dc=spring,dc=org", - "spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif" }) + "spring.ldap.embedded.ldif=classpath:org/springframework/boot/data/ldap/test/autoconfigure/schema.ldif" }) class DataLdapTestIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestPropertiesIntegrationTests.java index 09e17228bdf..27017686bab 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestWithIncludeFilterIntegrationTests.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestWithIncludeFilterIntegrationTests.java index 243cb51c49a..e620b34b2e3 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/DataLdapTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/DataLdapTestWithIncludeFilterIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.junit.jupiter.api.Test; @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @DataLdapTest(includeFilters = @Filter(Service.class)) @TestPropertySource(properties = { "spring.ldap.embedded.base-dn=dc=spring,dc=org", - "spring.ldap.embedded.ldif=classpath:org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif" }) + "spring.ldap.embedded.ldif=classpath:org/springframework/boot/data/ldap/test/autoconfigure/schema.ldif" }) class DataLdapTestWithIncludeFilterIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleEntry.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleEntry.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleEntry.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleEntry.java index bbae49229b3..a59ff35ef90 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleEntry.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleEntry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import javax.naming.Name; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleLdapApplication.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleLdapApplication.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleLdapApplication.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleLdapApplication.java index 8c9ce508c62..11fac36a3ef 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleLdapApplication.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleLdapApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleRepository.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleRepository.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleRepository.java index 42232550b93..8014dac05aa 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleRepository.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.springframework.data.ldap.repository.LdapRepository; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleService.java b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleService.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleService.java rename to module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleService.java index cc7b77e5176..dc29be0e24c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/ldap/ExampleService.java +++ b/module/spring-boot-data-ldap-test/src/test/java/org/springframework/boot/data/ldap/test/autoconfigure/ExampleService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.ldap; +package org.springframework.boot.data.ldap.test.autoconfigure; import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.query.LdapQuery; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif b/module/spring-boot-data-ldap-test/src/test/resources/org/springframework/boot/data/ldap/test/autoconfigure/schema.ldif similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/ldap/schema.ldif rename to module/spring-boot-data-ldap-test/src/test/resources/org/springframework/boot/data/ldap/test/autoconfigure/schema.ldif diff --git a/module/spring-boot-data-mongodb-test/build.gradle b/module/spring-boot-data-mongodb-test/build.gradle new file mode 100644 index 00000000000..de5df5ec768 --- /dev/null +++ b/module/spring-boot-data-mongodb-test/build.gradle @@ -0,0 +1,52 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data MongoDB Test" + +dependencies { + api(project(":module:spring-boot-data-mongodb")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-mongodb")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + dockerTestImplementation("io.projectreactor:reactor-core") + dockerTestImplementation("org.assertj:assertj-core") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.mongodb:mongodb-driver-reactivestreams") + dockerTestImplementation("org.mongodb:mongodb-driver-sync") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:mongodb") + dockerTestImplementation("org.testcontainers:testcontainers") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestIntegrationTests.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestIntegrationTests.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestIntegrationTests.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestIntegrationTests.java index c04d629bd07..66f5bfb0c58 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestIntegrationTests.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.junit.jupiter.api.Test; import org.testcontainers.containers.MongoDBContainer; @@ -31,7 +31,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Sample test for {@link DataMongoTest @DataMongoTest}. diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestReactiveIntegrationTests.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestReactiveIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestReactiveIntegrationTests.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestReactiveIntegrationTests.java index 82f893b41fb..81aa0052b9e 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestReactiveIntegrationTests.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestReactiveIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import java.time.Duration; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestWithIncludeFilterIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestWithIncludeFilterIntegrationTests.java index 89ee1b65025..29115e14d9d 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestWithIncludeFilterIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.junit.jupiter.api.Test; import org.testcontainers.containers.MongoDBContainer; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleDocument.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleDocument.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleDocument.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleDocument.java index 848a8809554..dc87d4a101c 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleDocument.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleDocument.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.springframework.data.mongodb.core.mapping.Document; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleReactiveRepository.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleReactiveRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleReactiveRepository.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleReactiveRepository.java index be0a73c21ad..feb5a4c4ab1 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleReactiveRepository.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleReactiveRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.springframework.data.mongodb.repository.ReactiveMongoRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleRepository.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleRepository.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleRepository.java index 0d783d54b34..22e6a4165b4 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleRepository.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.springframework.data.mongodb.repository.MongoRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleService.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleService.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleService.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleService.java index 907c0ddca61..f3dd8e24a53 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleService.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/ExampleService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/TransactionalDataMongoTestIntegrationTests.java b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/TransactionalDataMongoTestIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/TransactionalDataMongoTestIntegrationTests.java rename to module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/TransactionalDataMongoTestIntegrationTests.java index 4520d9f9146..fa82c6a285e 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/TransactionalDataMongoTestIntegrationTests.java +++ b/module/spring-boot-data-mongodb-test/src/dockerTest/java/org/springframework/boot/data/mongodb/test/autoconfigure/TransactionalDataMongoTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.junit.jupiter.api.Test; import org.testcontainers.containers.MongoDBContainer; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/AutoConfigureDataMongo.java b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/AutoConfigureDataMongo.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/AutoConfigureDataMongo.java rename to module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/AutoConfigureDataMongo.java index 51c0e46f70f..a9a4d81500b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/AutoConfigureDataMongo.java +++ b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/AutoConfigureDataMongo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * than using this annotation directly. * * @author Michael Simons - * @since 1.5.0 + * @since 4.0.0 * @see DataMongoTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java rename to module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTest.java index 08ddff1d2dd..3464624148e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTest.java +++ b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -50,7 +49,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * @author Michael Simons * @author Stephane Nicoll * @author Artsiom Yudovin - * @since 1.5.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -60,7 +59,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataMongoTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureDataMongo @ImportAutoConfiguration public @interface DataMongoTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java rename to module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestContextBootstrapper.java index aafee3ddd29..6183420f1d4 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestContextBootstrapper.java +++ b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTypeExcludeFilter.java b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTypeExcludeFilter.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTypeExcludeFilter.java rename to module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTypeExcludeFilter.java index 107a35f4fef..1702b4ab497 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTypeExcludeFilter.java +++ b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; @@ -23,7 +23,7 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust * {@link TypeExcludeFilter} for {@link DataMongoTest @DataMongoTest}. * * @author Michael Simons - * @since 2.2.1 + * @since 4.0.0 */ public final class DataMongoTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/package-info.java b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/package-info.java rename to module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/package-info.java index d69f90a45cd..88d4ab6cd84 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/mongo/package-info.java +++ b/module/spring-boot-data-mongodb-test/src/main/java/org/springframework/boot/data/mongodb/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data Mongo tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports b/module/spring-boot-data-mongodb-test/src/main/resources/META-INF/spring/org.springframework.boot.data.mongodb.test.autoconfigure.AutoConfigureDataMongo.imports similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports rename to module/spring-boot-data-mongodb-test/src/main/resources/META-INF/spring/org.springframework.boot.data.mongodb.test.autoconfigure.AutoConfigureDataMongo.imports index 6b03f9a6e94..b7fc7e185b6 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo.imports +++ b/module/spring-boot-data-mongodb-test/src/main/resources/META-INF/spring/org.springframework.boot.data.mongodb.test.autoconfigure.AutoConfigureDataMongo.imports @@ -1,4 +1,3 @@ -# AutoConfigureDataMongo auto-configuration imports org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration diff --git a/module/spring-boot-data-mongodb-test/src/test/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestApplication.java b/module/spring-boot-data-mongodb-test/src/test/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestApplication.java new file mode 100644 index 00000000000..aee3c6cca5a --- /dev/null +++ b/module/spring-boot-data-mongodb-test/src/test/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.data.mongodb.test.autoconfigure; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Test application for testing {@link DataMongoTest @DataMongoTest}. + * + * @author Michael Simons + */ +@SpringBootApplication +public class DataMongoTestApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java b/module/spring-boot-data-mongodb-test/src/test/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java rename to module/spring-boot-data-mongodb-test/src/test/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestPropertiesIntegrationTests.java index c288235a97c..83472a48c4e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-mongodb-test/src/test/java/org/springframework/boot/data/mongodb/test/autoconfigure/DataMongoTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.data.mongodb.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-data-neo4j-test/build.gradle b/module/spring-boot-data-neo4j-test/build.gradle new file mode 100644 index 00000000000..7520ffe3a40 --- /dev/null +++ b/module/spring-boot-data-neo4j-test/build.gradle @@ -0,0 +1,49 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data Neo4j Test" + +dependencies { + api(project(":module:spring-boot-data-neo4j")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + dockerTestImplementation("io.projectreactor:reactor-test") + dockerTestImplementation("org.assertj:assertj-core") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:neo4j") + dockerTestImplementation("org.testcontainers:testcontainers") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestIntegrationTests.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestIntegrationTests.java index c387dbaf40e..5d360ef9b16 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.junit.jupiter.api.Test; import org.testcontainers.containers.Neo4jContainer; @@ -31,7 +31,7 @@ import org.springframework.data.neo4j.core.Neo4jTemplate; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration test for {@link DataNeo4jTest @DataNeo4jTest}. diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestPropertiesIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestPropertiesIntegrationTests.java index 63259733d84..7efa67eafb7 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestReactiveIntegrationTests.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestReactiveIntegrationTests.java index e66b83af2e2..b7f1f88feaa 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestReactiveIntegrationTests.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestReactiveIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import java.time.Duration; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestWithIncludeFilterIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestWithIncludeFilterIntegrationTests.java index 84c0c26ff03..a633d267218 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestWithIncludeFilterIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.junit.jupiter.api.Test; import org.testcontainers.containers.Neo4jContainer; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleGraph.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleGraph.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleGraph.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleGraph.java index a31b9c152bb..0f946bb52c3 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleGraph.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleGraph.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.data.neo4j.core.schema.GeneratedValue; import org.springframework.data.neo4j.core.schema.Id; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleNeo4jApplication.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleNeo4jApplication.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleNeo4jApplication.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleNeo4jApplication.java index 90e7eac4202..e7fab4eafc6 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleNeo4jApplication.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleNeo4jApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleReactiveRepository.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleReactiveRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleReactiveRepository.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleReactiveRepository.java index cd725cb47c1..734487c286a 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleReactiveRepository.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleReactiveRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleRepository.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleRepository.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleRepository.java index f3f51bc9304..3e39e545806 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleRepository.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.data.neo4j.repository.Neo4jRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleService.java b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleService.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleService.java rename to module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleService.java index 45df432653f..b37ce330220 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleService.java +++ b/module/spring-boot-data-neo4j-test/src/dockerTest/java/org/springframework/boot/data/neo4j/test/autoconfigure/ExampleService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.data.neo4j.core.Neo4jTemplate; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/AutoConfigureDataNeo4j.java b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/AutoConfigureDataNeo4j.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/AutoConfigureDataNeo4j.java rename to module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/AutoConfigureDataNeo4j.java index 6a79391118a..50118647816 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/AutoConfigureDataNeo4j.java +++ b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/AutoConfigureDataNeo4j.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * than using this annotation directly. * * @author Eddú Meléndez - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java rename to module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTest.java index 15706667085..e1aa65cb457 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTest.java +++ b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -56,7 +55,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Eddú Meléndez * @author Stephane Nicoll * @author Artsiom Yudovin - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -67,7 +66,6 @@ import org.springframework.transaction.annotation.Transactional; @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataNeo4jTypeExcludeFilter.class) @Transactional -@AutoConfigureCache @AutoConfigureDataNeo4j @ImportAutoConfiguration public @interface DataNeo4jTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java rename to module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestContextBootstrapper.java index 721325f232a..79d63768e4d 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestContextBootstrapper.java +++ b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTypeExcludeFilter.java b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTypeExcludeFilter.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTypeExcludeFilter.java rename to module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTypeExcludeFilter.java index ec96eb84ba4..8b617a0f2ca 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTypeExcludeFilter.java +++ b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/DataNeo4jTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; @@ -23,7 +23,7 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust * {@link TypeExcludeFilter} for {@link DataNeo4jTest @DataNeo4jTest}. * * @author Eddú Meléndez - * @since 2.2.1 + * @since 4.0.0 */ public final class DataNeo4jTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/package-info.java b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/package-info.java rename to module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/package-info.java index 8ed23c35b67..ab9430cbafc 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/neo4j/package-info.java +++ b/module/spring-boot-data-neo4j-test/src/main/java/org/springframework/boot/data/neo4j/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data Neo4j tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.neo4j; +package org.springframework.boot.data.neo4j.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports b/module/spring-boot-data-neo4j-test/src/main/resources/META-INF/spring/org.springframework.boot.data.neo4j.test.autoconfigure.AutoConfigureDataNeo4j.imports similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports rename to module/spring-boot-data-neo4j-test/src/main/resources/META-INF/spring/org.springframework.boot.data.neo4j.test.autoconfigure.AutoConfigureDataNeo4j.imports index 53828c04f74..264332f283a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.neo4j.AutoConfigureDataNeo4j.imports +++ b/module/spring-boot-data-neo4j-test/src/main/resources/META-INF/spring/org.springframework.boot.data.neo4j.test.autoconfigure.AutoConfigureDataNeo4j.imports @@ -1,8 +1,7 @@ -# AutoConfigureDataNeo4j auto-configuration imports -org.springframework.boot.neo4j.autoconfigure.Neo4jAutoConfiguration org.springframework.boot.data.neo4j.autoconfigure.Neo4jDataAutoConfiguration org.springframework.boot.data.neo4j.autoconfigure.Neo4jReactiveDataAutoConfiguration org.springframework.boot.data.neo4j.autoconfigure.Neo4jReactiveRepositoriesAutoConfiguration org.springframework.boot.data.neo4j.autoconfigure.Neo4jRepositoriesAutoConfiguration +org.springframework.boot.neo4j.autoconfigure.Neo4jAutoConfiguration org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-data-r2dbc-test/build.gradle b/module/spring-boot-data-r2dbc-test/build.gradle new file mode 100644 index 00000000000..d44dca9f38a --- /dev/null +++ b/module/spring-boot-data-r2dbc-test/build.gradle @@ -0,0 +1,42 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data R2DBC Test" + +dependencies { + api(project(":module:spring-boot-data-r2dbc")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional(project(":module:spring-boot-jdbc-test")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + testImplementation("io.projectreactor:reactor-test") + testImplementation("io.r2dbc:r2dbc-h2") + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/AutoConfigureDataR2dbc.java b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/AutoConfigureDataR2dbc.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/AutoConfigureDataR2dbc.java rename to module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/AutoConfigureDataR2dbc.java index 744ce95ae86..fd81ed506c3 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/AutoConfigureDataR2dbc.java +++ b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/AutoConfigureDataR2dbc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization; /** * {@link ImportAutoConfiguration Auto-configuration imports} for typical Data R2DBC @@ -32,12 +33,13 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * * @author Mark Paluch * @see DataR2dbcTest - * @since 2.3.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited +@AutoConfigureDataSourceInitialization @ImportAutoConfiguration public @interface AutoConfigureDataR2dbc { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTest.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java rename to module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTest.java index dfb3f7ccfa5..cade199806c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTest.java +++ b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -48,7 +48,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * * @author Mark Paluch * @author Stephane Nicoll - * @since 2.3.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java rename to module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestContextBootstrapper.java index 4d69be5b8e2..a76100dcdfa 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestContextBootstrapper.java +++ b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTypeExcludeFilter.java b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTypeExcludeFilter.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTypeExcludeFilter.java rename to module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTypeExcludeFilter.java index 38af1368f9a..fd9651c4970 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTypeExcludeFilter.java +++ b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/package-info.java b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/package-info.java rename to module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/package-info.java index 33088559acb..839c5053e72 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/r2dbc/package-info.java +++ b/module/spring-boot-data-r2dbc-test/src/main/java/org/springframework/boot/data/r2dbc/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data R2DBC tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports b/module/spring-boot-data-r2dbc-test/src/main/resources/META-INF/spring/org.springframework.boot.data.r2dbc.test.autoconfigure.AutoConfigureDataR2dbc.imports similarity index 72% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports rename to module/spring-boot-data-r2dbc-test/src/main/resources/META-INF/spring/org.springframework.boot.data.r2dbc.test.autoconfigure.AutoConfigureDataR2dbc.imports index 7e81d4dce18..ecf95124aaa 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.r2dbc.AutoConfigureDataR2dbc.imports +++ b/module/spring-boot-data-r2dbc-test/src/main/resources/META-INF/spring/org.springframework.boot.data.r2dbc.test.autoconfigure.AutoConfigureDataR2dbc.imports @@ -1,10 +1,7 @@ -# AutoConfigureDataR2dbc auto-configuration imports -org.springframework.boot.data.r2dbc.autoconfigure.R2dbcRepositoriesAutoConfiguration org.springframework.boot.data.r2dbc.autoconfigure.R2dbcDataAutoConfiguration +org.springframework.boot.data.r2dbc.autoconfigure.R2dbcRepositoriesAutoConfiguration org.springframework.boot.r2dbc.autoconfigure.R2dbcAutoConfiguration org.springframework.boot.r2dbc.autoconfigure.R2dbcInitializationAutoConfiguration org.springframework.boot.r2dbc.autoconfigure.R2dbcTransactionManagerAutoConfiguration org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration -optional:org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration -optional:org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestIntegrationTests.java b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestIntegrationTests.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestIntegrationTests.java rename to module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestIntegrationTests.java index 37f85dd77cf..f165b7dbf5a 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestIntegrationTests.java +++ b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import java.time.Duration; import java.util.Map; @@ -30,7 +30,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.r2dbc.core.DatabaseClient; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration tests for {@link DataR2dbcTest}. @@ -38,7 +38,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor * @author Mark Paluch */ @DataR2dbcTest( - properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/test/autoconfigure/data/r2dbc/schema.sql") + properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/data/r2dbc/test/autoconfigure/schema.sql") class DataR2dbcTestIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java rename to module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestPropertiesIntegrationTests.java index e24a5fb8e85..9f41202fb92 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/DataR2dbcTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/DataR2dbcTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/Example.java b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/Example.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/Example.java rename to module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/Example.java index 3eba6c0cad5..98ee862d4de 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/Example.java +++ b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/Example.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.Table; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/ExampleR2dbcApplication.java b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/ExampleR2dbcApplication.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/ExampleR2dbcApplication.java rename to module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/ExampleR2dbcApplication.java index c950ddfbb27..d889b1a39ca 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/ExampleR2dbcApplication.java +++ b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/ExampleR2dbcApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/ExampleRepository.java b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/ExampleRepository.java rename to module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/ExampleRepository.java index dd6ec3172f5..4602ae1186d 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/r2dbc/ExampleRepository.java +++ b/module/spring-boot-data-r2dbc-test/src/test/java/org/springframework/boot/data/r2dbc/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.r2dbc; +package org.springframework.boot.data.r2dbc.test.autoconfigure; import org.springframework.data.repository.reactive.ReactiveCrudRepository; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/r2dbc/schema.sql b/module/spring-boot-data-r2dbc-test/src/test/resources/org/springframework/boot/data/r2dbc/test/autoconfigure/schema.sql similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/data/r2dbc/schema.sql rename to module/spring-boot-data-r2dbc-test/src/test/resources/org/springframework/boot/data/r2dbc/test/autoconfigure/schema.sql diff --git a/module/spring-boot-data-redis-test/build.gradle b/module/spring-boot-data-redis-test/build.gradle new file mode 100644 index 00000000000..957f59660ec --- /dev/null +++ b/module/spring-boot-data-redis-test/build.gradle @@ -0,0 +1,52 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Data Redis Test" + +dependencies { + api(project(":module:spring-boot-data-redis")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + dockerTestImplementation("com.redis:testcontainers-redis") + dockerTestImplementation("io.projectreactor:reactor-test") + dockerTestImplementation("org.assertj:assertj-core") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:testcontainers") + + dockerTestRuntimeOnly("io.lettuce:lettuce-core") + dockerTestRuntimeOnly("org.springframework.data:spring-data-redis") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestIntegrationTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestIntegrationTests.java index 9fc533f86a9..39aeb529ad1 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -34,7 +34,7 @@ import org.springframework.data.redis.core.RedisOperations; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration test for {@link DataRedisTest @DataRedisTest}. diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestPropertiesIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestPropertiesIntegrationTests.java index ed7fa769ca5..28a5507ac50 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import com.redis.testcontainers.RedisContainer; import org.junit.jupiter.api.Nested; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestReactiveIntegrationTests.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestReactiveIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestReactiveIntegrationTests.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestReactiveIntegrationTests.java index 8a9e2da2662..105329c41d3 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestReactiveIntegrationTests.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestReactiveIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import java.time.Duration; import java.util.UUID; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestWithIncludeFilterIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestWithIncludeFilterIntegrationTests.java index aba0768ef98..c219a048e39 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestWithIncludeFilterIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import com.redis.testcontainers.RedisContainer; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleRedisApplication.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleRedisApplication.java index 9b0550b508a..aa94a7b29e8 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleRedisApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleRepository.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleRepository.java index 910b8536b21..b6a307cfc60 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import org.springframework.data.repository.CrudRepository; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleService.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleService.java index 79eaeaa9707..17e027b6d5b 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/ExampleService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/PersonHash.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java rename to module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/PersonHash.java index 8adc9b357f7..40ac0cb0856 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java +++ b/module/spring-boot-data-redis-test/src/dockerTest/java/org/springframework/boot/data/redis/test/autoconfigure/PersonHash.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import org.springframework.data.annotation.Id; import org.springframework.data.redis.core.RedisHash; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/AutoConfigureDataRedis.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java rename to module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/AutoConfigureDataRedis.java index 9ae5388206b..d3ee0b10e4e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java +++ b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/AutoConfigureDataRedis.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * than using this annotation directly. * * @author Jayaram Pradhan - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java rename to module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTest.java index ed34eac72f8..93dd9936dd3 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java +++ b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; @@ -49,7 +48,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * * @author Jayaram Pradhan * @author Artsiom Yudovin - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -59,7 +58,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(DataRedisTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureDataRedis @ImportAutoConfiguration public @interface DataRedisTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestContextBootstrapper.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java rename to module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestContextBootstrapper.java index adad1762494..2c2f1ad294b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestContextBootstrapper.java +++ b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTypeExcludeFilter.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java rename to module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTypeExcludeFilter.java index 241e88bc1ca..da5248bdf50 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java +++ b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/DataRedisTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; @@ -23,7 +23,7 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust * {@link TypeExcludeFilter} for {@link DataRedisTest @DataRedisTest}. * * @author Jayaram Pradhan - * @since 2.2.1 + * @since 4.0.0 */ public final class DataRedisTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/package-info.java b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/package-info.java rename to module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/package-info.java index 4a3d8698dae..9c7d5846c28 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/package-info.java +++ b/module/spring-boot-data-redis-test/src/main/java/org/springframework/boot/data/redis/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Data Redis tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.data.redis; +package org.springframework.boot.data.redis.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports b/module/spring-boot-data-redis-test/src/main/resources/META-INF/spring/org.springframework.boot.data.redis.test.autoconfigure.AutoConfigureDataRedis.imports similarity index 88% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports rename to module/spring-boot-data-redis-test/src/main/resources/META-INF/spring/org.springframework.boot.data.redis.test.autoconfigure.AutoConfigureDataRedis.imports index e7f14895517..74786dc77a2 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis.imports +++ b/module/spring-boot-data-redis-test/src/main/resources/META-INF/spring/org.springframework.boot.data.redis.test.autoconfigure.AutoConfigureDataRedis.imports @@ -1,6 +1,5 @@ -# AutoConfigureDataRedis auto-configuration imports +org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration org.springframework.boot.data.redis.autoconfigure.RedisReactiveAutoConfiguration org.springframework.boot.data.redis.autoconfigure.RedisRepositoriesAutoConfiguration -org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-flyway/build.gradle b/module/spring-boot-flyway/build.gradle index 3093c512f30..2147f9ef904 100644 --- a/module/spring-boot-flyway/build.gradle +++ b/module/spring-boot-flyway/build.gradle @@ -21,6 +21,7 @@ plugins { id "org.springframework.boot.deployed" id "org.springframework.boot.docker-test" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Flyway" @@ -32,6 +33,7 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":core:spring-boot-docker-compose")) + optional(project(":module:spring-boot-jdbc-test")) optional(project(":core:spring-boot-testcontainers")) optional(project(":module:spring-boot-actuator-autoconfigure")) optional("org.flywaydb:flyway-database-oracle") @@ -49,6 +51,7 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-jooq")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("jakarta.persistence:jakarta.persistence-api") testImplementation("org.hibernate.orm:hibernate-core") testImplementation("org.hsqldb:hsqldb") diff --git a/module/spring-boot-flyway/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports b/module/spring-boot-flyway/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports new file mode 100644 index 00000000000..bec0e6000fe --- /dev/null +++ b/module/spring-boot-flyway/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports @@ -0,0 +1 @@ +org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration diff --git a/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigureDataSourceInitializationTests.java b/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigureDataSourceInitializationTests.java new file mode 100644 index 00000000000..96fc88f63f6 --- /dev/null +++ b/module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigureDataSourceInitializationTests.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.flyway.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Tests for Flyway using + * {@link AutoConfigureDataSourceInitialization @AutoConfigureDataSourceInitialization}. + * + * @author Andy Wilkinson + */ +@SpringBootTest +@AutoConfigureDataSourceInitialization +class FlywayAutoConfigureDataSourceInitializationTests { + + @Autowired + private ApplicationContext context; + + @Test + void flywayIsIncludedInAutoConfigureDataSourceInitialization() { + assertThat(this.context).has(importedAutoConfiguration(FlywayAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-freemarker/build.gradle b/module/spring-boot-freemarker/build.gradle index 5add3c05406..29d888dc12a 100644 --- a/module/spring-boot-freemarker/build.gradle +++ b/module/spring-boot-freemarker/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Freemarker" @@ -30,13 +31,17 @@ dependencies { api("org.springframework:spring-context-support") optional(project(":core:spring-boot-autoconfigure")) - optional("org.springframework:spring-webmvc") - optional("org.springframework:spring-webflux") + optional(project(":module:spring-boot-webflux")) + optional(project(":module:spring-boot-webflux-test")) + optional(project(":module:spring-boot-webmvc")) + optional(project(":module:spring-boot-webmvc-test")) optional("jakarta.servlet:jakarta.servlet-api") testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-servlet")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testRuntimeOnly("ch.qos.logback:logback-classic") } diff --git a/module/spring-boot-freemarker/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports b/module/spring-boot-freemarker/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports new file mode 100644 index 00000000000..6a71b86fac2 --- /dev/null +++ b/module/spring-boot-freemarker/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports @@ -0,0 +1 @@ +org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration diff --git a/module/spring-boot-freemarker/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-freemarker/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..6a71b86fac2 --- /dev/null +++ b/module/spring-boot-freemarker/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration diff --git a/module/spring-boot-freemarker/src/test/java/org/springframework/boot/freemarker/autoconfigure/FreeMarkerWebFluxTestIntegrationTests.java b/module/spring-boot-freemarker/src/test/java/org/springframework/boot/freemarker/autoconfigure/FreeMarkerWebFluxTestIntegrationTests.java new file mode 100644 index 00000000000..fde63a90d3f --- /dev/null +++ b/module/spring-boot-freemarker/src/test/java/org/springframework/boot/freemarker/autoconfigure/FreeMarkerWebFluxTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.freemarker.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for FreeMarker with {@link WebFluxTest @WebFluxTest}. + * + * @author Andy Wilkinson + */ +@WebFluxTest +class FreeMarkerWebFluxTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void freemarkerAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(FreeMarkerAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-freemarker/src/test/java/org/springframework/boot/freemarker/autoconfigure/FreeMarkerWebMvcTestIntegrationTests.java b/module/spring-boot-freemarker/src/test/java/org/springframework/boot/freemarker/autoconfigure/FreeMarkerWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..75dc284183f --- /dev/null +++ b/module/spring-boot-freemarker/src/test/java/org/springframework/boot/freemarker/autoconfigure/FreeMarkerWebMvcTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.freemarker.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for FreeMarker with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class FreeMarkerWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void freemarkerAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(FreeMarkerAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-graphql-test/build.gradle b/module/spring-boot-graphql-test/build.gradle index d28ddb24a39..85840a1e828 100644 --- a/module/spring-boot-graphql-test/build.gradle +++ b/module/spring-boot-graphql-test/build.gradle @@ -18,6 +18,7 @@ plugins { id "java-library" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" } description = "Spring Boot GraphQL Test" @@ -26,10 +27,18 @@ dependencies { api("org.springframework.graphql:spring-graphql-test") implementation(project(":core:spring-boot-test")) + implementation(project(":module:spring-boot-graphql")) + implementation(project(":module:spring-boot-jackson")) + optional(project(":module:spring-boot-json-test")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional(project(":module:spring-boot-validation")) + optional(project(":module:spring-boot-webclient")) + optional(project(":module:spring-boot-webflux-test")) + optional(project(":module:spring-boot-webmvc-test")) optional(project(":module:spring-boot-web-server")) - optional(project(":module:spring-boot-web-server-test")) optional("jakarta.servlet:jakarta.servlet-api") + optional("org.junit.jupiter:junit-jupiter-api") optional("org.springframework:spring-web") testImplementation(project(":module:spring-boot-tomcat")) @@ -40,7 +49,3 @@ dependencies { testRuntimeOnly("ch.qos.logback:logback-classic") testRuntimeOnly("tools.jackson.core:jackson-databind") } - -tasks.named("javadoc") { - enabled = false -} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/AutoConfigureGraphQl.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/AutoConfigureGraphQl.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/AutoConfigureGraphQl.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/AutoConfigureGraphQl.java index 153cfb5a9fc..beea53befea 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/AutoConfigureGraphQl.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/AutoConfigureGraphQl.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * using this annotation directly. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 * @see GraphQlTest * @see org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration * @see org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTest.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTest.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTest.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTest.java index b5f834ddfb7..021cbb40c21 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTest.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -27,12 +27,11 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureGraphQlTester; +import org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester; +import org.springframework.boot.json.test.autoconfigure.AutoConfigureJson; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureGraphQlTester; -import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; import org.springframework.context.annotation.ComponentScan; import org.springframework.core.annotation.AliasFor; import org.springframework.core.env.Environment; @@ -75,7 +74,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * with {@link AutoConfigureHttpGraphQlTester @AutoConfigureHttpGraphQlTester}. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 * @see AutoConfigureGraphQlTester */ @Target(ElementType.TYPE) @@ -86,7 +85,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(GraphQlTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureJson @AutoConfigureGraphQl @AutoConfigureGraphQlTester diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestContextBootstrapper.java index 4201c12d6ff..0ae261b0b43 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestContextBootstrapper.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilter.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTypeExcludeFilter.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilter.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTypeExcludeFilter.java index 243cdd63be4..2535ca0021a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilter.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import java.util.Arrays; import java.util.Collections; @@ -39,7 +39,7 @@ import org.springframework.util.ObjectUtils; * {@link TypeExcludeFilter} for {@link GraphQlTest @GraphQlTest}. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 */ public class GraphQlTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { @@ -47,7 +47,7 @@ public class GraphQlTypeExcludeFilter extends StandardAnnotationCustomizableType private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule" }; - private static final Set> DEFAULT_INCLUDES; + private static final Set> KNOWN_INCLUDES; static { Set> includes = new LinkedHashSet<>(); @@ -66,15 +66,15 @@ public class GraphQlTypeExcludeFilter extends StandardAnnotationCustomizableType // Ignore } } - DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES = Collections.unmodifiableSet(includes); } - private static final Set> DEFAULT_INCLUDES_AND_CONTROLLER; + private static final Set> KNOWN_INCLUDES_AND_CONTROLLER; static { - Set> includes = new LinkedHashSet<>(DEFAULT_INCLUDES); + Set> includes = new LinkedHashSet<>(KNOWN_INCLUDES); includes.add(Controller.class); - DEFAULT_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes); } private final Class[] controllers; @@ -85,11 +85,11 @@ public class GraphQlTypeExcludeFilter extends StandardAnnotationCustomizableType } @Override - protected Set> getDefaultIncludes() { + protected Set> getKnownIncludes() { if (ObjectUtils.isEmpty(this.controllers)) { - return DEFAULT_INCLUDES_AND_CONTROLLER; + return KNOWN_INCLUDES_AND_CONTROLLER; } - return DEFAULT_INCLUDES; + return KNOWN_INCLUDES; } @Override diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/package-info.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/package-info.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/package-info.java index f207b538eb6..3f701469249 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/package-info.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for GraphQL testing. */ @NullMarked -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureGraphQlTester.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureGraphQlTester.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureGraphQlTester.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureGraphQlTester.java index 3c4a637ee2f..a3741c03ecb 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureGraphQlTester.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureGraphQlTester.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql.tester; +package org.springframework.boot.graphql.test.autoconfigure.tester; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -30,7 +30,7 @@ import org.springframework.graphql.test.tester.GraphQlTester; * Annotation that can be applied to a test class to enable a {@link GraphQlTester}. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 * @see GraphQlTesterAutoConfiguration */ @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureHttpGraphQlTester.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java similarity index 81% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureHttpGraphQlTester.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java index 5831bca92b7..cbb81a83276 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/AutoConfigureHttpGraphQlTester.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/AutoConfigureHttpGraphQlTester.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql.tester; +package org.springframework.boot.graphql.test.autoconfigure.tester; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,12 +24,12 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.graphql.test.tester.HttpGraphQlTester; /** - * Annotation that can be applied to a test class to enable a {@link HttpGraphQlTester}. + * Annotation that can be applied to a test class to enable an {@link HttpGraphQlTester}. * *

* This annotation should be used with @@ -37,7 +37,7 @@ import org.springframework.graphql.test.tester.HttpGraphQlTester; * Spring MVC or Spring WebFlux mock infrastructures. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 * @see HttpGraphQlTesterAutoConfiguration */ @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/GraphQlTesterAutoConfiguration.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/GraphQlTesterAutoConfiguration.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/GraphQlTesterAutoConfiguration.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/GraphQlTesterAutoConfiguration.java index 1bb6c0de349..a239a233d7d 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/GraphQlTesterAutoConfiguration.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/GraphQlTesterAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql.tester; +package org.springframework.boot.graphql.test.autoconfigure.tester; import graphql.GraphQL; import tools.jackson.databind.json.JsonMapper; @@ -37,7 +37,7 @@ import org.springframework.http.codec.json.JacksonJsonEncoder; * Auto-configuration for {@link GraphQlTester}. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 */ @AutoConfiguration(after = GraphQlAutoConfiguration.class) @ConditionalOnClass({ GraphQL.class, GraphQlTester.class }) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/HttpGraphQlTesterAutoConfiguration.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java similarity index 83% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/HttpGraphQlTesterAutoConfiguration.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java index b17d34495b2..a80425904fd 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/HttpGraphQlTesterAutoConfiguration.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/HttpGraphQlTesterAutoConfiguration.java @@ -14,15 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql.tester; +package org.springframework.boot.graphql.test.autoconfigure.tester; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.graphql.autoconfigure.GraphQlProperties; -import org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.graphql.test.tester.HttpGraphQlTester; import org.springframework.graphql.test.tester.WebGraphQlTester; @@ -33,9 +31,10 @@ import org.springframework.web.reactive.function.client.WebClient; * Auto-configuration for {@link HttpGraphQlTester}. * * @author Brian Clozel - * @since 2.7.0 + * @since 4.0.0 */ -@AutoConfiguration(after = { WebTestClientAutoConfiguration.class, MockMvcAutoConfiguration.class }) +@AutoConfiguration(afterName = { "org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfiguration", + "org.springframework.boot.webmvc.test.autoconfigure.MockMvcAutoConfiguration" }) @ConditionalOnClass({ WebClient.class, WebTestClient.class, WebGraphQlTester.class }) public final class HttpGraphQlTesterAutoConfiguration { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/package-info.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/package-info.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/package-info.java index ed68ff723ab..ae89e48ec2f 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/graphql/tester/package-info.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/autoconfigure/tester/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for GraphQL tester. */ @NullMarked -package org.springframework.boot.test.autoconfigure.graphql.tester; +package org.springframework.boot.graphql.test.autoconfigure.tester; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizer.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizer.java similarity index 99% rename from module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizer.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizer.java index 1c0a5755b19..cdb09a97376 100644 --- a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizer.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import jakarta.servlet.ServletContext; import org.jspecify.annotations.Nullable; diff --git a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerFactory.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerFactory.java similarity index 97% rename from module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerFactory.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerFactory.java index 6add49a548e..f906e0781d8 100644 --- a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerFactory.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import java.util.List; diff --git a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/package-info.java b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/package-info.java similarity index 93% rename from module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/package-info.java rename to module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/package-info.java index 9fd3f19f750..d3c812f1b61 100644 --- a/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/test/graphql/tester/package-info.java +++ b/module/spring-boot-graphql-test/src/main/java/org/springframework/boot/graphql/test/tester/package-info.java @@ -18,6 +18,6 @@ * {@link org.springframework.graphql.test.tester.GraphQlTester} utilities. */ @NullMarked -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-graphql-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring.factories index ecf5d75359b..6f1b03ab271 100644 --- a/module/spring-boot-graphql-test/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring.factories @@ -1,3 +1,3 @@ # Spring Test Context Customizer Factories org.springframework.test.context.ContextCustomizerFactory=\ -org.springframework.boot.test.graphql.tester.HttpGraphQlTesterContextCustomizerFactory +org.springframework.boot.graphql.test.tester.HttpGraphQlTesterContextCustomizerFactory diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.AutoConfigureGraphQl.imports b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.AutoConfigureGraphQl.imports similarity index 82% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.AutoConfigureGraphQl.imports rename to module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.AutoConfigureGraphQl.imports index 55d33aaff51..0e0efd6a606 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.AutoConfigureGraphQl.imports +++ b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.AutoConfigureGraphQl.imports @@ -1,4 +1,3 @@ -# AutoConfigureGraphQl auto-configuration imports +org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfiguration optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration -org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfiguration diff --git a/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureGraphQlTester.imports b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureGraphQlTester.imports new file mode 100644 index 00000000000..8a631cf4a25 --- /dev/null +++ b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureGraphQlTester.imports @@ -0,0 +1 @@ +org.springframework.boot.graphql.test.autoconfigure.tester.GraphQlTesterAutoConfiguration diff --git a/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester.imports b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester.imports new file mode 100644 index 00000000000..8ea82d579cd --- /dev/null +++ b/module/spring-boot-graphql-test/src/main/resources/META-INF/spring/org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester.imports @@ -0,0 +1 @@ +org.springframework.boot.graphql.test.autoconfigure.tester.HttpGraphQlTesterAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/graphql/schema.graphqls b/module/spring-boot-graphql-test/src/main/resources/graphql/schema.graphqls similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/graphql/schema.graphqls rename to module/spring-boot-graphql-test/src/main/resources/graphql/schema.graphqls diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/Book.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/Book.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/Book.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/Book.java index d6c04b0cf6c..c9d1913c3ae 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/Book.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/Book.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; public class Book { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/BookController.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/BookController.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/BookController.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/BookController.java index 7d186aca408..4726b8d96df 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/BookController.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/BookController.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.QueryMapping; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/ExampleGraphQlApplication.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/ExampleGraphQlApplication.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/ExampleGraphQlApplication.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/ExampleGraphQlApplication.java index 087ef4cd09c..4d474d6b72e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/ExampleGraphQlApplication.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/ExampleGraphQlApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestIntegrationTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestIntegrationTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestIntegrationTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestIntegrationTests.java index 352b81bc6fc..c9b4d814eb8 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestIntegrationTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestPropertiesIntegrationTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestPropertiesIntegrationTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestPropertiesIntegrationTests.java index 9bc92673aab..5603081c252 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTestPropertiesIntegrationTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTypeExcludeFilterTests.java similarity index 99% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTypeExcludeFilterTests.java index 30fcfb8cff4..a00de165f73 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/GraphQlTypeExcludeFilterTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/GraphQlTypeExcludeFilterTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql; +package org.springframework.boot.graphql.test.autoconfigure; import java.io.IOException; import java.util.List; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/tester/GraphQlTesterAutoConfigurationTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/tester/GraphQlTesterAutoConfigurationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/tester/GraphQlTesterAutoConfigurationTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/tester/GraphQlTesterAutoConfigurationTests.java index bb7f603c1fa..316d404efeb 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/graphql/tester/GraphQlTesterAutoConfigurationTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/autoconfigure/tester/GraphQlTesterAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.graphql.tester; +package org.springframework.boot.graphql.test.autoconfigure.tester; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java similarity index 98% rename from module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java index cebe404bf9c..8a60e7f1daf 100644 --- a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import java.util.Collections; import java.util.Map; diff --git a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerTests.java similarity index 96% rename from module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerTests.java index 0a4d0b9d18e..3baf21a55e9 100644 --- a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerTests.java @@ -14,16 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.boot.graphql.test.tester.HttpGraphQlTesterContextCustomizer.HttpGraphQlTesterRegistrar; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.graphql.tester.HttpGraphQlTesterContextCustomizer.HttpGraphQlTesterRegistrar; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.graphql.test.tester.HttpGraphQlTester; diff --git a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java similarity index 98% rename from module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java index 6d2372af653..acc5afac599 100644 --- a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerWithCustomBasePathTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import java.util.Collections; import java.util.Map; diff --git a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java similarity index 97% rename from module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java rename to module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java index 97c1d31fa22..a4a7af81fa5 100644 --- a/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/test/graphql/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java +++ b/module/spring-boot-graphql-test/src/test/java/org/springframework/boot/graphql/test/tester/HttpGraphQlTesterContextCustomizerWithCustomContextPathTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.graphql.tester; +package org.springframework.boot.graphql.test.tester; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-groovy-templates/build.gradle b/module/spring-boot-groovy-templates/build.gradle index ddf719174ee..40b0ae41908 100644 --- a/module/spring-boot-groovy-templates/build.gradle +++ b/module/spring-boot-groovy-templates/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Groovy Templates" @@ -29,11 +30,14 @@ dependencies { api("org.apache.groovy:groovy-templates") optional(project(":core:spring-boot-autoconfigure")) - optional("org.springframework:spring-webmvc") + optional(project(":module:spring-boot-webmvc")) + optional(project(":module:spring-boot-webmvc-test")) optional("jakarta.servlet:jakarta.servlet-api") testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testRuntimeOnly("ch.qos.logback:logback-classic") } diff --git a/module/spring-boot-groovy-templates/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-groovy-templates/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..ec807a494e2 --- /dev/null +++ b/module/spring-boot-groovy-templates/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration diff --git a/module/spring-boot-groovy-templates/src/test/java/org/springframework/boot/groovy/template/autoconfigure/GroovyTemplateWebMvcTestIntegrationTests.java b/module/spring-boot-groovy-templates/src/test/java/org/springframework/boot/groovy/template/autoconfigure/GroovyTemplateWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..41a7d66d90a --- /dev/null +++ b/module/spring-boot-groovy-templates/src/test/java/org/springframework/boot/groovy/template/autoconfigure/GroovyTemplateWebMvcTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.groovy.template.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Groovy Templates with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class GroovyTemplateWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void groovyTemplateAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(GroovyTemplateAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-hateoas/build.gradle b/module/spring-boot-hateoas/build.gradle index d506d63aee0..c5720745d68 100644 --- a/module/spring-boot-hateoas/build.gradle +++ b/module/spring-boot-hateoas/build.gradle @@ -34,6 +34,8 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":test-support:spring-boot-test-support")) testImplementation("jakarta.servlet:jakarta.servlet-api") diff --git a/module/spring-boot-hateoas/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-hateoas/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..71e83fadd8f --- /dev/null +++ b/module/spring-boot-hateoas/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestHateoasIntegrationTests.java b/module/spring-boot-hateoas/src/test/java/org/springframework/boot/hateoas/autoconfigure/HypermediaWebMvcTestIntegrationTests.java similarity index 54% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestHateoasIntegrationTests.java rename to module/spring-boot-hateoas/src/test/java/org/springframework/boot/hateoas/autoconfigure/HypermediaWebMvcTestIntegrationTests.java index dc17a0f4e68..b45af35ea64 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestHateoasIntegrationTests.java +++ b/module/spring-boot-hateoas/src/test/java/org/springframework/boot/hateoas/autoconfigure/HypermediaWebMvcTestIntegrationTests.java @@ -14,14 +14,23 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.hateoas.autoconfigure; + +import java.util.HashMap; +import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.annotation.Import; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.LinkRelation; import org.springframework.test.web.servlet.assertj.MockMvcTester; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import static org.assertj.core.api.Assertions.assertThat; @@ -31,8 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Andy Wilkinson */ @WebMvcTest -@WithMockUser -class WebMvcTestHateoasIntegrationTests { +class HypermediaWebMvcTestIntegrationTests { @Autowired private MockMvcTester mvc; @@ -47,4 +55,26 @@ class WebMvcTestHateoasIntegrationTests { assertThat(this.mvc.get().uri("/hateoas/resource")).hasContentType("application/hal+json"); } + @SpringBootConfiguration + @Import(HateoasController.class) + static class TestConfiguration { + + } + + @RestController + @RequestMapping("/hateoas") + static class HateoasController { + + @RequestMapping("/resource") + EntityModel> resource() { + return EntityModel.of(new HashMap<>(), Link.of("self", LinkRelation.of("https://api.example.com"))); + } + + @RequestMapping("/plain") + Map plain() { + return new HashMap<>(); + } + + } + } diff --git a/module/spring-boot-jdbc-test/build.gradle b/module/spring-boot-jdbc-test/build.gradle new file mode 100644 index 00000000000..550cfad6680 --- /dev/null +++ b/module/spring-boot-jdbc-test/build.gradle @@ -0,0 +1,55 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.docker-test" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot JDBC Test" + +dependencies { + api(project(":module:spring-boot-jdbc")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + dockerTestImplementation(project(":core:spring-boot-docker-compose")) + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) + dockerTestImplementation("com.h2database:h2") + dockerTestImplementation("com.zaxxer:HikariCP") + dockerTestImplementation("org.assertj:assertj-core") + dockerTestImplementation("org.junit.jupiter:junit-jupiter") + dockerTestImplementation("org.postgresql:postgresql") + dockerTestImplementation("org.testcontainers:junit-jupiter") + dockerTestImplementation("org.testcontainers:postgresql") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(project(":module:spring-boot-tx")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("com.h2database:h2") + testRuntimeOnly("org.hsqldb:hsqldb") +} diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseDockerComposeIntegrationTests.java b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseDockerComposeIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseDockerComposeIntegrationTests.java rename to module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseDockerComposeIntegrationTests.java index 9e0964d4681..8e5b14413f3 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseDockerComposeIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseDockerComposeIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.io.IOException; import java.io.UncheckedIOException; @@ -30,8 +30,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabaseDockerComposeIntegrationTests.SetupDockerCompose; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseDockerComposeIntegrationTests.SetupDockerCompose; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable; import org.springframework.boot.testsupport.container.TestImage; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseDynamicPropertySourceIntegrationTests.java b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseDynamicPropertySourceIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseDynamicPropertySourceIntegrationTests.java rename to module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseDynamicPropertySourceIntegrationTests.java index 9aafdb25e6c..ffab7ab7ea3 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseDynamicPropertySourceIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseDynamicPropertySourceIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.java b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.java rename to module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.java index 94982c1940c..e0779b8d6cb 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; @@ -25,8 +25,8 @@ import org.testcontainers.junit.jupiter.Container; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.SetupDatabase; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseNonTestDatabaseIntegrationTests.SetupDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable; import org.springframework.boot.testsupport.container.TestImage; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseServiceConnectionIntegrationTests.java b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseServiceConnectionIntegrationTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseServiceConnectionIntegrationTests.java rename to module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseServiceConnectionIntegrationTests.java index 0b7a1d37c07..133ac4ad829 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseServiceConnectionIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseServiceConnectionIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; @@ -27,8 +27,8 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.java b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.java rename to module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.java index 3870569d645..035eccfc5e2 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/dockerTest/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; @@ -25,9 +25,9 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.InitializeDatasourceUrl; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseTestcontainersJdbcUrlIntegrationTests.InitializeDatasourceUrl; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/resources/postgres-compose.yaml b/module/spring-boot-jdbc-test/src/dockerTest/resources/postgres-compose.yaml similarity index 100% rename from module/spring-boot-test-autoconfigure/src/dockerTest/resources/postgres-compose.yaml rename to module/spring-boot-jdbc-test/src/dockerTest/resources/postgres-compose.yaml diff --git a/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureDataSourceInitialization.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureDataSourceInitialization.java new file mode 100644 index 00000000000..28976607d7a --- /dev/null +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureDataSourceInitialization.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.jdbc.test.autoconfigure; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; + +/** + * Annotation that can be applied to a test class to enable DataSource initialization. + * + * @author Andy Wilkinson + * @since 4.0.0 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@ImportAutoConfiguration +public @interface AutoConfigureDataSourceInitialization { + +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureJdbc.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureJdbc.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureJdbc.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureJdbc.java index ca0b585bc5f..3f127b660bb 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureJdbc.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureJdbc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -26,12 +26,12 @@ import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; /** - * {@link ImportAutoConfiguration Auto-configuration imports} for typical jdbc tests. Most + * {@link ImportAutoConfiguration Auto-configuration imports} for typical JDBC tests. Most * tests should consider using {@link JdbcTest @JdbcTest} rather than using this * annotation directly. * * @author Stephane Nicoll - * @since 1.5.0 + * @since 4.0.0 * @see JdbcTest */ @Target(ElementType.TYPE) @@ -39,6 +39,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; @Documented @Inherited @ImportAutoConfiguration +@AutoConfigureDataSourceInitialization public @interface AutoConfigureJdbc { } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabase.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabase.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java index 135ff278804..5bf8dda2b23 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabase.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabase.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -40,7 +40,7 @@ import org.springframework.test.context.DynamicPropertySource; * {@code DataSource} is considered. * * @author Phillip Webb - * @since 1.5.0 + * @since 4.0.0 * @see TestDatabaseAutoConfiguration */ @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTest.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTest.java index 9b3048e5b98..001313c8ad5 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTest.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -64,7 +63,6 @@ import org.springframework.transaction.annotation.Transactional; * @since 1.5.0 * @see AutoConfigureJdbc * @see AutoConfigureTestDatabase - * @see AutoConfigureCache */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -75,7 +73,6 @@ import org.springframework.transaction.annotation.Transactional; @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(JdbcTypeExcludeFilter.class) @Transactional -@AutoConfigureCache @AutoConfigureJdbc @AutoConfigureTestDatabase @ImportAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestContextBootstrapper.java index a513f00bb74..0beb729d023 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestContextBootstrapper.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTypeExcludeFilter.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTypeExcludeFilter.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTypeExcludeFilter.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTypeExcludeFilter.java index d790b914819..0b118e981a2 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTypeExcludeFilter.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfiguration.java similarity index 99% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfiguration.java index fd0190229c6..90517011743 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.util.ArrayList; import java.util.HashMap; @@ -51,8 +51,8 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyN import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.JdbcConnectionDetails; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.Replace; import org.springframework.boot.origin.PropertySourceOrigin; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Role; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/package-info.java b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/package-info.java rename to module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/package-info.java index ad76a3ead42..39bd5df7067 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/package-info.java +++ b/module/spring-boot-jdbc-test/src/main/java/org/springframework/boot/jdbc/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for JDBC tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-jdbc-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-jdbc-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000000..b2266bdbd07 --- /dev/null +++ b/module/spring-boot-jdbc-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "name": "spring.test.database.replace", + "type": "org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase$Replace", + "description": "Type of existing DataSource to replace.", + "defaultValue": "any" + } + ] +} diff --git a/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports b/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports new file mode 100644 index 00000000000..a7b7bc074a5 --- /dev/null +++ b/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports @@ -0,0 +1 @@ +org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports b/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc.imports similarity index 62% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports rename to module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc.imports index 5defb55be5d..2e4c183ed8c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc.imports +++ b/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc.imports @@ -1,10 +1,6 @@ -# AutoConfigureJdbc auto-configuration imports org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration org.springframework.boot.jdbc.autoconfigure.JdbcClientAutoConfiguration org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration -optional:org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration -optional:org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports b/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.imports similarity index 61% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports rename to module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.imports index d7148586622..07cf342912e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.imports +++ b/module/spring-boot-jdbc-test/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase.imports @@ -1,4 +1,3 @@ -# AutoConfigureTestDatabase auto-configuration imports org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration -org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration +org.springframework.boot.jdbc.test.autoconfigure.TestDatabaseAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests.java index f7a216d376b..a2e8c26e3f7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests.java index f4b4016952e..83a545faa0d 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleEntity.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntity.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleEntity.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntity.java index 02ef3c3f789..1274a683b3d 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleEntity.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; /** * Example entity used with {@link JdbcTest @JdbcTest} tests. diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleEntityRowMapper.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntityRowMapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleEntityRowMapper.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntityRowMapper.java index 4f6d9c7ea5d..48152cf02a9 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleEntityRowMapper.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleEntityRowMapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleJdbcApplication.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleJdbcApplication.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleJdbcApplication.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleJdbcApplication.java index 6f398b59b00..90ac4da2f37 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleJdbcApplication.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleJdbcApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleJdbcClientRepository.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleJdbcClientRepository.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleJdbcClientRepository.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleJdbcClientRepository.java index 7374feb0473..63ee8106a5a 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleJdbcClientRepository.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleJdbcClientRepository.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.util.Collection; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleRepository.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleRepository.java index 359f1543cc4..3fbd1c94dd3 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/ExampleRepository.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.util.Collection; -import jakarta.transaction.Transactional; - import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; /** * Example repository used with {@link JdbcTest @JdbcTest} tests. diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestIntegrationTests.java similarity index 82% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestIntegrationTests.java index 4aed9ef36d0..195b7a2f624 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import java.util.Collection; @@ -24,8 +24,6 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; -import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.jdbc.core.JdbcTemplate; @@ -34,7 +32,7 @@ import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration tests for {@link JdbcTest @JdbcTest}. @@ -44,7 +42,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor */ @JdbcTest @TestPropertySource( - properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/test/autoconfigure/jdbc/schema.sql") + properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/jdbc/test/autoconfigure/schema.sql") class JdbcTestIntegrationTests { @Autowired @@ -99,16 +97,6 @@ class JdbcTestIntegrationTests { .isThrownBy(() -> this.applicationContext.getBean(ExampleRepository.class)); } - @Test - void flywayAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(FlywayAutoConfiguration.class)); - } - - @Test - void liquibaseAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(LiquibaseAutoConfiguration.class)); - } - @Test void serviceConnectionAutoConfigurationWasImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(ServiceConnectionAutoConfiguration.class)); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestPropertiesIntegrationTests.java index 0a45b04d082..069083bee13 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestPropertiesIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java index a5970df2e20..b81c75adea5 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java index 0683e0a6189..c11ccf4f16f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java index f6042fd6a4f..ae9ea585f87 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java index 481880bf477..8c02c4d16e6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests.java index e9204730765..4887b467cb0 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests.java index a8f17e2c13e..69f6872b08f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyNoneIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyNoneIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyNoneIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyNoneIntegrationTests.java index 2d34b251ff5..f757bccf5d7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyNoneIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithAutoConfigureTestDatabaseReplacePropertyNoneIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithIncludeFilterIntegrationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithIncludeFilterIntegrationTests.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithIncludeFilterIntegrationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithIncludeFilterIntegrationTests.java index d213503ebc4..2b105fe6d44 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/JdbcTestWithIncludeFilterIntegrationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/JdbcTestWithIncludeFilterIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import org.junit.jupiter.api.Test; @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @JdbcTest(includeFilters = @Filter(Repository.class)) @TestPropertySource( - properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/test/autoconfigure/jdbc/schema.sql") + properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/jdbc/test/autoconfigure/schema.sql") class JdbcTestWithIncludeFilterIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfigurationNoEmbeddedTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfigurationNoEmbeddedTests.java index a41650d6f25..d55eb33a59b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestDatabaseAutoConfigurationNoEmbeddedTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfigurationNoEmbeddedTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.testsupport.classpath.ClassPathExclusions; import org.springframework.context.annotation.Bean; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfigurationTests.java b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfigurationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfigurationTests.java rename to module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfigurationTests.java index 886f97ac60a..68bfbfec64b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfigurationTests.java +++ b/module/spring-boot-jdbc-test/src/test/java/org/springframework/boot/jdbc/test/autoconfigure/TestDatabaseAutoConfigurationTests.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jdbc; +package org.springframework.boot.jdbc.test.autoconfigure; import javax.sql.DataSource; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration.EmbeddedDataSourceFactoryBean; +import org.springframework.boot.jdbc.test.autoconfigure.TestDatabaseAutoConfiguration.EmbeddedDataSourceFactoryBean; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/jdbc/schema.sql b/module/spring-boot-jdbc-test/src/test/resources/org/springframework/boot/jdbc/test/autoconfigure/schema.sql similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/jdbc/schema.sql rename to module/spring-boot-jdbc-test/src/test/resources/org/springframework/boot/jdbc/test/autoconfigure/schema.sql diff --git a/module/spring-boot-jooq-test/build.gradle b/module/spring-boot-jooq-test/build.gradle new file mode 100644 index 00000000000..0dab0304b3c --- /dev/null +++ b/module/spring-boot-jooq-test/build.gradle @@ -0,0 +1,44 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot jOOQ Test" + +dependencies { + api(project(":module:spring-boot-jooq")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":core:spring-boot-testcontainers")) + optional(project(":module:spring-boot-jdbc-test")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":module:spring-boot-flyway")) + testImplementation(project(":module:spring-boot-liquibase")) + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("com.h2database:h2") + testRuntimeOnly("org.hsqldb:hsqldb") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/AutoConfigureJooq.java b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/AutoConfigureJooq.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/AutoConfigureJooq.java rename to module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/AutoConfigureJooq.java index 4e6bea4fb70..a1718d15982 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/AutoConfigureJooq.java +++ b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/AutoConfigureJooq.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jooq; +package org.springframework.boot.jooq.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,6 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization; /** * {@link ImportAutoConfiguration Auto-configuration imports} for typical jOOQ tests. Most @@ -31,12 +32,13 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * annotation directly. * * @author Michael Simons - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited +@AutoConfigureDataSourceInitialization @ImportAutoConfiguration public @interface AutoConfigureJooq { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTest.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java rename to module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTest.java index eba07773663..d8a7a55622a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTest.java +++ b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jooq; +package org.springframework.boot.jooq.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -27,10 +27,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.core.annotation.AliasFor; import org.springframework.core.env.Environment; @@ -56,7 +55,7 @@ import org.springframework.transaction.annotation.Transactional; * @author Michael Simons * @author Stephane Nicoll * @author Artsiom Yudovin - * @since 2.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -67,7 +66,6 @@ import org.springframework.transaction.annotation.Transactional; @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(JooqTypeExcludeFilter.class) @Transactional -@AutoConfigureCache @AutoConfigureJooq @ImportAutoConfiguration public @interface JooqTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java rename to module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTestContextBootstrapper.java index 2b870b2975d..8ac0d9282fc 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestContextBootstrapper.java +++ b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jooq; +package org.springframework.boot.jooq.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTypeExcludeFilter.java b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTypeExcludeFilter.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTypeExcludeFilter.java rename to module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTypeExcludeFilter.java index c6c454ed49a..a53f2ccca2d 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/JooqTypeExcludeFilter.java +++ b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/JooqTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.jooq; +package org.springframework.boot.jooq.test.autoconfigure; import org.springframework.boot.context.TypeExcludeFilter; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; @@ -23,7 +23,7 @@ import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCust * {@link TypeExcludeFilter} for {@link JooqTest @JooqTest}. * * @author Michael Simons - * @since 2.2.1 + * @since 4.0.0 */ public final class JooqTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/package-info.java b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/package-info.java rename to module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/package-info.java index f7832f9a2c1..d6b2ba06c30 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jooq/package-info.java +++ b/module/spring-boot-jooq-test/src/main/java/org/springframework/boot/jooq/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for jOOQ tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.jooq; +package org.springframework.boot.jooq.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports b/module/spring-boot-jooq-test/src/main/resources/META-INF/spring/org.springframework.boot.jooq.test.autoconfigure.AutoConfigureJooq.imports similarity index 58% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports rename to module/spring-boot-jooq-test/src/main/resources/META-INF/spring/org.springframework.boot.jooq.test.autoconfigure.AutoConfigureJooq.imports index 853130bd8c3..90b05bf5719 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.jooq.AutoConfigureJooq.imports +++ b/module/spring-boot-jooq-test/src/main/resources/META-INF/spring/org.springframework.boot.jooq.test.autoconfigure.AutoConfigureJooq.imports @@ -1,9 +1,5 @@ -# AutoConfigureJooq auto-configuration imports -org.springframework.boot.jooq.autoconfigure.JooqAutoConfiguration org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration +org.springframework.boot.jooq.autoconfigure.JooqAutoConfiguration org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration -optional:org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration -optional:org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleComponent.java b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleComponent.java new file mode 100644 index 00000000000..a2a81d5bb6b --- /dev/null +++ b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleComponent.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.jooq; + +import org.springframework.stereotype.Component; + +/** + * Example component used with {@JooqTest @JooqTest} tests. + * + * @author Phillip Webb + */ +@Component +public class ExampleComponent { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleJooqApplication.java b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleJooqApplication.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleJooqApplication.java rename to module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleJooqApplication.java index 53287274e7f..a099b754005 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleJooqApplication.java +++ b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/ExampleJooqApplication.java @@ -19,6 +19,7 @@ package org.springframework.boot.test.autoconfigure.jooq; import javax.sql.DataSource; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.jooq.test.autoconfigure.JooqTest; import org.springframework.context.annotation.Bean; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestIntegrationTests.java b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestIntegrationTests.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestIntegrationTests.java rename to module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestIntegrationTests.java index 0f2f18df1d9..a74a80995fe 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestIntegrationTests.java +++ b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestIntegrationTests.java @@ -24,16 +24,16 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.cache.autoconfigure.CacheAutoConfiguration; import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; +import org.springframework.boot.jooq.test.autoconfigure.JooqTest; import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration; -import org.springframework.boot.test.autoconfigure.orm.jpa.ExampleComponent; import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration; import org.springframework.context.ApplicationContext; +import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Integration tests for {@link JooqTest @JooqTest}. @@ -41,6 +41,7 @@ import static org.springframework.boot.test.autoconfigure.AutoConfigurationImpor * @author Michael Simons */ @JooqTest +@TestPropertySource(properties = { "spring.flyway.enabled=false", "spring.liquibase.enabled=false" }) class JooqTestIntegrationTests { @Autowired @@ -81,11 +82,6 @@ class JooqTestIntegrationTests { assertThat(this.applicationContext).has(importedAutoConfiguration(LiquibaseAutoConfiguration.class)); } - @Test - void cacheAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(CacheAutoConfiguration.class)); - } - @Test void serviceConnectionAutoConfigurationWasImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(ServiceConnectionAutoConfiguration.class)); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java rename to module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java index bb3b4f047ac..a2cfe242121 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java +++ b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestPropertiesIntegrationTests.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.jooq.test.autoconfigure.JooqTest; import org.springframework.core.env.Environment; import static org.assertj.core.api.Assertions.assertThat; @@ -30,7 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Artsiom Yudovin */ -@JooqTest(properties = "spring.profiles.active=test") +@JooqTest( + properties = { "spring.profiles.active=test", "spring.flyway.enabled=false", "spring.liquibase.enabled=false" }) class JooqTestPropertiesIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestWithAutoConfigureTestDatabaseIntegrationTests.java b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestWithAutoConfigureTestDatabaseIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestWithAutoConfigureTestDatabaseIntegrationTests.java rename to module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestWithAutoConfigureTestDatabaseIntegrationTests.java index a6f7ca19a2e..5305fc9910b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestWithAutoConfigureTestDatabaseIntegrationTests.java +++ b/module/spring-boot-jooq-test/src/test/java/org/springframework/boot/test/autoconfigure/jooq/JooqTestWithAutoConfigureTestDatabaseIntegrationTests.java @@ -24,7 +24,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; +import org.springframework.boot.jooq.test.autoconfigure.JooqTest; +import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; @@ -35,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @JooqTest @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2) +@TestPropertySource(properties = { "spring.flyway.enabled=false", "spring.liquibase.enabled=false" }) class JooqTestWithAutoConfigureTestDatabaseIntegrationTests { @Autowired diff --git a/module/spring-boot-jpa-test/build.gradle b/module/spring-boot-jpa-test/build.gradle new file mode 100644 index 00000000000..7bd0448cdc4 --- /dev/null +++ b/module/spring-boot-jpa-test/build.gradle @@ -0,0 +1,36 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot JPA Test" + +dependencies { + api(project(":module:spring-boot-jpa")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-test-autoconfigure")) + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/AutoConfigureTestEntityManager.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java rename to module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/AutoConfigureTestEntityManager.java index aadfc1f33bb..af238207d59 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestEntityManager.java +++ b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/AutoConfigureTestEntityManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -30,7 +30,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * {@link TestEntityManager}. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see TestEntityManagerAutoConfiguration */ @Target({ ElementType.TYPE, ElementType.METHOD }) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManager.java similarity index 99% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java rename to module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManager.java index c983ff1a9b9..fcd5f6cb4c6 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java +++ b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.test.autoconfigure; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; @@ -30,7 +30,7 @@ import org.springframework.util.Assert; * common testing tasks such as {@link #persistFlushFind(Object) persist/flush/find}. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ public class TestEntityManager { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerAutoConfiguration.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java rename to module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerAutoConfiguration.java index e6e40968f31..77396f11750 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java +++ b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.test.autoconfigure; import jakarta.persistence.EntityManagerFactory; @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Bean; * Auto-configuration for {@link TestEntityManager}. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see AutoConfigureTestEntityManager */ @AutoConfiguration(afterName = "org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfiguration") diff --git a/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/package-info.java b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/package-info.java new file mode 100644 index 00000000000..c8f634d33a0 --- /dev/null +++ b/module/spring-boot-jpa-test/src/main/java/org/springframework/boot/jpa/test/autoconfigure/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Auto-configuration for JPA tests. + */ +@NullMarked +package org.springframework.boot.jpa.test.autoconfigure; + +import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-jpa-test/src/main/resources/META-INF/spring/org.springframework.boot.jpa.test.autoconfigure.AutoConfigureTestEntityManager.imports b/module/spring-boot-jpa-test/src/main/resources/META-INF/spring/org.springframework.boot.jpa.test.autoconfigure.AutoConfigureTestEntityManager.imports new file mode 100644 index 00000000000..1a35df721d4 --- /dev/null +++ b/module/spring-boot-jpa-test/src/main/resources/META-INF/spring/org.springframework.boot.jpa.test.autoconfigure.AutoConfigureTestEntityManager.imports @@ -0,0 +1 @@ +org.springframework.boot.jpa.test.autoconfigure.TestEntityManagerAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java b/module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java similarity index 99% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java rename to module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java index 0f497e3a53f..d3197d049c1 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerTests.java +++ b/module/spring-boot-jpa-test/src/test/java/org/springframework/boot/jpa/test/autoconfigure/TestEntityManagerTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.test.autoconfigure; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManagerFactory; diff --git a/module/spring-boot-json-test/build.gradle b/module/spring-boot-json-test/build.gradle new file mode 100644 index 00000000000..1f2f61e457c --- /dev/null +++ b/module/spring-boot-json-test/build.gradle @@ -0,0 +1,40 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot JSON Test" + +dependencies { + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-gson")) + optional(project(":module:spring-boot-jackson")) + optional(project(":module:spring-boot-jsonb")) + optional(project(":module:spring-boot-kotlin-serialization")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJson.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJson.java index f44347a28a8..a573fe70c64 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJson.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJson.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * annotation directly. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see JsonTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java index 1d624095c0c..a386694eb47 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/AutoConfigureJsonTesters.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -35,7 +35,7 @@ import org.springframework.boot.test.json.JsonbTester; * auto-configuration of JSON testers. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTest.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTest.java index 0f6ae886225..e71492cd06b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTest.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.json.GsonTester; import org.springframework.boot.test.json.JacksonTester; @@ -65,8 +64,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; * @author Artsiom Yudovin * @see AutoConfigureJson * @see AutoConfigureJsonTesters - * @see AutoConfigureCache - * @since 1.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -76,7 +74,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(JsonTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureJsonTesters @ImportAutoConfiguration public @interface JsonTest { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTestContextBootstrapper.java index 07680f40079..9f059d13006 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestContextBootstrapper.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTestersAutoConfiguration.java similarity index 99% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTestersAutoConfiguration.java index d6e89b8029e..8052dd979d0 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTestersAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -59,7 +59,7 @@ import org.springframework.util.ReflectionUtils; * * @author Phillip Webb * @author Eddú Meléndez - * @since 1.4.0 + * @since 4.0.0 * @see AutoConfigureJsonTesters */ @AutoConfiguration(afterName = { "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration", diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTypeExcludeFilter.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTypeExcludeFilter.java similarity index 85% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTypeExcludeFilter.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTypeExcludeFilter.java index 1984ff5dad1..819db4232cb 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTypeExcludeFilter.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/JsonTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.util.Collections; import java.util.LinkedHashSet; @@ -29,13 +29,13 @@ import org.springframework.util.ClassUtils; * {@link TypeExcludeFilter} for {@link JsonTest @JsonTest}. * * @author Phillip Webb - * @since 2.2.1 + * @since 4.0.0 */ public final class JsonTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { private static final String JACKSON_MODULE = "tools.jackson.databind.JacksonModule"; - private static final Set> DEFAULT_INCLUDES; + private static final Set> KNOWN_INCLUDES; static { Set> includes = new LinkedHashSet<>(); @@ -46,7 +46,7 @@ public final class JsonTypeExcludeFilter extends StandardAnnotationCustomizableT // Ignore } includes.add(JsonComponent.class); - DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES = Collections.unmodifiableSet(includes); } JsonTypeExcludeFilter(Class testClass) { @@ -54,8 +54,8 @@ public final class JsonTypeExcludeFilter extends StandardAnnotationCustomizableT } @Override - protected Set> getDefaultIncludes() { - return DEFAULT_INCLUDES; + protected Set> getKnownIncludes() { + return KNOWN_INCLUDES; } } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/package-info.java b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/package-info.java rename to module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/package-info.java index f71c02793d4..1fe28c1698a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/package-info.java +++ b/module/spring-boot-json-test/src/main/java/org/springframework/boot/json/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for JSON tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-json-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-json-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000000..59a95a32f89 --- /dev/null +++ b/module/spring-boot-json-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "name": "spring.test.jsontesters.enabled", + "type": "java.lang.Boolean", + "description": "Whether auto-configuration of JSON testers is enabled.", + "defaultValue": "true" + } + ] +} diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.json.AutoConfigureJson.imports b/module/spring-boot-json-test/src/main/resources/META-INF/spring/org.springframework.boot.json.test.autoconfigure.AutoConfigureJson.imports similarity index 68% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.json.AutoConfigureJson.imports rename to module/spring-boot-json-test/src/main/resources/META-INF/spring/org.springframework.boot.json.test.autoconfigure.AutoConfigureJson.imports index 4fdb8987209..1d713034429 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.json.AutoConfigureJson.imports +++ b/module/spring-boot-json-test/src/main/resources/META-INF/spring/org.springframework.boot.json.test.autoconfigure.AutoConfigureJson.imports @@ -1,5 +1,4 @@ -# AutoConfigureJson auto-configuration imports optional:org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration -org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration +optional:org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration optional:org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration optional:org.springframework.boot.kotlin.serialization.autoconfigure.KotlinSerializationAutoConfiguration diff --git a/module/spring-boot-json-test/src/main/resources/META-INF/spring/org.springframework.boot.json.test.autoconfigure.AutoConfigureJsonTesters.imports b/module/spring-boot-json-test/src/main/resources/META-INF/spring/org.springframework.boot.json.test.autoconfigure.AutoConfigureJsonTesters.imports new file mode 100644 index 00000000000..66c3a4a6a9b --- /dev/null +++ b/module/spring-boot-json-test/src/main/resources/META-INF/spring/org.springframework.boot.json.test.autoconfigure.AutoConfigureJsonTesters.imports @@ -0,0 +1 @@ +org.springframework.boot.json.test.autoconfigure.JsonTestersAutoConfiguration diff --git a/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestApplication.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestApplication.java new file mode 100644 index 00000000000..0d004f435e8 --- /dev/null +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.json.test.autoconfigure; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Application for testing of {@link JsonTest @JsonTest}. + * + * @author Andy Wilkinson + */ +@SpringBootApplication +class JsonTestApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestIntegrationTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestIntegrationTests.java index 3f9391d536c..f1aded34da6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestIntegrationTests.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.util.Date; import java.util.UUID; @@ -22,10 +22,10 @@ import java.util.UUID; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.app.ExampleBasicObject; -import org.springframework.boot.test.autoconfigure.json.app.ExampleCustomObject; -import org.springframework.boot.test.autoconfigure.json.app.ExampleJsonApplication; -import org.springframework.boot.test.autoconfigure.json.app.ExampleJsonObjectWithView; +import org.springframework.boot.json.test.autoconfigure.app.ExampleBasicObject; +import org.springframework.boot.json.test.autoconfigure.app.ExampleCustomObject; +import org.springframework.boot.json.test.autoconfigure.app.ExampleJsonApplication; +import org.springframework.boot.json.test.autoconfigure.app.ExampleJsonObjectWithView; import org.springframework.boot.test.json.BasicJsonTester; import org.springframework.boot.test.json.GsonTester; import org.springframework.boot.test.json.JacksonTester; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestPropertiesIntegrationTests.java index 55d6509118b..e275a8429ab 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestPropertiesIntegrationTests.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestWithAutoConfigureJsonTestersTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestWithAutoConfigureJsonTestersTests.java index 5657b5b4285..40585c81cda 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestWithAutoConfigureJsonTestersTests.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestWithAutoConfigureJsonTestersTests.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.app.ExampleBasicObject; -import org.springframework.boot.test.autoconfigure.json.app.ExampleJsonApplication; +import org.springframework.boot.json.test.autoconfigure.app.ExampleBasicObject; +import org.springframework.boot.json.test.autoconfigure.app.ExampleJsonApplication; import org.springframework.boot.test.json.BasicJsonTester; import org.springframework.boot.test.json.GsonTester; import org.springframework.boot.test.json.JacksonTester; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfigurationTests.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestersAutoConfigurationTests.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfigurationTests.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestersAutoConfigurationTests.java index 66e2a7ea810..eaf6c3ee12e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfigurationTests.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/JsonTestersAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import java.util.function.Consumer; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/SpringBootTestWithAutoConfigureJsonTestersTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/SpringBootTestWithAutoConfigureJsonTestersTests.java index 1244ad5f719..157bfe6bc42 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/SpringBootTestWithAutoConfigureJsonTestersTests.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/SpringBootTestWithAutoConfigureJsonTestersTests.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json; +package org.springframework.boot.json.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.app.ExampleBasicObject; -import org.springframework.boot.test.autoconfigure.json.app.ExampleJsonApplication; +import org.springframework.boot.json.test.autoconfigure.app.ExampleBasicObject; +import org.springframework.boot.json.test.autoconfigure.app.ExampleJsonApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.json.BasicJsonTester; import org.springframework.boot.test.json.GsonTester; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleBasicObject.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleBasicObject.java index ccfc0d80204..e34bd371b6e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleBasicObject.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json.app; +package org.springframework.boot.json.test.autoconfigure.app; /** * Example object to read/write as JSON. diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleCustomObject.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleCustomObject.java index 439ce06622d..e8ad05b55cc 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleCustomObject.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json.app; +package org.springframework.boot.json.test.autoconfigure.app; import java.util.Date; import java.util.UUID; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonApplication.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonApplication.java similarity index 76% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonApplication.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonApplication.java index 3262a4fbc9c..0d8fc737504 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonApplication.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonApplication.java @@ -14,11 +14,10 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json.app; +package org.springframework.boot.json.test.autoconfigure.app; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; -import org.springframework.boot.test.autoconfigure.json.JsonTest; +import org.springframework.boot.json.test.autoconfigure.JsonTest; /** * Example {@link SpringBootApplication @SpringBootApplication} for use with @@ -26,7 +25,7 @@ import org.springframework.boot.test.autoconfigure.json.JsonTest; * * @author Phillip Webb */ -@SpringBootApplication(exclude = CassandraAutoConfiguration.class) +@SpringBootApplication public class ExampleJsonApplication { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonComponent.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonComponent.java index bea9d6585e9..1f5823abd58 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonComponent.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonComponent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json.app; +package org.springframework.boot.json.test.autoconfigure.app; import java.util.Date; import java.util.UUID; @@ -28,7 +28,7 @@ import tools.jackson.databind.SerializationContext; import org.springframework.boot.jackson.JsonComponent; import org.springframework.boot.jackson.ObjectValueDeserializer; import org.springframework.boot.jackson.ObjectValueSerializer; -import org.springframework.boot.test.autoconfigure.json.JsonTest; +import org.springframework.boot.json.test.autoconfigure.JsonTest; /** * Example {@link JsonComponent @JsonComponent} for use with {@link JsonTest @JsonTest} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonObjectWithView.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java rename to module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonObjectWithView.java index 87f4e205603..bed0357a073 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java +++ b/module/spring-boot-json-test/src/test/java/org/springframework/boot/json/test/autoconfigure/app/ExampleJsonObjectWithView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.json.app; +package org.springframework.boot.json.test.autoconfigure.app; import com.fasterxml.jackson.annotation.JsonView; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/json/example.json b/module/spring-boot-json-test/src/test/resources/org/springframework/boot/json/test/autoconfigure/example.json similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/json/example.json rename to module/spring-boot-json-test/src/test/resources/org/springframework/boot/json/test/autoconfigure/example.json diff --git a/module/spring-boot-liquibase/build.gradle b/module/spring-boot-liquibase/build.gradle index 731747728ec..d135695754e 100644 --- a/module/spring-boot-liquibase/build.gradle +++ b/module/spring-boot-liquibase/build.gradle @@ -21,6 +21,7 @@ plugins { id "org.springframework.boot.deployed" id "org.springframework.boot.docker-test" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Liquibase" @@ -36,6 +37,7 @@ dependencies { optional(project(":core:spring-boot-docker-compose")) optional(project(":core:spring-boot-testcontainers")) optional(project(":module:spring-boot-actuator-autoconfigure")) + optional(project(":module:spring-boot-jdbc-test")) optional("org.testcontainers:jdbc") dockerTestImplementation(project(":core:spring-boot-test")) @@ -47,6 +49,7 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("com.h2database:h2") testImplementation("com.zaxxer:HikariCP") diff --git a/module/spring-boot-liquibase/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports b/module/spring-boot-liquibase/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports new file mode 100644 index 00000000000..7769b7aac3a --- /dev/null +++ b/module/spring-boot-liquibase/src/main/resources/META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization.imports @@ -0,0 +1 @@ +org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration diff --git a/module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfigureDataSourceInitializationTests.java b/module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfigureDataSourceInitializationTests.java new file mode 100644 index 00000000000..813472242e8 --- /dev/null +++ b/module/spring-boot-liquibase/src/test/java/org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfigureDataSourceInitializationTests.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.liquibase.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureDataSourceInitialization; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Tests for Liquibase using + * {@link AutoConfigureDataSourceInitialization @AutoConfigureDataSourceInitialization}. + * + * @author Andy Wilkinson + */ +@SpringBootTest +@AutoConfigureDataSourceInitialization +class LiquibaseAutoConfigureDataSourceInitializationTests { + + @Autowired + private ApplicationContext context; + + @Test + void liquibaseIsIncludedInAutoConfigureDataSourceInitialization() { + assertThat(this.context).has(importedAutoConfiguration(LiquibaseAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-micrometer-metrics-test/build.gradle b/module/spring-boot-micrometer-metrics-test/build.gradle new file mode 100644 index 00000000000..b843574d4ec --- /dev/null +++ b/module/spring-boot-micrometer-metrics-test/build.gradle @@ -0,0 +1,38 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Micrometer Metrics Test" + +dependencies { + api(project(":module:spring-boot-micrometer-metrics")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation("io.micrometer:micrometer-registry-prometheus") + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservability.java b/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetrics.java similarity index 73% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservability.java rename to module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetrics.java index 52cf40a9e83..3ac4b5be589 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservability.java +++ b/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetrics.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -23,36 +23,32 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.observation.ObservationRegistry; + import org.springframework.boot.autoconfigure.ImportAutoConfiguration; /** * Annotation that can be applied to a test class to enable auto-configuration for - * observability. + * metrics. *

- * If this annotation is applied to a sliced test, an in-memory {@code MeterRegistry}, a - * no-op {@code Tracer} and an {@code ObservationRegistry} are added to the application - * context. + * If this annotation is applied to a sliced test, an in-memory {@link MeterRegistry} and + * an {@link ObservationRegistry} are added to the application context. * * @author Moritz Halbritter - * @since 3.0.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @ImportAutoConfiguration -public @interface AutoConfigureObservability { +public @interface AutoConfigureMetrics { /** * Whether metrics should be reported to external systems in the test. * @return whether metrics should be reported to external systems in the test */ - boolean metrics() default true; - - /** - * Whether traces should be reported to external systems in the test. - * @return whether traces should be reported to external systems in the test - */ - boolean tracing() default true; + boolean export() default true; } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactory.java b/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactory.java similarity index 64% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactory.java rename to module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactory.java index f9cff06fde5..14e0c773e05 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactory.java +++ b/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; import java.util.List; import java.util.Objects; @@ -31,30 +31,32 @@ import org.springframework.test.context.MergedContextConfiguration; import org.springframework.test.context.TestContextAnnotationUtils; /** - * {@link ContextCustomizerFactory} that globally disables metrics export and tracing in - * tests. The behaviour can be controlled with {@link AutoConfigureObservability} on the - * test class or via the {@value #AUTO_CONFIGURE_PROPERTY} property. + * {@link ContextCustomizerFactory} that globally disables metrics export in tests. The + * behaviour can be controlled with {@link AutoConfigureMetrics} on the test class or via + * the {@value #AUTO_CONFIGURE_PROPERTY} property. * * @author Chris Bono * @author Moritz Halbritter + * @author Andy Wilkinson */ -class ObservabilityContextCustomizerFactory implements ContextCustomizerFactory { +class MetricsContextCustomizerFactory implements ContextCustomizerFactory { - static final String AUTO_CONFIGURE_PROPERTY = "spring.test.observability.auto-configure"; + // TODO spring.test.metrics.export? + static final String AUTO_CONFIGURE_PROPERTY = "spring.test.metrics.auto-configure"; @Override public ContextCustomizer createContextCustomizer(Class testClass, List configAttributes) { - AutoConfigureObservability annotation = TestContextAnnotationUtils.findMergedAnnotation(testClass, - AutoConfigureObservability.class); - return new DisableObservabilityContextCustomizer(annotation); + AutoConfigureMetrics annotation = TestContextAnnotationUtils.findMergedAnnotation(testClass, + AutoConfigureMetrics.class); + return new DisableMetricsExportContextCustomizer(annotation); } - private static class DisableObservabilityContextCustomizer implements ContextCustomizer { + private static class DisableMetricsExportContextCustomizer implements ContextCustomizer { - private final @Nullable AutoConfigureObservability annotation; + private final @Nullable AutoConfigureMetrics annotation; - DisableObservabilityContextCustomizer(@Nullable AutoConfigureObservability annotation) { + DisableMetricsExportContextCustomizer(@Nullable AutoConfigureMetrics annotation) { this.annotation = annotation; } @@ -67,21 +69,11 @@ class ObservabilityContextCustomizerFactory implements ContextCustomizerFactory "management.simple.metrics.export.enabled=true") .applyTo(context); } - if (isTracingDisabled(context.getEnvironment())) { - TestPropertyValues.of("management.tracing.export.enabled=false").applyTo(context); - } } private boolean areMetricsDisabled(Environment environment) { if (this.annotation != null) { - return !this.annotation.metrics(); - } - return !environment.getProperty(AUTO_CONFIGURE_PROPERTY, Boolean.class, false); - } - - private boolean isTracingDisabled(Environment environment) { - if (this.annotation != null) { - return !this.annotation.tracing(); + return !this.annotation.export(); } return !environment.getProperty(AUTO_CONFIGURE_PROPERTY, Boolean.class, false); } @@ -94,7 +86,7 @@ class ObservabilityContextCustomizerFactory implements ContextCustomizerFactory if (o == null || getClass() != o.getClass()) { return false; } - DisableObservabilityContextCustomizer that = (DisableObservabilityContextCustomizer) o; + DisableMetricsExportContextCustomizer that = (DisableMetricsExportContextCustomizer) o; return Objects.equals(this.annotation, that.annotation); } diff --git a/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/package-info.java b/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/package-info.java new file mode 100644 index 00000000000..ccb82133f5b --- /dev/null +++ b/module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Auto-configuration for handling metrics in tests. + */ +@NullMarked +package org.springframework.boot.micrometer.metrics.test.autoconfigure; + +import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring-configuration-metadata.json b/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring-configuration-metadata.json new file mode 100644 index 00000000000..a6c1795d0d7 --- /dev/null +++ b/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "name": "spring.test.metrics.auto-configure", + "type": "java.lang.Boolean", + "description": "Whether metrics should be auto-configured in tests.", + "defaultValue": false + } + ] +} diff --git a/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..a3cb5ae495f --- /dev/null +++ b/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Spring Test Context Customizer Factories +org.springframework.test.context.ContextCustomizerFactory=\ +org.springframework.boot.micrometer.metrics.test.autoconfigure.MetricsContextCustomizerFactory diff --git a/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring/org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics.imports b/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring/org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics.imports new file mode 100644 index 00000000000..8451884f8ba --- /dev/null +++ b/module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring/org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics.imports @@ -0,0 +1,4 @@ +org.springframework.boot.micrometer.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration +org.springframework.boot.micrometer.metrics.autoconfigure.MetricsAutoConfiguration +org.springframework.boot.micrometer.metrics.autoconfigure.export.simple.SimpleMetricsExportAutoConfiguration +org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilityMissingIntegrationTests.java b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsMissingIntegrationTests.java similarity index 79% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilityMissingIntegrationTests.java rename to module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsMissingIntegrationTests.java index b4431062c53..cd4b0e3eaea 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilityMissingIntegrationTests.java +++ b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsMissingIntegrationTests.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; +import io.micrometer.prometheusmetrics.PrometheusMeterRegistry; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -29,28 +30,25 @@ import static org.assertj.core.api.Assertions.assertThat; /** * Integration test to verify behaviour when - * {@link AutoConfigureObservability @AutoConfigureObservability} is not present on the - * test class. + * {@link AutoConfigureMetrics @AutoConfigureMetrics} is not present on the test class. * * @author Chris Bono * @author Moritz Halbritter */ @SpringBootTest -class AutoConfigureObservabilityMissingIntegrationTests { +class AutoConfigureMetricsMissingIntegrationTests { @Test void customizerRunsAndOnlyEnablesSimpleMeterRegistryWhenNoAnnotationPresent( @Autowired ApplicationContext applicationContext) { assertThat(applicationContext.getBean(MeterRegistry.class)).isInstanceOf(SimpleMeterRegistry.class); - assertThat(applicationContext.getBeansOfType(io.micrometer.prometheusmetrics.PrometheusMeterRegistry.class)) - .isEmpty(); + assertThat(applicationContext.getBeansOfType(PrometheusMeterRegistry.class)).isEmpty(); } @Test void customizerRunsAndSetsExclusionPropertiesWhenNoAnnotationPresent(@Autowired Environment environment) { assertThat(environment.getProperty("management.defaults.metrics.export.enabled")).isEqualTo("false"); assertThat(environment.getProperty("management.simple.metrics.export.enabled")).isEqualTo("true"); - assertThat(environment.getProperty("management.tracing.export.enabled")).isEqualTo("false"); } } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilityPresentIntegrationTests.java b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsPresentIntegrationTests.java similarity index 87% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilityPresentIntegrationTests.java rename to module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsPresentIntegrationTests.java index 14d992f0d60..d08f1d1cec5 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilityPresentIntegrationTests.java +++ b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsPresentIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; import org.junit.jupiter.api.Test; @@ -27,15 +27,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * Integration test to verify behaviour when - * {@link AutoConfigureObservability @AutoConfigureObservability} is present on the test - * class. + * {@link AutoConfigureMetrics @AutoConfigureMetrics} is present on the test class. * * @author Chris Bono * @author Moritz Halbritter */ @SpringBootTest -@AutoConfigureObservability -class AutoConfigureObservabilityPresentIntegrationTests { +@AutoConfigureMetrics +class AutoConfigureMetricsPresentIntegrationTests { @Test void customizerDoesNotDisableAvailableMeterRegistriesWhenAnnotationPresent( diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilitySlicedIntegrationTests.java b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsSlicedIntegrationTests.java similarity index 74% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilitySlicedIntegrationTests.java rename to module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsSlicedIntegrationTests.java index 158f4d5c8e8..666be3dbe8b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilitySlicedIntegrationTests.java +++ b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsSlicedIntegrationTests.java @@ -14,37 +14,33 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; import io.micrometer.observation.ObservationRegistry; -import io.micrometer.tracing.Tracer; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.context.ApplicationContext; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link AutoConfigureObservability} when used on a sliced test. + * Tests for {@link AutoConfigureMetrics} when used on a sliced test. * * @author Moritz Halbritter */ -@WebMvcTest -@AutoConfigureObservability -class AutoConfigureObservabilitySlicedIntegrationTests { +// TODO Test AutoConfigureMetrics in a sliced test +// @WebMvcTest +@Disabled +@AutoConfigureMetrics +class AutoConfigureMetricsSlicedIntegrationTests { @Autowired private ApplicationContext context; - @Test - void shouldHaveTracer() { - assertThat(this.context.getBean(Tracer.class)).isEqualTo(Tracer.NOOP); - } - @Test void shouldHaveMeterRegistry() { assertThat(this.context.getBean(MeterRegistry.class)).isInstanceOf(SimpleMeterRegistry.class); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebFluxApplication.java b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsSpringBootApplication.java similarity index 64% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebFluxApplication.java rename to module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsSpringBootApplication.java index 2ad35523bfe..c57bca6d13b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebFluxApplication.java +++ b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/AutoConfigureMetricsSpringBootApplication.java @@ -14,19 +14,21 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; /** - * Example {@link SpringBootApplication @SpringBootApplication} used with - * {@link WebFluxTest @WebFluxTest} tests. + * Example {@link SpringBootApplication @SpringBootApplication} for use with + * {@link AutoConfigureMetrics @AutoConfigureMetrics} tests. * - * @author Stephane Nicoll + * @author Chris Bono + * @author Moritz Halbritter */ -@SpringBootApplication(exclude = CassandraAutoConfiguration.class) -public class ExampleWebFluxApplication { +@SpringBootConfiguration +@EnableAutoConfiguration +class AutoConfigureMetricsSpringBootApplication { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactoryTests.java similarity index 63% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java rename to module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactoryTests.java index 7bb58b18c9b..95988d99843 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/ObservabilityContextCustomizerFactoryTests.java +++ b/module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactoryTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.metrics.test.autoconfigure; import java.util.Collections; @@ -28,113 +28,106 @@ import org.springframework.test.context.ContextCustomizer; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link AutoConfigureObservability} and - * {@link ObservabilityContextCustomizerFactory} working together. + * Tests for {@link AutoConfigureMetrics} and {@link MetricsContextCustomizerFactory} + * working together. * * @author Chris Bono * @author Moritz Halbritter + * @author Andy Wilkinson */ -class ObservabilityContextCustomizerFactoryTests { +class MetricsContextCustomizerFactoryTests { - private final ObservabilityContextCustomizerFactory factory = new ObservabilityContextCustomizerFactory(); + private final MetricsContextCustomizerFactory factory = new MetricsContextCustomizerFactory(); @Test - void shouldDisableBothWhenNotAnnotated() { + void whenNotAnnotatedMetricsExportIsDisabled() { ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class); ConfigurableApplicationContext context = new GenericApplicationContext(); applyCustomizerToContext(customizer, context); assertThatMetricsAreDisabled(context); - assertThatTracingIsDisabled(context); } @Test - void shouldDisableOnlyTracing() { - ContextCustomizer customizer = createContextCustomizer(OnlyMetrics.class); + void whenAnnotatedWithDefaultAttributeMetricsExportIsEnabled() { + ContextCustomizer customizer = createContextCustomizer(MetricsExportDefault.class); ConfigurableApplicationContext context = new GenericApplicationContext(); applyCustomizerToContext(customizer, context); assertThatMetricsAreEnabled(context); - assertThatTracingIsDisabled(context); } @Test - void shouldDisableOnlyMetrics() { - ContextCustomizer customizer = createContextCustomizer(OnlyTracing.class); + void whenAnnotatedWithFalseExportAttributeMetricsExportIsDisabled() { + ContextCustomizer customizer = createContextCustomizer(MetricsExportDisabled.class); ConfigurableApplicationContext context = new GenericApplicationContext(); applyCustomizerToContext(customizer, context); assertThatMetricsAreDisabled(context); - assertThatTracingIsEnabled(context); } @Test - void shouldEnableBothWhenAnnotated() { - ContextCustomizer customizer = createContextCustomizer(WithAnnotation.class); + void whenAnnotatedWithTrueExportAttributeMetricsExportIsEnabled() { + ContextCustomizer customizer = createContextCustomizer(MetricsExportEnabled.class); ConfigurableApplicationContext context = new GenericApplicationContext(); applyCustomizerToContext(customizer, context); assertThatMetricsAreEnabled(context); - assertThatTracingIsEnabled(context); } @Test void notEquals() { - ContextCustomizer customizer1 = createContextCustomizer(OnlyMetrics.class); - ContextCustomizer customizer2 = createContextCustomizer(OnlyTracing.class); + ContextCustomizer customizer1 = createContextCustomizer(MetricsExportEnabled.class); + ContextCustomizer customizer2 = createContextCustomizer(MetricsExportDisabled.class); assertThat(customizer1).isNotEqualTo(customizer2); } @Test void equals() { - ContextCustomizer customizer1 = createContextCustomizer(OnlyMetrics.class); - ContextCustomizer customizer2 = createContextCustomizer(OnlyMetrics.class); + ContextCustomizer customizer1 = createContextCustomizer(MetricsExportEnabled.class); + ContextCustomizer customizer2 = createContextCustomizer(MetricsExportEnabled.class); assertThat(customizer1).isEqualTo(customizer2); assertThat(customizer1).hasSameHashCodeAs(customizer2); } @Test - void metricsAndTracingCanBeEnabledViaProperty() { + void metricsExportCanBeEnabledViaProperty() { ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class); ConfigurableApplicationContext context = new GenericApplicationContext(); MockEnvironment environment = new MockEnvironment(); - environment.setProperty("spring.test.observability.auto-configure", "true"); + environment.setProperty("spring.test.metrics.auto-configure", "true"); context.setEnvironment(environment); applyCustomizerToContext(customizer, context); assertThatMetricsAreEnabled(context); - assertThatTracingIsEnabled(context); } @Test - void metricsAndTracingCanBeDisabledViaProperty() { + void metricsCanBeDisabledViaProperty() { ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class); ConfigurableApplicationContext context = new GenericApplicationContext(); MockEnvironment environment = new MockEnvironment(); - environment.setProperty("spring.test.observability.auto-configure", "false"); + environment.setProperty("spring.test.metrics.auto-configure", "false"); context.setEnvironment(environment); applyCustomizerToContext(customizer, context); assertThatMetricsAreDisabled(context); - assertThatTracingIsDisabled(context); } @Test void annotationTakesPrecedenceOverDisabledProperty() { - ContextCustomizer customizer = createContextCustomizer(WithAnnotation.class); + ContextCustomizer customizer = createContextCustomizer(MetricsExportEnabled.class); ConfigurableApplicationContext context = new GenericApplicationContext(); MockEnvironment environment = new MockEnvironment(); - environment.setProperty("spring.test.observability.auto-configure", "false"); + environment.setProperty("spring.test.metrics.auto-configure", "false"); context.setEnvironment(environment); applyCustomizerToContext(customizer, context); assertThatMetricsAreEnabled(context); - assertThatTracingIsEnabled(context); } @Test void annotationTakesPrecedenceOverEnabledProperty() { - ContextCustomizer customizer = createContextCustomizer(WithDisabledAnnotation.class); + ContextCustomizer customizer = createContextCustomizer(MetricsExportDisabled.class); ConfigurableApplicationContext context = new GenericApplicationContext(); MockEnvironment environment = new MockEnvironment(); - environment.setProperty("spring.test.observability.auto-configure", "true"); + environment.setProperty("spring.test.metrics.auto-configure", "true"); context.setEnvironment(environment); applyCustomizerToContext(customizer, context); assertThatMetricsAreDisabled(context); - assertThatTracingIsDisabled(context); } private void applyCustomizerToContext(ContextCustomizer customizer, ConfigurableApplicationContext context) { @@ -147,20 +140,12 @@ class ObservabilityContextCustomizerFactoryTests { return contextCustomizer; } - private void assertThatTracingIsDisabled(ConfigurableApplicationContext context) { - assertThat(context.getEnvironment().getProperty("management.tracing.export.enabled")).isEqualTo("false"); - } - private void assertThatMetricsAreDisabled(ConfigurableApplicationContext context) { assertThat(context.getEnvironment().getProperty("management.defaults.metrics.export.enabled")) .isEqualTo("false"); assertThat(context.getEnvironment().getProperty("management.simple.metrics.export.enabled")).isEqualTo("true"); } - private void assertThatTracingIsEnabled(ConfigurableApplicationContext context) { - assertThat(context.getEnvironment().getProperty("management.tracing.export.enabled")).isNull(); - } - private void assertThatMetricsAreEnabled(ConfigurableApplicationContext context) { assertThat(context.getEnvironment().getProperty("management.defaults.metrics.export.enabled")).isNull(); assertThat(context.getEnvironment().getProperty("management.simple.metrics.export.enabled")).isNull(); @@ -170,23 +155,18 @@ class ObservabilityContextCustomizerFactoryTests { } - @AutoConfigureObservability(tracing = false) - static class OnlyMetrics { + @AutoConfigureMetrics + static class MetricsExportDefault { } - @AutoConfigureObservability(metrics = false) - static class OnlyTracing { + @AutoConfigureMetrics(export = false) + static class MetricsExportDisabled { } - @AutoConfigureObservability - static class WithAnnotation { - - } - - @AutoConfigureObservability(metrics = false, tracing = false) - static class WithDisabledAnnotation { + @AutoConfigureMetrics(export = true) + static class MetricsExportEnabled { } diff --git a/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.java b/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.java index 35aa9d31e14..0780a47e1bc 100644 --- a/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.java +++ b/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.java @@ -84,6 +84,7 @@ public final class PrometheusMetricsExportAutoConfiguration { } @Configuration(proxyBeanMethods = false) + @ConditionalOnClass({ PrometheusScrapeEndpoint.class, ConditionalOnAvailableEndpoint.class }) @ConditionalOnAvailableEndpoint(PrometheusScrapeEndpoint.class) static class PrometheusScrapeEndpointConfiguration { @@ -101,7 +102,7 @@ public final class PrometheusMetricsExportAutoConfiguration { * Pushgateway. */ @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(PushGateway.class) + @ConditionalOnClass({ PushGateway.class, PrometheusPushGatewayManager.class }) @ConditionalOnBooleanProperty("management.prometheus.metrics.export.pushgateway.enabled") static class PrometheusPushGatewayConfiguration { diff --git a/module/spring-boot-micrometer-tracing-test/build.gradle b/module/spring-boot-micrometer-tracing-test/build.gradle new file mode 100644 index 00000000000..e0b58b0eda5 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/build.gradle @@ -0,0 +1,37 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Micrometer Tracing Test" + +dependencies { + api(project(":module:spring-boot-micrometer-tracing")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracing.java b/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracing.java new file mode 100644 index 00000000000..e9f83280dfc --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracing.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.micrometer.tracing.test.autoconfigure; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.micrometer.observation.ObservationRegistry; +import io.micrometer.tracing.Tracer; + +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; + +/** + * Annotation that can be applied to a test class to enable auto-configuration for + * tracing. + *

+ * If this annotation is applied to a sliced test, a no-op {@link Tracer} and an + * {@link ObservationRegistry} are added to the application context. + * + * @author Moritz Halbritter + * @since 4.0.0 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@ImportAutoConfiguration +public @interface AutoConfigureTracing { + + /** + * Whether traces should be reported to external systems in the test. + * @return whether traces should be reported to external systems in the test + */ + boolean export() default true; + +} diff --git a/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactory.java b/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactory.java new file mode 100644 index 00000000000..8ec991b5a80 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactory.java @@ -0,0 +1,97 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.micrometer.tracing.test.autoconfigure; + +import java.util.List; +import java.util.Objects; + +import org.jspecify.annotations.Nullable; + +import org.springframework.boot.test.util.TestPropertyValues; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfigurationAttributes; +import org.springframework.test.context.ContextCustomizer; +import org.springframework.test.context.ContextCustomizerFactory; +import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.TestContextAnnotationUtils; + +/** + * {@link ContextCustomizerFactory} that globally disables metrics export in tests. The + * behaviour can be controlled with {@link AutoConfigureTracing} on the test class or via + * the {@value #AUTO_CONFIGURE_PROPERTY} property. + * + * @author Chris Bono + * @author Moritz Halbritter + * @author Andy Wilkinson + */ +class TracingContextCustomizerFactory implements ContextCustomizerFactory { + + // TODO spring.test.tracing.export? + static final String AUTO_CONFIGURE_PROPERTY = "spring.test.tracing.auto-configure"; + + @Override + public ContextCustomizer createContextCustomizer(Class testClass, + List configAttributes) { + AutoConfigureTracing annotation = TestContextAnnotationUtils.findMergedAnnotation(testClass, + AutoConfigureTracing.class); + return new DisableTracingExportContextCustomizer(annotation); + } + + private static class DisableTracingExportContextCustomizer implements ContextCustomizer { + + private final @Nullable AutoConfigureTracing annotation; + + DisableTracingExportContextCustomizer(@Nullable AutoConfigureTracing annotation) { + this.annotation = annotation; + } + + @Override + public void customizeContext(ConfigurableApplicationContext context, + MergedContextConfiguration mergedContextConfiguration) { + if (isTracingDisabled(context.getEnvironment())) { + TestPropertyValues.of("management.tracing.export.enabled=false").applyTo(context); + } + } + + private boolean isTracingDisabled(Environment environment) { + if (this.annotation != null) { + return !this.annotation.export(); + } + return !environment.getProperty(AUTO_CONFIGURE_PROPERTY, Boolean.class, false); + } + + @Override + public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DisableTracingExportContextCustomizer that = (DisableTracingExportContextCustomizer) o; + return Objects.equals(this.annotation, that.annotation); + } + + @Override + public int hashCode() { + return Objects.hash(this.annotation); + } + + } + +} diff --git a/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/package-info.java b/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/package-info.java new file mode 100644 index 00000000000..3eb778cff10 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Auto-configuration for handling metrics in tests. + */ +@NullMarked +package org.springframework.boot.micrometer.tracing.test.autoconfigure; + +import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring-configuration-metadata.json b/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring-configuration-metadata.json new file mode 100644 index 00000000000..54334d8c829 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "name": "spring.test.tracing.auto-configure", + "type": "java.lang.Boolean", + "description": "Whether tracing should be auto-configured in tests.", + "defaultValue": false + } + ] +} diff --git a/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..6766f41ed8e --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Spring Test Context Customizer Factories +org.springframework.test.context.ContextCustomizerFactory=\ +org.springframework.boot.micrometer.tracing.test.autoconfigure.TracingContextCustomizerFactory diff --git a/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring/org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing.imports b/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring/org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing.imports new file mode 100644 index 00000000000..884746f7ca1 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring/org.springframework.boot.micrometer.tracing.test.autoconfigure.AutoConfigureTracing.imports @@ -0,0 +1,3 @@ +org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration +org.springframework.boot.micrometer.tracing.autoconfigure.MicrometerTracingAutoConfiguration +org.springframework.boot.micrometer.tracing.autoconfigure.NoopTracerAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingMissingIntegrationTests.java similarity index 55% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java rename to module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingMissingIntegrationTests.java index 59ee5ae979f..c9e4e460bef 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java +++ b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingMissingIntegrationTests.java @@ -14,33 +14,29 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.micrometer.tracing.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.web.servlet.assertj.MockMvcTester; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.env.Environment; import static org.assertj.core.api.Assertions.assertThat; /** - * Integration tests for {@link WebMvcTest @WebMvcTest} and Pageable support. + * Integration test to verify behaviour when + * {@link AutoConfigureTracing @AutoConfigureTracing} is not present on the test class. * - * @author Stephane Nicoll + * @author Chris Bono + * @author Moritz Halbritter */ -@WebMvcTest -@WithMockUser -class WebMvcTestPageableIntegrationTests { - - @Autowired - private MockMvcTester mvc; +@SpringBootTest +class AutoConfigureTracingMissingIntegrationTests { @Test - void shouldSupportPageable() { - assertThat(this.mvc.get().uri("/paged").param("page", "2").param("size", "42")).hasStatusOk() - .hasBodyTextEqualTo("2:42"); + void customizerRunsAndDisablesExportWhenNoAnnotationPresent(@Autowired Environment environment) { + assertThat(environment.getProperty("management.tracing.export.enabled")).isEqualTo("false"); } } diff --git a/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingPresentIntegrationTests.java b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingPresentIntegrationTests.java new file mode 100644 index 00000000000..2d531f50662 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingPresentIntegrationTests.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.micrometer.tracing.test.autoconfigure; + +import io.micrometer.tracing.Tracer; +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.core.env.Environment; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration test to verify behaviour when + * {@link AutoConfigureTracing @AutoConfigureTracing} is present on the test class. + * + * @author Chris Bono + * @author Moritz Halbritter + */ +@SpringBootTest +@AutoConfigureTracing +class AutoConfigureTracingPresentIntegrationTests { + + @Test + void customizerDoesNotDisableAvailableMeterRegistriesWhenAnnotationPresent( + @Autowired ApplicationContext applicationContext) { + assertThat(applicationContext.getBean(Tracer.class)).isEqualTo(Tracer.NOOP); + } + + @Test + void customizerDoesNotSetExportDisabledPropertyWhenAnnotationPresent(@Autowired Environment environment) { + assertThat(environment.containsProperty("management.tracing.export.enabled")).isFalse(); + } + +} diff --git a/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingSlicedIntegrationTests.java b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingSlicedIntegrationTests.java new file mode 100644 index 00000000000..b60bcc80806 --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingSlicedIntegrationTests.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.micrometer.tracing.test.autoconfigure; + +import io.micrometer.observation.ObservationRegistry; +import io.micrometer.tracing.Tracer; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link AutoConfigureTracing @AutoConfigureTracing} when used on a sliced + * test. + * + * @author Moritz Halbritter + */ +// TODO Test AutoConfigureTracing in a sliced test +// @WebMvcTest +@Disabled +@AutoConfigureTracing +class AutoConfigureTracingSlicedIntegrationTests { + + @Autowired + private ApplicationContext context; + + @Test + void shouldHaveTracer() { + assertThat(this.context.getBean(Tracer.class)).isEqualTo(Tracer.NOOP); + } + + @Test + void shouldHaveObservationRegistry() { + assertThat(this.context.getBean(ObservationRegistry.class)).isNotNull(); + } + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilitySpringBootApplication.java b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingSpringBootApplication.java similarity index 62% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilitySpringBootApplication.java rename to module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingSpringBootApplication.java index dd9f3d3f6e7..df71a838f6b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/observability/AutoConfigureObservabilitySpringBootApplication.java +++ b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/AutoConfigureTracingSpringBootApplication.java @@ -14,25 +14,21 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.micrometer.tracing.test.autoconfigure; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; -import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration; -import org.springframework.boot.mongodb.autoconfigure.MongoReactiveAutoConfiguration; /** * Example {@link SpringBootApplication @SpringBootApplication} for use with - * {@link AutoConfigureObservability @AutoConfigureObservability} tests. + * {@link AutoConfigureTracing @AutoConfigureTracing} tests. * * @author Chris Bono * @author Moritz Halbritter */ @SpringBootConfiguration -@EnableAutoConfiguration(exclude = { CassandraAutoConfiguration.class, MongoReactiveAutoConfiguration.class, - MongoAutoConfiguration.class }) -class AutoConfigureObservabilitySpringBootApplication { +@EnableAutoConfiguration +class AutoConfigureTracingSpringBootApplication { } diff --git a/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactoryTests.java b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactoryTests.java new file mode 100644 index 00000000000..19ee5a166ec --- /dev/null +++ b/module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactoryTests.java @@ -0,0 +1,169 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.micrometer.tracing.test.autoconfigure; + +import java.util.Collections; + +import org.junit.jupiter.api.Test; + +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.support.GenericApplicationContext; +import org.springframework.mock.env.MockEnvironment; +import org.springframework.test.context.ContextCustomizer; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link AutoConfigureTracing} and {@link TracingContextCustomizerFactory} + * working together. + * + * @author Chris Bono + * @author Moritz Halbritter + */ +class TracingContextCustomizerFactoryTests { + + private final TracingContextCustomizerFactory factory = new TracingContextCustomizerFactory(); + + @Test + void whenNotAnnotatedTracingExportIsDisabled() { + ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsDisabled(context); + } + + @Test + void whenAnnotatedWithDefaultAttributeTracingExportIsEnabled() { + ContextCustomizer customizer = createContextCustomizer(TracingExportDefault.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsEnabled(context); + } + + @Test + void whenAnnotatedWithFalseExportAttributeTracingExportIsDisabled() { + ContextCustomizer customizer = createContextCustomizer(TracingExportDisabled.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsDisabled(context); + } + + @Test + void whenAnnotatedWithTrueExportAttributeTracingExportIsEnabled() { + ContextCustomizer customizer = createContextCustomizer(TracingExportEnabled.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsEnabled(context); + } + + @Test + void notEquals() { + ContextCustomizer customizer1 = createContextCustomizer(TracingExportEnabled.class); + ContextCustomizer customizer2 = createContextCustomizer(TracingExportDisabled.class); + assertThat(customizer1).isNotEqualTo(customizer2); + } + + @Test + void equals() { + ContextCustomizer customizer1 = createContextCustomizer(TracingExportEnabled.class); + ContextCustomizer customizer2 = createContextCustomizer(TracingExportEnabled.class); + assertThat(customizer1).isEqualTo(customizer2); + assertThat(customizer1).hasSameHashCodeAs(customizer2); + } + + @Test + void tracingExportCanBeEnabledViaProperty() { + ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + MockEnvironment environment = new MockEnvironment(); + environment.setProperty("spring.test.tracing.auto-configure", "true"); + context.setEnvironment(environment); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsEnabled(context); + } + + @Test + void tracingExportCanBeDisabledViaProperty() { + ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + MockEnvironment environment = new MockEnvironment(); + environment.setProperty("spring.test.tracing.auto-configure", "false"); + context.setEnvironment(environment); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsDisabled(context); + } + + @Test + void annotationTakesPrecedenceOverDisabledProperty() { + ContextCustomizer customizer = createContextCustomizer(TracingExportEnabled.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + MockEnvironment environment = new MockEnvironment(); + environment.setProperty("spring.test.tracing.auto-configure", "false"); + context.setEnvironment(environment); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsEnabled(context); + } + + @Test + void annotationTakesPrecedenceOverEnabledProperty() { + ContextCustomizer customizer = createContextCustomizer(TracingExportDisabled.class); + ConfigurableApplicationContext context = new GenericApplicationContext(); + MockEnvironment environment = new MockEnvironment(); + environment.setProperty("spring.test.tracing.auto-configure", "true"); + context.setEnvironment(environment); + applyCustomizerToContext(customizer, context); + assertThatTracingExportIsDisabled(context); + } + + private void applyCustomizerToContext(ContextCustomizer customizer, ConfigurableApplicationContext context) { + customizer.customizeContext(context, null); + } + + private ContextCustomizer createContextCustomizer(Class testClass) { + ContextCustomizer contextCustomizer = this.factory.createContextCustomizer(testClass, Collections.emptyList()); + assertThat(contextCustomizer).as("contextCustomizer").isNotNull(); + return contextCustomizer; + } + + private void assertThatTracingExportIsDisabled(ConfigurableApplicationContext context) { + assertThat(context.getEnvironment().getProperty("management.tracing.export.enabled")).isEqualTo("false"); + } + + private void assertThatTracingExportIsEnabled(ConfigurableApplicationContext context) { + assertThat(context.getEnvironment().getProperty("management.tracing.export.enabled")).isNull(); + } + + static class NoAnnotation { + + } + + @AutoConfigureTracing + static class TracingExportDefault { + + } + + @AutoConfigureTracing(export = false) + static class TracingExportDisabled { + + } + + @AutoConfigureTracing(export = true) + static class TracingExportEnabled { + + } + +} diff --git a/module/spring-boot-mustache/build.gradle b/module/spring-boot-mustache/build.gradle index 03382423459..511155eaade 100644 --- a/module/spring-boot-mustache/build.gradle +++ b/module/spring-boot-mustache/build.gradle @@ -37,10 +37,14 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-reactor-netty")) testImplementation(project(":module:spring-boot-restclient")) - testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":module:spring-boot-reactor-netty")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) + testImplementation(project(":module:spring-boot-tomcat")) + testImplementation(project(":module:spring-boot-webflux-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":module:spring-boot-web-server-test")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("io.projectreactor:reactor-test") testRuntimeOnly("ch.qos.logback:logback-classic") diff --git a/module/spring-boot-mustache/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports b/module/spring-boot-mustache/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports new file mode 100644 index 00000000000..94e421b7af6 --- /dev/null +++ b/module/spring-boot-mustache/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports @@ -0,0 +1 @@ +org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration diff --git a/module/spring-boot-mustache/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-mustache/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..94e421b7af6 --- /dev/null +++ b/module/spring-boot-mustache/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration diff --git a/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheWebFluxTestIntegrationTests.java b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheWebFluxTestIntegrationTests.java new file mode 100644 index 00000000000..2ba85384672 --- /dev/null +++ b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheWebFluxTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.mustache.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Mustache with {@link WebFluxTest @WebFluxTest}. + * + * @author Andy Wilkinson + */ +@WebFluxTest +class MustacheWebFluxTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void mustacheAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(MustacheAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheWebMvcTestIntegrationTests.java b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..54ee055b779 --- /dev/null +++ b/module/spring-boot-mustache/src/test/java/org/springframework/boot/mustache/autoconfigure/MustacheWebMvcTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.mustache.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Mustache with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class MustacheWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void mustacheAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(MustacheAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-restclient-test/build.gradle b/module/spring-boot-restclient-test/build.gradle index 41e914a0e7b..bc014afeabf 100644 --- a/module/spring-boot-restclient-test/build.gradle +++ b/module/spring-boot-restclient-test/build.gradle @@ -18,6 +18,7 @@ plugins { id "java-library" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" } description = "Spring Boot RestClient Test" @@ -26,10 +27,15 @@ dependencies { api(project(":core:spring-boot")) optional(project(":core:spring-boot-autoconfigure")) + optional(project(":module:spring-boot-jackson")) + optional(project(":module:spring-boot-json-test")) optional(project(":module:spring-boot-restclient")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") optional("org.springframework:spring-test") testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":module:spring-boot-micrometer-metrics")) testImplementation(project(":test-support:spring-boot-test-support")) testRuntimeOnly("ch.qos.logback:logback-classic") diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java index 9ae0f3e278c..94e853b4fd6 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServer.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -45,7 +45,7 @@ import org.springframework.web.client.RestClient.Builder; * * @author Phillip Webb * @author Scott Frederick - * @since 1.4.0 + * @since 4.0.0 * @see MockServerRestTemplateCustomizer */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java index bd9971b2c51..69be8b0a4c0 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClient.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,8 +24,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.json.test.autoconfigure.AutoConfigureJson; import org.springframework.boot.restclient.RestTemplateBuilder; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; import org.springframework.web.client.RestTemplate; @@ -35,7 +35,7 @@ import org.springframework.web.client.RestTemplate; * * @author Stephane Nicoll * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/MockRestServiceServerAutoConfiguration.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/MockRestServiceServerAutoConfiguration.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/MockRestServiceServerAutoConfiguration.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/MockRestServiceServerAutoConfiguration.java index a68dd3726b0..a7be94682a1 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/MockRestServiceServerAutoConfiguration.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/MockRestServiceServerAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import java.io.IOException; import java.lang.reflect.Constructor; @@ -44,7 +44,7 @@ import org.springframework.web.client.RestTemplate; * * @author Phillip Webb * @author Scott Frederick - * @since 1.4.0 + * @since 4.0.0 * @see AutoConfigureMockRestServiceServer */ @AutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/MockRestServiceServerResetTestExecutionListener.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/MockRestServiceServerResetTestExecutionListener.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/MockRestServiceServerResetTestExecutionListener.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/MockRestServiceServerResetTestExecutionListener.java index fe62d77829c..32617b700cc 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/MockRestServiceServerResetTestExecutionListener.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/MockRestServiceServerResetTestExecutionListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.context.ApplicationContext; import org.springframework.core.Ordered; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java index 0262d519ca0..0a0c74d9df9 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTest.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -29,7 +29,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.restclient.RestTemplateBuilder; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.context.annotation.ComponentScan; import org.springframework.core.annotation.AliasFor; @@ -70,7 +69,7 @@ import org.springframework.web.client.RestTemplate; * @author Stephane Nicoll * @author Phillip Webb * @author Artsiom Yudovin - * @since 1.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -80,7 +79,6 @@ import org.springframework.web.client.RestTemplate; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(RestClientTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureWebClient @AutoConfigureMockRestServiceServer @ImportAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestContextBootstrapper.java index c94b3e55d8c..24606ba7ac8 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestContextBootstrapper.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTypeExcludeFilter.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTypeExcludeFilter.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTypeExcludeFilter.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTypeExcludeFilter.java index 1d2609bed4c..2404229c409 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTypeExcludeFilter.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import java.util.Arrays; import java.util.Collections; @@ -30,7 +30,7 @@ import org.springframework.util.ClassUtils; * {@link TypeExcludeFilter} for {@link RestClientTest @RestClientTest}. * * @author Stephane Nicoll - * @since 2.2.1 + * @since 4.0.0 */ public final class RestClientTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { @@ -38,7 +38,7 @@ public final class RestClientTypeExcludeFilter extends StandardAnnotationCustomi private static final String DATABIND_MODULE_CLASS_NAME = "tools.jackson.databind.JacksonModule"; - private static final Set> DEFAULT_INCLUDES; + private static final Set> KNOWN_INCLUDES; static { Set> includes = new LinkedHashSet<>(); @@ -52,7 +52,7 @@ public final class RestClientTypeExcludeFilter extends StandardAnnotationCustomi } includes.add(JsonComponent.class); } - DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES = Collections.unmodifiableSet(includes); } private final Class[] components; @@ -63,8 +63,8 @@ public final class RestClientTypeExcludeFilter extends StandardAnnotationCustomi } @Override - protected Set> getDefaultIncludes() { - return DEFAULT_INCLUDES; + protected Set> getKnownIncludes() { + return KNOWN_INCLUDES; } @Override diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/WebClientRestTemplateAutoConfiguration.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/WebClientRestTemplateAutoConfiguration.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/WebClientRestTemplateAutoConfiguration.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/WebClientRestTemplateAutoConfiguration.java index 8b6b39d48bc..e7f4665ae21 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/WebClientRestTemplateAutoConfiguration.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/WebClientRestTemplateAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; @@ -28,7 +28,7 @@ import org.springframework.web.client.RestTemplate; * {@link AutoConfigureWebClient#registerRestTemplate()} is {@code true}. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see AutoConfigureMockRestServiceServer */ @AutoConfiguration(afterName = "org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration") diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/package-info.java b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/package-info.java rename to module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/package-info.java index 592f4f6f42f..c13236cdf56 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/client/package-info.java +++ b/module/spring-boot-restclient-test/src/main/java/org/springframework/boot/restclient/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for web clients. */ @NullMarked -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring-configuration-metadata.json b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring-configuration-metadata.json new file mode 100644 index 00000000000..869c0754a12 --- /dev/null +++ b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring-configuration-metadata.json @@ -0,0 +1,16 @@ +{ + "properties": [ + { + "name": "spring.test.webclient.mockrestserviceserver.enabled", + "type": "java.lang.Boolean", + "description": "Whether a MockRestServiceServer should be auto-configured.", + "defaultValue": true + }, + { + "name": "spring.test.webclient.register-rest-template", + "type": "java.lang.Boolean", + "description": "Whether a RestTemplate bean should be registered.", + "defaultValue": false + } + ] +} diff --git a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..7f343218f08 --- /dev/null +++ b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Spring Test Execution Listeners +org.springframework.test.context.TestExecutionListener=\ +org.springframework.boot.restclient.test.autoconfigure.MockRestServiceServerResetTestExecutionListener diff --git a/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureMockRestServiceServer.imports b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureMockRestServiceServer.imports new file mode 100644 index 00000000000..217a77105cf --- /dev/null +++ b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureMockRestServiceServer.imports @@ -0,0 +1 @@ +org.springframework.boot.restclient.test.autoconfigure.MockRestServiceServerAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient.imports b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureWebClient.imports similarity index 79% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient.imports rename to module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureWebClient.imports index 5ae9ead0a85..165c5e9b42f 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient.imports +++ b/module/spring-boot-restclient-test/src/main/resources/META-INF/spring/org.springframework.boot.restclient.test.autoconfigure.AutoConfigureWebClient.imports @@ -1,7 +1,6 @@ -# AutoConfigureWebClient auto-configuration imports +org.springframework.boot.restclient.test.autoconfigure.WebClientRestTemplateAutoConfiguration optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration optional:org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration optional:org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration optional:org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration optional:org.springframework.boot.webclient.WebClientAutoConfiguration -org.springframework.boot.test.autoconfigure.web.client.WebClientRestTemplateAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AnotherExampleRestClientService.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AnotherExampleRestClientService.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AnotherExampleRestClientService.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AnotherExampleRestClientService.java index c3d810a515c..7d1b76821b2 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AnotherExampleRestClientService.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AnotherExampleRestClientService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClient; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AnotherExampleRestTemplateService.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AnotherExampleRestTemplateService.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AnotherExampleRestTemplateService.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AnotherExampleRestTemplateService.java index 9eaf059876f..f9a64c94aed 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AnotherExampleRestTemplateService.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AnotherExampleRestTemplateService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.boot.restclient.RestTemplateBuilder; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests.java index ab9b8f70f4c..27c5045203c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerEnabledFalseIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerWithRestClientIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerWithRestClientIntegrationTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerWithRestClientIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerWithRestClientIntegrationTests.java index 66972f95cfd..f56dd1ad18c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerWithRestClientIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerWithRestClientIntegrationTests.java @@ -14,13 +14,12 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -58,7 +57,7 @@ class AutoConfigureMockRestServiceServerWithRestClientIntegrationTests { assertThat(entity.getBody()).isEqualTo("hello"); } - @EnableAutoConfiguration(exclude = CassandraAutoConfiguration.class) + @EnableAutoConfiguration @Configuration(proxyBeanMethods = false) static class RootUriConfiguration { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests.java index d322558adb7..a02b1c8efc0 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import io.micrometer.core.instrument.MeterRegistry; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; import org.springframework.boot.restclient.RestTemplateBuilder; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; @@ -63,7 +62,7 @@ class AutoConfigureMockRestServiceServerWithRestTemplateRootUriIntegrationTests assertThat(this.meterRegistry.find("http.client.requests").tag("uri", "/test").timer()).isNotNull(); } - @EnableAutoConfiguration(exclude = CassandraAutoConfiguration.class) + @EnableAutoConfiguration @Configuration(proxyBeanMethods = false) static class RootUriConfiguration { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClientWithRestTemplateIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClientWithRestTemplateIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClientWithRestTemplateIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClientWithRestTemplateIntegrationTests.java index e9825625256..e896e0db503 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/AutoConfigureWebClientWithRestTemplateIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/AutoConfigureWebClientWithRestTemplateIntegrationTests.java @@ -14,14 +14,12 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; @@ -34,7 +32,7 @@ import static org.springframework.test.web.client.match.MockRestRequestMatchers. import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; /** - * Tests for {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} with + * Tests for {@link AutoConfigureWebClient @AutoConfigureWebClient} with * {@code registerRestTemplate=true}. * * @author Phillip Webb @@ -58,7 +56,7 @@ class AutoConfigureWebClientWithRestTemplateIntegrationTests { } @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration(exclude = CassandraAutoConfiguration.class) + @EnableAutoConfiguration static class Config { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleProperties.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleProperties.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleProperties.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleProperties.java index b16a5e27ffd..3d6a580281b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleProperties.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.bind.ConstructorBinding; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleRestClientService.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleRestClientService.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleRestClientService.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleRestClientService.java index 886d04a2f0e..4b19fadbc7f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleRestClientService.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleRestClientService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClient; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleRestTemplateService.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleRestTemplateService.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleRestTemplateService.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleRestTemplateService.java index 13a265c30c9..4a01d175de9 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleRestTemplateService.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleRestTemplateService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.boot.restclient.RestTemplateBuilder; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleWebClientApplication.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleWebClientApplication.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleWebClientApplication.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleWebClientApplication.java index 108a719d00a..8c3947fb0ca 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/ExampleWebClientApplication.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/ExampleWebClientApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestNoComponentIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestNoComponentIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestNoComponentIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestNoComponentIntegrationTests.java index f175c72385e..724c08b85d7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestNoComponentIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestNoComponentIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestPropertiesIntegrationTests.java index 2bbade55cfd..568bb38c730 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestPropertiesIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestClientIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestClientIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestClientIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestClientIntegrationTests.java index 6781b038cfb..8d62d05bded 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestClientIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestClientIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestClientTwoComponentsIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestClientTwoComponentsIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestClientTwoComponentsIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestClientTwoComponentsIntegrationTests.java index a358024bc59..befdf8ed000 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestClientTwoComponentsIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestClientTwoComponentsIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateAndRestClientTogetherIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateAndRestClientTogetherIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateAndRestClientTogetherIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateAndRestClientTogetherIntegrationTests.java index 93f8b07f128..a54a73b1bfe 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateAndRestClientTogetherIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateAndRestClientTogetherIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateIntegrationTests.java index 00e519aab37..1a178c2ab32 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateTwoComponentsIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateTwoComponentsIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateTwoComponentsIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateTwoComponentsIntegrationTests.java index 8cd8883e4f2..2cd40bab55a 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestRestTemplateTwoComponentsIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestRestTemplateTwoComponentsIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithConfigurationPropertiesIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithConfigurationPropertiesIntegrationTests.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithConfigurationPropertiesIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithConfigurationPropertiesIntegrationTests.java index 131980f2724..2644a6ca44e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithConfigurationPropertiesIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithConfigurationPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; @@ -39,7 +39,7 @@ class RestClientTestWithConfigurationPropertiesIntegrationTests { @Test void configurationPropertiesCanBeAddedAsComponent() { assertThat(this.applicationContext.getBeansOfType(ExampleProperties.class).keySet()) - .containsOnly("example-org.springframework.boot.test.autoconfigure.web.client.ExampleProperties"); + .containsOnly("example-" + ExampleProperties.class.getName()); assertThat(this.applicationContext.getBean(ExampleProperties.class).getName()).isEqualTo("Hello"); } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithRestClientComponentIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithRestClientComponentIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithRestClientComponentIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithRestClientComponentIntegrationTests.java index e2089fde7fd..28f156bf31b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithRestClientComponentIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithRestClientComponentIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithRestTemplateComponentIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithRestTemplateComponentIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithRestTemplateComponentIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithRestTemplateComponentIntegrationTests.java index f5261c16e98..7d052a0ffe4 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithRestTemplateComponentIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithRestTemplateComponentIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithoutJacksonIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java rename to module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithoutJacksonIntegrationTests.java index 885c1df4118..b5190fe6caa 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/client/RestClientTestWithoutJacksonIntegrationTests.java +++ b/module/spring-boot-restclient-test/src/test/java/org/springframework/boot/restclient/test/autoconfigure/RestClientTestWithoutJacksonIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.client; +package org.springframework.boot.restclient.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-restdocs/build.gradle b/module/spring-boot-restdocs/build.gradle new file mode 100644 index 00000000000..539b4e9ebd5 --- /dev/null +++ b/module/spring-boot-restdocs/build.gradle @@ -0,0 +1,43 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" +} + +description = "Spring Boot REST Docs" + +dependencies { + api("org.springframework.restdocs:spring-restdocs-core") + optional(project(":module:spring-boot-webmvc-test")) + optional(project(":module:spring-boot-web-server-test")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.springframework.restdocs:spring-restdocs-mockmvc") + optional("org.springframework.restdocs:spring-restdocs-restassured") + optional("org.springframework.restdocs:spring-restdocs-webtestclient") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(project(":module:spring-boot-webflux-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) + testImplementation(project(":module:spring-boot-hateoas")) + testImplementation("org.springframework.security:spring-security-test") + + testRuntimeOnly(project(":module:spring-boot-tomcat")) +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java index f362ab2eb0b..e133a5cf4f2 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/AutoConfigureRestDocs.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/AutoConfigureRestDocs.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -46,7 +46,7 @@ import org.springframework.test.web.servlet.MockMvc; * {@link RestDocsRestAssuredConfigurationCustomizer} bean can be used. * * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 * @see RestDocsAutoConfiguration * @see RestDocsMockMvcConfigurationCustomizer * @see RestDocsWebTestClientConfigurationCustomizer diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java index ec4d6a12f19..6c4e76fcbcf 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import io.restassured.builder.RequestSpecBuilder; import io.restassured.specification.RequestSpecification; @@ -44,7 +44,7 @@ import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation * @author Andy Wilkinson * @author Eddú Meléndez * @author Roman Zaynetdinov - * @since 1.4.0 + * @since 4.0.0 */ @AutoConfiguration @ConditionalOnWebApplication diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsMockMvcBuilderCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsMockMvcBuilderCustomizer.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsMockMvcBuilderCustomizer.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsMockMvcBuilderCustomizer.java index 3a640070993..f75622acdfd 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsMockMvcBuilderCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsMockMvcBuilderCustomizer.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.jspecify.annotations.Nullable; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.context.properties.PropertyMapper; -import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcBuilderCustomizer; +import org.springframework.boot.webmvc.test.autoconfigure.MockMvcBuilderCustomizer; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentationConfigurer; import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; import org.springframework.restdocs.mockmvc.UriConfigurer; @@ -30,7 +30,7 @@ import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder; * A {@link MockMvcBuilderCustomizer} that configures Spring REST Docs. * * @author Andy Wilkinson - * @since 1.5.22 + * @since 4.0.0 */ public class RestDocsMockMvcBuilderCustomizer implements InitializingBean, MockMvcBuilderCustomizer { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsMockMvcConfigurationCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsMockMvcConfigurationCustomizer.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsMockMvcConfigurationCustomizer.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsMockMvcConfigurationCustomizer.java index bfdcf1e1551..dc35f450c32 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsMockMvcConfigurationCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsMockMvcConfigurationCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentationConfigurer; @@ -27,7 +27,7 @@ import org.springframework.restdocs.mockmvc.MockMvcRestDocumentationConfigurer; * provide sufficient customization. * * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 */ @FunctionalInterface public interface RestDocsMockMvcConfigurationCustomizer { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsProperties.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsProperties.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsProperties.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsProperties.java index 97aee9c3cb2..6b9d4a4568a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsProperties.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.jspecify.annotations.Nullable; @@ -26,7 +26,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * @author Andy Wilkinson * @author Eddú Meléndez * @author Phillip Webb - * @since 2.0.0 + * @since 4.0.0 */ @ConfigurationProperties("spring.test.restdocs") public class RestDocsProperties { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsRestAssuredBuilderCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsRestAssuredBuilderCustomizer.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsRestAssuredBuilderCustomizer.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsRestAssuredBuilderCustomizer.java index d20d8bd0757..ce6c7ca0348 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsRestAssuredBuilderCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsRestAssuredBuilderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import io.restassured.specification.RequestSpecification; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsRestAssuredConfigurationCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsRestAssuredConfigurationCustomizer.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsRestAssuredConfigurationCustomizer.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsRestAssuredConfigurationCustomizer.java index d6d2a58f68f..53b774b193b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsRestAssuredConfigurationCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsRestAssuredConfigurationCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.springframework.restdocs.restassured.RestAssuredRestDocumentationConfigurer; @@ -27,7 +27,7 @@ import org.springframework.restdocs.restassured.RestAssuredRestDocumentationConf * provide sufficient customization. * * @author Eddú Meléndez - * @since 2.0.0 + * @since 4.0.0 */ @FunctionalInterface public interface RestDocsRestAssuredConfigurationCustomizer { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestExecutionListener.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestExecutionListener.java index f651a5ec94d..8c71ea1a1ea 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestExecutionListener.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestExecutionListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.jspecify.annotations.Nullable; @@ -31,7 +31,7 @@ import org.springframework.util.ClassUtils; * {@code @Rule} when using JUnit or manual before and after test calls when using TestNG. * * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 */ public class RestDocsTestExecutionListener extends AbstractTestExecutionListener { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientBuilderCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientBuilderCustomizer.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java index 527cc155be8..b8338e9e754 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientBuilderCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientBuilderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.jspecify.annotations.Nullable; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientConfigurationCustomizer.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientConfigurationCustomizer.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientConfigurationCustomizer.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientConfigurationCustomizer.java index 6c28991821b..cfa1800bbd1 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsWebTestClientConfigurationCustomizer.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsWebTestClientConfigurationCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer; @@ -27,7 +27,7 @@ import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation * provide sufficient customization. * * @author Roman Zaynetdinov - * @since 2.0.0 + * @since 4.0.0 */ @FunctionalInterface public interface RestDocsWebTestClientConfigurationCustomizer { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocumentationContextProviderRegistrar.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocumentationContextProviderRegistrar.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocumentationContextProviderRegistrar.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocumentationContextProviderRegistrar.java index de2e9858c33..43c9c110a4d 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocumentationContextProviderRegistrar.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocumentationContextProviderRegistrar.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.util.Map; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/package-info.java b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/package-info.java rename to module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/package-info.java index a139c6f08be..fa97144c450 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/package-info.java +++ b/module/spring-boot-restdocs/src/main/java/org/springframework/boot/restdocs/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for tests using Spring REST Docs. */ @NullMarked -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-restdocs/src/main/resources/META-INF/spring.factories b/module/spring-boot-restdocs/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..c9d881f9242 --- /dev/null +++ b/module/spring-boot-restdocs/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Spring Test Execution Listeners +org.springframework.test.context.TestExecutionListener=\ +org.springframework.boot.restdocs.test.autoconfigure.RestDocsTestExecutionListener diff --git a/module/spring-boot-restdocs/src/main/resources/META-INF/spring/org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs.imports b/module/spring-boot-restdocs/src/main/resources/META-INF/spring/org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs.imports new file mode 100644 index 00000000000..96a38bf5826 --- /dev/null +++ b/module/spring-boot-restdocs/src/main/resources/META-INF/spring/org.springframework.boot.restdocs.test.autoconfigure.AutoConfigureRestDocs.imports @@ -0,0 +1 @@ +org.springframework.boot.restdocs.test.autoconfigure.RestDocsAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java index 1bc77eaad3a..39a015d8892 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/MockMvcRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.io.File; @@ -22,9 +22,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.testsupport.BuildOutput; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.annotation.Bean; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/MockMvcRestDocsAutoConfigurationIntegrationTests.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/MockMvcRestDocsAutoConfigurationIntegrationTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/MockMvcRestDocsAutoConfigurationIntegrationTests.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/MockMvcRestDocsAutoConfigurationIntegrationTests.java index 42053704307..b86f2b9c597 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/MockMvcRestDocsAutoConfigurationIntegrationTests.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/MockMvcRestDocsAutoConfigurationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.io.File; @@ -22,8 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.testsupport.BuildOutput; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import org.springframework.util.FileSystemUtils; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java index 9a0604d1ba3..d609e332fa1 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.io.File; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestAssuredRestDocsAutoConfigurationIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestAssuredRestDocsAutoConfigurationIntegrationTests.java index c91fc2adf07..be28d6f77ec 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestAssuredRestDocsAutoConfigurationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.io.File; diff --git a/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestApplication.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestApplication.java new file mode 100644 index 00000000000..a3b6632ebe6 --- /dev/null +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.restdocs.test.autoconfigure; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Test application used with {@link AutoConfigureRestDocs @AutoConfigureRestDocs} tests. + * + * @author Andy Wilkinson + */ +@SpringBootApplication +public class RestDocsTestApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestController.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestController.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestController.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestController.java index a5981d1ba3d..be83e6b726f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestController.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/RestDocsTestController.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.util.HashMap; import java.util.Map; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java index 84cc5497ee2..ea8e6cf10d7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.io.File; @@ -22,9 +22,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.testsupport.BuildOutput; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; import org.springframework.context.annotation.Bean; import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/WebTestClientRestDocsAutoConfigurationIntegrationTests.java b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/WebTestClientRestDocsAutoConfigurationIntegrationTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/WebTestClientRestDocsAutoConfigurationIntegrationTests.java rename to module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/WebTestClientRestDocsAutoConfigurationIntegrationTests.java index 5b9cc2e4b46..19ec800f448 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/WebTestClientRestDocsAutoConfigurationIntegrationTests.java +++ b/module/spring-boot-restdocs/src/test/java/org/springframework/boot/restdocs/test/autoconfigure/WebTestClientRestDocsAutoConfigurationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.restdocs; +package org.springframework.boot.restdocs.test.autoconfigure; import java.io.File; @@ -22,8 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.boot.testsupport.BuildOutput; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.FileSystemUtils; diff --git a/module/spring-boot-security-oauth2-client/build.gradle b/module/spring-boot-security-oauth2-client/build.gradle index 2c3979ef1c0..86c31b7f7a4 100644 --- a/module/spring-boot-security-oauth2-client/build.gradle +++ b/module/spring-boot-security-oauth2-client/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Security OAuth2 Client" @@ -32,11 +33,16 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":module:spring-boot-reactor")) + optional(project(":module:spring-boot-webflux-test")) + optional(project(":module:spring-boot-webmvc-test")) + optional(project(":module:spring-boot-web-server-test")) testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) testImplementation(project(":module:spring-boot-webmvc")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("com.squareup.okhttp3:mockwebserver") testImplementation("tools.jackson.core:jackson-databind") diff --git a/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports new file mode 100644 index 00000000000..fd58474bc8f --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports @@ -0,0 +1,2 @@ +org.springframework.boot.security.oauth2.client.autoconfigure.reactive.ReactiveOAuth2ClientAutoConfiguration +org.springframework.boot.security.oauth2.client.autoconfigure.reactive.ReactiveOAuth2ClientWebSecurityAutoConfiguration diff --git a/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.imports b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.imports new file mode 100644 index 00000000000..4d2248ccfe6 --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.imports @@ -0,0 +1 @@ +org.springframework.boot.security.oauth2.client.autoconfigure.reactive.ReactiveOAuth2ClientAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports new file mode 100644 index 00000000000..2687109839d --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports @@ -0,0 +1,2 @@ +org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfiguration +org.springframework.boot.security.oauth2.client.autoconfigure.servlet.OAuth2ClientWebSecurityAutoConfiguration diff --git a/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/OAuth2ClientWebMvcTestIntegrationTests.java b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/OAuth2ClientWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..685a1641c26 --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/OAuth2ClientWebMvcTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.oauth2.client.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Mustache with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class OAuth2ClientWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void oauth2ClientAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(OAuth2ClientAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/reactive/ReactiveOAuth2ClientWebFluxTestIntegrationTests.java b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/reactive/ReactiveOAuth2ClientWebFluxTestIntegrationTests.java new file mode 100644 index 00000000000..002a02617ae --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/reactive/ReactiveOAuth2ClientWebFluxTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.oauth2.client.autoconfigure.reactive; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for reactive OAuth2 client with {@link WebFluxTest @WebFluxTest}. + * + * @author Andy Wilkinson + */ +@WebFluxTest +class ReactiveOAuth2ClientWebFluxTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void oauth2ClientAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(ReactiveOAuth2ClientAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/ExampleController.java b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/ExampleController.java new file mode 100644 index 00000000000..3748c407a3e --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/ExampleController.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.oauth2.client.autoconfigure.servlet.webmvc; + +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Example {@link Controller @Controller} used with {@link WebMvcTest @WebMvcTest} tests. + * + * @author Phillip Webb + * @author Moritz Halbritter + */ +@RestController +public class ExampleController { + + @GetMapping("/one") + public String one() { + return "one"; + } + +} diff --git a/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/OAuth2ClientWebMvcApplication.java b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/OAuth2ClientWebMvcApplication.java new file mode 100644 index 00000000000..8f0441678ef --- /dev/null +++ b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/OAuth2ClientWebMvcApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.oauth2.client.autoconfigure.servlet.webmvc; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; + +/** + * Test application for OAuth2 Client support with WebMvc. + * + * @author Andy Wilkinson + */ +@EnableWebSecurity +@SpringBootApplication +public class OAuth2ClientWebMvcApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestOAuth2Tests.java b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/OAuth2ClientWebMvcTestIntegrationTests.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestOAuth2Tests.java rename to module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/OAuth2ClientWebMvcTestIntegrationTests.java index d214fa1d7a3..6be72238822 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestOAuth2Tests.java +++ b/module/spring-boot-security-oauth2-client/src/test/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/webmvc/OAuth2ClientWebMvcTestIntegrationTests.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.security.oauth2.client.autoconfigure.servlet.webmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -31,11 +31,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @author Dmytro Nosan */ -@WebMvcTest(controllers = ExampleController1.class, +@WebMvcTest(controllers = ExampleController.class, properties = { "spring.security.oauth2.client.registration.test.client-id=test", "spring.security.oauth2.client.registration.test.authorization-grant-type=authorization-code", "spring.security.oauth2.client.provider.test.authorization-uri=https://auth.example.org" }) -class WebMvcTestOAuth2Tests { +class OAuth2ClientWebMvcTestIntegrationTests { @Autowired private MockMvc mockMvc; diff --git a/module/spring-boot-security-oauth2-resource-server/build.gradle b/module/spring-boot-security-oauth2-resource-server/build.gradle index 55968bbc103..c7ab7a5f0a7 100644 --- a/module/spring-boot-security-oauth2-resource-server/build.gradle +++ b/module/spring-boot-security-oauth2-resource-server/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Security OAuth2 Resource Server" @@ -33,14 +34,18 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":module:spring-boot-reactor")) + optional(project(":module:spring-boot-webflux-test")) + optional(project(":module:spring-boot-webmvc-test")) optional("jakarta.servlet:jakarta.servlet-api") testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-actuator-autoconfigure")) testImplementation(project(":module:spring-boot-jackson")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) testImplementation(project(":module:spring-boot-webflux")) testImplementation(project(":module:spring-boot-webmvc")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testImplementation("com.squareup.okhttp3:mockwebserver") testRuntimeOnly("ch.qos.logback:logback-classic") diff --git a/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports new file mode 100644 index 00000000000..8c05e4f3924 --- /dev/null +++ b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.web.server.test.autoconfigure.reactive.AutoConfigureWebTestClient.imports @@ -0,0 +1 @@ +org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive.ReactiveOAuth2ResourceServerAutoconfiguration diff --git a/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.imports b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.imports new file mode 100644 index 00000000000..6eca008c3d5 --- /dev/null +++ b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.imports @@ -0,0 +1 @@ +org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive.ReactiveOAuth2ResourceServerAutoConfiguration diff --git a/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports new file mode 100644 index 00000000000..759200960ef --- /dev/null +++ b/module/spring-boot-security-oauth2-resource-server/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports @@ -0,0 +1 @@ +org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration diff --git a/module/spring-boot-security-oauth2-resource-server/src/test/java/org/springframework/boot/security/oauth2/server/resource/autoconfigure/reactive/ReactiveOAuth2ResourceServerWebFluxTestIntegrationTests.java b/module/spring-boot-security-oauth2-resource-server/src/test/java/org/springframework/boot/security/oauth2/server/resource/autoconfigure/reactive/ReactiveOAuth2ResourceServerWebFluxTestIntegrationTests.java new file mode 100644 index 00000000000..cd3bc1703eb --- /dev/null +++ b/module/spring-boot-security-oauth2-resource-server/src/test/java/org/springframework/boot/security/oauth2/server/resource/autoconfigure/reactive/ReactiveOAuth2ResourceServerWebFluxTestIntegrationTests.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for reactive OAuth2 resource server with + * {@link WebFluxTest @WebFluxTest}. + * + * @author Andy Wilkinson + */ +@WebFluxTest +class ReactiveOAuth2ResourceServerWebFluxTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void oauth2ResourceServerAutoConfigurationWasImported() { + assertThat(this.applicationContext) + .has(importedAutoConfiguration(ReactiveOAuth2ResourceServerAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-security-oauth2-resource-server/src/test/java/org/springframework/boot/security/oauth2/server/resource/autoconfigure/servlet/OAuth2ResourceServerWebMvcTestIntegrationTests.java b/module/spring-boot-security-oauth2-resource-server/src/test/java/org/springframework/boot/security/oauth2/server/resource/autoconfigure/servlet/OAuth2ResourceServerWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..0fdcd116234 --- /dev/null +++ b/module/spring-boot-security-oauth2-resource-server/src/test/java/org/springframework/boot/security/oauth2/server/resource/autoconfigure/servlet/OAuth2ResourceServerWebMvcTestIntegrationTests.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for reactive OAuth2 resource server with + * {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class OAuth2ResourceServerWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void oauth2ResourceServerAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(OAuth2ResourceServerAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-security-saml2/build.gradle b/module/spring-boot-security-saml2/build.gradle index df03af040fe..1eb9ff78ab7 100644 --- a/module/spring-boot-security-saml2/build.gradle +++ b/module/spring-boot-security-saml2/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Security SAML2" @@ -34,8 +35,10 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-actuator-autoconfigure")) - testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) testImplementation(project(":module:spring-boot-webmvc")) + testImplementation(project(":module:spring-boot-webmvc-test")) + testImplementation(project(":test-support:spring-boot-test-support")) testImplementation("com.squareup.okhttp3:mockwebserver") testImplementation("jakarta.servlet:jakarta.servlet-api") testImplementation("tools.jackson.core:jackson-databind") diff --git a/module/spring-boot-security-saml2/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports b/module/spring-boot-security-saml2/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports new file mode 100644 index 00000000000..06e8706aa93 --- /dev/null +++ b/module/spring-boot-security-saml2/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.imports @@ -0,0 +1 @@ +org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfiguration diff --git a/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/ExampleController.java b/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/ExampleController.java new file mode 100644 index 00000000000..ab676aa36e3 --- /dev/null +++ b/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/ExampleController.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.saml2.autoconfigure.webmvc; + +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Example {@link Controller @Controller} used with {@link WebMvcTest @WebMvcTest} tests. + * + * @author Phillip Webb + * @author Moritz Halbritter + */ +@RestController +public class ExampleController { + + @GetMapping("/one") + public String one() { + return "one"; + } + +} diff --git a/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/Saml2RelyingPartyWebMvcApplication.java b/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/Saml2RelyingPartyWebMvcApplication.java new file mode 100644 index 00000000000..efdd1afb812 --- /dev/null +++ b/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/Saml2RelyingPartyWebMvcApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.saml2.autoconfigure.webmvc; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; + +/** + * Test application for SAML2 support with WebMvc. + * + * @author Andy Wilkinson + */ +@EnableWebSecurity +@SpringBootApplication +public class Saml2RelyingPartyWebMvcApplication { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestSaml2Tests.java b/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/Saml2RelyingPartyWebMvcTestIntegrationTests.java similarity index 87% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestSaml2Tests.java rename to module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/Saml2RelyingPartyWebMvcTestIntegrationTests.java index 1c0147c6715..fb3387f4de0 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestSaml2Tests.java +++ b/module/spring-boot-security-saml2/src/test/java/org/springframework/boot/security/saml2/autoconfigure/webmvc/Saml2RelyingPartyWebMvcTestIntegrationTests.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.security.saml2.autoconfigure.webmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.MockMvc; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -31,12 +31,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @author Dmytro Nosan */ -@WebMvcTest(controllers = ExampleController1.class, properties = { +@WebMvcTest(controllers = ExampleController.class, properties = { "spring.security.saml2.relyingparty.registration.test.entity-id=relyingparty", "spring.security.saml2.relyingparty.registration.test.assertingparty.entity-id=assertingparty", "spring.security.saml2.relyingparty.registration.test.assertingparty.singlesignon.url=https://example.com", "spring.security.saml2.relyingparty.registration.test.assertingparty.singlesignon.sign-request=false" }) -class WebMvcTestSaml2Tests { +class Saml2RelyingPartyWebMvcTestIntegrationTests { @Autowired private MockMvc mockMvc; diff --git a/module/spring-boot-security-test/build.gradle b/module/spring-boot-security-test/build.gradle new file mode 100644 index 00000000000..503f598c4df --- /dev/null +++ b/module/spring-boot-security-test/build.gradle @@ -0,0 +1,41 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" +} + +description = "Spring Boot Security Test" + +dependencies { + api(project(":module:spring-boot-security")) + api("org.springframework.security:spring-security-test") + + optional(project(":module:spring-boot-test-autoconfigure")) + optional(project(":module:spring-boot-webflux-test")) + optional(project(":module:spring-boot-webmvc-test")) + optional("org.seleniumhq.selenium:htmlunit3-driver") { + exclude(group: "com.sun.activation", module: "jakarta.activation") + } + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation("jakarta.servlet:jakarta.servlet-api") + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientSecurityConfiguration.java b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webflux/SecurityWebTestClientAutoConfiguration.java similarity index 80% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientSecurityConfiguration.java rename to module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webflux/SecurityWebTestClientAutoConfiguration.java index 1f5238f1cf0..59382b91bab 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientSecurityConfiguration.java +++ b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webflux/SecurityWebTestClientAutoConfiguration.java @@ -14,23 +14,24 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.security.test.autoconfigure.webflux; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers; import org.springframework.test.web.reactive.server.MockServerConfigurer; +import org.springframework.test.web.reactive.server.WebTestClient; /** - * Configuration for Spring Security's - * {@link org.springframework.test.web.reactive.server.WebTestClient} integration. + * Auto-configuration for Spring Security's {@link WebTestClient} integration. * * @author Madhura Bhave + * @since 4.0.0 */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass(SecurityMockServerConfigurers.class) -class WebTestClientSecurityConfiguration { +public final class SecurityWebTestClientAutoConfiguration { @Bean MockServerConfigurer mockServerConfigurer() { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/package-info.java b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webflux/package-info.java similarity index 83% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/package-info.java rename to module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webflux/package-info.java index a8352c5acc3..241303c020c 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/core/package-info.java +++ b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webflux/package-info.java @@ -15,9 +15,9 @@ */ /** - * Auto-configuration for core parts common to most Spring Boot applications. + * Auto-configuration for tests involving WebFlux and Spring Security. */ @NullMarked -package org.springframework.boot.test.autoconfigure.core; +package org.springframework.boot.security.test.autoconfigure.webflux; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcSecurityConfiguration.java b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityMockMvcAutoConfiguration.java similarity index 66% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcSecurityConfiguration.java rename to module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityMockMvcAutoConfiguration.java index 6d85ec76e77..709bb6fa2c3 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcSecurityConfiguration.java +++ b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityMockMvcAutoConfiguration.java @@ -14,28 +14,38 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.security.test.autoconfigure.webmvc; +import java.util.concurrent.Executors; + +import org.openqa.selenium.htmlunit.HtmlUnitDriver; + +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.webmvc.test.autoconfigure.MockMvcBuilderCustomizer; +import org.springframework.boot.webmvc.test.autoconfigure.MockMvcHtmlUnitDriverCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.security.concurrent.DelegatingSecurityContextExecutor; import org.springframework.security.test.context.TestSecurityContextHolder; import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer; +import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.RequestPostProcessor; import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcConfigurerAdapter; import org.springframework.web.context.WebApplicationContext; /** - * Configuration for Spring Security's MockMvc integration. + * Auto-configuration for Spring Security's MockMvc integration. * * @author Andy Wilkinson + * @since 4.0.0 */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass(SecurityMockMvcRequestPostProcessors.class) -class MockMvcSecurityConfiguration { +@AutoConfiguration +@ConditionalOnClass(MockMvc.class) +public final class SecurityMockMvcAutoConfiguration { private static final String DEFAULT_SECURITY_FILTER_NAME = AbstractSecurityWebApplicationInitializer.DEFAULT_FILTER_NAME; @@ -45,13 +55,24 @@ class MockMvcSecurityConfiguration { return new SecurityMockMvcBuilderCustomizer(); } + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(HtmlUnitDriver.class) + static class SecurityMockMvcHtmlUnitDriverConfiguration { + + MockMvcHtmlUnitDriverCustomizer securityDelegateMockMvcHtmlUnitDriverCustomizer() { + return (driver) -> driver + .setExecutor(new DelegatingSecurityContextExecutor(Executors.newSingleThreadExecutor())); + } + + } + /** * {@link MockMvcBuilderCustomizer} that ensures that requests run with the user in * the {@link TestSecurityContextHolder}. * * @see SecurityMockMvcRequestPostProcessors#testSecurityContext */ - class SecurityMockMvcBuilderCustomizer implements MockMvcBuilderCustomizer { + static class SecurityMockMvcBuilderCustomizer implements MockMvcBuilderCustomizer { @Override public void customize(ConfigurableMockMvcBuilder builder) { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/package-info.java b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webmvc/package-info.java similarity index 82% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/package-info.java rename to module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webmvc/package-info.java index a59f2ea52c6..cf33ffe3990 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/observability/package-info.java +++ b/module/spring-boot-security-test/src/main/java/org/springframework/boot/security/test/autoconfigure/webmvc/package-info.java @@ -15,9 +15,9 @@ */ /** - * Auto-configuration for handling observability in tests. + * Auto-configuration for tests involving Spring MVC and Spring Security. */ @NullMarked -package org.springframework.boot.test.autoconfigure.actuate.observability; +package org.springframework.boot.security.test.autoconfigure.webmvc; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports new file mode 100644 index 00000000000..c8a49b9a11a --- /dev/null +++ b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports @@ -0,0 +1,3 @@ +org.springframework.boot.security.autoconfigure.reactive.ReactiveSecurityAutoConfiguration +org.springframework.boot.security.autoconfigure.reactive.ReactiveUserDetailsServiceAutoConfiguration +org.springframework.boot.security.test.autoconfigure.webflux.SecurityWebTestClientAutoConfiguration diff --git a/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc.imports b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc.imports new file mode 100644 index 00000000000..8492ef9f3b2 --- /dev/null +++ b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc.imports @@ -0,0 +1,4 @@ +org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration +org.springframework.boot.security.autoconfigure.servlet.SecurityFilterAutoConfiguration +org.springframework.boot.security.autoconfigure.servlet.UserDetailsServiceAutoConfiguration +org.springframework.boot.security.test.autoconfigure.webmvc.SecurityMockMvcAutoConfiguration diff --git a/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes new file mode 100644 index 00000000000..c40ed292025 --- /dev/null +++ b/module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes @@ -0,0 +1 @@ +org.springframework.security.web.SecurityFilterChain diff --git a/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java new file mode 100644 index 00000000000..5df865afe50 --- /dev/null +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webflux/WebTestClientSecurityIntegrationTests.java @@ -0,0 +1,72 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.security.test.autoconfigure.webflux; + +import java.util.List; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.web.server.WebFilter; +import org.springframework.web.server.WebHandler; +import org.springframework.web.server.adapter.WebHttpHandlerBuilder; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +/** + * Integration tests for mocked-infrastructure-backed WebTestClient security. + * + * @author Andy Wilkinson + */ +class WebTestClientSecurityIntegrationTests { + + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration( + AutoConfigurations.of(WebTestClientAutoConfiguration.class, SecurityWebTestClientAutoConfiguration.class)); + + @Test + @SuppressWarnings("unchecked") + void shouldApplySpringSecurityConfigurer() { + this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> { + WebTestClient webTestClient = context.getBean(WebTestClient.class); + WebTestClient.Builder builder = (WebTestClient.Builder) ReflectionTestUtils.getField(webTestClient, + "builder"); + WebHttpHandlerBuilder httpHandlerBuilder = (WebHttpHandlerBuilder) ReflectionTestUtils.getField(builder, + "httpHandlerBuilder"); + List filters = (List) ReflectionTestUtils.getField(httpHandlerBuilder, "filters"); + assertThat(filters.get(0).getClass().getName()).isEqualTo( + "org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers$MutatorFilter"); + }); + } + + @Configuration(proxyBeanMethods = false) + static class BaseConfiguration { + + @Bean + WebHandler webHandler() { + return mock(WebHandler.class); + } + + } + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/AfterSecurityFilter.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/AfterSecurityFilter.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/AfterSecurityFilter.java rename to module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/AfterSecurityFilter.java index 20e0f3b1944..3289ec38da5 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/AfterSecurityFilter.java +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/AfterSecurityFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.security.test.autoconfigure.webmvc; import java.io.IOException; import java.security.Principal; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/AutoConfigureMockMvcSecurityFilterOrderingIntegrationTests.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/AutoConfigureMockMvcSecurityFilterOrderingIntegrationTests.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/AutoConfigureMockMvcSecurityFilterOrderingIntegrationTests.java rename to module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/AutoConfigureMockMvcSecurityFilterOrderingIntegrationTests.java index f62f197b1fa..d79f4947c07 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/AutoConfigureMockMvcSecurityFilterOrderingIntegrationTests.java +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/AutoConfigureMockMvcSecurityFilterOrderingIntegrationTests.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.security.test.autoconfigure.webmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.annotation.Import; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleFilter.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleFilter.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleFilter.java rename to module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleFilter.java index 7fc4608a241..0a77a041992 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleFilter.java +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.security.test.autoconfigure.webmvc; import java.io.IOException; @@ -27,7 +27,7 @@ import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletResponse; import org.springframework.boot.security.autoconfigure.SecurityProperties; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.core.Ordered; import org.springframework.stereotype.Component; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/security/MockMvcSecurityIntegrationTests.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/MockMvcSecurityIntegrationTests.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/security/MockMvcSecurityIntegrationTests.java rename to module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/MockMvcSecurityIntegrationTests.java index 0dc0f6e4a9c..5fec9408c76 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/security/MockMvcSecurityIntegrationTests.java +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/MockMvcSecurityIntegrationTests.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.security; +package org.springframework.boot.security.test.autoconfigure.webmvc; import java.util.Base64; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/security/SecurityTestApplication.java b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityTestApplication.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/security/SecurityTestApplication.java rename to module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityTestApplication.java index 907e09c031b..be20effd75d 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/security/SecurityTestApplication.java +++ b/module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityTestApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.security; +package org.springframework.boot.security.test.autoconfigure.webmvc; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.security.access.annotation.Secured; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/application.properties b/module/spring-boot-security-test/src/test/resources/application.properties similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/application.properties rename to module/spring-boot-security-test/src/test/resources/application.properties diff --git a/module/spring-boot-security/build.gradle b/module/spring-boot-security/build.gradle index 1c3ee945f9f..3d7039587e6 100644 --- a/module/spring-boot-security/build.gradle +++ b/module/spring-boot-security/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Security" @@ -34,9 +35,10 @@ dependencies { optional(project(":module:spring-boot-h2console")) optional(project(":module:spring-boot-reactor")) optional(project(":module:spring-boot-rsocket")) - optional(project(":module:spring-boot-webmvc")) optional(project(":module:spring-boot-webflux")) + optional(project(":module:spring-boot-webmvc")) optional(project(":module:spring-boot-web-server")) + optional(project(":module:spring-boot-web-server-test")) optional("jakarta.servlet:jakarta.servlet-api") optional("org.springframework:spring-messaging") optional("org.springframework:spring-webflux") diff --git a/module/spring-boot-test-autoconfigure/build.gradle b/module/spring-boot-test-autoconfigure/build.gradle index 4c6caef2b96..a56217d0b67 100644 --- a/module/spring-boot-test-autoconfigure/build.gradle +++ b/module/spring-boot-test-autoconfigure/build.gradle @@ -16,9 +16,7 @@ plugins { id "java-library" - id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" - id "org.springframework.boot.docker-test" id "org.springframework.boot.optional-dependencies" } @@ -31,130 +29,18 @@ dependencies { compileOnly("org.mockito:mockito-core") - optional(project(":module:spring-boot-cache")) - optional(project(":module:spring-boot-data-cassandra")) - optional(project(":module:spring-boot-data-commons")) - optional(project(":module:spring-boot-data-couchbase")) - optional(project(":module:spring-boot-data-elasticsearch")) - optional(project(":module:spring-boot-data-jdbc")) - optional(project(":module:spring-boot-data-jpa")) - optional(project(":module:spring-boot-data-ldap")) - optional(project(":module:spring-boot-data-mongodb")) - optional(project(":module:spring-boot-data-neo4j")) - optional(project(":module:spring-boot-data-r2dbc")) - optional(project(":module:spring-boot-data-redis")) - optional(project(":module:spring-boot-flyway")) - optional(project(":module:spring-boot-graphql")) - optional(project(":module:spring-boot-groovy-templates")) - optional(project(":module:spring-boot-hateoas")) - optional(project(":module:spring-boot-http-converter")) - optional(project(":module:spring-boot-http-codec")) - optional(project(":module:spring-boot-jackson")) - optional(project(":module:spring-boot-jdbc")) - optional(project(":module:spring-boot-jooq")) - optional(project(":module:spring-boot-jsonb")) - optional(project(":module:spring-boot-liquibase")) { - exclude(group: "org.liquibase") - } - optional(project(":module:spring-boot-micrometer-metrics")) - optional(project(":module:spring-boot-micrometer-observation")) - optional(project(":module:spring-boot-micrometer-tracing")) - optional(project(":module:spring-boot-mongodb")) - optional(project(":module:spring-boot-r2dbc")) - optional(project(":module:spring-boot-reactor-netty")) - optional(project(":module:spring-boot-restclient")) - optional(project(":module:spring-boot-restclient-test")) - optional(project(":module:spring-boot-security")) - optional(project(":module:spring-boot-security-oauth2-client")) - optional(project(":module:spring-boot-security-oauth2-resource-server")) - optional(project(":module:spring-boot-security-saml2")) - optional(project(":module:spring-boot-tx")) - optional(project(":module:spring-boot-validation")) - optional(project(":module:spring-boot-web-server-test")) - optional(project(":module:spring-boot-webclient")) - optional(project(":module:spring-boot-webflux")) - optional(project(":module:spring-boot-webmvc")) - optional(project(":module:spring-boot-webservices")) - optional("jakarta.json.bind:jakarta.json.bind-api") - optional("jakarta.persistence:jakarta.persistence-api") - optional("jakarta.servlet:jakarta.servlet-api") - optional("jakarta.transaction:jakarta.transaction-api") - optional("com.google.code.gson:gson") - optional("com.jayway.jsonpath:json-path") - optional("com.sun.xml.messaging.saaj:saaj-impl") - optional("org.hibernate.orm:hibernate-core") - optional("org.htmlunit:htmlunit") optional("org.junit.jupiter:junit-jupiter-api") - optional("org.seleniumhq.selenium:htmlunit3-driver") { - exclude(group: "com.sun.activation", module: "jakarta.activation") - } - optional("org.seleniumhq.selenium:selenium-api") - optional("org.springframework:spring-orm") - optional("org.springframework:spring-test") - optional("org.springframework:spring-web") - optional("org.springframework:spring-webflux") - optional("org.springframework.data:spring-data-couchbase") - optional("org.springframework.data:spring-data-jdbc") - optional("org.springframework.data:spring-data-jpa") - optional("org.springframework.data:spring-data-ldap") - optional("org.springframework.data:spring-data-mongodb") - optional("org.springframework.data:spring-data-r2dbc") - optional("org.springframework.data:spring-data-redis") - optional("org.springframework.graphql:spring-graphql-test") - optional("org.springframework.restdocs:spring-restdocs-mockmvc") - optional("org.springframework.restdocs:spring-restdocs-restassured") - optional("org.springframework.restdocs:spring-restdocs-webtestclient") - optional("org.springframework.security:spring-security-config") - optional("org.springframework.security:spring-security-test") - optional("org.springframework.ws:spring-ws-core") - optional("org.springframework.ws:spring-ws-test") - optional("org.apache.tomcat.embed:tomcat-embed-core") - optional("org.mongodb:mongodb-driver-reactivestreams") - optional("org.mongodb:mongodb-driver-sync") - optional("io.micrometer:micrometer-tracing") - - dockerTestImplementation(project(":core:spring-boot-docker-compose")) - dockerTestImplementation(project(":core:spring-boot-testcontainers")) - dockerTestImplementation(project(":module:spring-boot-data-mongodb")) - dockerTestImplementation(project(":module:spring-boot-tx")) - dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) - dockerTestImplementation("com.zaxxer:HikariCP") - dockerTestImplementation("io.projectreactor:reactor-test") - dockerTestImplementation("com.redis:testcontainers-redis") - dockerTestImplementation("com.h2database:h2") - dockerTestImplementation("org.assertj:assertj-core") - dockerTestImplementation("org.junit.jupiter:junit-jupiter") - dockerTestImplementation("org.postgresql:postgresql") - dockerTestImplementation("org.testcontainers:cassandra") - dockerTestImplementation("org.testcontainers:couchbase") - dockerTestImplementation("org.testcontainers:elasticsearch") - dockerTestImplementation("org.testcontainers:junit-jupiter") - dockerTestImplementation("org.testcontainers:mongodb") - dockerTestImplementation("org.testcontainers:neo4j") - dockerTestImplementation("org.testcontainers:postgresql") - dockerTestImplementation("org.testcontainers:testcontainers") - - dockerTestRuntimeOnly("io.lettuce:lettuce-core") - dockerTestRuntimeOnly("org.springframework.data:spring-data-redis") - + testImplementation(project(":core:spring-boot-testcontainers")) testImplementation(project(":module:spring-boot-actuator")) testImplementation(project(":module:spring-boot-actuator-autoconfigure")) - testImplementation(project(":module:spring-boot-freemarker")) - testImplementation(project(":module:spring-boot-gson")) - testImplementation(project(":module:spring-boot-mustache")) - testImplementation(project(":module:spring-boot-reactor")) - testImplementation(project(":module:spring-boot-thymeleaf")) testImplementation(project(":test-support:spring-boot-test-support")) testImplementation("ch.qos.logback:logback-classic") testImplementation("com.fasterxml.jackson.module:jackson-module-parameter-names") - testImplementation("com.h2database:h2") - testImplementation("com.unboundid:unboundid-ldapsdk") testImplementation("io.lettuce:lettuce-core") testImplementation("io.micrometer:micrometer-registry-prometheus") testImplementation("io.projectreactor.netty:reactor-netty-http") testImplementation("io.projectreactor:reactor-test") - testImplementation("io.r2dbc:r2dbc-h2") testImplementation("jakarta.json:jakarta.json-api") testImplementation("org.apache.commons:commons-pool2") testImplementation("org.apache.tomcat.embed:tomcat-embed-el") @@ -162,7 +48,6 @@ dependencies { testImplementation("org.aspectj:aspectjweaver") testImplementation("org.eclipse:yasson") testImplementation("org.hibernate.validator:hibernate-validator") - testImplementation("org.hsqldb:hsqldb") testImplementation("org.jooq:jooq") testImplementation("org.junit.platform:junit-platform-engine") testImplementation("org.junit.platform:junit-platform-launcher") @@ -174,12 +59,3 @@ dependencies { testRuntimeOnly(project(":module:spring-boot-tomcat")) testRuntimeOnly("org.flywaydb:flyway-database-hsqldb") } - -test { - include "**/*Tests.class" -} - -tasks.register("testSliceMetadata", org.springframework.boot.build.test.autoconfigure.TestSliceMetadata) { - sourceSet = sourceSets.main - outputFile = layout.buildDirectory.file("test-slice-metadata.properties") -} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/StandardAnnotationCustomizableTypeExcludeFilter.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/StandardAnnotationCustomizableTypeExcludeFilter.java index 561db64edf6..632994a21d9 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/StandardAnnotationCustomizableTypeExcludeFilter.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/StandardAnnotationCustomizableTypeExcludeFilter.java @@ -18,6 +18,7 @@ package org.springframework.boot.test.autoconfigure.filter; import java.lang.annotation.Annotation; import java.util.Collections; +import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -78,7 +79,14 @@ public abstract class StandardAnnotationCustomizableTypeExcludeFilter> getDefaultIncludes() { + protected final Set> getDefaultIncludes() { + Set> defaultIncludes = new HashSet<>(); + defaultIncludes.addAll(getKnownIncludes()); + defaultIncludes.addAll(TypeIncludes.load(this.annotation.getType(), getClass().getClassLoader()).getIncludes()); + return defaultIncludes; + } + + protected Set> getKnownIncludes() { return Collections.emptySet(); } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactory.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactory.java index da961705ee2..2e6475854de 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactory.java +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactory.java @@ -39,8 +39,6 @@ import org.springframework.test.context.TestContextAnnotationUtils.AnnotationDes */ class TypeExcludeFiltersContextCustomizerFactory implements ContextCustomizerFactory { - private static final Class[] NO_FILTERS = {}; - @Override public @Nullable ContextCustomizer createContextCustomizer(Class testClass, List configurationAttributes) { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeIncludes.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeIncludes.java new file mode 100644 index 00000000000..26c76022a2a --- /dev/null +++ b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeIncludes.java @@ -0,0 +1,148 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure.filter; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.jspecify.annotations.Nullable; + +import org.springframework.boot.context.TypeExcludeFilter; +import org.springframework.core.io.UrlResource; +import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; + +/** + * Contains types to be included by a {@link TypeExcludeFilter}. + * + * The {@link #load(Class, ClassLoader)} method can be used to discover the includes. + * + * @author Moritz Halbritter + * @author Scott Frederick + * @author Andy Wilkinson + */ +final class TypeIncludes implements Iterable> { + + private static final String LOCATION = "META-INF/spring/%s.includes"; + + private static final String COMMENT_START = "#"; + + private final Set> includes; + + private TypeIncludes(Set> includes) { + Assert.notNull(includes, "'includes' must not be null"); + this.includes = Collections.unmodifiableSet(includes); + } + + @Override + public Iterator> iterator() { + return this.includes.iterator(); + } + + Set> getIncludes() { + return this.includes; + } + + /** + * Loads the includes from the classpath. The names of the includes are stored in + * files named {@code META-INF/spring/fully-qualified-annotation-name.includes} on the + * classpath. Every line contains the fully qualified name of the included class. + * Comments are supported using the # character. + * @param annotation annotation to load + * @param classLoader class loader to use for loading + * @return list of names of included classes + */ + static TypeIncludes load(Class annotation, @Nullable ClassLoader classLoader) { + Assert.notNull(annotation, "'annotation' must not be null"); + ClassLoader classLoaderToUse = decideClassloader(classLoader); + String location = String.format(LOCATION, annotation.getName()); + Enumeration urls = findUrlsInClasspath(classLoaderToUse, location); + Set> includes = new HashSet<>(); + while (urls.hasMoreElements()) { + URL url = urls.nextElement(); + includes.addAll(loadIncludes(url, classLoader)); + } + return new TypeIncludes(includes); + } + + private static ClassLoader decideClassloader(@Nullable ClassLoader classLoader) { + if (classLoader == null) { + return TypeIncludes.class.getClassLoader(); + } + return classLoader; + } + + private static Enumeration findUrlsInClasspath(ClassLoader classLoader, String location) { + try { + return classLoader.getResources(location); + } + catch (IOException ex) { + throw new IllegalArgumentException("Failed to load includes from location [" + location + "]", ex); + } + } + + private static Set> loadIncludes(URL url, @Nullable ClassLoader classLoader) { + Set includeNames = readIncludes(url); + Set> includes = new HashSet<>(includeNames.size()); + for (String includeName : includeNames) { + try { + includes.add(ClassUtils.forName(includeName, classLoader)); + } + catch (Exception ex) { + throw new IllegalArgumentException("Failed to load include '" + includeName + "' declared in " + url); + } + } + return includes; + } + + private static Set readIncludes(URL url) { + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(new UrlResource(url).getInputStream(), StandardCharsets.UTF_8))) { + Set includes = new HashSet<>(); + String line; + while ((line = reader.readLine()) != null) { + line = stripComment(line); + line = line.trim(); + if (line.isEmpty()) { + continue; + } + includes.add(line); + } + return includes; + } + catch (IOException ex) { + throw new IllegalArgumentException("Unable to load includes from location [" + url + "]", ex); + } + } + + private static String stripComment(String line) { + int commentStart = line.indexOf(COMMENT_START); + if (commentStart == -1) { + return line; + } + return line.substring(0, commentStart); + } + +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/package-info.java b/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/package-info.java deleted file mode 100644 index f942576e965..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2012-present 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Auto-configuration for reactive web tests. - */ -@NullMarked -package org.springframework.boot.test.autoconfigure.web.reactive; - -import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 43e38bd0479..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "properties": [ - { - "name": "spring.test.database.replace", - "type": "org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase$Replace", - "description": "Type of existing DataSource to replace.", - "defaultValue": "any" - }, - { - "name": "spring.test.observability.auto-configure", - "type": "java.lang.Boolean", - "description": "Whether observability should be auto-configured in tests.", - "defaultValue": false - }, - { - "name": "spring.test.print-condition-evaluation-report", - "type": "java.lang.Boolean", - "description": "Whether the condition evaluation report should be printed when the ApplicationContext fails to start.", - "defaultValue": true - }, - { - "name": "spring.test.webtestclient.timeout", - "type": "java.time.Duration", - "description": "Maximum amount of time to wait for responses.", - "defaultValue": "5s" - } - ] -} diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json new file mode 100644 index 00000000000..c20ecd2b713 --- /dev/null +++ b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "name": "spring.test.print-condition-evaluation-report", + "type": "java.lang.Boolean", + "description": "Whether the condition evaluation report should be printed when the ApplicationContext fails to start.", + "defaultValue": true + } + ] +} diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories index 4a7ffc6de71..9ff7f084a64 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories @@ -2,15 +2,5 @@ org.springframework.test.context.ContextCustomizerFactory=\ org.springframework.boot.test.autoconfigure.OnFailureConditionReportContextCustomizerFactory,\ org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory,\ -org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory,\ org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizerFactory,\ -org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizerFactory,\ -org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory - -# Spring Test Execution Listeners -org.springframework.test.context.TestExecutionListener=\ -org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener,\ -org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener,\ -org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener,\ -org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener,\ -org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener +org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizerFactory diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability.imports deleted file mode 100644 index 05fb2527f10..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability.imports +++ /dev/null @@ -1,13 +0,0 @@ -# AutoConfigureObservability auto-configuration imports - -# Observation -org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration - -# Metrics -optional:org.springframework.boot.micrometer.metrics.autoconfigure.export.simple.SimpleMetricsExportAutoConfiguration -optional:org.springframework.boot.micrometer.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration -optional:org.springframework.boot.micrometer.metrics.autoconfigure.MetricsAutoConfiguration - -# Tracing -optional:org.springframework.boot.micrometer.tracing.autoconfigure.NoopTracerAutoConfiguration -optional:org.springframework.boot.micrometer.tracing.autoconfigure.MicrometerTracingAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.core.AutoConfigureCache.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.core.AutoConfigureCache.imports deleted file mode 100644 index 25dc15614b0..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.core.AutoConfigureCache.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureCache auto-configuration imports -optional:org.springframework.boot.cache.autoconfigure.CacheAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports deleted file mode 100644 index fa0f7f3ee9f..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.data.jdbc.AutoConfigureDataJdbc.imports +++ /dev/null @@ -1,11 +0,0 @@ -# AutoConfigureDataJdbc auto-configuration imports -org.springframework.boot.data.jdbc.autoconfigure.JdbcRepositoriesAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.JdbcClientAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration -org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration -optional:org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration -optional:org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration -optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureGraphQlTester.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureGraphQlTester.imports deleted file mode 100644 index bbc8368cbef..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureGraphQlTester.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureGraphQlTester auto-configuration imports -org.springframework.boot.test.autoconfigure.graphql.tester.GraphQlTesterAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester.imports deleted file mode 100644 index 78f1ffda4df..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureHttpGraphQlTester auto-configuration imports -org.springframework.boot.test.autoconfigure.graphql.tester.HttpGraphQlTesterAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters.imports deleted file mode 100644 index ed6678423b5..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureJsonTesters auto-configuration imports -org.springframework.boot.test.autoconfigure.json.JsonTestersAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports deleted file mode 100644 index 833fac5056d..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports +++ /dev/null @@ -1,12 +0,0 @@ -# AutoConfigureDataJpa auto-configuration imports -org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration -org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.JdbcClientAutoConfiguration -org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration -org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration -optional:org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration -optional:org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration -optional:org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager.imports deleted file mode 100644 index f69cfcc90fa..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureTestEntityManager auto-configuration imports -org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs.imports deleted file mode 100644 index 1eb7e5053d6..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureRestDocs auto-configuration imports -org.springframework.boot.test.autoconfigure.restdocs.RestDocsAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.client.AutoConfigureMockRestServiceServer.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.client.AutoConfigureMockRestServiceServer.imports deleted file mode 100644 index 9e680dcc0e2..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.client.AutoConfigureMockRestServiceServer.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureMockRestServiceServer -org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient.imports deleted file mode 100644 index 0c619da2da9..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient.imports +++ /dev/null @@ -1,7 +0,0 @@ -# AutoConfigureWebClient auto-configuration imports -optional:org.springframework.boot.security.autoconfigure.reactive.ReactiveSecurityAutoConfiguration -optional:org.springframework.boot.security.autoconfigure.reactive.ReactiveUserDetailsServiceAutoConfiguration -optional:org.springframework.boot.security.oauth2.client.autoconfigure.reactive.ReactiveOAuth2ClientAutoConfiguration -optional:org.springframework.boot.security.oauth2.client.autoconfigure.reactive.ReactiveOAuth2ClientWebSecurityAutoConfiguration -optional:org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive.ReactiveOAuth2ResourceServerAutoConfiguration -org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc.imports deleted file mode 100644 index 524269ef0a7..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc.imports +++ /dev/null @@ -1,13 +0,0 @@ -# AutoConfigureMockMvc auto-configuration imports -optional:org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration -optional:org.springframework.boot.security.autoconfigure.servlet.SecurityFilterAutoConfiguration -optional:org.springframework.boot.security.autoconfigure.servlet.UserDetailsServiceAutoConfiguration -optional:org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfiguration -optional:org.springframework.boot.security.oauth2.client.autoconfigure.servlet.OAuth2ClientWebSecurityAutoConfiguration -optional:org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration -optional:org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfiguration -org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration -org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration -org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration -org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration -org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports deleted file mode 100644 index bb75340455b..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports +++ /dev/null @@ -1,14 +0,0 @@ -# AutoConfigureWebMvc auto-configuration imports -optional:org.springframework.boot.data.autoconfigure.web.SpringDataWebAutoConfiguration -optional:org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration -optional:org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration -optional:org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration -optional:org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration -optional:org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration -optional:org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration -optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration -org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration -org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration -org.springframework.boot.servlet.autoconfigure.HttpEncodingAutoConfiguration -org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration -org.springframework.boot.webmvc.autoconfigure.error.ErrorMvcAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureMockWebServiceServer.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureMockWebServiceServer.imports deleted file mode 100644 index 972825a924e..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureMockWebServiceServer.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureMockWebServiceServer -org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.server.AutoConfigureMockWebServiceClient.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.server.AutoConfigureMockWebServiceClient.imports deleted file mode 100644 index 34c3609f0c7..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.server.AutoConfigureMockWebServiceClient.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureMockWebServiceClient auto-configuration imports -org.springframework.boot.test.autoconfigure.webservices.server.MockWebServiceClientAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.server.AutoConfigureWebServiceServer.imports b/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.server.AutoConfigureWebServiceServer.imports deleted file mode 100644 index 333a6d3c7aa..00000000000 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.server.AutoConfigureWebServiceServer.imports +++ /dev/null @@ -1,2 +0,0 @@ -# AutoConfigureWebServiceServer auto-configuration imports -org.springframework.boot.webservices.autoconfigure.WebServicesAutoConfiguration \ No newline at end of file diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java new file mode 100644 index 00000000000..bb7d86971f6 --- /dev/null +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; + +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; +import org.springframework.test.context.BootstrapWith; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +/** + * Example sliced-test annotation. + * + * @author Andy Wilkinson + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@BootstrapWith(ExampleTestContextBootstrapper.class) +@ExtendWith(SpringExtension.class) +@OverrideAutoConfiguration(enabled = false) +@ImportAutoConfiguration +@interface ExampleTest { + + String[] properties() default {}; + + @PropertyMapping("example.attribute") + boolean attribute() default true; + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestConfig.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestConfig.java index 272d23990fe..6099190f4e7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestConfig.java +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestConfig.java @@ -16,7 +16,6 @@ package org.springframework.boot.test.autoconfigure; -import org.springframework.boot.persistence.autoconfigure.EntityScan; import org.springframework.boot.test.context.TestConfiguration; /** @@ -26,7 +25,6 @@ import org.springframework.boot.test.context.TestConfiguration; * @author Phillip Webb */ @TestConfiguration(proxyBeanMethods = false) -@EntityScan("some.other.package") public class ExampleTestConfig { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestContextBootstrapper.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestContextBootstrapper.java new file mode 100644 index 00000000000..e183526a5a9 --- /dev/null +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ExampleTestContextBootstrapper.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.test.autoconfigure; + +import org.springframework.test.context.TestContextBootstrapper; + +/** + * {@link TestContextBootstrapper} for {@link ExampleTest @ExampleTest}. + * + * @author Andy Wilkinson + */ +class ExampleTestContextBootstrapper extends TestSliceTestContextBootstrapper { + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java similarity index 83% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java rename to module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java index 891d304955c..fec35567928 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.cache; +package org.springframework.boot.test.autoconfigure; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -29,9 +29,6 @@ import org.junit.platform.launcher.core.LauncherFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigurationPackage; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.persistence.autoconfigure.EntityScan; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.ExampleEntity; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; @@ -51,28 +48,34 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { @Test void testClassesThatHaveSameAnnotationsShareAContext() { - executeTests(DataJpaTest1.class); + executeTests(ExampleTest1.class); ApplicationContext test1Context = contextFromTest; - executeTests(DataJpaTest3.class); + assertThat(test1Context).isNotNull(); + executeTests(ExampleTest3.class); ApplicationContext test2Context = contextFromTest; + assertThat(test2Context).isNotNull(); assertThat(test1Context).isSameAs(test2Context); } @Test void testClassesThatOnlyHaveDifferingUnrelatedAnnotationsShareAContext() { - executeTests(DataJpaTest1.class); + executeTests(ExampleTest1.class); ApplicationContext test1Context = contextFromTest; - executeTests(DataJpaTest2.class); + assertThat(test1Context).isNotNull(); + executeTests(ExampleTest2.class); ApplicationContext test2Context = contextFromTest; + assertThat(test2Context).isNotNull(); assertThat(test1Context).isSameAs(test2Context); } @Test void testClassesThatOnlyHaveDifferingPropertyMappedAnnotationAttributesDoNotShareAContext() { - executeTests(DataJpaTest1.class); + executeTests(ExampleTest1.class); ApplicationContext test1Context = contextFromTest; - executeTests(DataJpaTest4.class); + assertThat(test1Context).isNotNull(); + executeTests(ExampleTest4.class); ApplicationContext test2Context = contextFromTest; + assertThat(test2Context).isNotNull(); assertThat(test1Context).isNotSameAs(test2Context); } @@ -84,10 +87,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { launcher.execute(request); } - @DataJpaTest + @ExampleTest @ContextConfiguration(classes = EmptyConfig.class) @Unrelated1 - static class DataJpaTest1 { + static class ExampleTest1 { @Autowired private ApplicationContext context; @@ -99,10 +102,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { } - @DataJpaTest + @ExampleTest @ContextConfiguration(classes = EmptyConfig.class) @Unrelated2 - static class DataJpaTest2 { + static class ExampleTest2 { @Autowired private ApplicationContext context; @@ -114,10 +117,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { } - @DataJpaTest + @ExampleTest @ContextConfiguration(classes = EmptyConfig.class) @Unrelated1 - static class DataJpaTest3 { + static class ExampleTest3 { @Autowired private ApplicationContext context; @@ -129,10 +132,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { } - @DataJpaTest(showSql = false) + @ExampleTest(attribute = false) @ContextConfiguration(classes = EmptyConfig.class) @Unrelated1 - static class DataJpaTest4 { + static class ExampleTest4 { @Autowired private ApplicationContext context; @@ -155,7 +158,6 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { } @Configuration(proxyBeanMethods = false) - @EntityScan(basePackageClasses = ExampleEntity.class) @AutoConfigurationPackage static class EmptyConfig { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OnFailureConditionReportContextCustomizerFactoryTests.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OnFailureConditionReportContextCustomizerFactoryTests.java index 774e39b58f1..52359ac5e7e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OnFailureConditionReportContextCustomizerFactoryTests.java +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/OnFailureConditionReportContextCustomizerFactoryTests.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; @@ -56,7 +56,7 @@ class OnFailureConditionReportContextCustomizerFactoryTests { @Test void loadFailureShouldPrintReport(CapturedOutput output) { load(); - assertThat(output.getErr()).contains("JacksonAutoConfiguration matched"); + assertThat(output.getErr()).contains("TestAutoConfiguration matched"); assertThat(output).contains("Error creating bean with name 'faultyBean'"); } @@ -64,7 +64,7 @@ class OnFailureConditionReportContextCustomizerFactoryTests { @WithResource(name = "application.xml", content = "invalid xml") void loadFailureShouldNotPrintReportWhenApplicationPropertiesIsBroken(CapturedOutput output) { load(); - assertThat(output).doesNotContain("JacksonAutoConfiguration matched") + assertThat(output).doesNotContain("TestAutoConfiguration matched") .doesNotContain("Error creating bean with name 'faultyBean'") .contains("java.util.InvalidPropertiesFormatException"); } @@ -73,7 +73,7 @@ class OnFailureConditionReportContextCustomizerFactoryTests { @WithResource(name = "application.properties", content = "spring.test.print-condition-evaluation-report=false") void loadFailureShouldNotPrintReportWhenDisabled(CapturedOutput output) { load(); - assertThat(output).doesNotContain("JacksonAutoConfiguration matched") + assertThat(output).doesNotContain("TestAutoConfiguration matched") .contains("Error creating bean with name 'faultyBean'"); } @@ -86,7 +86,7 @@ class OnFailureConditionReportContextCustomizerFactoryTests { static class FailingTests { @Configuration(proxyBeanMethods = false) - @ImportAutoConfiguration(JacksonAutoConfiguration.class) + @ImportAutoConfiguration(TestAutoConfiguration.class) static class TestConfig { @Bean @@ -98,4 +98,9 @@ class OnFailureConditionReportContextCustomizerFactoryTests { } + @ConditionalOnProperty(value = "com.example.test.enabled", matchIfMissing = true) + static class TestAutoConfiguration { + + } + } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/OverrideAutoConfigurationSpringBootApplication.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/OverrideAutoConfigurationSpringBootApplication.java index 948dbaff13a..b5d15111b69 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/OverrideAutoConfigurationSpringBootApplication.java +++ b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/override/OverrideAutoConfigurationSpringBootApplication.java @@ -19,7 +19,6 @@ package org.springframework.boot.test.autoconfigure.override; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; /** @@ -29,7 +28,7 @@ import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; * @author Andy Wilkinson */ @SpringBootConfiguration -@EnableAutoConfiguration(exclude = CassandraAutoConfiguration.class) +@EnableAutoConfiguration public class OverrideAutoConfigurationSpringBootApplication { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestApplication.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestApplication.java deleted file mode 100644 index 1fae47ae82d..00000000000 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsTestApplication.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2012-present 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.restdocs; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; -import org.springframework.boot.security.autoconfigure.actuate.servlet.ManagementWebSecurityAutoConfiguration; -import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration; - -/** - * Test application used with {@link AutoConfigureRestDocs @AutoConfigureRestDocs} tests. - * - * @author Andy Wilkinson - */ -@SpringBootApplication(exclude = { CassandraAutoConfiguration.class, SecurityAutoConfiguration.class, - ManagementWebSecurityAutoConfiguration.class }) -public class RestDocsTestApplication { - -} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/HateoasController.java b/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/HateoasController.java deleted file mode 100644 index e555a7fe326..00000000000 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/HateoasController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-present 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkRelation; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * {@link RestController @RestClientTest} used by - * {@link WebMvcTestHateoasIntegrationTests}. - * - * @author Andy Wilkinson - */ -@RestController -@RequestMapping("/hateoas") -class HateoasController { - - @RequestMapping("/resource") - EntityModel> resource() { - return EntityModel.of(new HashMap<>(), Link.of("self", LinkRelation.of("https://api.example.com"))); - } - - @RequestMapping("/plain") - Map plain() { - return new HashMap<>(); - } - -} diff --git a/module/spring-boot-thymeleaf/build.gradle b/module/spring-boot-thymeleaf/build.gradle index 30ad7a72f70..46b2975f7f3 100644 --- a/module/spring-boot-thymeleaf/build.gradle +++ b/module/spring-boot-thymeleaf/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.springframework.boot.configuration-properties" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Thymeleaf" @@ -31,7 +32,9 @@ dependencies { optional(project(":core:spring-boot-autoconfigure")) optional(project(":module:spring-boot-webflux")) + optional(project(":module:spring-boot-webflux-test")) optional(project(":module:spring-boot-webmvc")) + optional(project(":module:spring-boot-webmvc-test")) optional("org.springframework.security:spring-security-web") optional("org.thymeleaf:thymeleaf") optional("org.thymeleaf.extras:thymeleaf-extras-springsecurity6") @@ -40,7 +43,10 @@ dependencies { optional("jakarta.servlet:jakarta.servlet-api") testImplementation(project(":core:spring-boot-test")) + testImplementation(project(":module:spring-boot-test-autoconfigure")) + testImplementation(project(":module:spring-boot-webflux-test")) testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) testRuntimeOnly("ch.qos.logback:logback-classic") } diff --git a/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports new file mode 100644 index 00000000000..e1faae4a813 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports @@ -0,0 +1 @@ +org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration diff --git a/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.includes b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.includes new file mode 100644 index 00000000000..2e9870ce397 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.WebFluxTest.includes @@ -0,0 +1 @@ +org.thymeleaf.dialect.IDialect diff --git a/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..e1faae4a813 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration diff --git a/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes new file mode 100644 index 00000000000..2e9870ce397 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes @@ -0,0 +1 @@ +org.thymeleaf.dialect.IDialect diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafWebMvcTestIntegrationTests.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..1074c99605a --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/ThymeleafWebMvcTestIntegrationTests.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Thymeleaf with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class ThymeleafWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void thymeleafAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(ThymeleafAutoConfiguration.class)); + } + + @SpringBootConfiguration + static class TestConfiguration { + + } + +} diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ExampleDialect.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ExampleDialect.java new file mode 100644 index 00000000000..881738a55ac --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ExampleDialect.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure.webfluxtest; + +import org.thymeleaf.dialect.IDialect; + +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.stereotype.Component; + +/** + * {@link IDialect} used to test their inclusion in {@link WebFluxTest @WebFluxTest}s. + * + * @author Andy Wilkinson + */ +@Component +class ExampleDialect implements IDialect { + + @Override + public String getName() { + return "example"; + } + +} diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ThymeleafWebFluxTestApplication.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ThymeleafWebFluxTestApplication.java new file mode 100644 index 00000000000..b03f477f591 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ThymeleafWebFluxTestApplication.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure.webfluxtest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; + +/** + * Application for testing Thymeleaf integration with {@link WebFluxTest @WebFluxTest}. + * + * @author Andy Wilkinson + */ +@SpringBootApplication +public class ThymeleafWebFluxTestApplication { + +} diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ThymeleafWebFluxTestIntegrationTests.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ThymeleafWebFluxTestIntegrationTests.java new file mode 100644 index 00000000000..ff78b7dc6fa --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webfluxtest/ThymeleafWebFluxTestIntegrationTests.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure.webfluxtest; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration; +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Thymeleaf with {@link WebFluxTest @WebFluxTest}. + * + * @author Andy Wilkinson + */ +@WebFluxTest +class ThymeleafWebFluxTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void thymeleafAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(ThymeleafAutoConfiguration.class)); + } + + @Test + void idialectIsIncluded() { + assertThatNoException().isThrownBy(() -> this.applicationContext.getBean(ExampleDialect.class)); + } + +} diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ExampleDialect.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ExampleDialect.java new file mode 100644 index 00000000000..69241f31ba5 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ExampleDialect.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure.webmvctest; + +import org.thymeleaf.dialect.IDialect; + +import org.springframework.boot.webflux.test.autoconfigure.WebFluxTest; +import org.springframework.stereotype.Component; + +/** + * {@link IDialect} used to test their inclusion in {@link WebFluxTest @WebFluxTest}s. + * + * @author Andy Wilkinson + */ +@Component +class ExampleDialect implements IDialect { + + @Override + public String getName() { + return "example"; + } + +} diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ThymeleafWebMvcTestApplication.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ThymeleafWebMvcTestApplication.java new file mode 100644 index 00000000000..147c11c3322 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ThymeleafWebMvcTestApplication.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure.webmvctest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; + +/** + * Application for testing Thymeleaf integration with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@SpringBootApplication +public class ThymeleafWebMvcTestApplication { + +} diff --git a/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ThymeleafWebMvcTestIntegrationTests.java b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ThymeleafWebMvcTestIntegrationTests.java new file mode 100644 index 00000000000..48cc9826f62 --- /dev/null +++ b/module/spring-boot-thymeleaf/src/test/java/org/springframework/boot/thymeleaf/autoconfigure/webmvctest/ThymeleafWebMvcTestIntegrationTests.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.thymeleaf.autoconfigure.webmvctest; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; + +/** + * Integration tests for Thymeleaf with {@link WebMvcTest @WebMvcTest}. + * + * @author Andy Wilkinson + */ +@WebMvcTest +class ThymeleafWebMvcTestIntegrationTests { + + @Autowired + private ApplicationContext applicationContext; + + @Test + void thymeleafAutoConfigurationWasImported() { + assertThat(this.applicationContext).has(importedAutoConfiguration(ThymeleafAutoConfiguration.class)); + } + + @Test + void idialectIsIncluded() { + assertThatNoException().isThrownBy(() -> this.applicationContext.getBean(ExampleDialect.class)); + } + +} diff --git a/module/spring-boot-web-server-test/build.gradle b/module/spring-boot-web-server-test/build.gradle index b7ec76b9bc4..701ad75b8b3 100644 --- a/module/spring-boot-web-server-test/build.gradle +++ b/module/spring-boot-web-server-test/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.jetbrains.kotlin.jvm" id "org.springframework.boot.deployed" id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-auto-configuration" } description = "Spring Boot Web Server Test" @@ -31,20 +32,22 @@ dependencies { optional(project(":module:spring-boot-http-codec")) optional(project(":module:spring-boot-restclient")) + optional(project(":module:spring-boot-test-autoconfigure")) optional(project(":module:spring-boot-web-server")) optional(project(":module:spring-boot-webclient")) optional("jakarta.servlet:jakarta.servlet-api") optional("org.apache.httpcomponents.client5:httpclient5") + optional("org.htmlunit:htmlunit") optional("org.jetbrains.kotlin:kotlin-reflect") optional("org.jetbrains.kotlin:kotlin-stdlib") - optional("org.springframework:spring-test") - optional("org.springframework:spring-web") - optional("org.springframework:spring-webflux") - optional("org.htmlunit:htmlunit") optional("org.seleniumhq.selenium:htmlunit3-driver") { exclude(group: "com.sun.activation", module: "jakarta.activation") } optional("org.seleniumhq.selenium:selenium-api") + optional("org.springframework:spring-test") + optional("org.springframework:spring-web") + optional("org.springframework:spring-webflux") + optional("org.springframework.security:spring-security-test") testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-tomcat")) diff --git a/module/spring-boot-webflux-test/build.gradle b/module/spring-boot-webflux-test/build.gradle new file mode 100644 index 00000000000..e71e6905664 --- /dev/null +++ b/module/spring-boot-webflux-test/build.gradle @@ -0,0 +1,43 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot WebFlux Test" + +dependencies { + api(project(":module:spring-boot-webflux")) + + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-http-codec")) + optional(project(":module:spring-boot-jackson")) + optional(project(":module:spring-boot-json-test")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional(project(":module:spring-boot-validation")) + optional(project(":module:spring-boot-web-server-test")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + + testRuntimeOnly("ch.qos.logback:logback-classic") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebFlux.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebFlux.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebFlux.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebFlux.java index 24eba129c0b..d90a597aa41 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebFlux.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebFlux.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; * using this annotation directly. * * @author Stephane Nicoll - * @since 2.0.0 + * @since 4.0.0 * @see WebFluxTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebTestClient.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebTestClient.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java index d3884b831db..09e4a9fe570 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/AutoConfigureWebTestClient.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/AutoConfigureWebTestClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -35,7 +35,7 @@ import org.springframework.test.web.reactive.server.WebTestClient; * mock requests and responses. At the moment, only WebFlux applications are supported. * * @author Stephane Nicoll - * @since 2.0.0 + * @since 4.0.0 * @see WebTestClientAutoConfiguration * @see WebTestClient#bindToApplicationContext(ApplicationContext) */ diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/SpringBootWebTestClientBuilderCustomizer.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/SpringBootWebTestClientBuilderCustomizer.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/SpringBootWebTestClientBuilderCustomizer.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/SpringBootWebTestClientBuilderCustomizer.java index 228c3d8b7ac..c9a7e545c84 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/SpringBootWebTestClientBuilderCustomizer.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/SpringBootWebTestClientBuilderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.time.Duration; import java.util.Collection; @@ -37,7 +37,7 @@ import org.springframework.web.reactive.function.client.ExchangeStrategies; * directly. * * @author Andy Wilkinson - * @since 2.0.0 + * @since 4.0.0 */ public class SpringBootWebTestClientBuilderCustomizer implements WebTestClientBuilderCustomizer { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java index 537f3f24111..1a16b83fdc9 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTest.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -27,10 +27,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.json.test.autoconfigure.AutoConfigureJson; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; @@ -82,7 +81,7 @@ import org.springframework.test.web.reactive.server.WebTestClient; * * @author Stephane Nicoll * @author Artsiom Yudovin - * @since 2.0.0 + * @since 4.0.0 * @see AutoConfigureWebFlux * @see AutoConfigureWebTestClient */ @@ -94,7 +93,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(WebFluxTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureJson @AutoConfigureWebFlux @AutoConfigureWebTestClient diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestContextBootstrapper.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestContextBootstrapper.java index b8f23e2741a..890db8b80db 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestContextBootstrapper.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.boot.test.context.ReactiveWebMergedContextConfiguration; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilter.java similarity index 80% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilter.java index 986e386a4be..728c93cecf5 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.util.Arrays; import java.util.Collections; @@ -22,7 +22,6 @@ import java.util.LinkedHashSet; import java.util.Set; import org.springframework.boot.context.TypeExcludeFilter; -import org.springframework.boot.jackson.JsonComponent; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.GenericConverter; @@ -38,21 +37,20 @@ import org.springframework.web.server.WebFilter; * {@link TypeExcludeFilter} for {@link WebFluxTest @WebFluxTest}. * * @author Stephane Nicoll - * @since 2.2.1 + * @since 4.0.0 */ public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { private static final Class[] NO_CONTROLLERS = {}; private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule", - "org.thymeleaf.dialect.IDialect" }; + "org.springframework.boot.jackson.JsonComponent" }; - private static final Set> DEFAULT_INCLUDES; + private static final Set> KNOWN_INCLUDES; static { Set> includes = new LinkedHashSet<>(); includes.add(ControllerAdvice.class); - includes.add(JsonComponent.class); includes.add(WebFluxConfigurer.class); includes.add(Converter.class); includes.add(GenericConverter.class); @@ -66,15 +64,15 @@ public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizab // Ignore } } - DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES = Collections.unmodifiableSet(includes); } - private static final Set> DEFAULT_INCLUDES_AND_CONTROLLER; + private static final Set> KNOWN_INCLUDES_AND_CONTROLLER; static { - Set> includes = new LinkedHashSet<>(DEFAULT_INCLUDES); + Set> includes = new LinkedHashSet<>(KNOWN_INCLUDES); includes.add(Controller.class); - DEFAULT_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes); } private final Class[] controllers; @@ -85,11 +83,11 @@ public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizab } @Override - protected Set> getDefaultIncludes() { + protected Set> getKnownIncludes() { if (ObjectUtils.isEmpty(this.controllers)) { - return DEFAULT_INCLUDES_AND_CONTROLLER; + return KNOWN_INCLUDES_AND_CONTROLLER; } - return DEFAULT_INCLUDES; + return KNOWN_INCLUDES; } @Override diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfiguration.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java rename to module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfiguration.java index cd78bff2671..4125d53e52b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfiguration.java +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.util.List; @@ -29,7 +29,6 @@ import org.springframework.boot.http.codec.CodecCustomizer; import org.springframework.boot.web.server.test.client.reactive.WebTestClientBuilderCustomizer; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; import org.springframework.test.web.reactive.server.MockServerConfigurer; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.reactive.function.client.WebClient; @@ -40,12 +39,11 @@ import org.springframework.web.server.WebHandler; * * @author Stephane Nicoll * @author Andy Wilkinson - * @since 2.0.0 + * @since 4.0.0 */ @AutoConfiguration(afterName = { "org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration", "org.springframework.boot.webflux.autoconfigure.WebFluxAutoConfiguration" }) @ConditionalOnClass({ CodecCustomizer.class, WebClient.class, WebTestClient.class }) -@Import(WebTestClientSecurityConfiguration.class) @EnableConfigurationProperties public final class WebTestClientAutoConfiguration { diff --git a/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/package-info.java b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/package-info.java new file mode 100644 index 00000000000..63c2a71a3b6 --- /dev/null +++ b/module/spring-boot-webflux-test/src/main/java/org/springframework/boot/webflux/test/autoconfigure/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Auto-configuration for Spring WebFlux tests. + */ +@NullMarked +package org.springframework.boot.webflux.test.autoconfigure; + +import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-webflux-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-webflux-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000000..7481348e4ab --- /dev/null +++ b/module/spring-boot-webflux-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "name": "spring.test.webtestclient.timeout", + "type": "java.time.Duration", + "description": "Maximum amount of time to wait for responses.", + "defaultValue": "5s" + } + ] +} diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebFlux.imports b/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports similarity index 56% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebFlux.imports rename to module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports index 8f8cfbd395a..2852d643ce2 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebFlux.imports +++ b/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebFlux.imports @@ -1,9 +1,5 @@ -# AutoConfigureWebFlux auto-configuration imports org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration -optional:org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration -optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration -optional:org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration -optional:org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration -optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration org.springframework.boot.webflux.autoconfigure.WebFluxAutoConfiguration org.springframework.boot.webflux.autoconfigure.error.ErrorWebFluxAutoConfiguration +optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration +optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration diff --git a/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports b/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports new file mode 100644 index 00000000000..4fe476f62fe --- /dev/null +++ b/module/spring-boot-webflux-test/src/main/resources/META-INF/spring/org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient.imports @@ -0,0 +1 @@ +org.springframework.boot.webflux.test.autoconfigure.WebTestClientAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController1.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController1.java similarity index 88% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController1.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController1.java index b443afa7fd2..fa54826ddab 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController1.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController1.java @@ -14,11 +14,10 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import reactor.core.publisher.Mono; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController2.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController2.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java index 3e796bcf3d3..93e7dd4139b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController2.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleController2.java @@ -14,11 +14,10 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import reactor.core.publisher.Mono; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleId.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleId.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleId.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleId.java index 62c7a5e3e1b..b65fb527e8b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleId.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleId.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import java.util.UUID; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleIdConverter.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleIdConverter.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java index 3e535347964..524b6a85f30 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleIdConverter.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java @@ -14,13 +14,12 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import java.util.Collections; import java.util.Set; import java.util.UUID; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.GenericConverter; import org.springframework.stereotype.Component; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExamplePojo.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExamplePojo.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExamplePojo.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExamplePojo.java index 51370255360..8d01d6136b6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExamplePojo.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExamplePojo.java @@ -14,9 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; - -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +package org.springframework.boot.webflux.test.autoconfigure; /** * Example POJO used with {@link WebFluxTest @WebFluxTest} tests. diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleRealService.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleRealService.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleRealService.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleRealService.java index 86c492f425d..8e0ac3d555c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleRealService.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleRealService.java @@ -14,9 +14,8 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.stereotype.Service; /** diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebExceptionHandler.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebExceptionHandler.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebExceptionHandler.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebExceptionHandler.java index b318da5c0a7..2a5fbd67625 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebExceptionHandler.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebExceptionHandler.java @@ -14,11 +14,10 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import reactor.core.publisher.Mono; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.boot.webflux.error.ErrorWebExceptionHandler; import org.springframework.core.annotation.Order; import org.springframework.http.HttpStatus; diff --git a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleMongoApplication.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebFluxApplication.java similarity index 82% rename from module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleMongoApplication.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebFluxApplication.java index 2db4bba1387..474c04595d5 100644 --- a/module/spring-boot-test-autoconfigure/src/dockerTest/java/org/springframework/boot/test/autoconfigure/data/mongo/ExampleMongoApplication.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleWebFluxApplication.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.data.mongo; +package org.springframework.boot.webflux.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Example {@link SpringBootApplication @SpringBootApplication} used with - * {@link DataMongoTest @DataMongoTest} tests. + * {@link WebFluxTest @WebFluxTest} tests. * - * @author Michael Simons + * @author Stephane Nicoll */ @SpringBootApplication -public class ExampleMongoApplication { +public class ExampleWebFluxApplication { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/JsonController.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/JsonController.java similarity index 88% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/JsonController.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/JsonController.java index 5effc3a342a..8995e083405 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/JsonController.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/JsonController.java @@ -14,11 +14,10 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import reactor.core.publisher.Mono; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAllControllersIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestAllControllersIntegrationTests.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAllControllersIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestAllControllersIntegrationTests.java index beaf876da25..b4146ff110b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAllControllersIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestAllControllersIntegrationTests.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.reactive.server.WebTestClient; /** @@ -28,7 +26,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; * * @author Stephane Nicoll */ -@WithMockUser @WebFluxTest class WebFluxTestAllControllersIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAutoConfigurationIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestAutoConfigurationIntegrationTests.java similarity index 54% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAutoConfigurationIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestAutoConfigurationIntegrationTests.java index 1b88bd34a79..34913f26d33 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAutoConfigurationIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestAutoConfigurationIntegrationTests.java @@ -14,24 +14,18 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration; -import org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration; -import org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration; -import org.springframework.boot.security.oauth2.client.autoconfigure.reactive.ReactiveOAuth2ClientAutoConfiguration; -import org.springframework.boot.security.oauth2.server.resource.autoconfigure.reactive.ReactiveOAuth2ResourceServerAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration; import org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration; import org.springframework.boot.webflux.autoconfigure.error.ErrorWebFluxAutoConfiguration; import org.springframework.context.ApplicationContext; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Tests for the auto-configuration imported by {@link WebFluxTest @WebFluxTest}. @@ -57,35 +51,9 @@ class WebFluxTestAutoConfigurationIntegrationTests { assertThat(this.applicationContext).has(importedAutoConfiguration(ValidationAutoConfiguration.class)); } - @Test - void mustacheAutoConfigurationIsImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(MustacheAutoConfiguration.class)); - } - - @Test - void freeMarkerAutoConfigurationIsImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(FreeMarkerAutoConfiguration.class)); - } - - @Test - void thymeleafAutoConfigurationIsImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(ThymeleafAutoConfiguration.class)); - } - @Test void errorWebFluxAutoConfigurationIsImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(ErrorWebFluxAutoConfiguration.class)); } - @Test - void oAuth2ClientAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(ReactiveOAuth2ClientAutoConfiguration.class)); - } - - @Test - void oAuth2ResourceServerAutoConfigurationWasImported() { - assertThat(this.applicationContext) - .has(importedAutoConfiguration(ReactiveOAuth2ResourceServerAutoConfiguration.class)); - } - } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestConverterIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestConverterIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestConverterIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestConverterIntegrationTests.java index 0028c908729..d89b612565f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestConverterIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestConverterIntegrationTests.java @@ -14,15 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import java.util.UUID; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.reactive.server.WebTestClient; /** @@ -30,7 +28,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; * * @author Stephane Nicoll */ -@WithMockUser @WebFluxTest(controllers = ExampleController2.class) class WebFluxTestConverterIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestMessageSourceIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestMessageSourceIntegrationTests.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestMessageSourceIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestMessageSourceIntegrationTests.java index 38f02f8a6b3..00a0dce1e05 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestMessageSourceIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestMessageSourceIntegrationTests.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import java.util.Locale; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; import org.springframework.context.ApplicationContext; import org.springframework.context.MessageSource; import org.springframework.test.context.TestPropertySource; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestOneControllerIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestOneControllerIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestOneControllerIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestOneControllerIntegrationTests.java index f25ec06f003..f49697dd06e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestOneControllerIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestOneControllerIntegrationTests.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.reactive.server.WebTestClient; /** @@ -28,7 +26,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; * * @author Stephane Nicoll */ -@WithMockUser @WebFluxTest(controllers = ExampleController1.class) class WebFluxTestOneControllerIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestPropertiesIntegrationTests.java index 787525dba39..709e5056bda 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTestPropertiesIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestWebTestClientCodecCustomizationIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestWebTestClientCodecCustomizationIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestWebTestClientCodecCustomizationIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestWebTestClientCodecCustomizationIntegrationTests.java index 286ef616b77..b3c473002b5 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestWebTestClientCodecCustomizationIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTestWebTestClientCodecCustomizationIntegrationTests.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.reactive.server.WebTestClient; /** @@ -29,7 +27,6 @@ import org.springframework.test.web.reactive.server.WebTestClient; * * @author Andy Wilkinson */ -@WithMockUser @WebFluxTest(controllers = JsonController.class) class WebFluxTestWebTestClientCodecCustomizationIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java index 4e9ac0f7f68..7190c842534 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java @@ -14,12 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.io.IOException; import org.junit.jupiter.api.Test; -import org.thymeleaf.dialect.IDialect; import reactor.core.publisher.Mono; import tools.jackson.databind.module.SimpleModule; @@ -60,7 +59,6 @@ class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleRepository.class)).isTrue(); assertThat(excludes(filter, ExampleWebFilter.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } @Test @@ -74,7 +72,6 @@ class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleRepository.class)).isTrue(); assertThat(excludes(filter, ExampleWebFilter.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } @Test @@ -88,7 +85,6 @@ class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleRepository.class)).isTrue(); assertThat(excludes(filter, ExampleWebFilter.class)).isTrue(); assertThat(excludes(filter, ExampleModule.class)).isTrue(); - assertThat(excludes(filter, ExampleDialect.class)).isTrue(); } @Test @@ -102,7 +98,6 @@ class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleRepository.class)).isFalse(); assertThat(excludes(filter, ExampleWebFilter.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } @Test @@ -116,7 +111,6 @@ class WebFluxTypeExcludeFilterTests { assertThat(excludes(filter, ExampleRepository.class)).isTrue(); assertThat(excludes(filter, ExampleWebFilter.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } private boolean excludes(WebFluxTypeExcludeFilter filter, Class type) throws IOException { @@ -191,13 +185,4 @@ class WebFluxTypeExcludeFilterTests { } - static class ExampleDialect implements IDialect { - - @Override - public String getName() { - return "example"; - } - - } - } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java similarity index 65% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java index 2ca6cd83a06..67fc4284520 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientAutoConfigurationTests.java @@ -14,10 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive; +package org.springframework.boot.webflux.test.autoconfigure; import java.time.Duration; -import java.util.List; import org.junit.jupiter.api.Test; @@ -29,12 +28,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.http.codec.CodecConfigurer; -import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers; -import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.web.reactive.server.WebTestClient; -import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebHandler; -import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -87,38 +82,6 @@ class WebTestClientAutoConfigurationTests { }); } - @Test - @SuppressWarnings("unchecked") - void shouldApplySpringSecurityConfigurer() { - this.contextRunner.withUserConfiguration(BaseConfiguration.class).run((context) -> { - WebTestClient webTestClient = context.getBean(WebTestClient.class); - WebTestClient.Builder builder = (WebTestClient.Builder) ReflectionTestUtils.getField(webTestClient, - "builder"); - WebHttpHandlerBuilder httpHandlerBuilder = (WebHttpHandlerBuilder) ReflectionTestUtils.getField(builder, - "httpHandlerBuilder"); - List filters = (List) ReflectionTestUtils.getField(httpHandlerBuilder, "filters"); - assertThat(filters.get(0).getClass().getName()).isEqualTo( - "org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers$MutatorFilter"); - }); - } - - @Test - @SuppressWarnings("unchecked") - void shouldNotApplySpringSecurityConfigurerWhenSpringSecurityNotOnClassPath() { - FilteredClassLoader classLoader = new FilteredClassLoader(SecurityMockServerConfigurers.class); - this.contextRunner.withUserConfiguration(BaseConfiguration.class) - .withClassLoader(classLoader) - .run((context) -> { - WebTestClient webTestClient = context.getBean(WebTestClient.class); - WebTestClient.Builder builder = (WebTestClient.Builder) ReflectionTestUtils.getField(webTestClient, - "builder"); - WebHttpHandlerBuilder httpHandlerBuilder = (WebHttpHandlerBuilder) ReflectionTestUtils.getField(builder, - "httpHandlerBuilder"); - List filters = (List) ReflectionTestUtils.getField(httpHandlerBuilder, "filters"); - assertThat(filters).isEmpty(); - }); - } - @Test void shouldBackOffWithoutCodecCustomizer() { FilteredClassLoader classLoader = new FilteredClassLoader(CodecCustomizer.class); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebTestClientSpringBootTestIntegrationTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java similarity index 66% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebTestClientSpringBootTestIntegrationTests.java rename to module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java index ccf9a75c817..4eede12363e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebTestClientSpringBootTestIntegrationTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebTestClientSpringBootTestIntegrationTests.java @@ -14,18 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.reactive.webclient; +package org.springframework.boot.webflux.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.web.server.ServerHttpSecurity; -import org.springframework.security.web.server.SecurityWebFilterChain; import org.springframework.test.web.reactive.server.WebTestClient; import static org.assertj.core.api.Assertions.assertThat; @@ -37,9 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Stephane Nicoll */ -@SpringBootTest(properties = "spring.main.web-application-type=reactive", - classes = { WebTestClientSpringBootTestIntegrationTests.TestConfiguration.class, - ExampleWebFluxApplication.class }) +@SpringBootTest(properties = { "spring.main.web-application-type=reactive", "debug=true" }, + classes = ExampleWebFluxApplication.class) @AutoConfigureWebTestClient class WebTestClientSpringBootTestIntegrationTests { @@ -64,15 +58,4 @@ class WebTestClientSpringBootTestIntegrationTests { assertThat(this.applicationContext.getBeansOfType(ExampleRealService.class)).hasSize(1); } - @Configuration(proxyBeanMethods = false) - static class TestConfiguration { - - @Bean - SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { - http.authorizeExchange((exchanges) -> exchanges.anyExchange().permitAll()); - return http.build(); - } - - } - } diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/web-test-messages.properties b/module/spring-boot-webflux-test/src/test/resources/web-test-messages.properties similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/web-test-messages.properties rename to module/spring-boot-webflux-test/src/test/resources/web-test-messages.properties diff --git a/module/spring-boot-webflux/build.gradle b/module/spring-boot-webflux/build.gradle index c038068f92e..ac505de9bd8 100644 --- a/module/spring-boot-webflux/build.gradle +++ b/module/spring-boot-webflux/build.gradle @@ -47,7 +47,6 @@ dependencies { testImplementation(project(":core:spring-boot-test")) testImplementation(project(":module:spring-boot-jackson")) - testImplementation(project(":module:spring-boot-mustache")) testImplementation(project(":module:spring-boot-reactor-netty")) testImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":test-support:spring-boot-test-support")) diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java index 92746e71e8a..599d671b4ed 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java @@ -33,13 +33,11 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.web.WebProperties; -import org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration; import org.springframework.boot.reactor.netty.autoconfigure.NettyReactiveWebServerAutoConfiguration; import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.boot.testsupport.classpath.resources.WithResource; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.error.ErrorAttributeOptions.Include; import org.springframework.boot.web.server.autoconfigure.ServerProperties; @@ -88,7 +86,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner() .withConfiguration(AutoConfigurations.of(NettyReactiveWebServerAutoConfiguration.class, HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class, ErrorWebFluxAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class, MustacheAutoConfiguration.class)) + PropertyPlaceholderAutoConfiguration.class)) .withPropertyValues("spring.main.web-application-type=reactive", "server.port=0") .withUserConfiguration(Application.class); @@ -150,36 +148,6 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { }); } - @Test - @WithResource(name = "templates/error/error.mustache", content = """ - - -

- - - """) - void htmlError() { - Schedulers.shutdownNow(); - this.contextRunner.withPropertyValues("server.error.include-message=always").run((context) -> { - WebTestClient client = getWebClient(context); - String body = client.get() - .uri("/") - .accept(MediaType.TEXT_HTML) - .exchange() - .expectStatus() - .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) - .expectHeader() - .contentType(TEXT_HTML_UTF8) - .expectBody(String.class) - .returnResult() - .getResponseBody(); - assertThat(body).contains("status: 500").contains("message: Expected!"); - }); - } - @Test void bindingResultError() { this.contextRunner.run((context) -> { @@ -509,46 +477,6 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { }); } - @Test - void exactStatusTemplateErrorPage() { - this.contextRunner - .withPropertyValues("server.error.whitelabel.enabled=false", - "spring.mustache.prefix=" + getErrorTemplatesLocation()) - .run((context) -> { - WebTestClient client = getWebClient(context); - String body = client.get() - .uri("/notfound") - .accept(MediaType.TEXT_HTML) - .exchange() - .expectStatus() - .isNotFound() - .expectBody(String.class) - .returnResult() - .getResponseBody(); - assertThat(body).contains("404 page"); - }); - } - - @Test - void seriesStatusTemplateErrorPage() { - this.contextRunner - .withPropertyValues("server.error.whitelabel.enabled=false", - "spring.mustache.prefix=" + getErrorTemplatesLocation()) - .run((context) -> { - WebTestClient client = getWebClient(context); - String body = client.get() - .uri("/badRequest") - .accept(MediaType.TEXT_HTML) - .exchange() - .expectStatus() - .isBadRequest() - .expectBody(String.class) - .returnResult() - .getResponseBody(); - assertThat(body).contains("4xx page"); - }); - } - @Test void invalidAcceptMediaType() { this.contextRunner.run((context) -> { @@ -634,11 +562,6 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { }); } - private String getErrorTemplatesLocation() { - String packageName = getClass().getPackage().getName(); - return "classpath:/" + packageName.replace('.', '/') + "/templates/"; - } - private WebTestClient getWebClient(AssertableReactiveWebApplicationContext context) { return WebTestClient.bindToApplicationContext(context).webFilter(this.logIdFilter).build(); } diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerTests.java index fe4d5b52bd9..99d1372766a 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerTests.java @@ -30,6 +30,7 @@ import org.springframework.boot.webflux.error.ErrorAttributes; import org.springframework.context.ApplicationContext; import org.springframework.http.MediaType; import org.springframework.http.codec.HttpMessageReader; +import org.springframework.http.codec.ResourceHttpMessageWriter; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.mock.http.server.reactive.MockServerHttpRequest; import org.springframework.mock.web.server.MockServerWebExchange; @@ -53,12 +54,12 @@ import static org.mockito.Mockito.mock; class DefaultErrorWebExceptionHandlerTests { @Test - @WithResource(name = "templates/error/error.mustache", content = """ + @WithResource(name = "static/error/498.html", content = """
    -
  • status: {{status}}
  • -
  • message: {{message}}
  • +
  • status: 498
  • +
  • message: non standard error
@@ -71,6 +72,7 @@ class DefaultErrorWebExceptionHandlerTests { ApplicationContext context = new AnnotationConfigReactiveWebApplicationContext(); DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, resourceProperties, errorProperties, context); + exceptionHandler.setMessageWriters(List.of(new ResourceHttpMessageWriter())); setupViewResolver(exceptionHandler); ServerWebExchange exchange = MockServerWebExchange .from(MockServerHttpRequest.get("/some-other-path").accept(MediaType.TEXT_HTML)); diff --git a/module/spring-boot-webmvc-test/build.gradle b/module/spring-boot-webmvc-test/build.gradle new file mode 100644 index 00000000000..f9e8df179f0 --- /dev/null +++ b/module/spring-boot-webmvc-test/build.gradle @@ -0,0 +1,59 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Web MVC Test" + +dependencies { + api(project(":module:spring-boot-webmvc")) + + compileOnly("jakarta.servlet:jakarta.servlet-api") + + implementation(project(":core:spring-boot-test")) + implementation(project(":module:spring-boot-http-converter")) + implementation(project(":module:spring-boot-web-server")) + implementation(project(":module:spring-boot-web-server-test")) + + optional(project(":module:spring-boot-jackson")) + optional(project(":module:spring-boot-json-test")) + optional(project(":module:spring-boot-test-autoconfigure")) + optional(project(":module:spring-boot-validation")) + optional(project(":module:spring-boot-webflux")) + optional("org.junit.jupiter:junit-jupiter-api") + optional("org.seleniumhq.selenium:htmlunit3-driver") { + exclude(group: "com.sun.activation", module: "jakarta.activation") + } + optional("org.seleniumhq.selenium:selenium-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + testImplementation(testFixtures(project(":core:spring-boot-autoconfigure"))) + testImplementation("jakarta.servlet:jakarta.servlet-api") + testImplementation("org.junit.platform:junit-platform-engine") + testImplementation("org.junit.platform:junit-platform-launcher") + + testRuntimeOnly("ch.qos.logback:logback-classic") +} + +tasks.named("test") { + exclude("**/WebMvcTestPrintDefaultIntegrationTests\$*") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java index 5137f63a35a..dbd2dc099d0 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureMockMvc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -39,7 +39,7 @@ import org.springframework.test.web.servlet.assertj.MockMvcTester; * is auto-configured as well. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see MockMvcAutoConfiguration * @see SpringBootMockMvcBuilderCustomizer */ diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureWebMvc.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureWebMvc.java index 036898348d2..dccb816ef36 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureWebMvc.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/AutoConfigureWebMvc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; +import org.springframework.boot.json.test.autoconfigure.AutoConfigureJson; /** * {@link ImportAutoConfiguration Auto-configuration imports} for typical Spring MVC @@ -33,7 +33,7 @@ import org.springframework.boot.test.autoconfigure.json.AutoConfigureJson; * * @author Phillip Webb * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 * @see WebMvcTest */ @Target(ElementType.TYPE) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfiguration.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java index 401a475824c..b56b317a730 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.util.List; @@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration; import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.web.server.test.client.reactive.WebTestClientBuilderCustomizer; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath; @@ -46,10 +45,10 @@ import org.springframework.web.servlet.DispatcherServlet; * @author Andy Wilkinson * @author Stephane Nicoll * @author Brian Clozel - * @since 1.4.0 + * @since 4.0.0 * @see AutoConfigureWebMvc */ -@AutoConfiguration(after = { WebMvcAutoConfiguration.class, WebTestClientAutoConfiguration.class }) +@AutoConfiguration(after = WebMvcAutoConfiguration.class) @ConditionalOnWebApplication(type = Type.SERVLET) @EnableConfigurationProperties({ ServerProperties.class, WebMvcProperties.class }) @Import({ MockMvcConfiguration.class, MockMvcTesterConfiguration.class }) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcBuilderCustomizer.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcBuilderCustomizer.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcBuilderCustomizer.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcBuilderCustomizer.java index 92caddc7aea..ec820b13d7a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcBuilderCustomizer.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcBuilderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.springframework.test.web.servlet.MockMvcBuilder; import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder; @@ -25,7 +25,7 @@ import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder; * {@link #customize called} to customize the auto-configured {@link MockMvcBuilder}. * * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 * @see MockMvcAutoConfiguration */ @FunctionalInterface diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcConfiguration.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcConfiguration.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcConfiguration.java index d34ea6779ed..7f9ac6d9679 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.util.List; diff --git a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcHtmlUnitDriverCustomizer.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcHtmlUnitDriverCustomizer.java new file mode 100644 index 00000000000..c7b6a8738e7 --- /dev/null +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcHtmlUnitDriverCustomizer.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.webmvc.test.autoconfigure; + +import org.openqa.selenium.htmlunit.HtmlUnitDriver; + +/** + * Callback interface that can be implemented by beans wishing to customize the MockMvc + * {@link HtmlUnitDriver} to fine-tune its auto-configuration. + * + * @author Andy Wilkinson + * @since 4.0.0 + */ +@FunctionalInterface +public interface MockMvcHtmlUnitDriverCustomizer { + + /** + * Customize the MockMvc HtmlUnitDriver. + * @param htmlUnitDriver the driver to customize + */ + void customize(HtmlUnitDriver htmlUnitDriver); + +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcPrint.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcPrint.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcPrint.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcPrint.java index 20b5c3bf699..c8c6550b3ff 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcPrint.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcPrint.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; /** * MVC print options specified from {@link AutoConfigureMockMvc @AutoConfigureMockMvc}. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ public enum MockMvcPrint { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcPrintOnlyOnFailureTestExecutionListener.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcPrintOnlyOnFailureTestExecutionListener.java similarity index 88% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcPrintOnlyOnFailureTestExecutionListener.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcPrintOnlyOnFailureTestExecutionListener.java index 985fe613cc2..e077db03be9 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcPrintOnlyOnFailureTestExecutionListener.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcPrintOnlyOnFailureTestExecutionListener.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; -import org.springframework.boot.test.autoconfigure.web.servlet.SpringBootMockMvcBuilderCustomizer.DeferredLinesWriter; +import org.springframework.boot.webmvc.test.autoconfigure.SpringBootMockMvcBuilderCustomizer.DeferredLinesWriter; import org.springframework.core.Ordered; import org.springframework.test.context.TestContext; import org.springframework.test.context.TestExecutionListener; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcTesterConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcTesterConfiguration.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcTesterConfiguration.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcTesterConfiguration.java index 90e22d18805..64ee2a9cf4b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcTesterConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcTesterConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcWebClientAutoConfiguration.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcWebClientAutoConfiguration.java index c90051ba0e7..43c047ae245 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebClientAutoConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcWebClientAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.htmlunit.WebClient; @@ -33,7 +33,7 @@ import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder; * Auto-configuration for HtmlUnit {@link WebClient} MockMVC integration. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ @AutoConfiguration(after = MockMvcAutoConfiguration.class) @ConditionalOnClass(WebClient.class) diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcWebDriverAutoConfiguration.java similarity index 79% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcWebDriverAutoConfiguration.java index 8c86d113437..37bbb6f1427 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcWebDriverAutoConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcWebDriverAutoConfiguration.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; - -import java.util.concurrent.Executors; +package org.springframework.boot.webmvc.test.autoconfigure; import org.htmlunit.BrowserVersion; import org.openqa.selenium.WebDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; +import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; @@ -30,40 +29,36 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.web.server.test.htmlunit.webdriver.LocalHostWebConnectionHtmlUnitDriver; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; -import org.springframework.security.concurrent.DelegatingSecurityContextExecutor; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDriverBuilder; -import org.springframework.util.ClassUtils; /** * Auto-configuration for Selenium {@link WebDriver} MockMVC integration. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ @AutoConfiguration(after = MockMvcAutoConfiguration.class) @ConditionalOnClass(HtmlUnitDriver.class) @ConditionalOnBooleanProperty(name = "spring.test.mockmvc.webdriver.enabled", matchIfMissing = true) public final class MockMvcWebDriverAutoConfiguration { - private static final String SECURITY_CONTEXT_EXECUTOR = "org.springframework.security.concurrent.DelegatingSecurityContextExecutor"; - @Bean @ConditionalOnMissingBean({ WebDriver.class, MockMvcHtmlUnitDriverBuilder.class }) @ConditionalOnBean(MockMvc.class) MockMvcHtmlUnitDriverBuilder mockMvcHtmlUnitDriverBuilder(MockMvc mockMvc, Environment environment) { - return MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc) + MockMvcHtmlUnitDriverBuilder builder = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc) .withDelegate(new LocalHostWebConnectionHtmlUnitDriver(environment, BrowserVersion.CHROME)); + return builder; } @Bean @ConditionalOnMissingBean(WebDriver.class) @ConditionalOnBean(MockMvcHtmlUnitDriverBuilder.class) - HtmlUnitDriver htmlUnitDriver(MockMvcHtmlUnitDriverBuilder builder) { + HtmlUnitDriver htmlUnitDriver(MockMvcHtmlUnitDriverBuilder builder, + ObjectProvider customizers) { HtmlUnitDriver driver = builder.build(); - if (ClassUtils.isPresent(SECURITY_CONTEXT_EXECUTOR, getClass().getClassLoader())) { - driver.setExecutor(new DelegatingSecurityContextExecutor(Executors.newSingleThreadExecutor())); - } + customizers.orderedStream().forEach((customizer) -> customizer.customize(driver)); return driver; } diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizer.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizer.java similarity index 99% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizer.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizer.java index 9dd1ed9c650..e1652293484 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizer.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.io.PrintStream; import java.io.PrintWriter; @@ -59,7 +59,7 @@ import org.springframework.web.context.WebApplicationContext; * @author Phillip Webb * @author Andy Wilkinson * @author Moritz Halbritter - * @since 1.4.0 + * @since 4.0.0 */ public class SpringBootMockMvcBuilderCustomizer implements MockMvcBuilderCustomizer { diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizer.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverContextCustomizer.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizer.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverContextCustomizer.java index 29363645af0..f7bbda65300 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizer.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverContextCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.jspecify.annotations.Nullable; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverContextCustomizerFactory.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverContextCustomizerFactory.java index d3e488f4b30..36990e24302 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverContextCustomizerFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.util.List; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverScope.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverScope.java index cd6c7e2934a..cd901936987 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverScope.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.util.HashMap; import java.util.Map; @@ -37,7 +37,7 @@ import org.springframework.util.StringUtils; * {@link WebDriverTestExecutionListener}. * * @author Phillip Webb - * @since 3.0.0 + * @since 4.0.0 * @see WebDriverContextCustomizerFactory * @see WebDriverTestExecutionListener */ diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverTestExecutionListener.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverTestExecutionListener.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverTestExecutionListener.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverTestExecutionListener.java index 8c7362523fb..e57950358d7 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverTestExecutionListener.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebDriverTestExecutionListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.springframework.core.Ordered; import org.springframework.test.context.TestContext; @@ -26,7 +26,7 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution * {@link TestExecutionListener} to reset the {@link WebDriverScope}. * * @author Phillip Webb - * @since 3.0.0 + * @since 4.0.0 * @see WebDriverContextCustomizerFactory * @see WebDriverScope */ diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTest.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTest.java index 1444d337942..cb18113eb2e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan.Filter; @@ -91,8 +90,7 @@ import org.springframework.test.web.servlet.MockMvc; * @author Artsiom Yudovin * @see AutoConfigureWebMvc * @see AutoConfigureMockMvc - * @see AutoConfigureCache - * @since 1.4.0 + * @since 4.0.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -102,7 +100,6 @@ import org.springframework.test.web.servlet.MockMvc; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(WebMvcTypeExcludeFilter.class) -@AutoConfigureCache @AutoConfigureWebMvc @AutoConfigureMockMvc @ImportAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestContextBootstrapper.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestContextBootstrapper.java index a7f62d5835a..e8ed616c328 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestContextBootstrapper.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.MergedContextConfiguration; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilter.java similarity index 82% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilter.java index ddf2485f2bf..d82b32b823b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.util.Arrays; import java.util.Collections; @@ -22,7 +22,6 @@ import java.util.LinkedHashSet; import java.util.Set; import org.springframework.boot.context.TypeExcludeFilter; -import org.springframework.boot.jackson.JsonComponent; import org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter; import org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean; @@ -45,22 +44,22 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; * @author Phillip Webb * @author Madhura Bhave * @author Yanming Zhou - * @since 2.2.1 + * @since 4.0.0 */ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { private static final Class[] NO_CONTROLLERS = {}; - private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule", + private static final String[] OPTIONAL_INCLUDES = { "org.springframework.boot.jackson.JsonComponent", "org.springframework.security.config.annotation.web.WebSecurityConfigurer", - "org.springframework.security.web.SecurityFilterChain", "org.thymeleaf.dialect.IDialect" }; + "org.springframework.security.web.SecurityFilterChain", "org.thymeleaf.dialect.IDialect", + "tools.jackson.databind.JacksonModule" }; - private static final Set> DEFAULT_INCLUDES; + private static final Set> KNOWN_INCLUDES; static { Set> includes = new LinkedHashSet<>(); includes.add(ControllerAdvice.class); - includes.add(JsonComponent.class); includes.add(WebMvcConfigurer.class); includes.add(WebMvcRegistrations.class); includes.add(jakarta.servlet.Filter.class); @@ -80,15 +79,15 @@ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizabl // Ignore } } - DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES = Collections.unmodifiableSet(includes); } - private static final Set> DEFAULT_INCLUDES_AND_CONTROLLER; + private static final Set> KNOWN_INCLUDES_AND_CONTROLLER; static { - Set> includes = new LinkedHashSet<>(DEFAULT_INCLUDES); + Set> includes = new LinkedHashSet<>(KNOWN_INCLUDES); includes.add(Controller.class); - DEFAULT_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES_AND_CONTROLLER = Collections.unmodifiableSet(includes); } private final Class[] controllers; @@ -99,11 +98,11 @@ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizabl } @Override - protected Set> getDefaultIncludes() { + protected Set> getKnownIncludes() { if (ObjectUtils.isEmpty(this.controllers)) { - return DEFAULT_INCLUDES_AND_CONTROLLER; + return KNOWN_INCLUDES_AND_CONTROLLER; } - return DEFAULT_INCLUDES; + return KNOWN_INCLUDES; } @Override diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/package-info.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/package-info.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/package-info.java rename to module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/package-info.java index dd6c2f5130a..f6048f0d7ab 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/package-info.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for Spring MVC tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-webmvc-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-webmvc-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000000..7f03b81fb13 --- /dev/null +++ b/module/spring-boot-webmvc-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,16 @@ +{ + "properties": [ + { + "name": "spring.test.mockmvc.webclient.enabled", + "type": "java.lang.Boolean", + "description": "Whether HTMLUnit's WebClient should be auto-configured when it's on the classpath.", + "defaultValue": true + }, + { + "name": "spring.test.mockmvc.webdriver.enabled", + "type": "java.lang.Boolean", + "description": "Whether Selenium's WebDriver should be auto-configured when it's on the classpath.", + "defaultValue": true + } + ] +} diff --git a/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..291c836b08e --- /dev/null +++ b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring.factories @@ -0,0 +1,8 @@ +# Spring Test Context Customizer Factories +org.springframework.test.context.ContextCustomizerFactory=\ +org.springframework.boot.webmvc.test.autoconfigure.WebDriverContextCustomizerFactory + +# Spring Test Execution Listeners +org.springframework.test.context.TestExecutionListener=\ +org.springframework.boot.webmvc.test.autoconfigure.MockMvcPrintOnlyOnFailureTestExecutionListener,\ +org.springframework.boot.webmvc.test.autoconfigure.WebDriverTestExecutionListener diff --git a/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc.imports b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc.imports new file mode 100644 index 00000000000..4c92bd8aa62 --- /dev/null +++ b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc.imports @@ -0,0 +1,3 @@ +org.springframework.boot.webmvc.test.autoconfigure.MockMvcAutoConfiguration +org.springframework.boot.webmvc.test.autoconfigure.MockMvcWebClientAutoConfiguration +org.springframework.boot.webmvc.test.autoconfigure.MockMvcWebDriverAutoConfiguration diff --git a/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports new file mode 100644 index 00000000000..df1db0fe80c --- /dev/null +++ b/module/spring-boot-webmvc-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureWebMvc.imports @@ -0,0 +1,7 @@ +org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration +org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration +org.springframework.boot.servlet.autoconfigure.HttpEncodingAutoConfiguration +org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration +org.springframework.boot.webmvc.autoconfigure.error.ErrorMvcAutoConfiguration +optional:org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration +optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/webapp/inwebapp b/module/spring-boot-webmvc-test/src/main/webapp/inwebapp similarity index 100% rename from module/spring-boot-test-autoconfigure/src/main/webapp/inwebapp rename to module/spring-boot-webmvc-test/src/main/webapp/inwebapp diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleWebMvcApplication.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/ExampleWebMvcApplication.java similarity index 74% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleWebMvcApplication.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/ExampleWebMvcApplication.java index 91a2335297f..142ae383c80 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleWebMvcApplication.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/ExampleWebMvcApplication.java @@ -14,11 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; /** * Example {@link SpringBootApplication @SpringBootApplication} used with @@ -26,7 +24,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; * * @author Phillip Webb */ -@SpringBootApplication(exclude = CassandraAutoConfiguration.class) +@SpringBootApplication public class ExampleWebMvcApplication { } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java index f47f814e72a..0420234a1f6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/MockMvcAutoConfigurationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizerTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizerTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizerTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizerTests.java index e361300dafd..20dbcd6222d 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/SpringBootMockMvcBuilderCustomizerTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/SpringBootMockMvcBuilderCustomizerTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.util.ArrayList; import java.util.Arrays; @@ -36,10 +36,10 @@ import jakarta.servlet.http.HttpServlet; import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.web.servlet.SpringBootMockMvcBuilderCustomizer.DeferredLinesWriter; -import org.springframework.boot.test.autoconfigure.web.servlet.SpringBootMockMvcBuilderCustomizer.LinesWriter; import org.springframework.boot.web.context.servlet.AnnotationConfigServletWebApplicationContext; import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.boot.webmvc.test.autoconfigure.SpringBootMockMvcBuilderCustomizer.DeferredLinesWriter; +import org.springframework.boot.webmvc.test.autoconfigure.SpringBootMockMvcBuilderCustomizer.LinesWriter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.mock.web.MockServletContext; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestAutoConfigurationIntegrationTests.java similarity index 54% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestAutoConfigurationIntegrationTests.java index 758e62c2aae..e02de975265 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestAutoConfigurationIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestAutoConfigurationIntegrationTests.java @@ -14,25 +14,19 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; -import org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration; -import org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration; -import org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration; -import org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfiguration; -import org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration; import org.springframework.boot.servlet.autoconfigure.HttpEncodingAutoConfiguration; -import org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; +import static org.springframework.boot.autoconfigure.AutoConfigurationImportedCondition.importedAutoConfiguration; /** * Tests for the auto-configuration imported by {@link WebMvcTest @WebMvcTest}. @@ -47,26 +41,6 @@ class WebMvcTestAutoConfigurationIntegrationTests { @Autowired private ApplicationContext applicationContext; - @Test - void freemarkerAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(FreeMarkerAutoConfiguration.class)); - } - - @Test - void groovyTemplatesAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(GroovyTemplateAutoConfiguration.class)); - } - - @Test - void mustacheAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(MustacheAutoConfiguration.class)); - } - - @Test - void thymeleafAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(ThymeleafAutoConfiguration.class)); - } - @Test void taskExecutionAutoConfigurationWasImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(TaskExecutionAutoConfiguration.class)); @@ -79,16 +53,6 @@ class WebMvcTestAutoConfigurationIntegrationTests { .isSameAs(this.applicationContext.getBean("applicationTaskExecutor")); } - @Test - void oAuth2ClientAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(OAuth2ClientAutoConfiguration.class)); - } - - @Test - void oAuth2ResourceServerAutoConfigurationWasImported() { - assertThat(this.applicationContext).has(importedAutoConfiguration(OAuth2ResourceServerAutoConfiguration.class)); - } - @Test void httpEncodingAutoConfigurationWasImported() { assertThat(this.applicationContext).has(importedAutoConfiguration(HttpEncodingAutoConfiguration.class)); diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestPropertiesIntegrationTests.java index 717725801ee..c3c573d0fca 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTestPropertiesIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTestPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilterTests.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilterTests.java index de1eabe0868..2f5d1d9f980 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilterTests.java @@ -14,12 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet; +package org.springframework.boot.webmvc.test.autoconfigure; import java.io.IOException; import org.junit.jupiter.api.Test; -import org.thymeleaf.dialect.IDialect; import tools.jackson.databind.module.SimpleModule; import org.springframework.boot.webmvc.autoconfigure.WebMvcRegistrations; @@ -29,7 +28,6 @@ import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.SimpleMetadataReaderFactory; import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter; -import org.springframework.security.web.SecurityFilterChain; import org.springframework.stereotype.Controller; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; @@ -60,10 +58,8 @@ class WebMvcTypeExcludeFilterTests { assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, SecurityFilterChain.class)).isFalse(); assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } @Test @@ -77,10 +73,8 @@ class WebMvcTypeExcludeFilterTests { assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, SecurityFilterChain.class)).isFalse(); assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } @Test @@ -94,10 +88,8 @@ class WebMvcTypeExcludeFilterTests { assertThat(excludes(filter, ExampleMessageConverter.class)).isTrue(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, SecurityFilterChain.class)).isTrue(); assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isTrue(); assertThat(excludes(filter, ExampleModule.class)).isTrue(); - assertThat(excludes(filter, ExampleDialect.class)).isTrue(); } @Test @@ -113,7 +105,6 @@ class WebMvcTypeExcludeFilterTests { assertThat(excludes(filter, ExampleRepository.class)).isFalse(); assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } @Test @@ -127,10 +118,8 @@ class WebMvcTypeExcludeFilterTests { assertThat(excludes(filter, ExampleMessageConverter.class)).isFalse(); assertThat(excludes(filter, ExampleService.class)).isTrue(); assertThat(excludes(filter, ExampleRepository.class)).isTrue(); - assertThat(excludes(filter, SecurityFilterChain.class)).isFalse(); assertThat(excludes(filter, ExampleHandlerInterceptor.class)).isFalse(); assertThat(excludes(filter, ExampleModule.class)).isFalse(); - assertThat(excludes(filter, ExampleDialect.class)).isFalse(); } private boolean excludes(WebMvcTypeExcludeFilter filter, Class type) throws IOException { @@ -209,13 +198,4 @@ class WebMvcTypeExcludeFilterTests { } - static class ExampleDialect implements IDialect { - - @Override - public String getName() { - return "example"; - } - - } - } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleArgument.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleArgument.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleArgument.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleArgument.java index 9a2b3e9b15b..5e5eb19eee0 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleArgument.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleArgument.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; /** * @author Phillip Webb diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController1.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController1.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController1.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController1.java index 154fce08979..941728ea019 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController1.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController1.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController2.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController2.java similarity index 77% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController2.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController2.java index 1c1f54a9b81..664778c813b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController2.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController2.java @@ -14,10 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.data.domain.Pageable; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -43,10 +42,4 @@ public class ExampleController2 { return id.getId() + "two"; } - @GetMapping("/paged") - @ResponseBody - public String paged(Pageable pageable) { - return String.format("%s:%s", pageable.getPageNumber(), pageable.getPageSize()); - } - } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController3.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController3.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController3.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController3.java index af3df5e47e0..b0b1f073535 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController3.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleController3.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import jakarta.validation.constraints.Size; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.stereotype.Controller; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleControllerAdvice.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleControllerAdvice.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleControllerAdvice.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleControllerAdvice.java index 27d6bd0f79a..00d7bd8021c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleControllerAdvice.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleControllerAdvice.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleException.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleException.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleException.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleException.java index 8d9be294b72..d83165de2e8 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleException.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleException.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; /** * Example exception used in {@link WebMvcTest @WebMvcTest} tests. diff --git a/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleFilter.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleFilter.java new file mode 100644 index 00000000000..5202ecb8509 --- /dev/null +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleFilter.java @@ -0,0 +1,61 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; + +import java.io.IOException; + +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; +import org.springframework.core.Ordered; +import org.springframework.stereotype.Component; + +/** + * Example filter used with {@link WebMvcTest @WebMvcTest} tests. + * + * @author Phillip Webb + */ +@Component +public class ExampleFilter implements Filter, Ordered { + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + chain.doFilter(request, response); + ((HttpServletResponse) response).addHeader("x-test", "abc"); + } + + @Override + public void destroy() { + } + + @Override + public int getOrder() { + return 0; + } + +} diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleId.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleId.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleId.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleId.java index 2f8552df925..9a1c4d9e33c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleId.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleId.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.util.UUID; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleIdConverter.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleIdConverter.java similarity index 87% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleIdConverter.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleIdConverter.java index 5389841c8cf..2ba49e36166 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleIdConverter.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleIdConverter.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.util.UUID; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleMockableService.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleMockableService.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleMockableService.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleMockableService.java index 6d8e493f9a8..09388759acf 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleMockableService.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleMockableService.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.stereotype.Service; /** diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleRealService.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleRealService.java similarity index 85% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleRealService.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleRealService.java index 02debeb5d86..e9e02b34858 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleRealService.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleRealService.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.stereotype.Service; /** diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleWebMvcConfigurer.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleWebMvcConfigurer.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleWebMvcConfigurer.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleWebMvcConfigurer.java index b74ffba68d9..64a0ff7c345 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleWebMvcConfigurer.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/ExampleWebMvcConfigurer.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.util.List; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.core.MethodParameter; import org.springframework.stereotype.Component; import org.springframework.web.bind.support.WebDataBinderFactory; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcSpringBootTestIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java similarity index 90% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcSpringBootTestIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java index 2c13d57c1d8..f2f69a2f63c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcSpringBootTestIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcSpringBootTestIntegrationTests.java @@ -14,19 +14,18 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.MockMvcPrint; import org.springframework.context.ApplicationContext; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.MockMvc; @@ -47,7 +46,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @SpringBootTest @AutoConfigureMockMvc(print = MockMvcPrint.SYSTEM_ERR, printOnlyOnFailure = false) -@WithMockUser(username = "user", password = "secret") @ExtendWith(OutputCaptureExtension.class) class MockMvcSpringBootTestIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java index 958fcd36249..f3016eb0371 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/MockMvcTesterSpringBootTestIntegrationTests.java @@ -14,19 +14,18 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.MockMvcPrint; import org.springframework.context.ApplicationContext; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.test.web.servlet.assertj.MockMvcTester; @@ -43,7 +42,6 @@ import static org.assertj.core.api.Assertions.assertThat; */ @SpringBootTest @AutoConfigureMockMvc(print = MockMvcPrint.SYSTEM_ERR, printOnlyOnFailure = false) -@WithMockUser(username = "user", password = "secret") @ExtendWith(OutputCaptureExtension.class) class MockMvcTesterSpringBootTestIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestAllControllersIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestAllControllersIntegrationTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestAllControllersIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestAllControllersIntegrationTests.java index 762bbd19c24..b21a4b01565 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestAllControllersIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestAllControllersIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.util.function.Consumer; @@ -23,9 +23,8 @@ import jakarta.validation.ConstraintViolationException; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.webmvc.error.ErrorAttributes; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import org.springframework.test.web.servlet.assertj.MvcTestResult; @@ -38,7 +37,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll */ @WebMvcTest -@WithMockUser class WebMvcTestAllControllersIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestConverterIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestConverterIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestConverterIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestConverterIntegrationTests.java index e194cdffd10..c3781bdfb04 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestConverterIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestConverterIntegrationTests.java @@ -14,15 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.util.UUID; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll */ @WebMvcTest(controllers = ExampleController2.class) -@WithMockUser class WebMvcTestConverterIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestCustomDispatcherServletIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestCustomDispatcherServletIntegrationTests.java similarity index 87% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestCustomDispatcherServletIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestCustomDispatcherServletIntegrationTests.java index f476f20e329..711ab7e7790 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestCustomDispatcherServletIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestCustomDispatcherServletIntegrationTests.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.HttpStatus; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.assertj.MockMvcTester; import org.springframework.web.servlet.DispatcherServlet; @@ -34,7 +33,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll */ @WebMvcTest -@WithMockUser @TestPropertySource(properties = { "spring.mvc.throw-exception-if-no-handler-found=true", "spring.mvc.static-path-pattern=/static/**" }) class WebMvcTestCustomDispatcherServletIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestMessageSourceIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestMessageSourceIntegrationTests.java similarity index 86% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestMessageSourceIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestMessageSourceIntegrationTests.java index 9007487f8d7..8e926cce958 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestMessageSourceIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestMessageSourceIntegrationTests.java @@ -14,17 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.util.Locale; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.ApplicationContext; import org.springframework.context.MessageSource; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.TestPropertySource; import static org.assertj.core.api.Assertions.assertThat; @@ -36,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Andy Wilkinson */ @WebMvcTest -@WithMockUser @TestPropertySource(properties = "spring.messages.basename=web-test-messages") class WebMvcTestMessageSourceIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestNestedIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestNestedIntegrationTests.java similarity index 87% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestNestedIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestNestedIntegrationTests.java index 0d17c3d5db5..3d401287378 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestNestedIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestNestedIntegrationTests.java @@ -14,15 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.HttpStatus; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; @@ -33,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Andy Wilkinson */ @WebMvcTest(controllers = ExampleController2.class) -@WithMockUser class WebMvcTestNestedIntegrationTests { @Autowired @@ -50,7 +48,6 @@ class WebMvcTestNestedIntegrationTests { } @Nested - @WithMockUser class NestedTests { @Test diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestOneControllerIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestOneControllerIntegrationTests.java similarity index 85% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestOneControllerIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestOneControllerIntegrationTests.java index 09818d47691..1e8106197d6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestOneControllerIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestOneControllerIntegrationTests.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.http.HttpStatus; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; @@ -32,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb */ @WebMvcTest(controllers = ExampleController2.class) -@WithMockUser class WebMvcTestOneControllerIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java similarity index 82% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java index a906e81227d..25faed0033b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java @@ -14,17 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; @@ -35,7 +34,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb */ @WebMvcTest -@WithMockUser @AutoConfigureMockMvc(printOnlyOnFailure = false) @ExtendWith(OutputCaptureExtension.class) class WebMvcTestPrintAlwaysIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java index a38155c8449..f0b577dd50b 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; @@ -27,11 +27,10 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; import org.junit.platform.launcher.core.LauncherFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; @@ -67,7 +66,6 @@ class WebMvcTestPrintDefaultIntegrationTests { } @WebMvcTest - @WithMockUser @AutoConfigureMockMvc static class ShouldNotPrint { @@ -82,7 +80,6 @@ class WebMvcTestPrintDefaultIntegrationTests { } @WebMvcTest - @WithMockUser @AutoConfigureMockMvc static class ShouldPrint { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java similarity index 87% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java index c75dbeb7144..0555f859024 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java @@ -14,16 +14,15 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.assertj.MockMvcTester; @@ -35,7 +34,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb */ @WebMvcTest -@WithMockUser @TestPropertySource(properties = "spring.test.mockmvc.print=NONE") @ExtendWith(OutputCaptureExtension.class) class WebMvcTestPrintDefaultOverrideIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java similarity index 79% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java index cfe786f9e86..ba9d3b73b15 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java @@ -14,18 +14,17 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.MockMvcPrint; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; @@ -36,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb */ @WebMvcTest -@WithMockUser @AutoConfigureMockMvc(print = MockMvcPrint.NONE) @ExtendWith(OutputCaptureExtension.class) class WebMvcTestPrintOverrideIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletContextResourceTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletContextResourceTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletContextResourceTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletContextResourceTests.java index 4c8e99ae428..b3948173ebb 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletContextResourceTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletContextResourceTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.net.MalformedURLException; import java.net.URL; @@ -23,7 +23,7 @@ import jakarta.servlet.ServletContext; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterIntegrationTests.java similarity index 88% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterIntegrationTests.java index bf11e065f97..a49c28e3e9c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterIntegrationTests.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterRegistrationDisabledIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterRegistrationDisabledIntegrationTests.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterRegistrationDisabledIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterRegistrationDisabledIntegrationTests.java index ca567b36ce7..3899b0c532a 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterRegistrationDisabledIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterRegistrationDisabledIntegrationTests.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.annotation.Bean; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterRegistrationIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterRegistrationIntegrationTests.java similarity index 91% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterRegistrationIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterRegistrationIntegrationTests.java index 6d437ac1c6f..3323502443f 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestServletFilterRegistrationIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestServletFilterRegistrationIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.io.IOException; import java.util.Collections; @@ -29,11 +29,10 @@ import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.security.autoconfigure.SecurityProperties; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.web.servlet.FilterRegistration; import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.Order; import org.springframework.test.web.servlet.assertj.MockMvcTester; @@ -80,7 +79,7 @@ class WebMvcTestServletFilterRegistrationIntegrationTests { @FilterRegistration(name = "annotation", urlPatterns = "/annotation", initParameters = { @WebInitParam(name = "param1", value = "value1"), @WebInitParam(name = "param2", value = "value2") }) - @Order(SecurityProperties.DEFAULT_FILTER_ORDER - 1) + @Order(0) TestFilter testFilterAnnotationBean() { return new TestFilter(); } @@ -91,7 +90,7 @@ class WebMvcTestServletFilterRegistrationIntegrationTests { registration.setName("registration"); registration.addUrlPatterns("/registration"); registration.setInitParameters(Map.of("param3", "value3", "param4", "value4")); - registration.setOrder(SecurityProperties.DEFAULT_FILTER_ORDER - 1); + registration.setOrder(0); return registration; } diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebClientIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebClientIntegrationTests.java similarity index 84% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebClientIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebClientIntegrationTests.java index 4d7b2590cb8..6fb61f120c7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebClientIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebClientIntegrationTests.java @@ -14,15 +14,14 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.htmlunit.WebClient; import org.htmlunit.html.HtmlPage; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import static org.assertj.core.api.Assertions.assertThat; @@ -32,7 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb */ @WebMvcTest -@WithMockUser class WebMvcTestWebClientIntegrationTests { @Autowired diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebDriverCustomScopeIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebDriverCustomScopeIntegrationTests.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebDriverCustomScopeIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebDriverCustomScopeIntegrationTests.java index 72fd5a0fa29..bf6edd058f6 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebDriverCustomScopeIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebDriverCustomScopeIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; @@ -25,7 +25,7 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebDriverIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebDriverIntegrationTests.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebDriverIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebDriverIntegrationTests.java index 8918bdd793d..e355e703e75 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWebDriverIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWebDriverIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Test; @@ -25,8 +25,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -37,7 +36,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Phillip Webb */ @WebMvcTest -@WithMockUser @TestMethodOrder(MethodOrderer.MethodName.class) class WebMvcTestWebDriverIntegrationTests { diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java similarity index 89% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java index e70501c9ebe..a8b45255e6a 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWithAutoConfigureMockMvcIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import org.htmlunit.WebClient; import org.junit.jupiter.api.Test; @@ -22,8 +22,8 @@ import org.openqa.selenium.WebDriver; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.ApplicationContext; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWithWebAppConfigurationTests.java b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWithWebAppConfigurationTests.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWithWebAppConfigurationTests.java rename to module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWithWebAppConfigurationTests.java index e7aa1140777..7aecf00810e 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestWithWebAppConfigurationTests.java +++ b/module/spring-boot-webmvc-test/src/test/java/org/springframework/boot/webmvc/test/autoconfigure/mockmvc/WebMvcTestWithWebAppConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.web.servlet.mockmvc; +package org.springframework.boot.webmvc.test.autoconfigure.mockmvc; import java.net.MalformedURLException; import java.net.URL; @@ -23,7 +23,7 @@ import jakarta.servlet.ServletContext; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.context.web.WebAppConfiguration; import static org.assertj.core.api.Assertions.assertThat; diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/META-INF/resources/inmetainfresources b/module/spring-boot-webmvc-test/src/test/resources/META-INF/resources/inmetainfresources similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/META-INF/resources/inmetainfresources rename to module/spring-boot-webmvc-test/src/test/resources/META-INF/resources/inmetainfresources diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/public/inpublic b/module/spring-boot-webmvc-test/src/test/resources/public/inpublic similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/public/inpublic rename to module/spring-boot-webmvc-test/src/test/resources/public/inpublic diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/resources/inresources b/module/spring-boot-webmvc-test/src/test/resources/resources/inresources similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/resources/inresources rename to module/spring-boot-webmvc-test/src/test/resources/resources/inresources diff --git a/module/spring-boot-test-autoconfigure/src/test/resources/static/instatic b/module/spring-boot-webmvc-test/src/test/resources/static/instatic similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/resources/static/instatic rename to module/spring-boot-webmvc-test/src/test/resources/static/instatic diff --git a/module/spring-boot-webmvc-test/src/test/resources/web-test-messages.properties b/module/spring-boot-webmvc-test/src/test/resources/web-test-messages.properties new file mode 100644 index 00000000000..2291e29f1fe --- /dev/null +++ b/module/spring-boot-webmvc-test/src/test/resources/web-test-messages.properties @@ -0,0 +1 @@ +a=alpha diff --git a/module/spring-boot-test-autoconfigure/src/test/webapp/inwebapp b/module/spring-boot-webmvc-test/src/test/webapp/inwebapp similarity index 100% rename from module/spring-boot-test-autoconfigure/src/test/webapp/inwebapp rename to module/spring-boot-webmvc-test/src/test/webapp/inwebapp diff --git a/module/spring-boot-webmvc/build.gradle b/module/spring-boot-webmvc/build.gradle index 3510f57f7f9..2229cc98efb 100644 --- a/module/spring-boot-webmvc/build.gradle +++ b/module/spring-boot-webmvc/build.gradle @@ -51,7 +51,6 @@ dependencies { testFixturesImplementation(project(":module:spring-boot-tomcat")) testImplementation(project(":core:spring-boot-test")) - testImplementation(project(":module:spring-boot-freemarker")) testImplementation(project(":module:spring-boot-jackson")) testImplementation(project(":module:spring-boot-restclient")) testImplementation(project(":module:spring-boot-tomcat")) diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java index 48ab4582b46..81ce84f26d2 100755 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java @@ -39,9 +39,7 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.testsupport.classpath.resources.WithResource; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.error.ErrorAttributeOptions.Include; @@ -326,18 +324,6 @@ class BasicErrorControllerIntegrationTests { assertThat(entity.getBody()).doesNotContainKey("errors"); } - @Test - @WithResource(name = "templates/error/507.ftlh", content = "We are out of storage") - void testConventionTemplateMapping() { - load(); - RequestEntity request = RequestEntity.get(URI.create(createUrl("/noStorage"))) - .accept(MediaType.TEXT_HTML) - .build(); - ResponseEntity entity = new TestRestTemplate().exchange(request, String.class); - String resp = entity.getBody(); - assertThat(resp).contains("We are out of storage"); - } - @Test void testIncompatibleMediaType() { load(); @@ -406,7 +392,7 @@ class BasicErrorControllerIntegrationTests { @Configuration(proxyBeanMethods = false) @MinimalWebConfiguration - @ImportAutoConfiguration(FreeMarkerAutoConfiguration.class) + // @ImportAutoConfiguration(FreeMarkerAutoConfiguration.class) public static class TestConfiguration { // For manual testing @@ -473,11 +459,6 @@ class BasicErrorControllerIntegrationTests { return body.content; } - @RequestMapping(path = "/noStorage") - String noStorage() { - throw new InsufficientStorageException(); - } - @RequestMapping(path = "/incompatibleType", produces = "text/plain") String incompatibleType() { throw new ExpectedException(); @@ -489,11 +470,6 @@ class BasicErrorControllerIntegrationTests { } - @ResponseStatus(HttpStatus.INSUFFICIENT_STORAGE) - static class InsufficientStorageException extends RuntimeException { - - } - @ResponseStatus(HttpStatus.NOT_ACCEPTABLE) @SuppressWarnings("serial") static class NoReasonExpectedException extends RuntimeException { diff --git a/module/spring-boot-webservices-test/build.gradle b/module/spring-boot-webservices-test/build.gradle new file mode 100644 index 00000000000..b2343ca57e5 --- /dev/null +++ b/module/spring-boot-webservices-test/build.gradle @@ -0,0 +1,40 @@ +/* + * Copyright 2012-present 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id "java-library" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" + id "org.springframework.boot.test-slice" +} + +description = "Spring Boot Web Services Test" + +dependencies { + api(project(":module:spring-boot-webservices")) + api("org.springframework.ws:spring-ws-test") + + implementation(project(":core:spring-boot-test")) + + optional(project(":module:spring-boot-test-autoconfigure")) + optional("org.junit.jupiter:junit-jupiter-api") + + testImplementation(project(":test-support:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("jakarta.servlet:jakarta.servlet-api") +} diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureMockWebServiceServer.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureMockWebServiceServer.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java index 2dbf4e79c6e..938b7007449 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureMockWebServiceServer.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureWebServiceClient.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureWebServiceClient.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java index 4b17388edc3..ea40958cb31 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureWebServiceClient.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerAutoConfiguration.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerAutoConfiguration.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerAutoConfiguration.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerAutoConfiguration.java index f4d546fdc71..a017980fdd4 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerAutoConfiguration.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerTestExecutionListener.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerTestExecutionListener.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerTestExecutionListener.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerTestExecutionListener.java index 39688fb95cb..0c6798173ac 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerTestExecutionListener.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerTestExecutionListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.context.ApplicationContext; import org.springframework.core.Ordered; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerWebServiceTemplateCustomizer.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerWebServiceTemplateCustomizer.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerWebServiceTemplateCustomizer.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerWebServiceTemplateCustomizer.java index 2981792b04b..64ad71e3486 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/MockWebServiceServerWebServiceTemplateCustomizer.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/MockWebServiceServerWebServiceTemplateCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/TestMockWebServiceServer.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/TestMockWebServiceServer.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/TestMockWebServiceServer.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/TestMockWebServiceServer.java index 9ac0cf1ab15..d6fb31fbee5 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/TestMockWebServiceServer.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/TestMockWebServiceServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.ws.test.client.MockWebServiceMessageSender; import org.springframework.ws.test.client.MockWebServiceServer; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientExcludeFilter.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientExcludeFilter.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientExcludeFilter.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientExcludeFilter.java index 78cd9bf5f29..52ba0bad3cc 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientExcludeFilter.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import java.util.Arrays; import java.util.LinkedHashSet; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTemplateAutoConfiguration.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTemplateAutoConfiguration.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTemplateAutoConfiguration.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTemplateAutoConfiguration.java index 48435013619..1048a99d08a 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTemplateAutoConfiguration.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTemplateAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTest.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTest.java index d392357a12c..43c4fe5fdca 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTest.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -28,7 +28,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; -import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; import org.springframework.boot.webservices.client.WebServiceTemplateBuilder; import org.springframework.context.annotation.ComponentScan; @@ -63,7 +62,6 @@ import org.springframework.ws.test.client.MockWebServiceServer; @ExtendWith(SpringExtension.class) @OverrideAutoConfiguration(enabled = false) @TypeExcludeFilters(WebServiceClientExcludeFilter.class) -@AutoConfigureCache @AutoConfigureMockWebServiceServer @AutoConfigureWebServiceClient @ImportAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTestContextBootstrapper.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTestContextBootstrapper.java index c5f9ca588e9..66e08b289c7 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientTestContextBootstrapper.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.TestContextBootstrapper; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/package-info.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/package-info.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/package-info.java index 15a0dedc9fa..b65a6a1f00f 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/client/package-info.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/client/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for web service clients. */ @NullMarked -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/AutoConfigureMockWebServiceClient.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/AutoConfigureMockWebServiceClient.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/AutoConfigureMockWebServiceClient.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/AutoConfigureMockWebServiceClient.java index 6793000d652..ee505c354ca 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/AutoConfigureMockWebServiceClient.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/AutoConfigureMockWebServiceClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/AutoConfigureWebServiceServer.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/AutoConfigureWebServiceServer.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/AutoConfigureWebServiceServer.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/AutoConfigureWebServiceServer.java index fe2f61ed3c3..2616fcdec19 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/AutoConfigureWebServiceServer.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/AutoConfigureWebServiceServer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/MockWebServiceClientAutoConfiguration.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/MockWebServiceClientAutoConfiguration.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/MockWebServiceClientAutoConfiguration.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/MockWebServiceClientAutoConfiguration.java index 2721eefe945..525209c2709 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/MockWebServiceClientAutoConfiguration.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/MockWebServiceClientAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTest.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTest.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTest.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTest.java index d0efe491710..0f25a6e871b 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTest.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTestContextBootstrapper.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTestContextBootstrapper.java index cea6fb3d9cc..57d253f9f81 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTestContextBootstrapper.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTestContextBootstrapper.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.springframework.boot.test.autoconfigure.TestSliceTestContextBootstrapper; import org.springframework.test.context.MergedContextConfiguration; diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTypeExcludeFilter.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTypeExcludeFilter.java similarity index 79% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTypeExcludeFilter.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTypeExcludeFilter.java index ccd05685bf7..ed6e257812e 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTypeExcludeFilter.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTypeExcludeFilter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import java.util.Arrays; import java.util.Collections; @@ -38,20 +38,20 @@ public class WebServiceServerTypeExcludeFilter private static final Class[] NO_ENDPOINTS = {}; - private static final Set> DEFAULT_INCLUDES; + private static final Set> KNOWN_INCLUDES; - private static final Set> DEFAULT_INCLUDES_AND_ENDPOINT; + private static final Set> KNOWN_INCLUDES_AND_ENDPOINT; static { Set> includes = new LinkedHashSet<>(); includes.add(EndpointInterceptor.class); - DEFAULT_INCLUDES = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES = Collections.unmodifiableSet(includes); } static { - Set> includes = new LinkedHashSet<>(DEFAULT_INCLUDES); + Set> includes = new LinkedHashSet<>(KNOWN_INCLUDES); includes.add(Endpoint.class); - DEFAULT_INCLUDES_AND_ENDPOINT = Collections.unmodifiableSet(includes); + KNOWN_INCLUDES_AND_ENDPOINT = Collections.unmodifiableSet(includes); } private final Class[] endpoints; @@ -62,11 +62,11 @@ public class WebServiceServerTypeExcludeFilter } @Override - protected Set> getDefaultIncludes() { + protected Set> getKnownIncludes() { if (ObjectUtils.isEmpty(this.endpoints)) { - return DEFAULT_INCLUDES_AND_ENDPOINT; + return KNOWN_INCLUDES_AND_ENDPOINT; } - return DEFAULT_INCLUDES; + return KNOWN_INCLUDES; } @Override diff --git a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/package-info.java b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/package-info.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/package-info.java rename to module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/package-info.java index f596133ff82..76739e1613f 100644 --- a/module/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/webservices/server/package-info.java +++ b/module/spring-boot-webservices-test/src/main/java/org/springframework/boot/webservices/test/autoconfigure/server/package-info.java @@ -18,6 +18,6 @@ * Auto-configuration for web service server tests. */ @NullMarked -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.jspecify.annotations.NullMarked; diff --git a/module/spring-boot-webservices-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-webservices-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000000..aedb6e4355d --- /dev/null +++ b/module/spring-boot-webservices-test/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,16 @@ +{ + "properties": [ + { + "name": "spring.test.webservice.client.mockserver.enabled", + "type": "java.lang.Boolean", + "description": "Whether a MockWebServiceServer should be auto-configured.", + "defaultValue": true + }, + { + "name": "spring.test.webservice.client.register-web-service-template", + "type": "java.lang.Boolean", + "description": "Whether a WebServiceTemplate bean should be registered.", + "defaultValue": false + } + ] +} diff --git a/module/spring-boot-webservices-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..bd3923eab56 --- /dev/null +++ b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Spring Test Execution Listeners +org.springframework.test.context.TestExecutionListener=\ +org.springframework.boot.webservices.test.autoconfigure.client.MockWebServiceServerTestExecutionListener diff --git a/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.client.AutoConfigureMockWebServiceServer.imports b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.client.AutoConfigureMockWebServiceServer.imports new file mode 100644 index 00000000000..1e3f2395a69 --- /dev/null +++ b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.client.AutoConfigureMockWebServiceServer.imports @@ -0,0 +1 @@ +org.springframework.boot.webservices.test.autoconfigure.client.MockWebServiceServerAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureWebServiceClient.imports b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.client.AutoConfigureWebServiceClient.imports similarity index 58% rename from module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureWebServiceClient.imports rename to module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.client.AutoConfigureWebServiceClient.imports index b3ca63de69a..16a2ee1d7b8 100644 --- a/module/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.webservices.client.AutoConfigureWebServiceClient.imports +++ b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.client.AutoConfigureWebServiceClient.imports @@ -1,3 +1,2 @@ -# AutoConfigureWebServiceClient -org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTemplateAutoConfiguration org.springframework.boot.webservices.autoconfigure.client.WebServiceTemplateAutoConfiguration +org.springframework.boot.webservices.test.autoconfigure.client.WebServiceClientTemplateAutoConfiguration diff --git a/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.server.AutoConfigureMockWebServiceClient.imports b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.server.AutoConfigureMockWebServiceClient.imports new file mode 100644 index 00000000000..13115e4d534 --- /dev/null +++ b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.server.AutoConfigureMockWebServiceClient.imports @@ -0,0 +1 @@ +org.springframework.boot.webservices.test.autoconfigure.server.MockWebServiceClientAutoConfiguration diff --git a/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.server.AutoConfigureWebServiceServer.imports b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.server.AutoConfigureWebServiceServer.imports new file mode 100644 index 00000000000..e0955200aa2 --- /dev/null +++ b/module/spring-boot-webservices-test/src/main/resources/META-INF/spring/org.springframework.boot.webservices.test.autoconfigure.server.AutoConfigureWebServiceServer.imports @@ -0,0 +1 @@ +org.springframework.boot.webservices.autoconfigure.WebServicesAutoConfiguration diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureMockWebServiceServerEnabledIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServerEnabledIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureMockWebServiceServerEnabledIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServerEnabledIntegrationTests.java index 2fa2a74516f..7dc39773f18 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureMockWebServiceServerEnabledIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureMockWebServiceServerEnabledIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests.java index a87df9a0758..20fbb8309d4 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/AutoConfigureWebServiceClientWebServiceTemplateIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/ExampleWebServiceClient.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/ExampleWebServiceClient.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/ExampleWebServiceClient.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/ExampleWebServiceClient.java index e38bbe9a43e..fabf38a5dad 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/ExampleWebServiceClient.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/ExampleWebServiceClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.boot.webservices.client.WebServiceTemplateBuilder; import org.springframework.stereotype.Service; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/ExampleWebServiceClientApplication.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/ExampleWebServiceClientApplication.java similarity index 94% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/ExampleWebServiceClientApplication.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/ExampleWebServiceClientApplication.java index 46cb5638b9f..54164430f02 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/ExampleWebServiceClientApplication.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/ExampleWebServiceClientApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/Request.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/Request.java similarity index 92% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/Request.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/Request.java index cb5514f1796..8e7cd4df3e5 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/Request.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/Request.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import jakarta.xml.bind.annotation.XmlRootElement; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/Response.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/Response.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/Response.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/Response.java index c4737d3d3d9..849cac25895 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/Response.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/Response.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientIntegrationTests.java index 749240535de..2f3220e3ce7 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientNoComponentIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientNoComponentIntegrationTests.java similarity index 97% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientNoComponentIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientNoComponentIntegrationTests.java index c82b5600393..bcaf9febb07 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientNoComponentIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientNoComponentIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientPropertiesIntegrationTests.java index d05664e1a34..f9b0021ca28 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceClientPropertiesIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceClientPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceMarshallerConfiguration.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceMarshallerConfiguration.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceMarshallerConfiguration.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceMarshallerConfiguration.java index 3dc46141f4f..8c8bca95e07 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/client/WebServiceMarshallerConfiguration.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/client/WebServiceMarshallerConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.client; +package org.springframework.boot.webservices.test.autoconfigure.client; import org.springframework.boot.webservices.client.WebServiceTemplateCustomizer; import org.springframework.context.annotation.Bean; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/ExampleWebServiceEndpoint.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/ExampleWebServiceEndpoint.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/ExampleWebServiceEndpoint.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/ExampleWebServiceEndpoint.java index 40030a7ac90..f3b475fff67 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/ExampleWebServiceEndpoint.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/ExampleWebServiceEndpoint.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.springframework.ws.server.endpoint.annotation.Endpoint; import org.springframework.ws.server.endpoint.annotation.PayloadRoot; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/ExampleWebServiceServerApplication.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/ExampleWebServiceServerApplication.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/ExampleWebServiceServerApplication.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/ExampleWebServiceServerApplication.java index bd7ef8b2645..949c177c4b9 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/ExampleWebServiceServerApplication.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/ExampleWebServiceServerApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/MockWebServiceClientAutoConfigurationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/MockWebServiceClientAutoConfigurationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/MockWebServiceClientAutoConfigurationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/MockWebServiceClientAutoConfigurationTests.java index 25c633f948a..b1c9949a5dc 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/MockWebServiceClientAutoConfigurationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/MockWebServiceClientAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/Request.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/Request.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/Request.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/Request.java index bfe878ec0dc..ae124e0ad7c 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/Request.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/Request.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/Response.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/Response.java similarity index 93% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/Response.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/Response.java index 17c71f7d0ae..e3bf0d37616 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/Response.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/Response.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerIntegrationTests.java similarity index 95% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerIntegrationTests.java index 6717456cdab..d4bcc1bcad9 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerPropertiesIntegrationTests.java similarity index 96% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerPropertiesIntegrationTests.java index b632211ee5f..78f89036442 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerPropertiesIntegrationTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerPropertiesIntegrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTypeExcludeFilterTests.java b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTypeExcludeFilterTests.java similarity index 98% rename from module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTypeExcludeFilterTests.java rename to module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTypeExcludeFilterTests.java index 162fbc80bc7..207e1d22717 100644 --- a/module/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/webservices/server/WebServiceServerTypeExcludeFilterTests.java +++ b/module/spring-boot-webservices-test/src/test/java/org/springframework/boot/webservices/test/autoconfigure/server/WebServiceServerTypeExcludeFilterTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.test.autoconfigure.webservices.server; +package org.springframework.boot.webservices.test.autoconfigure.server; import java.io.IOException; diff --git a/settings.gradle b/settings.gradle index 767a0ca918c..fee4ee2111e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -86,20 +86,31 @@ include "module:spring-boot-autoconfigure-classic" include "module:spring-boot-autoconfigure-classic-modules" include "module:spring-boot-batch" include "module:spring-boot-cache" +include "module:spring-boot-cache-test" include "module:spring-boot-cassandra" include "module:spring-boot-cloudfoundry" include "module:spring-boot-couchbase" include "module:spring-boot-data-cassandra" +include "module:spring-boot-data-cassandra-test" include "module:spring-boot-data-commons" include "module:spring-boot-data-couchbase" +include "module:spring-boot-data-couchbase-test" include "module:spring-boot-data-elasticsearch" +include "module:spring-boot-data-elasticsearch-test" include "module:spring-boot-data-jdbc" +include "module:spring-boot-data-jdbc-test" include "module:spring-boot-data-jpa" +include "module:spring-boot-data-jpa-test" include "module:spring-boot-data-ldap" +include "module:spring-boot-data-ldap-test" include "module:spring-boot-data-mongodb" +include "module:spring-boot-data-mongodb-test" include "module:spring-boot-data-neo4j" +include "module:spring-boot-data-neo4j-test" include "module:spring-boot-data-r2dbc" +include "module:spring-boot-data-r2dbc-test" include "module:spring-boot-data-redis" +include "module:spring-boot-data-redis-test" include "module:spring-boot-data-rest" include "module:spring-boot-devtools" include "module:spring-boot-elasticsearch" @@ -120,10 +131,14 @@ include "module:spring-boot-http-converter" include "module:spring-boot-integration" include "module:spring-boot-jackson" include "module:spring-boot-jdbc" +include "module:spring-boot-jdbc-test" include "module:spring-boot-jetty" include "module:spring-boot-jms" include "module:spring-boot-jooq" +include "module:spring-boot-jooq-test" include "module:spring-boot-jpa" +include "module:spring-boot-jpa-test" +include "module:spring-boot-json-test" include "module:spring-boot-jsonb" include "module:spring-boot-kafka" include "module:spring-boot-kotlin-serialization" @@ -131,8 +146,10 @@ include "module:spring-boot-ldap" include "module:spring-boot-liquibase" include "module:spring-boot-mail" include "module:spring-boot-micrometer-metrics" +include "module:spring-boot-micrometer-metrics-test" include "module:spring-boot-micrometer-observation" include "module:spring-boot-micrometer-tracing" +include "module:spring-boot-micrometer-tracing-test" include "module:spring-boot-mongodb" include "module:spring-boot-mustache" include "module:spring-boot-neo4j" @@ -146,8 +163,10 @@ include "module:spring-boot-reactor" include "module:spring-boot-reactor-netty" include "module:spring-boot-restclient" include "module:spring-boot-restclient-test" +include "module:spring-boot-restdocs" include "module:spring-boot-rsocket" include "module:spring-boot-security" +include "module:spring-boot-security-test" include "module:spring-boot-security-oauth2-authorization-server" include "module:spring-boot-security-oauth2-client" include "module:spring-boot-security-oauth2-resource-server" @@ -169,8 +188,11 @@ include "module:spring-boot-web-server" // FIXME move to core? include "module:spring-boot-web-server-test" // FIXME move to core? include "module:spring-boot-webclient" include "module:spring-boot-webflux" +include "module:spring-boot-webflux-test" include "module:spring-boot-webmvc" +include "module:spring-boot-webmvc-test" include "module:spring-boot-webservices" +include "module:spring-boot-webservices-test" include "module:spring-boot-websocket" include "module:spring-boot-zipkin" diff --git a/smoke-test/spring-boot-smoke-test-actuator-log4j2/build.gradle b/smoke-test/spring-boot-smoke-test-actuator-log4j2/build.gradle index 693ce28322f..31490f9aecb 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-log4j2/build.gradle +++ b/smoke-test/spring-boot-smoke-test-actuator-log4j2/build.gradle @@ -30,5 +30,6 @@ dependencies { implementation(project(":starter:spring-boot-starter-security")) implementation(project(":starter:spring-boot-starter-webmvc")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } \ No newline at end of file diff --git a/smoke-test/spring-boot-smoke-test-actuator-log4j2/src/test/java/smoketest/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-log4j2/src/test/java/smoketest/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java index 1fcb67dbf73..0bc67d0dae2 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-log4j2/src/test/java/smoketest/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-log4j2/src/test/java/smoketest/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java @@ -24,10 +24,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-data-cassandra/build.gradle b/smoke-test/spring-boot-smoke-test-data-cassandra/build.gradle index 9180d16a12f..4a0a1384d34 100644 --- a/smoke-test/spring-boot-smoke-test-data-cassandra/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-cassandra/build.gradle @@ -26,9 +26,10 @@ dependencies { implementation(project(":starter:spring-boot-starter-data-cassandra-reactive")) dockerTestImplementation(project(":core:spring-boot-test")) + dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-cassandra-test")) dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) - dockerTestImplementation(project(":core:spring-boot-testcontainers")) dockerTestImplementation("org.junit.jupiter:junit-jupiter") dockerTestImplementation("org.junit.platform:junit-platform-engine") dockerTestImplementation("org.junit.platform:junit-platform-launcher") diff --git a/smoke-test/spring-boot-smoke-test-data-cassandra/src/dockerTest/java/smoketest/data/cassandra/SampleCassandraApplicationSslTests.java b/smoke-test/spring-boot-smoke-test-data-cassandra/src/dockerTest/java/smoketest/data/cassandra/SampleCassandraApplicationSslTests.java index dbae6930620..3f1e87f0233 100644 --- a/smoke-test/spring-boot-smoke-test-data-cassandra/src/dockerTest/java/smoketest/data/cassandra/SampleCassandraApplicationSslTests.java +++ b/smoke-test/spring-boot-smoke-test-data-cassandra/src/dockerTest/java/smoketest/data/cassandra/SampleCassandraApplicationSslTests.java @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest; +import org.springframework.boot.data.cassandra.test.autoconfigure.DataCassandraTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.testcontainers.service.connection.JksKeyStore; import org.springframework.boot.testcontainers.service.connection.JksTrustStore; diff --git a/smoke-test/spring-boot-smoke-test-data-couchbase/build.gradle b/smoke-test/spring-boot-smoke-test-data-couchbase/build.gradle index 10a6d53d4b1..9f52e47ef24 100644 --- a/smoke-test/spring-boot-smoke-test-data-couchbase/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-couchbase/build.gradle @@ -25,10 +25,11 @@ dependencies { implementation(project(":starter:spring-boot-starter-data-couchbase")) implementation(project(":starter:spring-boot-starter-data-couchbase-reactive")) - dockerTestImplementation(project(":module:spring-boot-reactor")) - dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":core:spring-boot-test")) dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-reactor")) + dockerTestImplementation(project(":module:spring-boot-data-couchbase-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation("io.projectreactor:reactor-test") dockerTestImplementation("org.apache.httpcomponents.client5:httpclient5") diff --git a/smoke-test/spring-boot-smoke-test-data-couchbase/src/dockerTest/java/smoketest/data/couchbase/SampleCouchbaseApplicationSslTests.java b/smoke-test/spring-boot-smoke-test-data-couchbase/src/dockerTest/java/smoketest/data/couchbase/SampleCouchbaseApplicationSslTests.java index 5aafca137bb..d8c238a21bb 100644 --- a/smoke-test/spring-boot-smoke-test-data-couchbase/src/dockerTest/java/smoketest/data/couchbase/SampleCouchbaseApplicationSslTests.java +++ b/smoke-test/spring-boot-smoke-test-data-couchbase/src/dockerTest/java/smoketest/data/couchbase/SampleCouchbaseApplicationSslTests.java @@ -23,7 +23,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest; +import org.springframework.boot.data.couchbase.test.autoconfigure.DataCouchbaseTest; import org.springframework.boot.testcontainers.service.connection.PemKeyStore; import org.springframework.boot.testcontainers.service.connection.PemTrustStore; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/smoke-test/spring-boot-smoke-test-data-elasticsearch/build.gradle b/smoke-test/spring-boot-smoke-test-data-elasticsearch/build.gradle index 10ddc6a5fe1..20fb01bf04d 100644 --- a/smoke-test/spring-boot-smoke-test-data-elasticsearch/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-elasticsearch/build.gradle @@ -25,10 +25,11 @@ description = "Spring Boot Data Elasticsearch smoke test" dependencies { implementation(project(":starter:spring-boot-starter-data-elasticsearch")) - dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":core:spring-boot-test")) - dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-elasticsearch-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-test")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation("org.junit.jupiter:junit-jupiter") dockerTestImplementation("org.junit.platform:junit-platform-engine") dockerTestImplementation("org.junit.platform:junit-platform-launcher") diff --git a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch8ApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch8ApplicationTests.java index f0cc7cf512d..3d2e85b69bd 100644 --- a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch8ApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch8ApplicationTests.java @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testcontainers.service.connection.Ssl; import org.springframework.boot.testsupport.container.TestImage; diff --git a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch9ApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch9ApplicationTests.java index 89a1b895539..31050d83854 100644 --- a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch9ApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearch9ApplicationTests.java @@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testcontainers.service.connection.Ssl; import org.springframework.boot.testsupport.container.TestImage; diff --git a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchApplicationTests.java index e44e8fea8cc..2348aa16de0 100644 --- a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchApplicationTests.java @@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; diff --git a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchSslApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchSslApplicationTests.java index 6483e276c2a..bcee9c3fb46 100644 --- a/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchSslApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-elasticsearch/src/dockerTest/java/smoketest/data/elasticsearch/SampleElasticsearchSslApplicationTests.java @@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.boot.data.elasticsearch.test.autoconfigure.DataElasticsearchTest; import org.springframework.boot.testcontainers.service.connection.PemTrustStore; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; diff --git a/smoke-test/spring-boot-smoke-test-data-jdbc/build.gradle b/smoke-test/spring-boot-smoke-test-data-jdbc/build.gradle index 0a9b52e031e..52f39c28a20 100644 --- a/smoke-test/spring-boot-smoke-test-data-jdbc/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-jdbc/build.gradle @@ -26,5 +26,7 @@ dependencies { runtimeOnly("com.h2database:h2") + testImplementation(project(":module:spring-boot-data-jdbc-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/CustomerRepositoryIntegrationTests.java b/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/CustomerRepositoryIntegrationTests.java index f09622cb04b..3cb456e840a 100644 --- a/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/CustomerRepositoryIntegrationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/CustomerRepositoryIntegrationTests.java @@ -19,7 +19,7 @@ package smoketest.data.jdbc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/SampleDataJdbcApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/SampleDataJdbcApplicationTests.java index 4bedf6c5961..776393b43e6 100644 --- a/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/SampleDataJdbcApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-jdbc/src/test/java/smoketest/data/jdbc/SampleDataJdbcApplicationTests.java @@ -19,8 +19,8 @@ package smoketest.data.jdbc; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-data-jpa/build.gradle b/smoke-test/spring-boot-smoke-test-data-jpa/build.gradle index 720b6d5291f..f4f9de48d1c 100644 --- a/smoke-test/spring-boot-smoke-test-data-jpa/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-jpa/build.gradle @@ -27,5 +27,8 @@ dependencies { runtimeOnly("com.h2database:h2") + + testImplementation(project(":module:spring-boot-data-jpa-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SampleDataJpaApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SampleDataJpaApplicationTests.java index 412f134dc18..b91b8882ddf 100644 --- a/smoke-test/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SampleDataJpaApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-jpa/src/test/java/smoketest/data/jpa/SampleDataJpaApplicationTests.java @@ -23,8 +23,8 @@ import javax.management.ObjectName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/smoke-test/spring-boot-smoke-test-data-mongo/build.gradle b/smoke-test/spring-boot-smoke-test-data-mongo/build.gradle index 9ffa435aca5..88f27f6488d 100644 --- a/smoke-test/spring-boot-smoke-test-data-mongo/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-mongo/build.gradle @@ -25,10 +25,11 @@ dependencies { implementation(project(":starter:spring-boot-starter-data-mongodb")) implementation(project(":starter:spring-boot-starter-data-mongodb-reactive")) - dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":core:spring-boot-test")) - dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-mongodb-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-test")) + dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation("io.projectreactor:reactor-test") dockerTestImplementation("org.junit.jupiter:junit-jupiter") dockerTestImplementation("org.junit.platform:junit-platform-engine") diff --git a/smoke-test/spring-boot-smoke-test-data-mongo/src/dockerTest/java/smoketest/data/mongo/SampleMongoApplicationSslTests.java b/smoke-test/spring-boot-smoke-test-data-mongo/src/dockerTest/java/smoketest/data/mongo/SampleMongoApplicationSslTests.java index c47c1fb348d..802d9758cde 100644 --- a/smoke-test/spring-boot-smoke-test-data-mongo/src/dockerTest/java/smoketest/data/mongo/SampleMongoApplicationSslTests.java +++ b/smoke-test/spring-boot-smoke-test-data-mongo/src/dockerTest/java/smoketest/data/mongo/SampleMongoApplicationSslTests.java @@ -22,7 +22,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; +import org.springframework.boot.data.mongodb.test.autoconfigure.DataMongoTest; import org.springframework.boot.testcontainers.service.connection.PemKeyStore; import org.springframework.boot.testcontainers.service.connection.PemTrustStore; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle b/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle index 20bc0f3371f..0bc7f5fdeba 100644 --- a/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle @@ -30,8 +30,10 @@ dependencies { runtimeOnly("org.postgresql:r2dbc-postgresql") runtimeOnly("org.springframework:spring-jdbc") - dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-r2dbc-test")) + dockerTestImplementation(project(":module:spring-boot-jdbc-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation("io.projectreactor:reactor-test") dockerTestImplementation("org.testcontainers:junit-jupiter") diff --git a/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java b/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java index a2d8dedfa18..662425a3f53 100644 --- a/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java +++ b/smoke-test/spring-boot-smoke-test-data-r2dbc-flyway/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; import reactor.test.StepVerifier; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest; +import org.springframework.boot.data.r2dbc.test.autoconfigure.DataR2dbcTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; diff --git a/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle b/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle index 036e0cb4e9f..2cbb22ae026 100644 --- a/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle @@ -28,8 +28,10 @@ dependencies { runtimeOnly("org.postgresql:postgresql") runtimeOnly("org.postgresql:r2dbc-postgresql") - dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-r2dbc-test")) + dockerTestImplementation(project(":module:spring-boot-jdbc-test")) + dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation("io.projectreactor:reactor-test") dockerTestImplementation("org.testcontainers:junit-jupiter") diff --git a/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java b/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java index ec1347077dd..68a3866cd06 100644 --- a/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java +++ b/smoke-test/spring-boot-smoke-test-data-r2dbc-liquibase/src/dockerTest/java/smoketest/data/r2dbc/CityRepositoryTests.java @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; import reactor.test.StepVerifier; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.r2dbc.DataR2dbcTest; +import org.springframework.boot.data.r2dbc.test.autoconfigure.DataR2dbcTest; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.boot.testsupport.container.TestImage; diff --git a/smoke-test/spring-boot-smoke-test-data-redis/build.gradle b/smoke-test/spring-boot-smoke-test-data-redis/build.gradle index 6da130e54cf..04a293fc002 100644 --- a/smoke-test/spring-boot-smoke-test-data-redis/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-redis/build.gradle @@ -24,10 +24,11 @@ description = "Spring Boot Data Redis smoke test" dependencies { implementation(project(":starter:spring-boot-starter-data-redis")) - dockerTestImplementation(project(":module:spring-boot-reactor")) - dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":core:spring-boot-test")) dockerTestImplementation(project(":core:spring-boot-testcontainers")) + dockerTestImplementation(project(":module:spring-boot-data-redis-test")) + dockerTestImplementation(project(":module:spring-boot-reactor")) + dockerTestImplementation(project(":starter:spring-boot-starter-test")) dockerTestImplementation(project(":test-support:spring-boot-docker-test-support")) dockerTestImplementation("com.redis:testcontainers-redis") dockerTestImplementation("io.projectreactor:reactor-test") diff --git a/smoke-test/spring-boot-smoke-test-data-redis/src/dockerTest/java/smoketest/data/redis/SampleRedisApplicationJedisSslTests.java b/smoke-test/spring-boot-smoke-test-data-redis/src/dockerTest/java/smoketest/data/redis/SampleRedisApplicationJedisSslTests.java index 3c60bfe1acf..efbd40e2fa4 100644 --- a/smoke-test/spring-boot-smoke-test-data-redis/src/dockerTest/java/smoketest/data/redis/SampleRedisApplicationJedisSslTests.java +++ b/smoke-test/spring-boot-smoke-test-data-redis/src/dockerTest/java/smoketest/data/redis/SampleRedisApplicationJedisSslTests.java @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; +import org.springframework.boot.data.redis.test.autoconfigure.DataRedisTest; import org.springframework.boot.testcontainers.service.connection.PemKeyStore; import org.springframework.boot.testcontainers.service.connection.PemTrustStore; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/smoke-test/spring-boot-smoke-test-data-rest/build.gradle b/smoke-test/spring-boot-smoke-test-data-rest/build.gradle index 05894b2276f..f88a0f99e87 100644 --- a/smoke-test/spring-boot-smoke-test-data-rest/build.gradle +++ b/smoke-test/spring-boot-smoke-test-data-rest/build.gradle @@ -29,6 +29,7 @@ dependencies { runtimeOnly(project(":starter:spring-boot-starter-jetty")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) testRuntimeOnly("com.jayway.jsonpath:json-path") diff --git a/smoke-test/spring-boot-smoke-test-data-rest/src/test/java/smoketest/data/rest/SampleDataRestApplicationTests.java b/smoke-test/spring-boot-smoke-test-data-rest/src/test/java/smoketest/data/rest/SampleDataRestApplicationTests.java index f43acd93e02..1ad0f888fca 100644 --- a/smoke-test/spring-boot-smoke-test-data-rest/src/test/java/smoketest/data/rest/SampleDataRestApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-data-rest/src/test/java/smoketest/data/rest/SampleDataRestApplicationTests.java @@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test; import smoketest.data.rest.domain.City; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-graphql/build.gradle b/smoke-test/spring-boot-smoke-test-graphql/build.gradle index 3abeb6cd928..d17deb96d55 100644 --- a/smoke-test/spring-boot-smoke-test-graphql/build.gradle +++ b/smoke-test/spring-boot-smoke-test-graphql/build.gradle @@ -25,7 +25,9 @@ dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) implementation(project(":starter:spring-boot-starter-security")) + testImplementation(project(":module:spring-boot-graphql-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) - testImplementation(project(":starter:spring-boot-starter-webflux")) - testImplementation('org.springframework.graphql:spring-graphql-test') + + testRuntimeOnly("org.springframework:spring-webflux") } diff --git a/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/GreetingControllerTests.java b/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/GreetingControllerTests.java index 452e377268a..aae016e40a7 100644 --- a/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/GreetingControllerTests.java +++ b/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/GreetingControllerTests.java @@ -19,14 +19,14 @@ package smoketest.graphql; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.graphql.tester.AutoConfigureHttpGraphQlTester; +import org.springframework.boot.graphql.test.autoconfigure.tester.AutoConfigureHttpGraphQlTester; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.graphql.execution.ErrorType; import org.springframework.graphql.test.tester.HttpGraphQlTester; import static org.assertj.core.api.Assertions.assertThat; -@SpringBootTest +@SpringBootTest(properties = "debug=true") @AutoConfigureHttpGraphQlTester class GreetingControllerTests { diff --git a/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/ProjectControllerTests.java b/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/ProjectControllerTests.java index 99d11b78998..dc7a1cc1e7e 100644 --- a/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/ProjectControllerTests.java +++ b/smoke-test/spring-boot-smoke-test-graphql/src/test/java/smoketest/graphql/ProjectControllerTests.java @@ -19,7 +19,7 @@ package smoketest.graphql; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest; +import org.springframework.boot.graphql.test.autoconfigure.GraphQlTest; import org.springframework.graphql.test.tester.GraphQlTester; @GraphQlTest(ProjectController.class) diff --git a/smoke-test/spring-boot-smoke-test-hibernate/build.gradle b/smoke-test/spring-boot-smoke-test-hibernate/build.gradle index 4df1fdf9afb..f74044f0bcc 100644 --- a/smoke-test/spring-boot-smoke-test-hibernate/build.gradle +++ b/smoke-test/spring-boot-smoke-test-hibernate/build.gradle @@ -31,5 +31,6 @@ dependencies { runtimeOnly("com.h2database:h2") runtimeOnly("jakarta.transaction:jakarta.transaction-api") + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-hibernate/src/test/java/smoketest/jpa/SampleJpaApplicationTests.java b/smoke-test/spring-boot-smoke-test-hibernate/src/test/java/smoketest/jpa/SampleJpaApplicationTests.java index 0bf8a02bbfb..3ca83a23671 100644 --- a/smoke-test/spring-boot-smoke-test-hibernate/src/test/java/smoketest/jpa/SampleJpaApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-hibernate/src/test/java/smoketest/jpa/SampleJpaApplicationTests.java @@ -19,8 +19,8 @@ package smoketest.jpa; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.test.web.servlet.assertj.MockMvcTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-prometheus/build.gradle b/smoke-test/spring-boot-smoke-test-prometheus/build.gradle index 89b1655509d..5c2d9638c24 100644 --- a/smoke-test/spring-boot-smoke-test-prometheus/build.gradle +++ b/smoke-test/spring-boot-smoke-test-prometheus/build.gradle @@ -27,6 +27,7 @@ dependencies { runtimeOnly('io.micrometer:micrometer-registry-prometheus') + testImplementation(project(":module:spring-boot-micrometer-metrics-test")) testImplementation(project(":starter:spring-boot-starter-restclient")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java b/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java index 23846c9cc14..d171f10c087 100644 --- a/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-prometheus/src/test/java/smoketest/prometheus/SamplePrometheusApplicationTests.java @@ -19,7 +19,7 @@ package smoketest.prometheus; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; +import org.springframework.boot.micrometer.metrics.test.autoconfigure.AutoConfigureMetrics; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.test.client.TestRestTemplate; @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Moritz Halbritter */ @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@AutoConfigureObservability +@AutoConfigureMetrics class SamplePrometheusApplicationTests { @Autowired diff --git a/smoke-test/spring-boot-smoke-test-test/build.gradle b/smoke-test/spring-boot-smoke-test-test/build.gradle index db9b9dc6526..eb7f6a7c757 100644 --- a/smoke-test/spring-boot-smoke-test-test/build.gradle +++ b/smoke-test/spring-boot-smoke-test-test/build.gradle @@ -28,6 +28,11 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":starter:spring-boot-starter-test")) + testImplementation(project(":module:spring-boot-data-jpa-test")) + testImplementation(project(":module:spring-boot-jdbc-test")) + testImplementation(project(":module:spring-boot-json-test")) + testImplementation(project(":module:spring-boot-restclient-test")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation("org.htmlunit:htmlunit") testImplementation("org.mockito:mockito-junit-jupiter") testImplementation("org.seleniumhq.selenium:selenium-api") diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java index 3a128a168f5..edb62b2df74 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/SampleTestApplicationWebIntegrationTests.java @@ -23,7 +23,7 @@ import smoketest.test.service.VehicleDetails; import smoketest.test.service.VehicleDetailsService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.test.client.TestRestTemplate; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserEntityTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserEntityTests.java index bcd09d2580b..6fc9fcd551d 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserEntityTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserEntityTests.java @@ -19,8 +19,8 @@ package smoketest.test.domain; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserRepositoryTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserRepositoryTests.java index 1f6e7c8ddea..ef7acc77852 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserRepositoryTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/domain/UserRepositoryTests.java @@ -19,8 +19,8 @@ package smoketest.test.domain; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; +import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest; +import org.springframework.boot.jpa.test.autoconfigure.TestEntityManager; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/RemoteVehicleDetailsServiceTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/RemoteVehicleDetailsServiceTests.java index c2b99d41f96..7fbc9f190bf 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/RemoteVehicleDetailsServiceTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/RemoteVehicleDetailsServiceTests.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import smoketest.test.domain.VehicleIdentificationNumber; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.client.RestClientTest; +import org.springframework.boot.restclient.test.autoconfigure.RestClientTest; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/VehicleDetailsJsonTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/VehicleDetailsJsonTests.java index b9439620b51..a166e48ad21 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/VehicleDetailsJsonTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/service/VehicleDetailsJsonTests.java @@ -19,7 +19,7 @@ package smoketest.test.service; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.json.JsonTest; +import org.springframework.boot.json.test.autoconfigure.JsonTest; import org.springframework.boot.test.json.JacksonTester; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerApplicationTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerApplicationTests.java index f0e6e4643dd..07c77879e11 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerApplicationTests.java @@ -21,9 +21,9 @@ import smoketest.test.WelcomeCommandLineRunner; import smoketest.test.service.VehicleDetails; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.context.ApplicationContext; import org.springframework.http.MediaType; import org.springframework.test.context.bean.override.mockito.MockitoBean; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerHtmlUnitTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerHtmlUnitTests.java index f913feb69df..7f179f034c7 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerHtmlUnitTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerHtmlUnitTests.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import smoketest.test.service.VehicleDetails; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerSeleniumTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerSeleniumTests.java index effaec3eba2..5137225971a 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerSeleniumTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerSeleniumTests.java @@ -23,7 +23,7 @@ import org.openqa.selenium.WebElement; import smoketest.test.service.VehicleDetails; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerTests.java b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerTests.java index d79e687d048..bdc6bce021e 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerTests.java +++ b/smoke-test/spring-boot-smoke-test-test/src/test/java/smoketest/test/web/UserVehicleControllerTests.java @@ -24,7 +24,7 @@ import smoketest.test.service.VehicleIdentificationNumberNotFoundException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/java/smoketest/freemarker/WelcomeController.java b/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/java/smoketest/freemarker/WelcomeController.java index 122731268aa..c79ef182269 100644 --- a/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/java/smoketest/freemarker/WelcomeController.java +++ b/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/java/smoketest/freemarker/WelcomeController.java @@ -20,8 +20,10 @@ import java.util.Date; import java.util.Map; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.server.ResponseStatusException; @Controller public class WelcomeController { @@ -36,4 +38,9 @@ public class WelcomeController { return "welcome"; } + @GetMapping("insufficient-storage") + void outOfStorage() { + throw new ResponseStatusException(HttpStatus.INSUFFICIENT_STORAGE); + } + } diff --git a/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/resources/templates/error/507.ftlh b/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/resources/templates/error/507.ftlh new file mode 100644 index 00000000000..9064abdb42a --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-web-freemarker/src/main/resources/templates/error/507.ftlh @@ -0,0 +1 @@ +We are out of storage \ No newline at end of file diff --git a/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java b/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java index 90cbbeb9c38..227f9725a3e 100644 --- a/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-web-freemarker/src/test/java/smoketest/freemarker/SampleWebFreeMarkerApplicationTests.java @@ -65,4 +65,17 @@ class SampleWebFreeMarkerApplicationTests { assertThat(responseEntity.getBody()).contains("Something went wrong: 404 Not Found"); } + @Test + void templateErrorPageForSpecificStatusCode() { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); + HttpEntity requestEntity = new HttpEntity<>(headers); + + ResponseEntity responseEntity = this.testRestTemplate.exchange("/insufficient-storage", HttpMethod.GET, + requestEntity, String.class); + + assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.INSUFFICIENT_STORAGE); + assertThat(responseEntity.getBody()).contains("We are out of storage"); + } + } diff --git a/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle b/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle index 30ba5c4fc43..fcc424edb27 100644 --- a/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-groovy-templates/build.gradle @@ -26,6 +26,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) implementation("jakarta.xml.bind:jakarta.xml.bind-api") + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-restclient")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/MessageControllerWebTests.java b/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/MessageControllerWebTests.java index a1965bdfff6..8bc66d91c44 100755 --- a/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/MessageControllerWebTests.java +++ b/smoke-test/spring-boot-smoke-test-web-groovy-templates/src/test/java/smoketest/groovytemplates/MessageControllerWebTests.java @@ -24,8 +24,8 @@ import org.hamcrest.TypeSafeMatcher; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.http.HttpStatus; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle b/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle index 4b8b5bcde19..1c5d9d92442 100644 --- a/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle +++ b/smoke-test/spring-boot-smoke-test-web-thymeleaf/build.gradle @@ -25,6 +25,7 @@ dependencies { implementation(project(":starter:spring-boot-starter-webmvc")) implementation(project(":starter:spring-boot-starter-validation")) + testImplementation(project(":module:spring-boot-webmvc-test")) testImplementation(project(":starter:spring-boot-starter-restclient")) testImplementation(project(":starter:spring-boot-starter-test")) } diff --git a/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/MessageControllerWebTests.java b/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/MessageControllerWebTests.java index 02c0b24255d..f36781d8bc4 100644 --- a/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/MessageControllerWebTests.java +++ b/smoke-test/spring-boot-smoke-test-web-thymeleaf/src/test/java/smoketest/web/thymeleaf/MessageControllerWebTests.java @@ -24,8 +24,8 @@ import org.hamcrest.TypeSafeMatcher; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.http.HttpStatus; import org.springframework.test.web.servlet.assertj.MockMvcTester; diff --git a/smoke-test/spring-boot-smoke-test-webflux/build.gradle b/smoke-test/spring-boot-smoke-test-webflux/build.gradle index 430c0327cc6..aef59e3aa64 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/build.gradle +++ b/smoke-test/spring-boot-smoke-test-webflux/build.gradle @@ -22,6 +22,7 @@ description = "Spring Boot WebFlux smoke test" dependencies { implementation(project(":starter:spring-boot-starter-actuator")) + implementation(project(":starter:spring-boot-starter-mustache")) implementation(project(":starter:spring-boot-starter-webflux")) testImplementation(project(":starter:spring-boot-starter-restclient")) diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/main/java/smoketest/webflux/ExampleController.java b/smoke-test/spring-boot-smoke-test-webflux/src/main/java/smoketest/webflux/ExampleController.java index 349bf96a417..92da5c3d9f9 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/main/java/smoketest/webflux/ExampleController.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/main/java/smoketest/webflux/ExampleController.java @@ -16,9 +16,14 @@ package smoketest.webflux; +import reactor.core.publisher.Mono; + +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; @RestController public class ExampleController { @@ -29,4 +34,14 @@ public class ExampleController { return "Hello World"; } + @GetMapping("/bad-request") + Mono badRequest() { + return Mono.error(new ResponseStatusException(HttpStatus.BAD_REQUEST)); + } + + @GetMapping("five-hundred") + void fiveHundred() { + throw new RuntimeException("Expected!"); + } + } diff --git a/module/spring-boot-webflux/src/test/resources/org/springframework/boot/webflux/autoconfigure/error/templates/error/404.mustache b/smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/404.mustache similarity index 100% rename from module/spring-boot-webflux/src/test/resources/org/springframework/boot/webflux/autoconfigure/error/templates/error/404.mustache rename to smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/404.mustache diff --git a/module/spring-boot-webflux/src/test/resources/org/springframework/boot/webflux/autoconfigure/error/templates/error/4xx.mustache b/smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/4xx.mustache similarity index 100% rename from module/spring-boot-webflux/src/test/resources/org/springframework/boot/webflux/autoconfigure/error/templates/error/4xx.mustache rename to smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/4xx.mustache diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/error.mustache b/smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/error.mustache new file mode 100644 index 00000000000..fca46048694 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-webflux/src/main/resources/templates/error/error.mustache @@ -0,0 +1,8 @@ + + +
    +
  • status: {{status}}
  • +
  • message: {{message}}
  • +
+ + \ No newline at end of file diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java index 0684a79d89c..909b41f5ee6 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationTests.java @@ -22,15 +22,18 @@ import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.web.reactive.server.WebTestClient; +import static org.assertj.core.api.Assertions.assertThat; + /** * Basic integration tests for WebFlux application. * * @author Brian Clozel */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "server.error.include-message=always") class SampleWebFluxApplicationTests { @Autowired @@ -70,4 +73,40 @@ class SampleWebFluxApplicationTests { .json("{\"status\":\"UP\"}"); } + @Test + void templated404ErrorPage() { + this.webClient.get() + .uri("/404") + .accept(MediaType.TEXT_HTML) + .exchange() + .expectStatus() + .isNotFound() + .expectBody(String.class) + .value((body) -> assertThat(body).isEqualToNormalizingNewlines("404 page\n")); + } + + @Test + void templated4xxErrorPage() { + this.webClient.get() + .uri("/bad-request") + .accept(MediaType.TEXT_HTML) + .exchange() + .expectStatus() + .isBadRequest() + .expectBody(String.class) + .value((body) -> assertThat(body).isEqualToNormalizingNewlines("4xx page\n")); + } + + @Test + void htmlErrorPage() { + this.webClient.get() + .uri("/five-hundred") + .accept(MediaType.TEXT_HTML) + .exchange() + .expectStatus() + .isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR) + .expectBody(String.class) + .value((body) -> assertThat(body).contains("status: 500").contains("message: Expected!")); + } + } diff --git a/smoke-test/spring-boot-smoke-test-webservices/build.gradle b/smoke-test/spring-boot-smoke-test-webservices/build.gradle index 3714ef97fc2..363b8fe8d71 100644 --- a/smoke-test/spring-boot-smoke-test-webservices/build.gradle +++ b/smoke-test/spring-boot-smoke-test-webservices/build.gradle @@ -28,5 +28,5 @@ dependencies { runtimeOnly("wsdl4j:wsdl4j") testImplementation(project(":starter:spring-boot-starter-test")) - testImplementation("org.springframework.ws:spring-ws-test") + testImplementation(project(":module:spring-boot-webservices-test")) } diff --git a/smoke-test/spring-boot-smoke-test-webservices/src/test/java/smoketest/webservices/WebServiceServerTestSampleWsApplicationTests.java b/smoke-test/spring-boot-smoke-test-webservices/src/test/java/smoketest/webservices/WebServiceServerTestSampleWsApplicationTests.java index 65f2b57fbb9..58178bdfb8c 100644 --- a/smoke-test/spring-boot-smoke-test-webservices/src/test/java/smoketest/webservices/WebServiceServerTestSampleWsApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-webservices/src/test/java/smoketest/webservices/WebServiceServerTestSampleWsApplicationTests.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import smoketest.webservices.service.HumanResourceService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.webservices.server.WebServiceServerTest; +import org.springframework.boot.webservices.test.autoconfigure.server.WebServiceServerTest; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.ws.test.server.MockWebServiceClient; import org.springframework.ws.test.server.RequestCreators;