Upgrade to spring-javaformat 0.0.11
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,7 @@ public class ExitCodeApplication {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.exit(SpringApplication
|
||||
.exit(SpringApplication.run(ExitCodeApplication.class, args)));
|
||||
System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeApplication.class, args)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,8 +37,7 @@ public class EnvironmentPostProcessorExample implements EnvironmentPostProcessor
|
||||
private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment,
|
||||
SpringApplication application) {
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
Resource path = new ClassPathResource("com/example/myapp/config.yml");
|
||||
PropertySource<?> propertySource = loadYaml(path);
|
||||
environment.getPropertySources().addLast(propertySource);
|
||||
@@ -52,8 +51,7 @@ public class EnvironmentPostProcessorExample implements EnvironmentPostProcessor
|
||||
return this.loader.load("custom-resource", path, null);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to load yaml configuration from " + path, ex);
|
||||
throw new IllegalStateException("Failed to load yaml configuration from " + path, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,8 +51,7 @@ public class TomcatLegacyCookieProcessorExample {
|
||||
|
||||
@Override
|
||||
public void customize(Context context) {
|
||||
context.setCookieProcessor(
|
||||
new LegacyCookieProcessor());
|
||||
context.setCookieProcessor(new LegacyCookieProcessor());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,8 +35,7 @@ public class HibernateSearchElasticsearchExample {
|
||||
* {@link EntityManagerFactory} beans depend on the {@code elasticsearchClient} bean.
|
||||
*/
|
||||
@Configuration
|
||||
static class ElasticsearchJpaDependencyConfiguration
|
||||
extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
static class ElasticsearchJpaDependencyConfiguration extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
ElasticsearchJpaDependencyConfiguration() {
|
||||
super("elasticsearchClient");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,8 +51,7 @@ public class ConfigurableDataSourceExample {
|
||||
@Bean
|
||||
@ConfigurationProperties("app.datasource")
|
||||
public HikariDataSource dataSource(DataSourceProperties properties) {
|
||||
return (HikariDataSource) properties.initializeDataSourceBuilder()
|
||||
.type(HikariDataSource.class).build();
|
||||
return (HikariDataSource) properties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
|
||||
}
|
||||
// end::configuration[]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,8 +42,7 @@ public class SimpleDataSourceExample {
|
||||
@Bean
|
||||
@ConfigurationProperties("app.datasource")
|
||||
public HikariDataSource dataSource() {
|
||||
return (HikariDataSource) DataSourceBuilder.create()
|
||||
.type(HikariDataSource.class).build();
|
||||
return (HikariDataSource) DataSourceBuilder.create().type(HikariDataSource.class).build();
|
||||
}
|
||||
// end::configuration[]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,8 +59,7 @@ public class SimpleTwoDataSourcesExample {
|
||||
@Bean
|
||||
@ConfigurationProperties("app.datasource.bar")
|
||||
public BasicDataSource barDataSource() {
|
||||
return (BasicDataSource) DataSourceBuilder.create()
|
||||
.type(BasicDataSource.class).build();
|
||||
return (BasicDataSource) DataSourceBuilder.create().type(BasicDataSource.class).build();
|
||||
}
|
||||
// end::configuration[]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,7 @@ public class JerseySetStatusOverSendErrorExample {
|
||||
|
||||
public JerseyConfig() {
|
||||
register(Endpoint.class);
|
||||
setProperties(Collections.singletonMap(
|
||||
"jersey.config.server.response.setStatusOverSendError", true));
|
||||
setProperties(Collections.singletonMap("jersey.config.server.response.setStatusOverSendError", true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,8 +52,7 @@ public class KafkaSpecialProducerConsumerConfigExample {
|
||||
@Bean
|
||||
public ProducerFactory<?, ?> kafkaProducerFactory(KafkaProperties properties) {
|
||||
Map<String, Object> producerProperties = properties.buildProducerProperties();
|
||||
producerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG,
|
||||
MyProducerMetricsReporter.class);
|
||||
producerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG, MyProducerMetricsReporter.class);
|
||||
return new DefaultKafkaProducerFactory<Object, Object>(producerProperties);
|
||||
}
|
||||
|
||||
@@ -65,8 +64,7 @@ public class KafkaSpecialProducerConsumerConfigExample {
|
||||
@Bean
|
||||
public ConsumerFactory<?, ?> kafkaConsumerFactory(KafkaProperties properties) {
|
||||
Map<String, Object> consumerProperties = properties.buildConsumerProperties();
|
||||
consumerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG,
|
||||
MyConsumerMetricsReporter.class);
|
||||
consumerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG, MyConsumerMetricsReporter.class);
|
||||
return new DefaultKafkaConsumerFactory<Object, Object>(consumerProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,22 +44,19 @@ public class RestTemplateProxyCustomizationExample {
|
||||
@Override
|
||||
public void customize(RestTemplate restTemplate) {
|
||||
HttpHost proxy = new HttpHost("proxy.example.com");
|
||||
HttpClient httpClient = HttpClientBuilder.create()
|
||||
.setRoutePlanner(new DefaultProxyRoutePlanner(proxy) {
|
||||
HttpClient httpClient = HttpClientBuilder.create().setRoutePlanner(new DefaultProxyRoutePlanner(proxy) {
|
||||
|
||||
@Override
|
||||
public HttpHost determineProxy(HttpHost target,
|
||||
HttpRequest request, HttpContext context)
|
||||
throws HttpException {
|
||||
if (target.getHostName().equals("192.168.0.5")) {
|
||||
return null;
|
||||
}
|
||||
return super.determineProxy(target, request, context);
|
||||
}
|
||||
@Override
|
||||
public HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context)
|
||||
throws HttpException {
|
||||
if (target.getHostName().equals("192.168.0.5")) {
|
||||
return null;
|
||||
}
|
||||
return super.determineProxy(target, request, context);
|
||||
}
|
||||
|
||||
}).build();
|
||||
restTemplate.setRequestFactory(
|
||||
new HttpComponentsClientHttpRequestFactory(httpClient));
|
||||
}).build();
|
||||
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,8 +35,7 @@ public class EnvironmentPostProcessorExampleTests {
|
||||
@Test
|
||||
public void applyEnvironmentPostProcessor() {
|
||||
assertThat(this.environment.containsProperty("test.foo.bar")).isFalse();
|
||||
new EnvironmentPostProcessorExample().postProcessEnvironment(this.environment,
|
||||
new SpringApplication());
|
||||
new EnvironmentPostProcessorExample().postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertThat(this.environment.containsProperty("test.foo.bar")).isTrue();
|
||||
assertThat(this.environment.getProperty("test.foo.bar")).isEqualTo("value");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,10 +40,9 @@ public class TomcatLegacyCookieProcessorExampleTests {
|
||||
public void cookieProcessorIsCustomized() {
|
||||
EmbeddedWebApplicationContext applicationContext = (EmbeddedWebApplicationContext) new SpringApplication(
|
||||
TestConfiguration.class, LegacyCookieProcessorConfiguration.class).run();
|
||||
Context context = (Context) ((TomcatEmbeddedServletContainer) applicationContext
|
||||
.getEmbeddedServletContainer()).getTomcat().getHost().findChildren()[0];
|
||||
assertThat(context.getCookieProcessor())
|
||||
.isInstanceOf(LegacyCookieProcessor.class);
|
||||
Context context = (Context) ((TomcatEmbeddedServletContainer) applicationContext.getEmbeddedServletContainer())
|
||||
.getTomcat().getHost().findChildren()[0];
|
||||
assertThat(context.getCookieProcessor()).isInstanceOf(LegacyCookieProcessor.class);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,8 +48,7 @@ public class BasicDataSourceExampleTests {
|
||||
public void validateConfiguration() throws SQLException {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(1);
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.isEqualTo("jdbc:h2:mem:basic");
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL()).isEqualTo("jdbc:h2:mem:basic");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,12 +49,9 @@ public class CompleteTwoDataSourcesExampleTests {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.startsWith("jdbc:h2:mem:");
|
||||
DataSource barDataSource = this.context.getBean("barDataSource",
|
||||
DataSource.class);
|
||||
assertThat(barDataSource.getConnection().getMetaData().getURL())
|
||||
.startsWith("jdbc:h2:mem:");
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL()).startsWith("jdbc:h2:mem:");
|
||||
DataSource barDataSource = this.context.getBean("barDataSource", DataSource.class);
|
||||
assertThat(barDataSource.getConnection().getMetaData().getURL()).startsWith("jdbc:h2:mem:");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,9 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(
|
||||
properties = { "app.datasource.url=jdbc:h2:mem:configurable;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.maximum-pool-size=42" })
|
||||
@SpringBootTest(properties = { "app.datasource.url=jdbc:h2:mem:configurable;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.maximum-pool-size=42" })
|
||||
@Import(ConfigurableDataSourceExample.ConfigurableDataSourceConfiguration.class)
|
||||
public class ConfigurableDataSourceExampleTests {
|
||||
|
||||
@@ -51,8 +50,7 @@ public class ConfigurableDataSourceExampleTests {
|
||||
public void validateConfiguration() throws SQLException {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(1);
|
||||
HikariDataSource dataSource = this.context.getBean(HikariDataSource.class);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.isEqualTo("jdbc:h2:mem:configurable");
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL()).isEqualTo("jdbc:h2:mem:configurable");
|
||||
assertThat(dataSource.getMaximumPoolSize()).isEqualTo(42);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,9 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(
|
||||
properties = { "app.datasource.jdbc-url=jdbc:h2:mem:simple;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.maximum-pool-size=42" })
|
||||
@SpringBootTest(properties = { "app.datasource.jdbc-url=jdbc:h2:mem:simple;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.maximum-pool-size=42" })
|
||||
@Import(SimpleDataSourceExample.SimpleDataSourceConfiguration.class)
|
||||
public class SimpleDataSourceExampleTests {
|
||||
|
||||
@@ -51,8 +50,7 @@ public class SimpleDataSourceExampleTests {
|
||||
public void validateConfiguration() throws SQLException {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(1);
|
||||
HikariDataSource dataSource = this.context.getBean(HikariDataSource.class);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.isEqualTo("jdbc:h2:mem:simple");
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL()).isEqualTo("jdbc:h2:mem:simple");
|
||||
assertThat(dataSource.getMaximumPoolSize()).isEqualTo(42);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,8 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = { "app.datasource.bar.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.bar.max-total=42" })
|
||||
@SpringBootTest(
|
||||
properties = { "app.datasource.bar.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1", "app.datasource.bar.max-total=42" })
|
||||
@Import(SimpleTwoDataSourcesExample.SimpleDataSourcesConfiguration.class)
|
||||
public class SimpleTwoDataSourcesExampleTests {
|
||||
|
||||
@@ -51,10 +51,8 @@ public class SimpleTwoDataSourcesExampleTests {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.startsWith("jdbc:h2:mem:");
|
||||
BasicDataSource barDataSource = this.context.getBean("barDataSource",
|
||||
BasicDataSource.class);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL()).startsWith("jdbc:h2:mem:");
|
||||
BasicDataSource barDataSource = this.context.getBean("barDataSource", BasicDataSource.class);
|
||||
assertThat(barDataSource.getUrl()).isEqualTo("jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1");
|
||||
assertThat(barDataSource.getMaxTotal()).isEqualTo(42);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,9 +36,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SpringBootConfiguration
|
||||
@ImportAutoConfiguration({ EmbeddedServletContainerAutoConfiguration.class,
|
||||
ServerPropertiesAutoConfiguration.class, DispatcherServletAutoConfiguration.class,
|
||||
WebMvcAutoConfiguration.class, JacksonAutoConfiguration.class,
|
||||
@ImportAutoConfiguration({ EmbeddedServletContainerAutoConfiguration.class, ServerPropertiesAutoConfiguration.class,
|
||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class, JacksonAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class })
|
||||
class SampleWebClientConfiguration {
|
||||
|
||||
@@ -47,9 +46,7 @@ class SampleWebClientConfiguration {
|
||||
|
||||
@RequestMapping("/example")
|
||||
public ResponseEntity<String> example() {
|
||||
return ResponseEntity.ok()
|
||||
.location(URI.create("https://other.example.com/example"))
|
||||
.body("test");
|
||||
return ResponseEntity.ok().location(URI.create("https://other.example.com/example")).body("test");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* * Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,8 +45,7 @@ public class SampleWebClientTests {
|
||||
|
||||
@Test
|
||||
public void testRequest() {
|
||||
HttpHeaders headers = this.template.getForEntity("/example", String.class)
|
||||
.getHeaders();
|
||||
HttpHeaders headers = this.template.getForEntity("/example", String.class).getHeaders();
|
||||
assertThat(headers.getLocation()).hasHost("other.example.com");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user