|
22 | 22 |
|
23 | 23 | import org.junit.jupiter.api.BeforeEach;
|
24 | 24 | import org.junit.jupiter.api.Test;
|
| 25 | +import org.mockito.ArgumentCaptor; |
25 | 26 |
|
26 | 27 | import org.springframework.boot.autoconfigure.web.ServerProperties;
|
27 | 28 | import org.springframework.boot.context.properties.bind.Bindable;
|
28 | 29 | import org.springframework.boot.context.properties.bind.Binder;
|
29 | 30 | import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
|
30 | 31 | import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
|
31 | 32 | import org.springframework.boot.web.server.Cookie;
|
| 33 | +import org.springframework.boot.web.server.MimeMappings; |
32 | 34 | import org.springframework.boot.web.server.Shutdown;
|
33 | 35 | import org.springframework.boot.web.server.Ssl;
|
34 | 36 | import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
@@ -74,10 +76,25 @@ void testCustomizeDisplayName() {
|
74 | 76 | }
|
75 | 77 |
|
76 | 78 | @Test
|
77 |
| - void testCustomMimeMappings() { |
| 79 | + void withNoCustomMimeMappingsThenEmptyMimeMappingsIsAdded() { |
78 | 80 | ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
|
79 | 81 | this.customizer.customize(factory);
|
80 |
| - then(factory).should().setMimeMappings(this.properties.getMimeMappings()); |
| 82 | + ArgumentCaptor<MimeMappings> mimeMappingsCaptor = ArgumentCaptor.forClass(MimeMappings.class); |
| 83 | + then(factory).should().addMimeMappings(mimeMappingsCaptor.capture()); |
| 84 | + MimeMappings mimeMappings = mimeMappingsCaptor.getValue(); |
| 85 | + assertThat(mimeMappings.getAll()).isEmpty(); |
| 86 | + } |
| 87 | + |
| 88 | + @Test |
| 89 | + void withCustomMimeMappingsThenPopulatedMimeMappingsIsAdded() { |
| 90 | + this.properties.getMimeMappings().add("a", "alpha"); |
| 91 | + this.properties.getMimeMappings().add("b", "bravo"); |
| 92 | + ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class); |
| 93 | + this.customizer.customize(factory); |
| 94 | + ArgumentCaptor<MimeMappings> mimeMappingsCaptor = ArgumentCaptor.forClass(MimeMappings.class); |
| 95 | + then(factory).should().addMimeMappings(mimeMappingsCaptor.capture()); |
| 96 | + MimeMappings mimeMappings = mimeMappingsCaptor.getValue(); |
| 97 | + assertThat(mimeMappings.getAll()).hasSize(2); |
81 | 98 | }
|
82 | 99 |
|
83 | 100 | @Test
|
|
0 commit comments