Support @Nested tests in MockServerContainerContextCustomizerFactory
Prior to this commit, MockServerContainerContextCustomizerFactory did not find @WebAppConfiguration on an enclosing class and therefore failed to create a MockServerContainerContextCustomizer for a @Nested test class. This commit addresses this by using TestContextAnnotationUtils to determine if the test class is "annotated" with @WebAppConfiguration. Closes gh-29037
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.test.context.web.socket;
|
||||
|
||||
import javax.websocket.server.ServerContainer;
|
||||
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -46,6 +47,20 @@ class WebSocketServletServerContainerFactoryBeanTests {
|
||||
assertThat(serverContainer.getDefaultMaxTextMessageBufferSize()).isEqualTo(42);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Nested test class to verify that the MockServerContainerContextCustomizerFactory
|
||||
* properly supports finding @WebAppConfiguration on an enclosing class.
|
||||
*/
|
||||
@Nested
|
||||
class NestedTests {
|
||||
|
||||
@Test // gh-29037
|
||||
void servletServerContainerFactoryBeanSupport(@Autowired ServerContainer serverContainer) {
|
||||
assertThat(serverContainer.getDefaultMaxTextMessageBufferSize()).isEqualTo(42);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableWebSocket
|
||||
|
||||
Reference in New Issue
Block a user