JarTypeFilterTests Class — spring-boot Architecture
Architecture documentation for the JarTypeFilterTests class in JarTypeFilterTests.java from the spring-boot codebase.
Entity Profile
Source Code
build-plugin/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/JarTypeFilterTests.java lines 39–108
class JarTypeFilterTests {
@TempDir
@SuppressWarnings("NullAway.Init")
Path temp;
@Test
void whenArtifactHasNoJarTypeThenItIsIncluded() {
assertThat(new JarTypeFilter().filter(createArtifact(null))).isFalse();
}
@Test
void whenArtifactHasJarTypeThatIsNotExcludedThenItIsIncluded() {
assertThat(new JarTypeFilter().filter(createArtifact("something-included"))).isFalse();
}
@Test
void whenArtifactHasDependenciesStarterJarTypeThenItIsExcluded() {
assertThat(new JarTypeFilter().filter(createArtifact("dependencies-starter"))).isTrue();
}
@Test
void whenArtifactHasAnnotationProcessorJarTypeThenItIsExcluded() {
assertThat(new JarTypeFilter().filter(createArtifact("annotation-processor"))).isTrue();
}
@Test
void whenArtifactHasDevelopmentToolJarTypeThenItIsExcluded() {
assertThat(new JarTypeFilter().filter(createArtifact("development-tool"))).isTrue();
}
@Test
void whenArtifactHasNoManifestFileThenItIsIncluded() {
assertThat(new JarTypeFilter().filter(createArtifactWithNoManifest())).isFalse();
}
private Artifact createArtifact(@Nullable String springBootJarType) {
Path jarPath = this.temp.resolve("test.jar");
Manifest manifest = new Manifest();
manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
if (springBootJarType != null) {
manifest.getMainAttributes().putValue("Spring-Boot-Jar-Type", springBootJarType);
}
try {
new JarOutputStream(new FileOutputStream(jarPath.toFile()), manifest).close();
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
return mockArtifact(jarPath);
}
private Artifact createArtifactWithNoManifest() {
Path jarPath = this.temp.resolve("test.jar");
try {
new JarOutputStream(new FileOutputStream(jarPath.toFile())).close();
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
return mockArtifact(jarPath);
}
private Artifact mockArtifact(Path jarPath) {
Artifact artifact = mock(Artifact.class);
given(artifact.getFile()).willReturn(jarPath.toFile());
return artifact;
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free