StandardConfigDataResourceTests Class — spring-boot Architecture
Architecture documentation for the StandardConfigDataResourceTests class in StandardConfigDataResourceTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/context/config/StandardConfigDataResourceTests.java lines 42–101
class StandardConfigDataResourceTests {
StandardConfigDataReference reference = mock(StandardConfigDataReference.class);
private final Resource resource = mock(Resource.class);
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenReferenceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new StandardConfigDataResource(null, this.resource))
.withMessage("'reference' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenResourceIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> new StandardConfigDataResource(this.reference, null))
.withMessage("'resource' must not be null");
}
@Test
void equalsWhenResourceIsTheSameReturnsTrue() {
Resource resource = new ClassPathResource("config/");
StandardConfigDataResource location = new StandardConfigDataResource(this.reference, resource);
StandardConfigDataResource other = new StandardConfigDataResource(this.reference, resource);
assertThat(location).isEqualTo(other);
}
@Test
void equalsWhenResourceIsDifferentReturnsFalse() {
Resource resource1 = new ClassPathResource("config/");
Resource resource2 = new ClassPathResource("configdata/");
StandardConfigDataResource location = new StandardConfigDataResource(this.reference, resource1);
StandardConfigDataResource other = new StandardConfigDataResource(this.reference, resource2);
assertThat(location).isNotEqualTo(other);
}
@Test // gh-34212
@WithResource(name = "test.resource", content = "test")
void equalsAndHashCodeWhenSameUnderlyingResource(@ResourcePath("test.resource") Path path) throws IOException {
Path directory = path.getParent();
assertThat(directory).isNotNull();
URLClassLoader classLoader = new URLClassLoader(new URL[] { directory.toUri().toURL() },
getClass().getClassLoader());
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try {
ClassPathResource classResource = new ClassPathResource("test.resource", classLoader);
FileUrlResource fileResource = new FileUrlResource(classResource.getURL());
ConfigDataResource classDataResource = new StandardConfigDataResource(this.reference, classResource);
ConfigDataResource fileDataResource = new StandardConfigDataResource(this.reference, fileResource);
assertThat(classDataResource).isEqualTo(fileDataResource);
assertThat(classDataResource).hasSameHashCodeAs(fileDataResource);
}
finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free