Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -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,8 +36,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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,14 +50,12 @@ public class CloudFoundryCustomContextPathExample {
|
||||
return new TomcatServletWebServerFactory() {
|
||||
|
||||
@Override
|
||||
protected void prepareContext(Host host,
|
||||
ServletContextInitializer[] initializers) {
|
||||
protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
|
||||
super.prepareContext(host, initializers);
|
||||
StandardContext child = new StandardContext();
|
||||
child.addLifecycleListener(new Tomcat.FixContextListener());
|
||||
child.setPath("/cloudfoundryapplication");
|
||||
ServletContainerInitializer initializer = getServletContextInitializer(
|
||||
getContextPath());
|
||||
ServletContainerInitializer initializer = getServletContextInitializer(getContextPath());
|
||||
child.addServletContainerInitializer(initializer, Collections.emptySet());
|
||||
child.setCrossContext(true);
|
||||
host.addChild(child);
|
||||
@@ -71,12 +69,9 @@ public class CloudFoundryCustomContextPathExample {
|
||||
Servlet servlet = new GenericServlet() {
|
||||
|
||||
@Override
|
||||
public void service(ServletRequest req, ServletResponse res)
|
||||
throws ServletException, IOException {
|
||||
ServletContext context = req.getServletContext()
|
||||
.getContext(contextPath);
|
||||
context.getRequestDispatcher("/cloudfoundryapplication").forward(req,
|
||||
res);
|
||||
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
|
||||
ServletContext context = req.getServletContext().getContext(contextPath);
|
||||
context.getRequestDispatcher("/cloudfoundryapplication").forward(req, res);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
@@ -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).get(0);
|
||||
}
|
||||
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.
|
||||
@@ -39,8 +39,8 @@ public class TomcatLegacyCookieProcessorExample {
|
||||
// tag::customizer[]
|
||||
@Bean
|
||||
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
|
||||
return (factory) -> factory.addContextCustomizers(
|
||||
(context) -> context.setCookieProcessor(new LegacyCookieProcessor()));
|
||||
return (factory) -> factory
|
||||
.addContextCustomizers((context) -> context.setCookieProcessor(new LegacyCookieProcessor()));
|
||||
}
|
||||
// end::customizer[]
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -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-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 CompleteTwoDataSourcesExample {
|
||||
@Primary
|
||||
@ConfigurationProperties("app.datasource.first.configuration")
|
||||
public HikariDataSource firstDataSource() {
|
||||
return firstDataSourceProperties().initializeDataSourceBuilder()
|
||||
.type(HikariDataSource.class).build();
|
||||
return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -64,8 +63,7 @@ public class CompleteTwoDataSourcesExample {
|
||||
@Bean
|
||||
@ConfigurationProperties("app.datasource.second.configuration")
|
||||
public BasicDataSource secondDataSource() {
|
||||
return secondDataSourceProperties().initializeDataSourceBuilder()
|
||||
.type(BasicDataSource.class).build();
|
||||
return secondDataSourceProperties().initializeDataSourceBuilder().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.
|
||||
@@ -51,8 +51,7 @@ public class ConfigurableDataSourceExample {
|
||||
@Bean
|
||||
@ConfigurationProperties("app.datasource.configuration")
|
||||
public HikariDataSource dataSource(DataSourceProperties properties) {
|
||||
return properties.initializeDataSourceBuilder().type(HikariDataSource.class)
|
||||
.build();
|
||||
return properties.initializeDataSourceBuilder().type(HikariDataSource.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.
|
||||
@@ -54,8 +54,7 @@ public class SimpleTwoDataSourcesExample {
|
||||
@Primary
|
||||
@ConfigurationProperties("app.datasource.first.configuration")
|
||||
public HikariDataSource firstDataSource() {
|
||||
return firstDataSourceProperties().initializeDataSourceBuilder()
|
||||
.type(HikariDataSource.class).build();
|
||||
return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -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-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.
|
||||
@@ -33,10 +33,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class HibernateSecondLevelCacheExample {
|
||||
|
||||
@Bean
|
||||
public HibernatePropertiesCustomizer hibernateSecondLevelCacheCustomizer(
|
||||
JCacheCacheManager cacheManager) {
|
||||
return (properties) -> properties.put(ConfigSettings.CACHE_MANAGER,
|
||||
cacheManager.getCacheManager());
|
||||
public HibernatePropertiesCustomizer hibernateSecondLevelCacheCustomizer(JCacheCacheManager cacheManager) {
|
||||
return (properties) -> properties.put(ConfigSettings.CACHE_MANAGER, cacheManager.getCacheManager());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -25,8 +25,7 @@ public class AdvancedConfigurationExample {
|
||||
|
||||
// tag::configuration[]
|
||||
@TestConfiguration
|
||||
public static class CustomizationConfiguration
|
||||
implements RestDocsRestAssuredConfigurationCustomizer {
|
||||
public static class CustomizationConfiguration implements RestDocsRestAssuredConfigurationCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(RestAssuredRestDocumentationConfigurer configurer) {
|
||||
|
||||
@@ -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,8 @@ public class UserDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void listUsers() {
|
||||
given(this.documentationSpec).filter(document("list-users")).when()
|
||||
.port(this.port).get("/").then().assertThat().statusCode(is(200));
|
||||
given(this.documentationSpec).filter(document("list-users")).when().port(this.port).get("/").then().assertThat()
|
||||
.statusCode(is(200));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ public class AdvancedConfigurationExample {
|
||||
|
||||
// tag::configuration[]
|
||||
@TestConfiguration
|
||||
public static class CustomizationConfiguration
|
||||
implements RestDocsWebTestClientConfigurationCustomizer {
|
||||
public static class CustomizationConfiguration implements RestDocsWebTestClientConfigurationCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(WebTestClientRestDocumentationConfigurer configurer) {
|
||||
|
||||
@@ -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.
|
||||
@@ -41,8 +41,7 @@ public class MockMvcExampleTests {
|
||||
|
||||
@Test
|
||||
public void exampleTest() throws Exception {
|
||||
this.mvc.perform(get("/")).andExpect(status().isOk())
|
||||
.andExpect(content().string("Hello World"));
|
||||
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Hello World"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -37,8 +37,8 @@ public class MockWebTestClientExampleTests {
|
||||
|
||||
@Test
|
||||
public void exampleTest() {
|
||||
this.webClient.get().uri("/").exchange().expectStatus().isOk()
|
||||
.expectBody(String.class).isEqualTo("Hello World");
|
||||
this.webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.isEqualTo("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,8 +36,8 @@ public class RandomPortWebTestClientExampleTests {
|
||||
|
||||
@Test
|
||||
public void exampleTest() {
|
||||
this.webClient.get().uri("/").exchange().expectStatus().isOk()
|
||||
.expectBody(String.class).isEqualTo("Hello World");
|
||||
this.webClient.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.isEqualTo("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,22 +45,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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user