Commit 9127c48f authored by Phillip Webb's avatar Phillip Webb

Fixup warnings

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