Fixup warnings
This commit is contained in:
parent
a869d25dbb
commit
9127c48fb5
|
@ -93,20 +93,25 @@ public class MetricFilterAutoConfigurationTests {
|
||||||
public void recordsHttpInteractions() throws Exception {
|
public void recordsHttpInteractions() throws Exception {
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||||
Config.class, MetricFilterAutoConfiguration.class);
|
Config.class, MetricFilterAutoConfiguration.class);
|
||||||
Filter filter = context.getBean(Filter.class);
|
try {
|
||||||
final MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
Filter filter = context.getBean(Filter.class);
|
||||||
"/test/path");
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
||||||
final MockHttpServletResponse response = new MockHttpServletResponse();
|
"/test/path");
|
||||||
FilterChain chain = mock(FilterChain.class);
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
willAnswer((invocation) -> {
|
FilterChain chain = mock(FilterChain.class);
|
||||||
response.setStatus(200);
|
willAnswer((invocation) -> {
|
||||||
return null;
|
response.setStatus(200);
|
||||||
}).given(chain).doFilter(request, response);
|
return null;
|
||||||
filter.doFilter(request, response, chain);
|
}).given(chain).doFilter(request, response);
|
||||||
verify(context.getBean(CounterService.class)).increment("status.200.test.path");
|
filter.doFilter(request, response, chain);
|
||||||
verify(context.getBean(GaugeService.class)).submit(eq("response.test.path"),
|
verify(context.getBean(CounterService.class))
|
||||||
anyDouble());
|
.increment("status.200.test.path");
|
||||||
context.close();
|
verify(context.getBean(GaugeService.class)).submit(eq("response.test.path"),
|
||||||
|
anyDouble());
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -355,9 +360,8 @@ public class MetricFilterAutoConfigurationTests {
|
||||||
.applyTo(context);
|
.applyTo(context);
|
||||||
context.refresh();
|
context.refresh();
|
||||||
Filter filter = context.getBean(Filter.class);
|
Filter filter = context.getBean(Filter.class);
|
||||||
final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
|
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/test/path");
|
||||||
"/test/path");
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
final MockHttpServletResponse response = new MockHttpServletResponse();
|
|
||||||
FilterChain chain = mock(FilterChain.class);
|
FilterChain chain = mock(FilterChain.class);
|
||||||
willAnswer((invocation) -> {
|
willAnswer((invocation) -> {
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
@ -383,9 +387,8 @@ public class MetricFilterAutoConfigurationTests {
|
||||||
"endpoints.metrics.filter.counter-submissions=").applyTo(context);
|
"endpoints.metrics.filter.counter-submissions=").applyTo(context);
|
||||||
context.refresh();
|
context.refresh();
|
||||||
Filter filter = context.getBean(Filter.class);
|
Filter filter = context.getBean(Filter.class);
|
||||||
final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
|
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/test/path");
|
||||||
"/test/path");
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
final MockHttpServletResponse response = new MockHttpServletResponse();
|
|
||||||
FilterChain chain = mock(FilterChain.class);
|
FilterChain chain = mock(FilterChain.class);
|
||||||
willAnswer((invocation) -> {
|
willAnswer((invocation) -> {
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
@ -402,28 +405,32 @@ public class MetricFilterAutoConfigurationTests {
|
||||||
public void whenExceptionIsThrownResponseStatusIsUsedWhenResponseHasBeenCommitted()
|
public void whenExceptionIsThrownResponseStatusIsUsedWhenResponseHasBeenCommitted()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||||
context.register(Config.class, MetricFilterAutoConfiguration.class);
|
|
||||||
context.refresh();
|
|
||||||
Filter filter = context.getBean(Filter.class);
|
|
||||||
final MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
|
||||||
"/test/path");
|
|
||||||
final MockHttpServletResponse response = new MockHttpServletResponse();
|
|
||||||
FilterChain chain = mock(FilterChain.class);
|
|
||||||
willAnswer((invocation) -> {
|
|
||||||
response.setStatus(200);
|
|
||||||
response.setCommitted(true);
|
|
||||||
throw new IOException();
|
|
||||||
}).given(chain).doFilter(request, response);
|
|
||||||
try {
|
try {
|
||||||
filter.doFilter(request, response, chain);
|
context.register(Config.class, MetricFilterAutoConfiguration.class);
|
||||||
fail();
|
context.refresh();
|
||||||
|
Filter filter = context.getBean(Filter.class);
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest("GET",
|
||||||
|
"/test/path");
|
||||||
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
|
FilterChain chain = mock(FilterChain.class);
|
||||||
|
willAnswer((invocation) -> {
|
||||||
|
response.setStatus(200);
|
||||||
|
response.setCommitted(true);
|
||||||
|
throw new IOException();
|
||||||
|
}).given(chain).doFilter(request, response);
|
||||||
|
try {
|
||||||
|
filter.doFilter(request, response, chain);
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
// Continue
|
||||||
|
}
|
||||||
|
verify(context.getBean(CounterService.class))
|
||||||
|
.increment(eq("status.200.test.path"));
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
finally {
|
||||||
// Continue
|
context.close();
|
||||||
}
|
}
|
||||||
verify(context.getBean(CounterService.class))
|
|
||||||
.increment(eq("status.200.test.path"));
|
|
||||||
context.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.template;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider.TemplateAvailabilityProperties;
|
|
||||||
import org.springframework.boot.context.properties.bind.Binder;
|
import org.springframework.boot.context.properties.bind.Binder;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
@ -33,19 +32,21 @@ import org.springframework.util.ClassUtils;
|
||||||
* @author Madhura Bhave
|
* @author Madhura Bhave
|
||||||
* @since 1.4.6
|
* @since 1.4.6
|
||||||
*/
|
*/
|
||||||
public abstract class PathBasedTemplateAvailabilityProvider<T extends TemplateAvailabilityProperties>
|
public abstract class PathBasedTemplateAvailabilityProvider
|
||||||
implements TemplateAvailabilityProvider {
|
implements TemplateAvailabilityProvider {
|
||||||
|
|
||||||
private final String className;
|
private final String className;
|
||||||
|
|
||||||
private final Class<T> propertiesClass;
|
private final Class<TemplateAvailabilityProperties> propertiesClass;
|
||||||
|
|
||||||
private final String propertyPrefix;
|
private final String propertyPrefix;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public PathBasedTemplateAvailabilityProvider(String className,
|
public PathBasedTemplateAvailabilityProvider(String className,
|
||||||
Class<T> propertiesClass, String propertyPrefix) {
|
Class<? extends TemplateAvailabilityProperties> propertiesClass,
|
||||||
|
String propertyPrefix) {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
this.propertiesClass = propertiesClass;
|
this.propertiesClass = (Class<TemplateAvailabilityProperties>) propertiesClass;
|
||||||
this.propertyPrefix = propertyPrefix;
|
this.propertyPrefix = propertyPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,9 +55,10 @@ public abstract class PathBasedTemplateAvailabilityProvider<T extends TemplateAv
|
||||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||||
if (ClassUtils.isPresent(this.className, classLoader)) {
|
if (ClassUtils.isPresent(this.className, classLoader)) {
|
||||||
Binder binder = Binder.get(environment);
|
Binder binder = Binder.get(environment);
|
||||||
TemplateAvailabilityProperties properties = binder
|
TemplateAvailabilityProperties properties1 = binder
|
||||||
.bind(this.propertyPrefix, this.propertiesClass)
|
.bind(this.propertyPrefix, this.propertiesClass)
|
||||||
.orElseCreate(this.propertiesClass);
|
.orElseCreate(this.propertiesClass);
|
||||||
|
TemplateAvailabilityProperties properties = properties1;
|
||||||
return isTemplateAvailable(view, resourceLoader, properties);
|
return isTemplateAvailable(view, resourceLoader, properties);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -261,8 +261,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||||
.of("security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys")
|
.of("security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys")
|
||||||
.applyTo(this.environment);
|
.applyTo(this.environment);
|
||||||
this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class,
|
this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class,
|
||||||
ResourceConfiguration.class).environment(this.environment).web(false)
|
ResourceConfiguration.class).environment(this.environment)
|
||||||
.run();
|
.web(WebApplicationType.NONE).run();
|
||||||
assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
|
assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,8 +271,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||||
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
|
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
|
||||||
.applyTo(this.environment);
|
.applyTo(this.environment);
|
||||||
this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class,
|
this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class,
|
||||||
ResourceConfiguration.class).environment(this.environment).web(false)
|
ResourceConfiguration.class).environment(this.environment)
|
||||||
.run();
|
.web(WebApplicationType.NONE).run();
|
||||||
assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
|
assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ public class UserInfoTokenServicesTests {
|
||||||
|
|
||||||
private Map<String, Object> map = new LinkedHashMap<>();
|
private Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
this.resource.setClientId("foo");
|
this.resource.setClientId("foo");
|
||||||
|
|
|
@ -175,11 +175,6 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||||
assertThat(this.response.getStatus()).isEqualTo(200);
|
assertThat(this.response.getStatus()).isEqualTo(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTunnelInvoked(boolean value) {
|
|
||||||
assertThat(this.context.getBean(MockHttpTunnelServer.class).invoked)
|
|
||||||
.isEqualTo(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertRestartInvoked(boolean value) {
|
private void assertRestartInvoked(boolean value) {
|
||||||
assertThat(this.context.getBean(MockHttpRestartServer.class).invoked)
|
assertThat(this.context.getBean(MockHttpRestartServer.class).invoked)
|
||||||
.isEqualTo(value);
|
.isEqualTo(value);
|
||||||
|
@ -211,8 +206,6 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||||
*/
|
*/
|
||||||
static class MockHttpTunnelServer extends HttpTunnelServer {
|
static class MockHttpTunnelServer extends HttpTunnelServer {
|
||||||
|
|
||||||
private boolean invoked;
|
|
||||||
|
|
||||||
MockHttpTunnelServer(TargetServerConnection serverConnection) {
|
MockHttpTunnelServer(TargetServerConnection serverConnection) {
|
||||||
super(serverConnection);
|
super(serverConnection);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +213,6 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ServerHttpRequest request, ServerHttpResponse response)
|
public void handle(ServerHttpRequest request, ServerHttpResponse response)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
this.invoked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SpringBootDependencyInjectionTestExecutionListenerTests {
|
||||||
IllegalStateException originalFailure = new IllegalStateException();
|
IllegalStateException originalFailure = new IllegalStateException();
|
||||||
given(testContext.getTestInstance()).willThrow(originalFailure);
|
given(testContext.getTestInstance()).willThrow(originalFailure);
|
||||||
SpringApplication application = new SpringApplication(Config.class);
|
SpringApplication application = new SpringApplication(Config.class);
|
||||||
application.setWebEnvironment(false);
|
application.setWebApplicationType(WebApplicationType.NONE);
|
||||||
given(testContext.getApplicationContext()).willThrow(new RuntimeException());
|
given(testContext.getApplicationContext()).willThrow(new RuntimeException());
|
||||||
this.thrown.expect(is(originalFailure));
|
this.thrown.expect(is(originalFailure));
|
||||||
this.reportListener.prepareTestInstance(testContext);
|
this.reportListener.prepareTestInstance(testContext);
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class JsonContentTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void assertThatShouldReturnJsonContentAssert() throws Exception {
|
public void assertThatShouldReturnJsonContentAssert() throws Exception {
|
||||||
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
|
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
|
||||||
assertThat(content.assertThat()).isInstanceOf(JsonContentAssert.class);
|
assertThat(content.assertThat()).isInstanceOf(JsonContentAssert.class);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class UnboundElementsSourceFilter
|
||||||
public Boolean apply(ConfigurationPropertySource configurationPropertySource) {
|
public Boolean apply(ConfigurationPropertySource configurationPropertySource) {
|
||||||
Object underlyingSource = configurationPropertySource.getUnderlyingSource();
|
Object underlyingSource = configurationPropertySource.getUnderlyingSource();
|
||||||
if (underlyingSource instanceof PropertySource) {
|
if (underlyingSource instanceof PropertySource) {
|
||||||
String name = ((PropertySource) underlyingSource).getName();
|
String name = ((PropertySource<?>) underlyingSource).getName();
|
||||||
return !BENIGN_PROPERTY_SOURCE_NAMES.contains(name);
|
return !BENIGN_PROPERTY_SOURCE_NAMES.contains(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,8 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set {@link UndertowBuilderCustomizer}s that should be applied to the Undertow
|
* Set {@link UndertowBuilderCustomizer}s that should be applied to the Undertow
|
||||||
* {@link Undertow.Builder}. Calling this method will replace any existing
|
* {@link io.undertow.Undertow.Builder Builder}. Calling this method will replace any
|
||||||
* customizers.
|
* existing customizers.
|
||||||
* @param customizers the customizers to set
|
* @param customizers the customizers to set
|
||||||
*/
|
*/
|
||||||
public void setBuilderCustomizers(
|
public void setBuilderCustomizers(
|
||||||
|
@ -129,7 +129,7 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a mutable collection of the {@link UndertowBuilderCustomizer}s that will be
|
* Returns a mutable collection of the {@link UndertowBuilderCustomizer}s that will be
|
||||||
* applied to the Undertow {@link Undertow.Builder} .
|
* applied to the Undertow {@link io.undertow.Undertow.Builder Builder}.
|
||||||
* @return the customizers that will be applied
|
* @return the customizers that will be applied
|
||||||
*/
|
*/
|
||||||
public Collection<UndertowBuilderCustomizer> getBuilderCustomizers() {
|
public Collection<UndertowBuilderCustomizer> getBuilderCustomizers() {
|
||||||
|
@ -138,7 +138,7 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add {@link UndertowBuilderCustomizer}s that should be used to customize the
|
* Add {@link UndertowBuilderCustomizer}s that should be used to customize the
|
||||||
* Undertow {@link Undertow.Builder}.
|
* Undertow {@link io.undertow.Undertow.Builder Builder}.
|
||||||
* @param customizers the customizers to add
|
* @param customizers the customizers to add
|
||||||
*/
|
*/
|
||||||
public void addBuilderCustomizers(UndertowBuilderCustomizer... customizers) {
|
public void addBuilderCustomizers(UndertowBuilderCustomizer... customizers) {
|
||||||
|
|
Loading…
Reference in New Issue