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

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

@ -208,11 +208,13 @@ public class CloudFoundryActuatorAutoConfigurationTests {
}
@Test
public void allEndpointsAvailableUnderCloudFoundryWithoutEnablingWeb() throws Exception {
public void allEndpointsAvailableUnderCloudFoundryWithoutEnablingWeb()
throws Exception {
this.context.register(TestConfiguration.class);
this.context.refresh();
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.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,
Class<?> beanType, Class<?> endpointClass) {
EndpointInfo<T> endpoint = endpoints.get(endpointClass);
Assert.state(endpoint != null, () -> "Invalid extension '" + beanType.getName()
+ "': no endpoint found with type '" + endpointClass.getName() + "'");
Assert.state(endpoint != null,
() -> "Invalid extension '" + beanType.getName()
+ "': no endpoint found with type '" + endpointClass.getName()
+ "'");
return endpoint;
}

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

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

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

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

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

@ -208,7 +208,8 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
Registration registration = new Registration();
properties.getRegistration().put("missing", registration);
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);
}

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

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

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

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

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

@ -40,7 +40,8 @@ import org.gradle.process.JavaExecSpec;
*/
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")
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
*/

@ -92,14 +92,14 @@ public class PackagingDocumentationTests {
@Test
public void springBootDslMainClass() throws IOException {
this.gradleBuild
.script("src/main/gradle/packaging/spring-boot-dsl-main-class.gradle")
.build("bootJar");
.script("src/main/gradle/packaging/spring-boot-dsl-main-class.gradle")
.build("bootJar");
File file = new File(this.gradleBuild.getProjectDir(),
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
assertThat(file).isFile();
try (JarFile jar = new JarFile(file)) {
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
.script("src/main/gradle/running/spring-boot-dsl-main-class-name.gradle")
.build("configuredMainClass").getOutput())
.contains("com.example.ExampleApplication");
.contains("com.example.ExampleApplication");
}
@Test

@ -120,9 +120,9 @@ public abstract class AbstractBootArchiveIntegrationTests {
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
try (JarFile jarFile = new JarFile(
new File(this.gradleBuild.getProjectDir(), "build/libs")
.listFiles()[0])) {
.listFiles()[0])) {
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();
XPath xpath = xPathFactory.newXPath();
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;
}
catch (Exception ex) {

@ -43,14 +43,14 @@ public class RunArgumentsTests {
@Test
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).containsOnly("foo", "bar");
}
@Test
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).containsOnly("foo", "", "bar");
}

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

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

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

Loading…
Cancel
Save