Polish
This commit is contained in:
parent
1640add8be
commit
3ca896e63f
|
|
@ -45,7 +45,6 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@ConditionalOnBean(RestClient.class)
|
@ConditionalOnBean(RestClient.class)
|
||||||
@ConditionalOnEnabledHealthIndicator("elasticsearch")
|
@ConditionalOnEnabledHealthIndicator("elasticsearch")
|
||||||
@AutoConfigureAfter(RestClientAutoConfiguration.class)
|
@AutoConfigureAfter(RestClientAutoConfiguration.class)
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class ElasticSearchRestHealthContributorAutoConfiguration
|
public class ElasticSearchRestHealthContributorAutoConfiguration
|
||||||
extends CompositeHealthContributorConfiguration<ElasticsearchRestHealthIndicator, RestClient> {
|
extends CompositeHealthContributorConfiguration<ElasticsearchRestHealthIndicator, RestClient> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,11 +164,11 @@ public final class EndpointRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private EndpointServerWebExchangeMatcher(Class<?>[] endpoints, boolean includeLinks) {
|
private EndpointServerWebExchangeMatcher(Class<?>[] endpoints, boolean includeLinks) {
|
||||||
this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks);
|
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EndpointServerWebExchangeMatcher(String[] endpoints, boolean includeLinks) {
|
private EndpointServerWebExchangeMatcher(String[] endpoints, boolean includeLinks) {
|
||||||
this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks);
|
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EndpointServerWebExchangeMatcher(List<Object> includes, List<Object> excludes, boolean includeLinks) {
|
private EndpointServerWebExchangeMatcher(List<Object> includes, List<Object> excludes, boolean includeLinks) {
|
||||||
|
|
|
||||||
|
|
@ -196,11 +196,11 @@ public final class EndpointRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private EndpointRequestMatcher(Class<?>[] endpoints, boolean includeLinks) {
|
private EndpointRequestMatcher(Class<?>[] endpoints, boolean includeLinks) {
|
||||||
this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks);
|
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EndpointRequestMatcher(String[] endpoints, boolean includeLinks) {
|
private EndpointRequestMatcher(String[] endpoints, boolean includeLinks) {
|
||||||
this(Arrays.asList(endpoints), Collections.emptyList(), includeLinks);
|
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EndpointRequestMatcher(List<Object> includes, List<Object> excludes, boolean includeLinks) {
|
private EndpointRequestMatcher(List<Object> includes, List<Object> excludes, boolean includeLinks) {
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||||
* @param prefix the prefix
|
* @param prefix the prefix
|
||||||
* @return the serialized instance
|
* @return the serialized instance
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
private Map<String, Object> safeSerialize(ObjectMapper mapper, Object bean, String prefix) {
|
private Map<String, Object> safeSerialize(ObjectMapper mapper, Object bean, String prefix) {
|
||||||
try {
|
try {
|
||||||
return new HashMap<>(mapper.convertValue(bean, Map.class));
|
return new HashMap<>(mapper.convertValue(bean, Map.class));
|
||||||
|
|
|
||||||
|
|
@ -162,12 +162,10 @@ public class JerseyEndpointResourceFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, Object> extractBodyArguments(ContainerRequestContext data) {
|
private Map<String, Object> extractBodyArguments(ContainerRequestContext data) {
|
||||||
Map<String, Object> entity = ((ContainerRequest) data).readEntity(Map.class);
|
Map<String, Object> entity = ((ContainerRequest) data).readEntity(Map.class);
|
||||||
if (entity == null) {
|
return (entity != null) ? entity : Collections.emptyMap();
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> extractPathParameters(ContainerRequestContext requestContext) {
|
private Map<String, Object> extractPathParameters(ContainerRequestContext requestContext) {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,10 @@ import com.couchbase.client.java.env.ClusterEnvironment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback interface that can be implemented by beans wishing to customize the
|
* Callback interface that can be implemented by beans wishing to customize the
|
||||||
* {@link ClusterEnvironment} via a {@link ClusterEnvironment.Builder} whilst retaining
|
* {@link ClusterEnvironment} via a
|
||||||
* default auto-configuration.whilst retaining default auto-configuration.
|
* {@link com.couchbase.client.java.env.ClusterEnvironment.Builder
|
||||||
|
* ClusterEnvironment.Builder} whilst retaining default auto-configuration.whilst
|
||||||
|
* retaining default auto-configuration.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
|
@ -30,7 +32,8 @@ import com.couchbase.client.java.env.ClusterEnvironment;
|
||||||
public interface ClusterEnvironmentBuilderCustomizer {
|
public interface ClusterEnvironmentBuilderCustomizer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customize the {@link ClusterEnvironment.Builder}.
|
* Customize the {@link com.couchbase.client.java.env.ClusterEnvironment.Builder
|
||||||
|
* ClusterEnvironment.Builder}.
|
||||||
* @param builder the builder to customize
|
* @param builder the builder to customize
|
||||||
*/
|
*/
|
||||||
void customize(ClusterEnvironment.Builder builder);
|
void customize(ClusterEnvironment.Builder builder);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import org.springframework.util.Assert;
|
||||||
/**
|
/**
|
||||||
* Base class for setup that is common to MongoDB client factories.
|
* Base class for setup that is common to MongoDB client factories.
|
||||||
*
|
*
|
||||||
|
* @param <T> the mongo client type
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Scott Frederick
|
* @author Scott Frederick
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,8 @@ public final class ConnectionFactoryBuilder {
|
||||||
static class ConnectionFactoryOptionsInitializer {
|
static class ConnectionFactoryOptionsInitializer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a {@link ConnectionFactoryOptions.Builder} using the specified
|
* Initialize a {@link io.r2dbc.spi.ConnectionFactoryOptions.Builder
|
||||||
* properties.
|
* ConnectionFactoryOptions.Builder} using the specified properties.
|
||||||
* @param properties the properties to use to initialize the builder
|
* @param properties the properties to use to initialize the builder
|
||||||
* @param embeddedDatabaseConnection the embedded connection to use as a fallback
|
* @param embeddedDatabaseConnection the embedded connection to use as a fallback
|
||||||
* @return an initialized builder
|
* @return an initialized builder
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,7 @@ public class UndertowWebServerFactoryCustomizer
|
||||||
return (value) -> this.factory.addBuilderCustomizers((builder) -> builder.setSocketOption(option, value));
|
return (value) -> this.factory.addBuilderCustomizers((builder) -> builder.setSocketOption(option, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
<T> Consumer<Map<String, String>> forEach(Function<Option<T>, Consumer<T>> function) {
|
<T> Consumer<Map<String, String>> forEach(Function<Option<T>, Consumer<T>> function) {
|
||||||
return (map) -> map.forEach((key, value) -> {
|
return (map) -> map.forEach((key, value) -> {
|
||||||
Option<T> option = (Option<T>) NAME_LOOKUP.get(getCanonicalName(key));
|
Option<T> option = (Option<T>) NAME_LOOKUP.get(getCanonicalName(key));
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@ package org.springframework.boot.autoconfigure.web.format;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.ResolverStyle;
|
import java.time.format.ResolverStyle;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import org.springframework.format.datetime.DateFormatter;
|
import org.springframework.format.datetime.DateFormatter;
|
||||||
import org.springframework.format.datetime.DateFormatterRegistrar;
|
import org.springframework.format.datetime.DateFormatterRegistrar;
|
||||||
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
||||||
|
|
@ -49,8 +46,6 @@ public class WebConversionService extends DefaultFormattingConversionService {
|
||||||
private static final boolean JSR_354_PRESENT = ClassUtils.isPresent("javax.money.MonetaryAmount",
|
private static final boolean JSR_354_PRESENT = ClassUtils.isPresent("javax.money.MonetaryAmount",
|
||||||
WebConversionService.class.getClassLoader());
|
WebConversionService.class.getClassLoader());
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(WebConversionService.class);
|
|
||||||
|
|
||||||
private final String dateFormat;
|
private final String dateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ import static org.testcontainers.shaded.org.apache.commons.codec.binary.Base64.e
|
||||||
* Temporary copy of TestContainers's Couchbase support until it works against Couchbase
|
* Temporary copy of TestContainers's Couchbase support until it works against Couchbase
|
||||||
* SDK v3.
|
* SDK v3.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
|
class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
|
||||||
|
|
||||||
public static final String VERSION = "5.5.1";
|
public static final String VERSION = "5.5.1";
|
||||||
|
|
@ -198,7 +199,6 @@ class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "unchecked", "ConstantConditions" })
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
try {
|
try {
|
||||||
stopCluster();
|
stopCluster();
|
||||||
|
|
|
||||||
|
|
@ -667,6 +667,7 @@ class KafkaAutoConfigurationTests {
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
static class ConsumerFactoryConfiguration {
|
static class ConsumerFactoryConfiguration {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private final ConsumerFactory<String, Object> consumerFactory = mock(ConsumerFactory.class);
|
private final ConsumerFactory<String, Object> consumerFactory = mock(ConsumerFactory.class);
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import static org.mockito.Mockito.verify;
|
||||||
/**
|
/**
|
||||||
* Tests for {@link MongoClientFactorySupport}.
|
* Tests for {@link MongoClientFactorySupport}.
|
||||||
*
|
*
|
||||||
|
* @param <T> the mongo client type
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,8 @@ class R2dbcAutoConfigurationTests {
|
||||||
this.contextRunner.withPropertyValues("spring.r2dbc.pool.enabled=false", "spring.r2dbc.url:r2dbc:simple://foo",
|
this.contextRunner.withPropertyValues("spring.r2dbc.pool.enabled=false", "spring.r2dbc.url:r2dbc:simple://foo",
|
||||||
"spring.r2dbc.properties.test=value", "spring.r2dbc.properties.another=2").run((context) -> {
|
"spring.r2dbc.properties.test=value", "spring.r2dbc.properties.another=2").run((context) -> {
|
||||||
SimpleTestConnectionFactory connectionFactory = context.getBean(SimpleTestConnectionFactory.class);
|
SimpleTestConnectionFactory connectionFactory = context.getBean(SimpleTestConnectionFactory.class);
|
||||||
assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("test")))
|
assertThat(getRequiredOptionsValue(connectionFactory, "test")).isEqualTo("value");
|
||||||
.isEqualTo("value");
|
assertThat(getRequiredOptionsValue(connectionFactory, "another")).isEqualTo("2");
|
||||||
assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("another")))
|
|
||||||
.isEqualTo("2");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,13 +179,15 @@ class R2dbcAutoConfigurationTests {
|
||||||
assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class);
|
assertThat(context).hasSingleBean(ConnectionFactory.class).hasSingleBean(ConnectionPool.class);
|
||||||
SimpleTestConnectionFactory connectionFactory = (SimpleTestConnectionFactory) context
|
SimpleTestConnectionFactory connectionFactory = (SimpleTestConnectionFactory) context
|
||||||
.getBean(ConnectionPool.class).unwrap();
|
.getBean(ConnectionPool.class).unwrap();
|
||||||
assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("test")))
|
assertThat(getRequiredOptionsValue(connectionFactory, "test")).isEqualTo("value");
|
||||||
.isEqualTo("value");
|
assertThat(getRequiredOptionsValue(connectionFactory, "another")).isEqualTo("2");
|
||||||
assertThat((Object) connectionFactory.options.getRequiredValue(Option.valueOf("another")))
|
|
||||||
.isEqualTo("2");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getRequiredOptionsValue(SimpleTestConnectionFactory connectionFactory, String name) {
|
||||||
|
return connectionFactory.options.getRequiredValue(Option.valueOf(name));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void configureWithoutUrlShouldCreateEmbeddedConnectionPoolByDefault() {
|
void configureWithoutUrlShouldCreateEmbeddedConnectionPoolByDefault() {
|
||||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ConnectionFactory.class)
|
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ConnectionFactory.class)
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(ReactiveJwtDecoder.class);
|
assertThat(context).hasSingleBean(ReactiveJwtDecoder.class);
|
||||||
ReactiveJwtDecoder reactiveJwtDecoder = context.getBean(ReactiveJwtDecoder.class);
|
ReactiveJwtDecoder reactiveJwtDecoder = context.getBean(ReactiveJwtDecoder.class);
|
||||||
DelegatingOAuth2TokenValidator<Jwt> jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils
|
DelegatingOAuth2TokenValidator<Jwt> jwtValidator = (DelegatingOAuth2TokenValidator<Jwt>) ReflectionTestUtils
|
||||||
.getField(reactiveJwtDecoder, "jwtValidator");
|
.getField(reactiveJwtDecoder, "jwtValidator");
|
||||||
Collection<OAuth2TokenValidator<Jwt>> tokenValidators = (Collection<OAuth2TokenValidator<Jwt>>) ReflectionTestUtils
|
Collection<OAuth2TokenValidator<Jwt>> tokenValidators = (Collection<OAuth2TokenValidator<Jwt>>) ReflectionTestUtils
|
||||||
.getField(jwtValidator, "tokenValidators");
|
.getField(jwtValidator, "tokenValidators");
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||||
.run((context) -> {
|
.run((context) -> {
|
||||||
assertThat(context).hasSingleBean(JwtDecoder.class);
|
assertThat(context).hasSingleBean(JwtDecoder.class);
|
||||||
JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class);
|
JwtDecoder jwtDecoder = context.getBean(JwtDecoder.class);
|
||||||
DelegatingOAuth2TokenValidator<Jwt> jwtValidator = (DelegatingOAuth2TokenValidator) ReflectionTestUtils
|
DelegatingOAuth2TokenValidator<Jwt> jwtValidator = (DelegatingOAuth2TokenValidator<Jwt>) ReflectionTestUtils
|
||||||
.getField(jwtDecoder, "jwtValidator");
|
.getField(jwtDecoder, "jwtValidator");
|
||||||
Collection<OAuth2TokenValidator<Jwt>> tokenValidators = (Collection<OAuth2TokenValidator<Jwt>>) ReflectionTestUtils
|
Collection<OAuth2TokenValidator<Jwt>> tokenValidators = (Collection<OAuth2TokenValidator<Jwt>>) ReflectionTestUtils
|
||||||
.getField(jwtValidator, "tokenValidators");
|
.getField(jwtValidator, "tokenValidators");
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,7 @@ public abstract class AbstractApplicationContextRunner<SELF extends AbstractAppl
|
||||||
* @param consumer the consumer of the created {@link ApplicationContext}
|
* @param consumer the consumer of the created {@link ApplicationContext}
|
||||||
* @return this instance
|
* @return this instance
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public SELF run(ContextConsumer<? super A> consumer) {
|
public SELF run(ContextConsumer<? super A> consumer) {
|
||||||
withContextClassLoader(this.classLoader, () -> this.systemProperties.applyToSystemProperties(() -> {
|
withContextClassLoader(this.classLoader, () -> this.systemProperties.applyToSystemProperties(() -> {
|
||||||
try (A context = createAssertableContext()) {
|
try (A context = createAssertableContext()) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
import org.junit.Assert;
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.rules.TestRule;
|
import org.junit.rules.TestRule;
|
||||||
import org.junit.runner.Description;
|
import org.junit.runner.Description;
|
||||||
|
|
@ -70,7 +70,7 @@ public class OutputCaptureRule implements TestRule, CapturedOutput {
|
||||||
try {
|
try {
|
||||||
if (!OutputCaptureRule.this.matchers.isEmpty()) {
|
if (!OutputCaptureRule.this.matchers.isEmpty()) {
|
||||||
String output = OutputCaptureRule.this.delegate.toString();
|
String output = OutputCaptureRule.this.delegate.toString();
|
||||||
Assert.assertThat(output, allOf(OutputCaptureRule.this.matchers));
|
MatcherAssert.assertThat(output, allOf(OutputCaptureRule.this.matchers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ public class GenericBuilderProperties<T extends GenericBuilderProperties<T>> {
|
||||||
return this.number;
|
return this.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public T setNumber(int number) {
|
public T setNumber(int number) {
|
||||||
this.number = number;
|
this.number = number;
|
||||||
return (T) this;
|
return (T) this;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class SingleConstructorMethodConfig {
|
public class SingleConstructorMethodConfig {
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "foo")
|
@ConfigurationProperties(prefix = "foo")
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import org.springframework.boot.configurationsample.MetaConstructorBinding;
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
@MetaConstructorBinding
|
@MetaConstructorBinding
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class TwoConstructorsClassConstructorBindingExample {
|
public class TwoConstructorsClassConstructorBindingExample {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
||||||
|
|
@ -240,10 +240,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||||
|| (this.systemPropertyVariables != null && !this.systemPropertyVariables.isEmpty());
|
|| (this.systemPropertyVariables != null && !this.systemPropertyVariables.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasEnvVariables() {
|
|
||||||
return (this.environmentVariables != null && !this.environmentVariables.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasWorkingDirectorySet() {
|
private boolean hasWorkingDirectorySet() {
|
||||||
return this.workingDirectory != null;
|
return this.workingDirectory != null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ class JacksonJsonParserTests extends AbstractJsonParserTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
void instanceWithSpecificObjectMapper() throws IOException {
|
void instanceWithSpecificObjectMapper() throws IOException {
|
||||||
ObjectMapper objectMapper = spy(new ObjectMapper());
|
ObjectMapper objectMapper = spy(new ObjectMapper());
|
||||||
new JacksonJsonParser(objectMapper).parseMap("{}");
|
new JacksonJsonParser(objectMapper).parseMap("{}");
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class LogbackConfigurationTests {
|
||||||
Appender<ILoggingEvent> appender = context.getLogger("ROOT").getAppender("FILE");
|
Appender<ILoggingEvent> appender = context.getLogger("ROOT").getAppender("FILE");
|
||||||
assertThat(appender).isInstanceOf(RollingFileAppender.class);
|
assertThat(appender).isInstanceOf(RollingFileAppender.class);
|
||||||
RollingPolicy rollingPolicy = ((RollingFileAppender<?>) appender).getRollingPolicy();
|
RollingPolicy rollingPolicy = ((RollingFileAppender<?>) appender).getRollingPolicy();
|
||||||
String fileNamePattern = ((SizeAndTimeBasedRollingPolicy) rollingPolicy).getFileNamePattern();
|
String fileNamePattern = ((SizeAndTimeBasedRollingPolicy<?>) rollingPolicy).getFileNamePattern();
|
||||||
assertThat(fileNamePattern).endsWith("spring.log.%d{yyyy-MM-dd}.%i.gz");
|
assertThat(fileNamePattern).endsWith("spring.log.%d{yyyy-MM-dd}.%i.gz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ class LogbackConfigurationTests {
|
||||||
Appender<ILoggingEvent> appender = context.getLogger("ROOT").getAppender("FILE");
|
Appender<ILoggingEvent> appender = context.getLogger("ROOT").getAppender("FILE");
|
||||||
assertThat(appender).isInstanceOf(RollingFileAppender.class);
|
assertThat(appender).isInstanceOf(RollingFileAppender.class);
|
||||||
RollingPolicy rollingPolicy = ((RollingFileAppender<?>) appender).getRollingPolicy();
|
RollingPolicy rollingPolicy = ((RollingFileAppender<?>) appender).getRollingPolicy();
|
||||||
String fileNamePattern = ((SizeAndTimeBasedRollingPolicy) rollingPolicy).getFileNamePattern();
|
String fileNamePattern = ((SizeAndTimeBasedRollingPolicy<?>) rollingPolicy).getFileNamePattern();
|
||||||
assertThat(fileNamePattern).endsWith("my.log.%d{yyyyMMdd}.%i.gz");
|
assertThat(fileNamePattern).endsWith("my.log.%d{yyyyMMdd}.%i.gz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import org.apache.catalina.startup.Tomcat;
|
||||||
import org.apache.catalina.valves.RemoteIpValve;
|
import org.apache.catalina.valves.RemoteIpValve;
|
||||||
import org.apache.coyote.ProtocolHandler;
|
import org.apache.coyote.ProtocolHandler;
|
||||||
import org.apache.coyote.http11.AbstractHttp11Protocol;
|
import org.apache.coyote.http11.AbstractHttp11Protocol;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
@ -46,7 +47,6 @@ import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFac
|
||||||
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests;
|
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests;
|
||||||
import org.springframework.boot.web.server.PortInUseException;
|
import org.springframework.boot.web.server.PortInUseException;
|
||||||
import org.springframework.boot.web.server.Shutdown;
|
import org.springframework.boot.web.server.Shutdown;
|
||||||
import org.springframework.boot.web.server.Ssl;
|
|
||||||
import org.springframework.boot.web.server.WebServerException;
|
import org.springframework.boot.web.server.WebServerException;
|
||||||
import org.springframework.http.server.reactive.HttpHandler;
|
import org.springframework.http.server.reactive.HttpHandler;
|
||||||
import org.springframework.util.SocketUtils;
|
import org.springframework.util.SocketUtils;
|
||||||
|
|
@ -55,7 +55,6 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.inOrder;
|
import static org.mockito.Mockito.inOrder;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -75,14 +74,16 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
|
||||||
return new TomcatReactiveWebServerFactory(0);
|
return new TomcatReactiveWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
@Disabled("gh-19702")
|
@Disabled("gh-19702")
|
||||||
void compressionOfResponseToGetRequest() {
|
protected void compressionOfResponseToGetRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
@Disabled("gh-19702")
|
@Disabled("gh-19702")
|
||||||
void compressionOfResponseToPostRequest() {
|
protected void compressionOfResponseToPostRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -248,18 +249,9 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
void sslWithInvalidAliasFailsDuringStartup() {
|
protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) {
|
||||||
String keyStore = "classpath:test.jks";
|
assertThatExceptionOfType(WebServerException.class).isThrownBy(call);
|
||||||
String keyPassword = "password";
|
|
||||||
AbstractReactiveWebServerFactory factory = getFactory();
|
|
||||||
Ssl ssl = new Ssl();
|
|
||||||
ssl.setKeyStore(keyStore);
|
|
||||||
ssl.setKeyPassword(keyPassword);
|
|
||||||
ssl.setKeyAlias("test-alias-404");
|
|
||||||
factory.setSsl(ssl);
|
|
||||||
assertThatThrownBy(() -> factory.getWebServer(new EchoHandler()).start())
|
|
||||||
.isInstanceOf(WebServerException.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -65,18 +65,16 @@ import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.jasper.servlet.JspServlet;
|
import org.apache.jasper.servlet.JspServlet;
|
||||||
import org.apache.tomcat.JarScanFilter;
|
import org.apache.tomcat.JarScanFilter;
|
||||||
import org.apache.tomcat.JarScanType;
|
import org.apache.tomcat.JarScanType;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.InOrder;
|
import org.mockito.InOrder;
|
||||||
|
|
||||||
import org.springframework.boot.testsupport.system.CapturedOutput;
|
import org.springframework.boot.testsupport.system.CapturedOutput;
|
||||||
import org.springframework.boot.testsupport.web.servlet.ExampleServlet;
|
|
||||||
import org.springframework.boot.web.server.PortInUseException;
|
import org.springframework.boot.web.server.PortInUseException;
|
||||||
import org.springframework.boot.web.server.Shutdown;
|
import org.springframework.boot.web.server.Shutdown;
|
||||||
import org.springframework.boot.web.server.Ssl;
|
|
||||||
import org.springframework.boot.web.server.WebServerException;
|
import org.springframework.boot.web.server.WebServerException;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
|
||||||
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
|
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
|
||||||
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
|
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
|
||||||
import org.springframework.core.io.ByteArrayResource;
|
import org.springframework.core.io.ByteArrayResource;
|
||||||
|
|
@ -93,7 +91,6 @@ import org.springframework.web.client.RestTemplate;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.inOrder;
|
import static org.mockito.Mockito.inOrder;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -555,14 +552,9 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
|
||||||
this.webServer.start();
|
this.webServer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
void sslWithInvalidAliasFailsDuringStartup() {
|
protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) {
|
||||||
AbstractServletWebServerFactory factory = getFactory();
|
assertThatExceptionOfType(WebServerException.class).isThrownBy(call);
|
||||||
Ssl ssl = getSsl(null, "password", "test-alias-404", "src/test/resources/test.jks");
|
|
||||||
factory.setSsl(ssl);
|
|
||||||
ServletRegistrationBean<ExampleServlet> registration = new ServletRegistrationBean<>(
|
|
||||||
new ExampleServlet(true, false), "/hello");
|
|
||||||
assertThatThrownBy(() -> factory.getWebServer(registration).start()).isInstanceOf(WebServerException.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import io.netty.handler.codec.http.HttpResponse;
|
||||||
import io.netty.handler.ssl.SslContextBuilder;
|
import io.netty.handler.ssl.SslContextBuilder;
|
||||||
import io.netty.handler.ssl.SslProvider;
|
import io.netty.handler.ssl.SslProvider;
|
||||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
@ -178,8 +179,11 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
ssl.setKeyPassword(keyPassword);
|
ssl.setKeyPassword(keyPassword);
|
||||||
ssl.setKeyAlias("test-alias-404");
|
ssl.setKeyAlias("test-alias-404");
|
||||||
factory.setSsl(ssl);
|
factory.setSsl(ssl);
|
||||||
assertThatThrownBy(() -> factory.getWebServer(new EchoHandler()).start())
|
assertThatSslWithInvalidAliasCallFails(() -> factory.getWebServer(new EchoHandler()).start());
|
||||||
.hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'");
|
}
|
||||||
|
|
||||||
|
protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) {
|
||||||
|
assertThatThrownBy(call).hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ReactorClientHttpConnector buildTrustAllSslConnector() {
|
protected ReactorClientHttpConnector buildTrustAllSslConnector() {
|
||||||
|
|
@ -280,7 +284,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void compressionOfResponseToGetRequest() {
|
protected void compressionOfResponseToGetRequest() {
|
||||||
WebClient client = prepareCompressionTest();
|
WebClient client = prepareCompressionTest();
|
||||||
ResponseEntity<Void> response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class))
|
ResponseEntity<Void> response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class))
|
||||||
.block(Duration.ofSeconds(30));
|
.block(Duration.ofSeconds(30));
|
||||||
|
|
@ -288,7 +292,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void compressionOfResponseToPostRequest() {
|
protected void compressionOfResponseToPostRequest() {
|
||||||
WebClient client = prepareCompressionTest();
|
WebClient client = prepareCompressionTest();
|
||||||
ResponseEntity<Void> response = client.post().exchange().flatMap((res) -> res.toEntity(Void.class))
|
ResponseEntity<Void> response = client.post().exchange().flatMap((res) -> res.toEntity(Void.class))
|
||||||
.block(Duration.ofSeconds(30));
|
.block(Duration.ofSeconds(30));
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ import org.apache.http.ssl.SSLContextBuilder;
|
||||||
import org.apache.http.ssl.TrustStrategy;
|
import org.apache.http.ssl.TrustStrategy;
|
||||||
import org.apache.jasper.EmbeddedServletOptions;
|
import org.apache.jasper.EmbeddedServletOptions;
|
||||||
import org.apache.jasper.servlet.JspServlet;
|
import org.apache.jasper.servlet.JspServlet;
|
||||||
|
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assumptions;
|
import org.junit.jupiter.api.Assumptions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
@ -469,8 +470,12 @@ public abstract class AbstractServletWebServerFactoryTests {
|
||||||
factory.setSsl(ssl);
|
factory.setSsl(ssl);
|
||||||
ServletRegistrationBean<ExampleServlet> registration = new ServletRegistrationBean<>(
|
ServletRegistrationBean<ExampleServlet> registration = new ServletRegistrationBean<>(
|
||||||
new ExampleServlet(true, false), "/hello");
|
new ExampleServlet(true, false), "/hello");
|
||||||
assertThatThrownBy(() -> factory.getWebServer(registration).start())
|
ThrowingCallable call = () -> factory.getWebServer(registration).start();
|
||||||
.hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'");
|
assertThatSslWithInvalidAliasCallFails(call);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void assertThatSslWithInvalidAliasCallFails(ThrowingCallable call) {
|
||||||
|
assertThatThrownBy(call).hasStackTraceContaining("Keystore does not contain specified alias 'test-alias-404'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue