pull/10764/head
Andy Wilkinson 7 years ago
parent 7065a41711
commit a256602c7b

@ -85,8 +85,8 @@ public class CloudFoundryActuatorAutoConfiguration {
endpointMediaTypes); endpointMediaTypes);
return new CloudFoundryWebEndpointServletHandlerMapping( return new CloudFoundryWebEndpointServletHandlerMapping(
new EndpointMapping("/cloudfoundryapplication"), new EndpointMapping("/cloudfoundryapplication"),
endpointDiscoverer.discoverEndpoints(), endpointMediaTypes, getCorsConfiguration(), endpointDiscoverer.discoverEndpoints(), endpointMediaTypes,
getSecurityInterceptor(builder, environment)); getCorsConfiguration(), getSecurityInterceptor(builder, environment));
} }
private CloudFoundrySecurityInterceptor getSecurityInterceptor( private CloudFoundrySecurityInterceptor getSecurityInterceptor(

@ -208,11 +208,13 @@ public class CloudFoundryActuatorAutoConfigurationTests {
} }
@Test @Test
public void allEndpointsAvailableUnderCloudFoundryWithoutEnablingWeb() throws Exception { public void allEndpointsAvailableUnderCloudFoundryWithoutEnablingWeb()
throws Exception {
this.context.register(TestConfiguration.class); this.context.register(TestConfiguration.class);
this.context.refresh(); this.context.refresh();
CloudFoundryWebEndpointServletHandlerMapping handlerMapping = getHandlerMapping(); CloudFoundryWebEndpointServletHandlerMapping handlerMapping = getHandlerMapping();
List<EndpointInfo<WebEndpointOperation>> endpoints = (List<EndpointInfo<WebEndpointOperation>>) handlerMapping.getEndpoints(); List<EndpointInfo<WebEndpointOperation>> endpoints = (List<EndpointInfo<WebEndpointOperation>>) handlerMapping
.getEndpoints();
assertThat(endpoints.size()).isEqualTo(1); assertThat(endpoints.size()).isEqualTo(1);
assertThat(endpoints.get(0).getId()).isEqualTo("test"); assertThat(endpoints.get(0).getId()).isEqualTo("test");
} }

@ -163,8 +163,10 @@ public abstract class AnnotationEndpointDiscoverer<T extends Operation, K>
private EndpointInfo<T> getEndpointInfo(Map<Class<?>, EndpointInfo<T>> endpoints, private EndpointInfo<T> getEndpointInfo(Map<Class<?>, EndpointInfo<T>> endpoints,
Class<?> beanType, Class<?> endpointClass) { Class<?> beanType, Class<?> endpointClass) {
EndpointInfo<T> endpoint = endpoints.get(endpointClass); EndpointInfo<T> endpoint = endpoints.get(endpointClass);
Assert.state(endpoint != null, () -> "Invalid extension '" + beanType.getName() Assert.state(endpoint != null,
+ "': no endpoint found with type '" + endpointClass.getName() + "'"); () -> "Invalid extension '" + beanType.getName()
+ "': no endpoint found with type '" + endpointClass.getName()
+ "'");
return endpoint; return endpoint;
} }

@ -75,8 +75,8 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
@ConditionalOnMissingBean(RedisConnectionFactory.class) @ConditionalOnMissingBean(RedisConnectionFactory.class)
public LettuceConnectionFactory redisConnectionFactory( public LettuceConnectionFactory redisConnectionFactory(
ClientResources clientResources) throws UnknownHostException { ClientResources clientResources) throws UnknownHostException {
LettuceClientConfiguration clientConfig = getLettuceClientConfiguration(clientResources, LettuceClientConfiguration clientConfig = getLettuceClientConfiguration(
this.properties.getLettuce().getPool()); clientResources, this.properties.getLettuce().getPool());
return createLettuceConnectionFactory(clientConfig); return createLettuceConnectionFactory(clientConfig);
} }

@ -41,8 +41,7 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager;
* @author Madhura Bhave * @author Madhura Bhave
*/ */
@Configuration @Configuration
@ConditionalOnClass({ AuthenticationManager.class, @ConditionalOnClass({ AuthenticationManager.class, EnableWebSecurity.class })
EnableWebSecurity.class })
@EnableConfigurationProperties(SecurityProperties.class) @EnableConfigurationProperties(SecurityProperties.class)
@Import({ SpringBootWebSecurityConfiguration.class, WebSecurityEnablerConfiguration.class, @Import({ SpringBootWebSecurityConfiguration.class, WebSecurityEnablerConfiguration.class,
AuthenticationManagerConfiguration.class, SecurityDataConfiguration.class }) AuthenticationManagerConfiguration.class, SecurityDataConfiguration.class })

@ -70,10 +70,12 @@ final class OAuth2ClientPropertiesRegistrationAdapter {
private static Builder getBuilder(String registrationId, String configuredProviderId, private static Builder getBuilder(String registrationId, String configuredProviderId,
Map<String, Provider> providers) { Map<String, Provider> providers) {
String providerId = (configuredProviderId == null ? registrationId : configuredProviderId); String providerId = (configuredProviderId == null ? registrationId
: configuredProviderId);
CommonOAuth2Provider provider = getCommonProvider(providerId); CommonOAuth2Provider provider = getCommonProvider(providerId);
if (provider == null && !providers.containsKey(providerId)) { if (provider == null && !providers.containsKey(providerId)) {
throw new IllegalStateException(getErrorMessage(configuredProviderId, registrationId)); throw new IllegalStateException(
getErrorMessage(configuredProviderId, registrationId));
} }
Builder builder = (provider != null ? provider.getBuilder(registrationId) Builder builder = (provider != null ? provider.getBuilder(registrationId)
: ClientRegistration.withRegistrationId(registrationId)); : ClientRegistration.withRegistrationId(registrationId));
@ -83,9 +85,12 @@ final class OAuth2ClientPropertiesRegistrationAdapter {
return builder; return builder;
} }
private static String getErrorMessage(String configuredProviderId, String registrationId) { private static String getErrorMessage(String configuredProviderId,
return (configuredProviderId == null ? "Provider ID must be specified for client registration '" + registrationId + "'" : String registrationId) {
"Unknown provider ID '" + configuredProviderId + "'"); return (configuredProviderId == null
? "Provider ID must be specified for client registration '"
+ registrationId + "'"
: "Unknown provider ID '" + configuredProviderId + "'");
} }
private static Builder getBuilder(Builder builder, Provider provider) { private static Builder getBuilder(Builder builder, Provider provider) {

@ -55,31 +55,31 @@ public class CustomHibernateJpaAutoConfigurationTests {
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class, .withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class)); HibernateJpaAutoConfiguration.class));
@Test @Test
public void namingStrategyDelegatorTakesPrecedence() { public void namingStrategyDelegatorTakesPrecedence() {
this.contextRunner this.contextRunner
.withPropertyValues( .withPropertyValues(
"spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:" "spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
+ "org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator" + "org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator")
).run((context) -> { .run((context) -> {
JpaProperties bean = context.getBean(JpaProperties.class); JpaProperties bean = context.getBean(JpaProperties.class);
Map<String, String> hibernateProperties = bean Map<String, String> hibernateProperties = bean
.getHibernateProperties("create-drop"); .getHibernateProperties("create-drop");
assertThat(hibernateProperties.get("hibernate.ejb.naming_strategy")).isNull(); assertThat(hibernateProperties.get("hibernate.ejb.naming_strategy"))
}); .isNull();
});
} }
@Test @Test
public void defaultDatabaseForH2() { public void defaultDatabaseForH2() {
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues("spring.datasource.url:jdbc:h2:mem:testdb",
"spring.datasource.url:jdbc:h2:mem:testdb",
"spring.datasource.initialize:false").run((context) -> { "spring.datasource.initialize:false").run((context) -> {
HibernateJpaVendorAdapter bean = context HibernateJpaVendorAdapter bean = context
.getBean(HibernateJpaVendorAdapter.class); .getBean(HibernateJpaVendorAdapter.class);
Database database = (Database) ReflectionTestUtils.getField(bean, "database"); Database database = (Database) ReflectionTestUtils.getField(bean,
assertThat(database).isEqualTo(Database.H2); "database");
}); assertThat(database).isEqualTo(Database.H2);
});
} }
@Configuration @Configuration

@ -258,8 +258,7 @@ public class HibernateJpaAutoConfigurationTests
@Test @Test
public void customResourceMapping() { public void customResourceMapping() {
contextRunner() contextRunner().withClassLoader(new HideDataScriptClassLoader())
.withClassLoader(new HideDataScriptClassLoader())
.withPropertyValues( .withPropertyValues(
"spring.datasource.data:classpath:/db/non-annotated-data.sql", "spring.datasource.data:classpath:/db/non-annotated-data.sql",
"spring.jpa.mapping-resources=META-INF/mappings/non-annotated.xml") "spring.jpa.mapping-resources=META-INF/mappings/non-annotated.xml")

@ -208,7 +208,8 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
Registration registration = new Registration(); Registration registration = new Registration();
properties.getRegistration().put("missing", registration); properties.getRegistration().put("missing", registration);
this.thrown.expect(IllegalStateException.class); this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Provider ID must be specified for client registration 'missing'"); this.thrown.expectMessage(
"Provider ID must be specified for client registration 'missing'");
OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties); OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties);
} }

@ -154,7 +154,8 @@ public class OAuth2WebSecurityConfigurationTests {
} }
private ClientRegistration getClientRegistration(String id, String userInfoUri) { private ClientRegistration getClientRegistration(String id, String userInfoUri) {
ClientRegistration.Builder builder = ClientRegistration.withRegistrationId(id); ClientRegistration.Builder builder = ClientRegistration
.withRegistrationId(id);
builder.clientName("foo").clientId("foo") builder.clientName("foo").clientId("foo")
.clientAuthenticationMethod( .clientAuthenticationMethod(
org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC) org.springframework.security.oauth2.core.ClientAuthenticationMethod.BASIC)

@ -103,8 +103,8 @@ public class ReactiveSecurityAutoConfigurationTests {
TestConfig.class) TestConfig.class)
.withConfiguration( .withConfiguration(
AutoConfigurations.of(ReactiveSecurityAutoConfiguration.class)) AutoConfigurations.of(ReactiveSecurityAutoConfiguration.class))
.run((context) -> assertThat(context).getBean(ReactiveUserDetailsService.class) .run((context) -> assertThat(context)
.isNull()); .getBean(ReactiveUserDetailsService.class).isNull());
} }
@Configuration @Configuration

@ -93,8 +93,9 @@ public final class CommandLineInvoker {
} }
File bin = new File(unpacked.listFiles()[0], "bin"); File bin = new File(unpacked.listFiles()[0], "bin");
File launchScript = new File(bin, isWindows() ? "spring.bat" : "spring"); File launchScript = new File(bin, isWindows() ? "spring.bat" : "spring");
Assert.state(launchScript.exists() && launchScript.isFile(), () -> Assert.state(launchScript.exists() && launchScript.isFile(),
"Could not find CLI launch script " + launchScript.getAbsolutePath()); () -> "Could not find CLI launch script "
+ launchScript.getAbsolutePath());
return launchScript; return launchScript;
} }

@ -39,8 +39,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(properties = "spring.main.web-application-type=reactive", classes = { WebTestClientSpringBootTestIntegrationTests.TestConfiguration.class, @SpringBootTest(properties = "spring.main.web-application-type=reactive", classes = {
ExampleWebFluxApplication.class }) WebTestClientSpringBootTestIntegrationTests.TestConfiguration.class,
ExampleWebFluxApplication.class })
@AutoConfigureWebTestClient @AutoConfigureWebTestClient
public class WebTestClientSpringBootTestIntegrationTests { public class WebTestClientSpringBootTestIntegrationTests {
@ -71,7 +72,8 @@ public class WebTestClientSpringBootTestIntegrationTests {
@Configuration @Configuration
static class TestConfiguration { static class TestConfiguration {
@Bean @Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception { public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http)
throws Exception {
http.authorizeExchange().anyExchange().permitAll(); http.authorizeExchange().anyExchange().permitAll();
return http.build(); return http.build();
} }

@ -109,8 +109,8 @@ class DefinitionsParser {
private void addDefinition(AnnotatedElement element, Definition definition, private void addDefinition(AnnotatedElement element, Definition definition,
String type) { String type) {
boolean isNewDefinition = this.definitions.add(definition); boolean isNewDefinition = this.definitions.add(definition);
Assert.state(isNewDefinition, () -> Assert.state(isNewDefinition,
"Duplicate " + type + " definition " + definition); () -> "Duplicate " + type + " definition " + definition);
if (element instanceof Field) { if (element instanceof Field) {
Field field = (Field) element; Field field = (Field) element;
this.definitionFields.put(definition, field); this.definitionFields.put(definition, field);

@ -40,7 +40,8 @@ import org.gradle.process.JavaExecSpec;
*/ */
public class BootRun extends DefaultTask { public class BootRun extends DefaultTask {
private final PropertyState<String> mainClassName = getProject().property(String.class); private final PropertyState<String> mainClassName = getProject()
.property(String.class);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private final PropertyState<List<String>> jvmArgs = (PropertyState<List<String>>) (Object) getProject() private final PropertyState<List<String>> jvmArgs = (PropertyState<List<String>>) (Object) getProject()
@ -90,7 +91,8 @@ public class BootRun extends DefaultTask {
} }
/** /**
* Sets the name of the main class to be executed using the given {@code mainClassNameProvider}. * Sets the name of the main class to be executed using the given
* {@code mainClassNameProvider}.
* *
* @param mainClassNameProvider provider of the main class name * @param mainClassNameProvider provider of the main class name
*/ */

@ -92,14 +92,14 @@ public class PackagingDocumentationTests {
@Test @Test
public void springBootDslMainClass() throws IOException { public void springBootDslMainClass() throws IOException {
this.gradleBuild this.gradleBuild
.script("src/main/gradle/packaging/spring-boot-dsl-main-class.gradle") .script("src/main/gradle/packaging/spring-boot-dsl-main-class.gradle")
.build("bootJar"); .build("bootJar");
File file = new File(this.gradleBuild.getProjectDir(), File file = new File(this.gradleBuild.getProjectDir(),
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar"); "build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
assertThat(file).isFile(); assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) { try (JarFile jar = new JarFile(file)) {
assertThat(jar.getManifest().getMainAttributes().getValue("Start-Class")) assertThat(jar.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.ExampleApplication"); .isEqualTo("com.example.ExampleApplication");
} }
} }

@ -56,7 +56,7 @@ public class RunningDocumentationTests {
assertThat(this.gradleBuild assertThat(this.gradleBuild
.script("src/main/gradle/running/spring-boot-dsl-main-class-name.gradle") .script("src/main/gradle/running/spring-boot-dsl-main-class-name.gradle")
.build("configuredMainClass").getOutput()) .build("configuredMainClass").getOutput())
.contains("com.example.ExampleApplication"); .contains("com.example.ExampleApplication");
} }
@Test @Test

@ -120,9 +120,9 @@ public abstract class AbstractBootArchiveIntegrationTests {
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS); .getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile( try (JarFile jarFile = new JarFile(
new File(this.gradleBuild.getProjectDir(), "build/libs") new File(this.gradleBuild.getProjectDir(), "build/libs")
.listFiles()[0])) { .listFiles()[0])) {
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")) assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
.isEqualTo("com.example.CustomMain"); .isEqualTo("com.example.CustomMain");
} }
} }

@ -196,7 +196,8 @@ public class GradleBuild implements TestRule {
XPathFactory xPathFactory = XPathFactory.newInstance(); XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath(); XPath xpath = xPathFactory.newXPath();
XPathExpression expr = xpath.compile(expression); XPathExpression expr = xpath.compile(expression);
String version = expr.evaluate(new InputSource(new FileReader(".flattened-pom.xml"))); String version = expr
.evaluate(new InputSource(new FileReader(".flattened-pom.xml")));
return version; return version;
} }
catch (Exception ex) { catch (Exception ex) {

@ -43,14 +43,14 @@ public class RunArgumentsTests {
@Test @Test
public void parseArrayContainingNullValue() { public void parseArrayContainingNullValue() {
String[] args = new RunArguments(new String[]{"foo", null, "bar"}).asArray(); String[] args = new RunArguments(new String[] { "foo", null, "bar" }).asArray();
assertThat(args).isNotNull(); assertThat(args).isNotNull();
assertThat(args).containsOnly("foo", "bar"); assertThat(args).containsOnly("foo", "bar");
} }
@Test @Test
public void parseArrayContainingEmptyValue() { public void parseArrayContainingEmptyValue() {
String[] args = new RunArguments(new String[]{"foo", "", "bar"}).asArray(); String[] args = new RunArguments(new String[] { "foo", "", "bar" }).asArray();
assertThat(args).isNotNull(); assertThat(args).isNotNull();
assertThat(args).containsOnly("foo", "", "bar"); assertThat(args).containsOnly("foo", "", "bar");
} }

@ -91,8 +91,8 @@ public class ApplicationTemp {
Assert.state(StringUtils.hasLength(property), "No 'java.io.tmpdir' property set"); Assert.state(StringUtils.hasLength(property), "No 'java.io.tmpdir' property set");
File file = new File(property); File file = new File(property);
Assert.state(file.exists(), () -> "Temp directory" + file + " does not exist"); Assert.state(file.exists(), () -> "Temp directory" + file + " does not exist");
Assert.state(file.isDirectory(), () -> "Temp location " + file Assert.state(file.isDirectory(),
+ " is not a directory"); () -> "Temp location " + file + " is not a directory");
return file; return file;
} }

@ -53,9 +53,9 @@ import org.springframework.validation.Validator;
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Madhura Bhave * @author Madhura Bhave
*/ */
public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProcessor, public class ConfigurationPropertiesBindingPostProcessor
BeanFactoryAware, EnvironmentAware, ApplicationContextAware, InitializingBean, implements BeanPostProcessor, BeanFactoryAware, EnvironmentAware,
PriorityOrdered { ApplicationContextAware, InitializingBean, PriorityOrdered {
private static final Log logger = LogFactory private static final Log logger = LogFactory
.getLog(ConfigurationPropertiesBindingPostProcessor.class); .getLog(ConfigurationPropertiesBindingPostProcessor.class);

@ -171,9 +171,10 @@ public class EntityManagerFactoryBuilder {
/** /**
* The mapping resources (equivalent to {@code <mapping-file>} entries in * The mapping resources (equivalent to {@code <mapping-file>} entries in
* {@code persistence.xml}) for the persistence unit. * {@code persistence.xml}) for the persistence unit.
* <p>Note that mapping resources must be relative to the classpath root, * <p>
* e.g. "META-INF/mappings.xml" or "com/mycompany/repository/mappings.xml", * Note that mapping resources must be relative to the classpath root, e.g.
* so that they can be loaded through {@code ClassLoader.getResource}. * "META-INF/mappings.xml" or "com/mycompany/repository/mappings.xml", so that
* they can be loaded through {@code ClassLoader.getResource}.
* @param mappingResources the mapping resources to use * @param mappingResources the mapping resources to use
* @return the builder for fluent usage * @return the builder for fluent usage
*/ */

Loading…
Cancel
Save