Home / Class/ ServletListenerRegistrationBeanTests Class — spring-boot Architecture

ServletListenerRegistrationBeanTests Class — spring-boot Architecture

Architecture documentation for the ServletListenerRegistrationBeanTests class in ServletListenerRegistrationBeanTests.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletListenerRegistrationBeanTests.java lines 38–75

@ExtendWith(MockitoExtension.class)
class ServletListenerRegistrationBeanTests {

	@Mock
	@SuppressWarnings("NullAway.Init")
	private ServletContextListener listener;

	@Mock
	@SuppressWarnings("NullAway.Init")
	private ServletContext servletContext;

	@Test
	void startupWithDefaults() throws Exception {
		ServletListenerRegistrationBean<ServletContextListener> bean = new ServletListenerRegistrationBean<>(
				this.listener);
		bean.onStartup(this.servletContext);
		then(this.servletContext).should().addListener(this.listener);
	}

	@Test
	void disable() throws Exception {
		ServletListenerRegistrationBean<ServletContextListener> bean = new ServletListenerRegistrationBean<>(
				this.listener);
		bean.setEnabled(false);
		bean.onStartup(this.servletContext);
		then(this.servletContext).should(never()).addListener(any(ServletContextListener.class));
	}

	@Test
	void cannotRegisterUnsupportedType() {
		assertThatIllegalArgumentException()
			.isThrownBy(() -> new ServletListenerRegistrationBean<>(new EventListener() {

			}))
			.withMessageContaining("'listener' is not of a supported type");
	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free