DefaultSslBundleRegistryTests Class — spring-boot Architecture
Architecture documentation for the DefaultSslBundleRegistryTests class in DefaultSslBundleRegistryTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/ssl/DefaultSslBundleRegistryTests.java lines 42–143
@ExtendWith(OutputCaptureExtension.class)
class DefaultSslBundleRegistryTests {
private final SslBundle bundle1 = mock(SslBundle.class);
private final SslBundle bundle2 = mock(SslBundle.class);
private DefaultSslBundleRegistry registry;
@BeforeEach
void setUp() {
this.registry = new DefaultSslBundleRegistry();
}
@Test
void createWithNameAndBundleRegistersBundle() {
DefaultSslBundleRegistry registry = new DefaultSslBundleRegistry("test", this.bundle1);
assertThat(registry.getBundle("test")).isSameAs(this.bundle1);
}
@Test
@SuppressWarnings("NullAway") // Test null check
void registerBundleWhenNameIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.registry.registerBundle(null, this.bundle1))
.withMessage("'name' must not be null");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void registerBundleWhenBundleIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.registry.registerBundle("test", null))
.withMessage("'bundle' must not be null");
}
@Test
void registerBundleWhenNameIsTakenThrowsException() {
this.registry.registerBundle("test", this.bundle1);
assertThatIllegalStateException().isThrownBy(() -> this.registry.registerBundle("test", this.bundle2))
.withMessage("Cannot replace existing SSL bundle 'test'");
}
@Test
void registerBundleRegistersBundle() {
this.registry.registerBundle("test", this.bundle1);
assertThat(this.registry.getBundle("test")).isSameAs(this.bundle1);
}
@Test
@SuppressWarnings("NullAway") // Test null check
void getBundleWhenNameIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> this.registry.getBundle(null))
.withMessage("'name' must not be null");
}
@Test
void getBundleWhenNoSuchBundleThrowsException() {
this.registry.registerBundle("test", this.bundle1);
assertThatExceptionOfType(NoSuchSslBundleException.class).isThrownBy(() -> this.registry.getBundle("missing"))
.satisfies((ex) -> assertThat(ex.getBundleName()).isEqualTo("missing"));
}
@Test
void getBundleReturnsBundle() {
this.registry.registerBundle("test1", this.bundle1);
this.registry.registerBundle("test2", this.bundle2);
assertThat(this.registry.getBundle("test1")).isSameAs(this.bundle1);
assertThat(this.registry.getBundle("test2")).isSameAs(this.bundle2);
}
@Test
void getBundleNamesReturnsNames() {
this.registry.registerBundle("test1", this.bundle1);
this.registry.registerBundle("test2", this.bundle2);
assertThat(this.registry.getBundleNames()).containsExactly("test1", "test2");
}
@Test
void updateBundleShouldNotifyUpdateHandlers() {
AtomicReference<SslBundle> updatedBundle = new AtomicReference<>();
this.registry.registerBundle("test1", this.bundle1);
this.registry.addBundleUpdateHandler("test1", updatedBundle::set);
this.registry.updateBundle("test1", this.bundle2);
Awaitility.await().untilAtomic(updatedBundle, Matchers.equalTo(this.bundle2));
}
@Test
void shouldFailIfUpdatingNonRegisteredBundle() {
assertThatExceptionOfType(NoSuchSslBundleException.class)
.isThrownBy(() -> this.registry.updateBundle("dummy", this.bundle1))
.withMessageContaining("'dummy'");
}
@Test
void shouldLogIfUpdatingBundleWithoutListeners(CapturedOutput output) {
this.registry.registerBundle("test1", this.bundle1);
this.registry.getBundle("test1");
this.registry.updateBundle("test1", this.bundle2);
assertThat(output).contains(
"SSL bundle 'test1' has been updated but may be in use by a technology that doesn't support SSL reloading");
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free