mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 10:08:22 +08:00
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:
@@ -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());
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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')",
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user