Upgrade to Spring Boot 2.0.0

This commit upgrades to Spring Boot 2.0.0.

Please note that this commit does not change metrics names to use new
features of Micrometer yet (see gh-526)

Closes gh-611
This commit is contained in:
Stephane Nicoll
2018-02-27 14:43:53 +01:00
parent 5629f95da2
commit fe7650f2c8
29 changed files with 216 additions and 290 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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,7 +35,7 @@ import org.mockito.ArgumentMatcher;
import org.springframework.context.ApplicationEventPublisher;
import static org.mockito.Matchers.argThat;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -105,15 +105,17 @@ public abstract class AbstractProjectGeneratorTests {
}
protected void verifyProjectSuccessfulEventFor(ProjectRequest request) {
verify(eventPublisher, times(1)).publishEvent(argThat(new ProjectGeneratedEventMatcher(request)));
verify(eventPublisher, times(1)).publishEvent(
argThat(new ProjectGeneratedEventMatcher(request)));
}
protected void verifyProjectFailedEventFor(ProjectRequest request, Exception ex) {
verify(eventPublisher, times(1)).publishEvent(argThat(new ProjectFailedEventMatcher(request, ex)));
verify(eventPublisher, times(1)).publishEvent(
argThat(new ProjectFailedEventMatcher(request, ex)));
}
protected static class ProjectGeneratedEventMatcher
extends ArgumentMatcher<ProjectGeneratedEvent> {
implements ArgumentMatcher<ProjectGeneratedEvent> {
private final ProjectRequest request;
@@ -122,16 +124,16 @@ public abstract class AbstractProjectGeneratorTests {
}
@Override
public boolean matches(Object argument) {
ProjectGeneratedEvent event = (ProjectGeneratedEvent) argument;
public boolean matches(ProjectGeneratedEvent event) {
return request.equals(event.getProjectRequest());
}
}
private static class ProjectFailedEventMatcher
extends ArgumentMatcher<ProjectFailedEvent> {
implements ArgumentMatcher<ProjectFailedEvent> {
private final ProjectRequest request;
private final Exception cause;
ProjectFailedEventMatcher(ProjectRequest request, Exception cause) {
@@ -140,8 +142,7 @@ public abstract class AbstractProjectGeneratorTests {
}
@Override
public boolean matches(Object argument) {
ProjectFailedEvent event = (ProjectFailedEvent) argument;
public boolean matches(ProjectFailedEvent event) {
return request.equals(event.getProjectRequest())
&& cause.equals(event.getCause());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@@ -26,7 +26,7 @@ import org.mockito.Mockito;
import org.springframework.core.io.ClassPathResource;
import static org.mockito.Matchers.argThat;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;

View File

@@ -826,7 +826,7 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
applyMetadata(metadata);
ProjectRequest request = createProjectRequest("one", "web", "two", "data-jpa");
assertThat(generateGradleBuild(request).getGradleBuild())
.containsSequence(
.containsSubsequence(
"compile('org.springframework.boot:spring-boot-starter-data-jpa')",
"compile('org.springframework.boot:spring-boot-starter-web')",
"compile('com.example:second:1.2.3')",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@@ -23,9 +23,9 @@ import java.util.Properties;
import org.junit.Test;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.boot.bind.PropertiesConfigurationFactory;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@@ -208,19 +208,10 @@ public class InitializrMetadataBuilderTests {
}
private static InitializrProperties load(Resource resource) {
PropertiesConfigurationFactory<InitializrProperties> factory = new PropertiesConfigurationFactory<>(
InitializrProperties.class);
factory.setTargetName("initializr");
MutablePropertySources sources = new MutablePropertySources();
sources.addFirst(new PropertiesPropertySource("main", loadProperties(resource)));
factory.setPropertySources(sources);
try {
factory.afterPropertiesSet();
return factory.getObject();
}
catch (Exception e) {
throw new IllegalStateException("Could not create InitializrProperties", e);
}
ConfigurationPropertySource source = new MapConfigurationPropertySource(
loadProperties(resource));
Binder binder = new Binder(source);
return binder.bind("initializr", InitializrProperties.class).get();
}
private static Properties loadProperties(Resource resource) {