Polish "Auto-configure a ResourceConfig for Jersey endpoints if needed"

Closes gh-11948
pull/13144/merge
Andy Wilkinson 7 years ago
parent bb2864ad02
commit a325b13d05

@ -31,27 +31,26 @@ import org.springframework.context.annotation.Configuration;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link JerseyWebEndpointManagementContextConfiguration}.
*
* @author Michael Simons
*/
public class JerseyWebEndpointManagementContextConfigurationTests {
private final WebApplicationContextRunner runner = new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(WebEndpointAutoConfiguration.class, JerseyWebEndpointManagementContextConfiguration.class));
.withConfiguration(AutoConfigurations.of(WebEndpointAutoConfiguration.class,
JerseyWebEndpointManagementContextConfiguration.class));
@Test
public void contextShouldContainSingleResourceConfig() {
this.runner
.withUserConfiguration(WebEndpointsSupplierConfig.class)
.run(context -> assertThat(context).hasSingleBean(ResourceConfig.class));
public void resourceConfigIsAutoConfiguredWhenNeeded() {
this.runner.withUserConfiguration(WebEndpointsSupplierConfig.class).run(
(context) -> assertThat(context).hasSingleBean(ResourceConfig.class));
}
@Test
public void contextWhenResourceConfigExistsShouldContainSingleResourceConfig() {
this.runner
.withUserConfiguration(
WebEndpointsSupplierConfig.class,
ConfigWithResourceConfig.class)
.run(context -> {
public void existingResourceConfigIsUsedWhenAvailable() {
this.runner.withUserConfiguration(WebEndpointsSupplierConfig.class,
ConfigWithResourceConfig.class).run((context) -> {
assertThat(context).hasSingleBean(ResourceConfig.class);
assertThat(context).hasBean("customResourceConfig");
});
@ -64,6 +63,7 @@ public class JerseyWebEndpointManagementContextConfigurationTests {
public WebEndpointsSupplier webEndpointsSupplier() {
return () -> Collections.emptyList();
}
}
@Configuration
@ -73,5 +73,7 @@ public class JerseyWebEndpointManagementContextConfigurationTests {
public ResourceConfig customResourceConfig() {
return new ResourceConfig();
}
}
}

Loading…
Cancel
Save