Skip to content

Commit 097d841

Browse files
committed
Add Jackson test dep & relax negotiation test
Add com.fasterxml.jackson.core:jackson-databind as a test dependency and adjust WebMvcAutoConfigurationAllEnabledTest to be less brittle. The test now asserts the strategies list is non-empty and iterates to find a ParameterContentNegotiationStrategy (asserting its parameter name is "p") instead of relying on an exact size and specific ordering.
1 parent 66f6aca commit 097d841

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

microsphere-spring-boot-webmvc/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
<scope>test</scope>
7575
</dependency>
7676

77+
<!-- Jackson -->
78+
<dependency>
79+
<groupId>com.fasterxml.jackson.core</groupId>
80+
<artifactId>jackson-databind</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
7784
</dependencies>
7885

7986
</project>

microsphere-spring-boot-webmvc/src/test/java/io/microsphere/spring/boot/webmvc/autoconfigure/WebMvcAutoConfigurationAllEnabledTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import java.util.List;
3636

3737
import static org.junit.jupiter.api.Assertions.assertEquals;
38-
import static org.junit.jupiter.api.Assertions.assertTrue;
38+
import static org.junit.jupiter.api.Assertions.assertFalse;
3939

4040
/**
4141
* {@link WebMvcAutoConfiguration} Test with all enabled components
@@ -95,15 +95,12 @@ void test() throws Exception {
9595

9696
void assertContentNegotiationManager(ContentNegotiationManager contentNegotiationManager) {
9797
List<ContentNegotiationStrategy> strategies = contentNegotiationManager.getStrategies();
98-
assertEquals(2, strategies.size());
98+
assertFalse(strategies.isEmpty());
9999

100-
ContentNegotiationStrategy strategy1 = strategies.get(0);
101-
ContentNegotiationStrategy strategy2 = strategies.get(1);
102-
103-
assertTrue(strategy2 instanceof ParameterContentNegotiationStrategy);
104-
105-
ParameterContentNegotiationStrategy parameterContentNegotiationStrategy = (ParameterContentNegotiationStrategy) strategy2;
106-
107-
assertEquals("p", parameterContentNegotiationStrategy.getParameterName());
100+
for (ContentNegotiationStrategy strategy : strategies) {
101+
if (strategy instanceof ParameterContentNegotiationStrategy parameterContentNegotiationStrategy) {
102+
assertEquals("p", parameterContentNegotiationStrategy.getParameterName());
103+
}
104+
}
108105
}
109106
}

0 commit comments

Comments
 (0)