Polish migration to JUnit5

See gh-802
This commit is contained in:
Stephane Nicoll
2019-01-28 14:33:54 +01:00
parent 8ec763e0ba
commit 2b6ab498cf
52 changed files with 526 additions and 530 deletions

View File

@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Stephane Nicoll
*/
public class CloudfoundryEnvironmentPostProcessorTests {
class CloudfoundryEnvironmentPostProcessorTests {
private final CloudfoundryEnvironmentPostProcessor postProcessor = new CloudfoundryEnvironmentPostProcessor();
@@ -35,7 +35,7 @@ public class CloudfoundryEnvironmentPostProcessorTests {
private final SpringApplication application = new SpringApplication();
@Test
public void parseUriWithCredentials() {
void parseUriWithCredentials() {
this.environment.setProperty("vcap.services.stats-index.credentials.uri",
"https://user:pass@example.com/bar/biz?param=one");
this.postProcessor.postProcessEnvironment(this.environment, this.application);
@@ -49,7 +49,7 @@ public class CloudfoundryEnvironmentPostProcessorTests {
}
@Test
public void parseUri() {
void parseUri() {
this.environment.setProperty("vcap.services.stats-index.credentials.uri",
"http://example.com/bar/biz?param=one");
this.postProcessor.postProcessEnvironment(this.environment, this.application);
@@ -63,7 +63,7 @@ public class CloudfoundryEnvironmentPostProcessorTests {
}
@Test
public void parseNoVcapUri() {
void parseNoVcapUri() {
this.postProcessor.postProcessEnvironment(this.environment, this.application);
assertThat(this.environment.getProperty("initializr.stats.elastic.uri")).isNull();

View File

@@ -52,20 +52,20 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll
* @author Madhura Bhave
*/
public class InitializrAutoConfigurationTests {
class InitializrAutoConfigurationTests {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RestTemplateAutoConfiguration.class,
JacksonAutoConfiguration.class, InitializrAutoConfiguration.class));
@Test
public void autoConfigRegistersProjectGenerator() {
void autoConfigRegistersProjectGenerator() {
this.contextRunner.run(
(context) -> assertThat(context).hasSingleBean(ProjectGenerator.class));
}
@Test
public void autoConfigWhenProjectGeneratorBeanPresentDoesNotRegisterProjectGenerator() {
void autoConfigWhenProjectGeneratorBeanPresentDoesNotRegisterProjectGenerator() {
this.contextRunner
.withUserConfiguration(CustomProjectGeneratorConfiguration.class)
.run((context) -> {
@@ -75,13 +75,13 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void autoConfigRegistersTemplateRenderer() {
void autoConfigRegistersTemplateRenderer() {
this.contextRunner.run(
(context) -> assertThat(context).hasSingleBean(TemplateRenderer.class));
}
@Test
public void autoConfigWhenTemplateRendererBeanPresentDoesNotRegisterTemplateRenderer() {
void autoConfigWhenTemplateRendererBeanPresentDoesNotRegisterTemplateRenderer() {
this.contextRunner
.withUserConfiguration(CustomTemplateRendererConfiguration.class)
.run((context) -> {
@@ -91,13 +91,13 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void autoConfigRegistersProjectRequestResolver() {
void autoConfigRegistersProjectRequestResolver() {
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(ProjectRequestResolver.class));
}
@Test
public void autoConfigWhenProjectRequestResolverBeanPresentDoesNotRegisterProjectRequestResolver() {
void autoConfigWhenProjectRequestResolverBeanPresentDoesNotRegisterProjectRequestResolver() {
this.contextRunner
.withUserConfiguration(CustomProjectRequestResolverConfiguration.class)
.run((context) -> {
@@ -107,13 +107,13 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void autoConfigRegistersProjectResourceLocator() {
void autoConfigRegistersProjectResourceLocator() {
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(ProjectResourceLocator.class));
}
@Test
public void autoConfigWhenProjectResourceLocatorBeanPresentDoesNotRegisterProjectResourceLocator() {
void autoConfigWhenProjectResourceLocatorBeanPresentDoesNotRegisterProjectResourceLocator() {
this.contextRunner
.withUserConfiguration(CustomProjectResourceLocatorConfiguration.class)
.run((context) -> {
@@ -123,13 +123,13 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void autoConfigRegistersInitializrMetadataProvider() {
void autoConfigRegistersInitializrMetadataProvider() {
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(InitializrMetadataProvider.class));
}
@Test
public void autoConfigWhenInitializrMetadataProviderBeanPresentDoesNotRegisterInitializrMetadataProvider() {
void autoConfigWhenInitializrMetadataProviderBeanPresentDoesNotRegisterInitializrMetadataProvider() {
this.contextRunner
.withUserConfiguration(
CustomInitializrMetadataProviderConfiguration.class)
@@ -140,13 +140,13 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void autoConfigRegistersDependencyMetadataProvider() {
void autoConfigRegistersDependencyMetadataProvider() {
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(DependencyMetadataProvider.class));
}
@Test
public void autoConfigWhenDependencyMetadataProviderBeanPresentDoesNotRegisterDependencyMetadataProvider() {
void autoConfigWhenDependencyMetadataProviderBeanPresentDoesNotRegisterDependencyMetadataProvider() {
this.contextRunner
.withUserConfiguration(
CustomDependencyMetadataProviderConfiguration.class)
@@ -157,7 +157,7 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void customRestTemplateBuilderIsUsed() {
void customRestTemplateBuilderIsUsed() {
this.contextRunner.withUserConfiguration(CustomRestTemplateConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(InitializrMetadataProvider.class);
@@ -170,7 +170,7 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void webConfiguration() {
void webConfiguration() {
WebApplicationContextRunner webContextRunner = new WebApplicationContextRunner()
.withConfiguration(
AutoConfigurations.of(RestTemplateAutoConfiguration.class,
@@ -186,7 +186,7 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void webConfigurationConditionalOnWebApplication() {
void webConfigurationConditionalOnWebApplication() {
this.contextRunner.run((context) -> {
assertThat(context).doesNotHaveBean(InitializrWebConfig.class);
assertThat(context).doesNotHaveBean(MainController.class);
@@ -195,13 +195,13 @@ public class InitializrAutoConfigurationTests {
}
@Test
public void cacheConfiguration() {
void cacheConfiguration() {
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(JCacheManagerCustomizer.class));
}
@Test
public void cacheConfigurationConditionalOnClass() {
void cacheConfigurationConditionalOnClass() {
this.contextRunner
.withClassLoader(new FilteredClassLoader("javax.cache.CacheManager"))
.run((context) -> assertThat(context)

View File

@@ -32,12 +32,12 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Stephane Nicoll
*/
public class DependencyMetadataJsonMapperTests {
class DependencyMetadataJsonMapperTests {
private final DependencyMetadataJsonMapper mapper = new DependencyMetadataV21JsonMapper();
@Test
public void mapDependency() throws Exception {
void mapDependency() throws Exception {
Dependency d = Dependency.withId("foo", "org.foo", "foo");
d.setRepository("my-repo");
d.setBom("my-bom");

View File

@@ -31,14 +31,14 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Stephane Nicoll
*/
public class InitializrMetadataJsonMapperTests {
class InitializrMetadataJsonMapperTests {
private static final ObjectMapper objectMapper = new ObjectMapper();
private final InitializrMetadataJsonMapper jsonMapper = new InitializrMetadataV21JsonMapper();
@Test
public void withNoAppUrl() throws IOException {
void withNoAppUrl() throws IOException {
InitializrMetadata metadata = new InitializrMetadataTestBuilder()
.addType("foo", true, "/foo.zip", "none", "test")
.addDependencyGroup("foo", "one", "two").build();
@@ -50,7 +50,7 @@ public class InitializrMetadataJsonMapperTests {
}
@Test
public void withAppUrl() throws IOException {
void withAppUrl() throws IOException {
InitializrMetadata metadata = new InitializrMetadataTestBuilder()
.addType("foo", true, "/foo.zip", "none", "test")
.addDependencyGroup("foo", "one", "two").build();
@@ -62,7 +62,7 @@ public class InitializrMetadataJsonMapperTests {
}
@Test
public void linksRendered() {
void linksRendered() {
Dependency dependency = Dependency.withId("foo", "com.example", "foo");
dependency.getLinks().add(Link.create("guide", "https://example.com/how-to"));
dependency.getLinks().add(Link.create("reference", "https://example.com/doc"));

View File

@@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
public class LinkMapperTests {
class LinkMapperTests {
@Test
public void mapSimpleRel() {
void mapSimpleRel() {
List<Link> links = new ArrayList<>();
links.add(Link.create("a", "https://example.com", "some description"));
ObjectNode model = LinkMapper.mapLinks(links);
@@ -47,7 +47,7 @@ public class LinkMapperTests {
}
@Test
public void mapTemplatedRel() {
void mapTemplatedRel() {
List<Link> links = new ArrayList<>();
links.add(Link.create("a", "https://example.com/{bootVersion}/a", true));
ObjectNode model = LinkMapper.mapLinks(links);
@@ -61,7 +61,7 @@ public class LinkMapperTests {
}
@Test
public void mergeSeveralLinksInArray() {
void mergeSeveralLinksInArray() {
List<Link> links = new ArrayList<>();
links.add(Link.create("a", "https://example.com", "some description"));
links.add(Link.create("a", "https://example.com/2"));
@@ -77,7 +77,7 @@ public class LinkMapperTests {
}
@Test
public void keepOrdering() {
void keepOrdering() {
List<Link> links = new ArrayList<>();
links.add(Link.create("first", "https://example.com"));
links.add(Link.create("second", "https://example.com"));
@@ -87,7 +87,7 @@ public class LinkMapperTests {
}
@Test
public void keepOrderingWithMultipleUrlForSameRel() {
void keepOrderingWithMultipleUrlForSameRel() {
List<Link> links = new ArrayList<>();
links.add(Link.create("first", "https://example.com"));
links.add(Link.create("second", "https://example.com"));

View File

@@ -32,11 +32,11 @@ import org.springframework.test.context.ActiveProfiles;
* @author Stephane Nicoll
*/
@ActiveProfiles("test-default")
public class CommandLineExampleIntegrationTests
class CommandLineExampleIntegrationTests
extends AbstractInitializrControllerIntegrationTests {
@Test
public void generateDefaultProject() {
void generateDefaultProject() {
downloadZip("/starter.zip").isJavaProject().isMavenProject()
.hasStaticAndTemplatesResources(false).pomAssert()
.hasSpringBootStarterRootDependency().hasSpringBootStarterTest()
@@ -44,7 +44,7 @@ public class CommandLineExampleIntegrationTests
}
@Test
public void generateWebProjectWithJava8() {
void generateWebProjectWithJava8() {
downloadZip("/starter.zip?dependencies=web&javaVersion=1.8").isJavaProject()
.isMavenProject().hasStaticAndTemplatesResources(true).pomAssert()
.hasJavaVersion("1.8").hasSpringBootStarterDependency("web")
@@ -52,7 +52,7 @@ public class CommandLineExampleIntegrationTests
}
@Test
public void generateWebDataJpaGradleProject() {
void generateWebDataJpaGradleProject() {
downloadTgz(
"/starter.tgz?dependencies=web,data-jpa&type=gradle-project&baseDir=my-dir")
.hasBaseDir("my-dir").isJavaProject().isGradleProject()
@@ -62,7 +62,7 @@ public class CommandLineExampleIntegrationTests
}
@Test
public void generateMavenPomWithWarPackaging() {
void generateMavenPomWithWarPackaging() {
ResponseEntity<String> response = getRestTemplate()
.getForEntity(createUrl("/pom.xml?packaging=war"), String.class);
PomAssert pomAssert = new PomAssert(response.getBody());

View File

@@ -28,13 +28,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@ActiveProfiles({ "test-default", "test-custom-defaults" })
public class MainControllerDefaultsIntegrationTests
class MainControllerDefaultsIntegrationTests
extends AbstractInitializrControllerIntegrationTests {
// see defaults customization
@Test
public void generateDefaultPom() {
void generateDefaultPom() {
String content = getRestTemplate().getForObject(createUrl("/pom.xml?style=web"),
String.class);
PomAssert pomAssert = new PomAssert(content);
@@ -44,7 +44,7 @@ public class MainControllerDefaultsIntegrationTests
}
@Test
public void defaultsAppliedToHome() {
void defaultsAppliedToHome() {
String body = htmlHome();
assertThat(body).as("custom groupId not found").contains("org.foo");
assertThat(body).as("custom artifactId not found").contains("foo-bar");

View File

@@ -33,11 +33,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@ActiveProfiles("test-default")
public class MainControllerDependenciesTests
class MainControllerDependenciesTests
extends AbstractInitializrControllerIntegrationTests {
@Test
public void noBootVersion() throws JSONException {
void noBootVersion() throws JSONException {
ResponseEntity<String> response = execute("/dependencies", String.class, null,
"application/json");
assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull();
@@ -46,7 +46,7 @@ public class MainControllerDependenciesTests
}
@Test
public void filteredDependencies() throws JSONException {
void filteredDependencies() throws JSONException {
ResponseEntity<String> response = execute(
"/dependencies?bootVersion=2.2.1.RELEASE", String.class, null,
"application/json");

View File

@@ -34,11 +34,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@ActiveProfiles({ "test-default", "test-custom-env" })
public class MainControllerEnvIntegrationTests
class MainControllerEnvIntegrationTests
extends AbstractInitializrControllerIntegrationTests {
@Test
public void downloadCliWithCustomRepository() throws Exception {
void downloadCliWithCustomRepository() throws Exception {
ResponseEntity<?> entity = getRestTemplate().getForEntity(createUrl("/spring"),
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
@@ -47,7 +47,7 @@ public class MainControllerEnvIntegrationTests
}
@Test
public void generateProjectWithInvalidName() {
void generateProjectWithInvalidName() {
downloadZip("/starter.zip?style=data-jpa&name=Invalid")
.isJavaProject(ProjectAssert.DEFAULT_PACKAGE_NAME, "FooBarApplication")
.isMavenProject().hasStaticAndTemplatesResources(false).pomAssert()
@@ -56,7 +56,7 @@ public class MainControllerEnvIntegrationTests
}
@Test
public void googleAnalytics() {
void googleAnalytics() {
String body = htmlHome();
assertThat(body).contains("https://www.googletagmanager.com/gtm.js");
}

View File

@@ -43,11 +43,11 @@ import static org.assertj.core.api.Assertions.fail;
* @author Stephane Nicoll
*/
@ActiveProfiles("test-default")
public class MainControllerIntegrationTests
class MainControllerIntegrationTests
extends AbstractInitializrControllerIntegrationTests {
@Test
public void simpleZipProject() {
void simpleZipProject() {
downloadZip("/starter.zip?style=web&style=jpa").isJavaProject()
.hasFile(".gitignore").hasExecutableFile("mvnw").isMavenProject()
.hasStaticAndTemplatesResources(true).pomAssert().hasDependenciesCount(3)
@@ -57,7 +57,7 @@ public class MainControllerIntegrationTests
}
@Test
public void simpleTgzProject() {
void simpleTgzProject() {
downloadTgz("/starter.tgz?style=org.acme:foo").isJavaProject()
.hasFile(".gitignore").hasExecutableFile("mvnw").isMavenProject()
.hasStaticAndTemplatesResources(false).pomAssert().hasDependenciesCount(2)
@@ -65,7 +65,7 @@ public class MainControllerIntegrationTests
}
@Test
public void dependencyInRange() {
void dependencyInRange() {
Dependency biz = Dependency.create("org.acme", "biz", "1.3.5", "runtime");
downloadTgz("/starter.tgz?style=org.acme:biz&bootVersion=2.2.1.RELEASE")
.isJavaProject().isMavenProject().hasStaticAndTemplatesResources(false)
@@ -73,7 +73,7 @@ public class MainControllerIntegrationTests
}
@Test
public void dependencyNotInRange() {
void dependencyNotInRange() {
try {
execute("/starter.tgz?style=org.acme:bur", byte[].class, null,
(String[]) null);
@@ -84,7 +84,7 @@ public class MainControllerIntegrationTests
}
@Test
public void noDependencyProject() {
void noDependencyProject() {
downloadZip("/starter.zip").isJavaProject().isMavenProject()
.hasStaticAndTemplatesResources(false).pomAssert().hasDependenciesCount(2)
// the root dep is added if none is specified
@@ -92,7 +92,7 @@ public class MainControllerIntegrationTests
}
@Test
public void dependenciesIsAnAliasOfStyle() {
void dependenciesIsAnAliasOfStyle() {
downloadZip("/starter.zip?dependencies=web&dependencies=jpa").isJavaProject()
.isMavenProject().hasStaticAndTemplatesResources(true).pomAssert()
.hasDependenciesCount(3).hasSpringBootStarterDependency("web")
@@ -101,7 +101,7 @@ public class MainControllerIntegrationTests
}
@Test
public void dependenciesIsAnAliasOfStyleCommaSeparated() {
void dependenciesIsAnAliasOfStyleCommaSeparated() {
downloadZip("/starter.zip?dependencies=web,jpa").isJavaProject().isMavenProject()
.hasStaticAndTemplatesResources(true).pomAssert().hasDependenciesCount(3)
.hasSpringBootStarterDependency("web")
@@ -110,35 +110,35 @@ public class MainControllerIntegrationTests
}
@Test
public void kotlinRange() {
void kotlinRange() {
downloadZip("/starter.zip?style=web&language=kotlin&bootVersion=2.0.1.RELEASE")
.isKotlinProject().isMavenProject().pomAssert().hasDependenciesCount(4)
.hasProperty("kotlin.version", "1.1");
}
@Test
public void gradleWarProject() {
void gradleWarProject() {
downloadZip("/starter.zip?style=web&style=security&packaging=war&type=gradle.zip")
.isJavaWarProject().isGradleProject();
}
@Test
public void downloadCli() throws Exception {
void downloadCli() throws Exception {
assertSpringCliRedirect("/spring", "zip");
}
@Test
public void downloadCliAsZip() throws Exception {
void downloadCliAsZip() throws Exception {
assertSpringCliRedirect("/spring.zip", "zip");
}
@Test
public void downloadCliAsTarGz() throws Exception {
void downloadCliAsTarGz() throws Exception {
assertSpringCliRedirect("/spring.tar.gz", "tar.gz");
}
@Test
public void downloadCliAsTgz() throws Exception {
void downloadCliAsTgz() throws Exception {
assertSpringCliRedirect("/spring.tgz", "tar.gz");
}
@@ -153,7 +153,7 @@ public class MainControllerIntegrationTests
}
@Test
public void metadataWithNoAcceptHeader() {
void metadataWithNoAcceptHeader() {
// rest template sets application/json by default
ResponseEntity<String> response = invokeHome(null, "*/*");
validateCurrentMetadata(response);
@@ -169,7 +169,7 @@ public class MainControllerIntegrationTests
}
@Test
public void metadataWithV2AcceptHeader() {
void metadataWithV2AcceptHeader() {
ResponseEntity<String> response = invokeHome(null,
"application/vnd.initializr.v2+json");
validateMetadata(response, InitializrMetadataVersion.V2.getMediaType(), "2.0.0",
@@ -177,7 +177,7 @@ public class MainControllerIntegrationTests
}
@Test
public void metadataWithCurrentAcceptHeader() {
void metadataWithCurrentAcceptHeader() {
getRequests().setFields("_links.maven-project", "dependencies.values[0]",
"type.values[0]", "javaVersion.values[0]", "packaging.values[0]",
"bootVersion.values[0]", "language.values[0]");
@@ -190,7 +190,7 @@ public class MainControllerIntegrationTests
}
@Test
public void metadataWithSeveralAcceptHeader() {
void metadataWithSeveralAcceptHeader() {
ResponseEntity<String> response = invokeHome(null,
"application/vnd.initializr.v2.1+json",
"application/vnd.initializr.v2+json");
@@ -200,7 +200,7 @@ public class MainControllerIntegrationTests
}
@Test
public void metadataWithHalAcceptHeader() {
void metadataWithHalAcceptHeader() {
ResponseEntity<String> response = invokeHome(null, "application/hal+json");
assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull();
validateContentType(response, MainController.HAL_JSON_CONTENT_TYPE);
@@ -208,7 +208,7 @@ public class MainControllerIntegrationTests
}
@Test
public void metadataWithUnknownAcceptHeader() {
void metadataWithUnknownAcceptHeader() {
try {
invokeHome(null, "application/vnd.initializr.v5.4+json");
}
@@ -218,20 +218,20 @@ public class MainControllerIntegrationTests
}
@Test
public void curlReceivesTextByDefault() {
void curlReceivesTextByDefault() {
ResponseEntity<String> response = invokeHome("curl/1.2.4", "*/*");
validateCurlHelpContent(response);
}
@Test
public void curlCanStillDownloadZipArchive() {
void curlCanStillDownloadZipArchive() {
ResponseEntity<byte[]> response = execute("/starter.zip", byte[].class,
"curl/1.2.4", "*/*");
zipProjectAssert(response.getBody()).isMavenProject().isJavaProject();
}
@Test
public void curlCanStillDownloadTgzArchive() {
void curlCanStillDownloadTgzArchive() {
ResponseEntity<byte[]> response = execute("/starter.tgz", byte[].class,
"curl/1.2.4", "*/*");
tgzProjectAssert(response.getBody()).isMavenProject().isJavaProject();
@@ -247,19 +247,19 @@ public class MainControllerIntegrationTests
}
@Test
public void curlWithAcceptHeaderTextPlain() {
void curlWithAcceptHeaderTextPlain() {
ResponseEntity<String> response = invokeHome("curl/1.2.4", "text/plain");
validateCurlHelpContent(response);
}
@Test
public void unknownAgentReceivesJsonByDefault() {
void unknownAgentReceivesJsonByDefault() {
ResponseEntity<String> response = invokeHome("foo/1.0", "*/*");
validateCurrentMetadata(response);
}
@Test
public void httpieReceivesTextByDefault() {
void httpieReceivesTextByDefault() {
ResponseEntity<String> response = invokeHome("HTTPie/0.8.0", "*/*");
validateHttpIeHelpContent(response);
}
@@ -274,19 +274,19 @@ public class MainControllerIntegrationTests
}
@Test
public void httpieWithAcceptHeaderTextPlain() {
void httpieWithAcceptHeaderTextPlain() {
ResponseEntity<String> response = invokeHome("HTTPie/0.8.0", "text/plain");
validateHttpIeHelpContent(response);
}
@Test
public void unknownCliWithTextPlain() {
void unknownCliWithTextPlain() {
ResponseEntity<String> response = invokeHome(null, "text/plain");
validateGenericHelpContent(response);
}
@Test
public void springBootCliReceivesJsonByDefault() {
void springBootCliReceivesJsonByDefault() {
ResponseEntity<String> response = invokeHome("SpringBootCli/1.2.0", "*/*");
validateContentType(response,
AbstractInitializrIntegrationTests.CURRENT_METADATA_MEDIA_TYPE);
@@ -294,7 +294,7 @@ public class MainControllerIntegrationTests
}
@Test
public void springBootCliWithAcceptHeaderText() {
void springBootCliWithAcceptHeaderText() {
ResponseEntity<String> response = invokeHome("SpringBootCli/1.2.0", "text/plain");
validateSpringBootHelpContent(response);
}
@@ -306,7 +306,7 @@ public class MainControllerIntegrationTests
}
@Test
public void doNotForceSslByDefault() {
void doNotForceSslByDefault() {
ResponseEntity<String> response = invokeHome("curl/1.2.4", "*/*");
String body = response.getBody();
assertThat(body).as("Must not force https").contains("http://start.spring.io/");
@@ -342,7 +342,7 @@ public class MainControllerIntegrationTests
}
@Test
public void missingDependencyProperException() {
void missingDependencyProperException() {
try {
downloadArchive("/starter.zip?style=foo:bar");
fail("Should have failed");
@@ -355,7 +355,7 @@ public class MainControllerIntegrationTests
}
@Test
public void invalidDependencyProperException() {
void invalidDependencyProperException() {
try {
downloadArchive("/starter.zip?style=foo");
fail("Should have failed");
@@ -368,13 +368,13 @@ public class MainControllerIntegrationTests
}
@Test
public void homeIsJson() {
void homeIsJson() {
String body = invokeHome(null, (String[]) null).getBody();
assertThat(body).contains("\"dependencies\"");
}
@Test
public void webIsAddedPom() {
void webIsAddedPom() {
String body = getRestTemplate().getForObject(createUrl("/pom.xml?packaging=war"),
String.class);
assertThat(body).contains("spring-boot-starter-web");
@@ -382,7 +382,7 @@ public class MainControllerIntegrationTests
}
@Test
public void webIsAddedGradle() {
void webIsAddedGradle() {
String body = getRestTemplate()
.getForObject(createUrl("/build.gradle?packaging=war"), String.class);
assertThat(body).contains("spring-boot-starter-web");
@@ -390,27 +390,27 @@ public class MainControllerIntegrationTests
}
@Test
public void homeHasWebStyle() {
void homeHasWebStyle() {
String body = htmlHome();
assertThat(body).contains("name=\"style\" value=\"web\"");
}
@Test
public void homeHasBootVersion() {
void homeHasBootVersion() {
String body = htmlHome();
assertThat(body).contains("name=\"bootVersion\"");
assertThat(body).contains("2.2.0.BUILD-SNAPSHOT\"");
}
@Test
public void homeHasOnlyProjectFormatTypes() {
void homeHasOnlyProjectFormatTypes() {
String body = htmlHome();
assertThat(body).contains("Maven Project");
assertThat(body).doesNotContain("Maven POM");
}
@Test
public void downloadStarter() {
void downloadStarter() {
byte[] body = getRestTemplate().getForObject(createUrl("starter.zip"),
byte[].class);
assertThat(body).isNotNull();
@@ -418,7 +418,7 @@ public class MainControllerIntegrationTests
}
@Test
public void installer() {
void installer() {
ResponseEntity<String> response = getRestTemplate()
.getForEntity(createUrl("install.sh"), String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
@@ -426,7 +426,7 @@ public class MainControllerIntegrationTests
}
@Test
public void googleAnalyticsDisabledByDefault() {
void googleAnalyticsDisabledByDefault() {
String body = htmlHome();
assertThat(body).doesNotContain("GoogleAnalyticsObject");
}

View File

@@ -40,14 +40,14 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@ActiveProfiles("test-default")
public class MainControllerServiceMetadataIntegrationTests
class MainControllerServiceMetadataIntegrationTests
extends AbstractFullStackInitializrIntegrationTests {
@Autowired
private InitializrMetadataProvider metadataProvider;
@Test
public void initializeRemoteConfig() throws Exception {
void initializeRemoteConfig() throws Exception {
InitializrMetadata localMetadata = this.metadataProvider.get();
InitializrMetadata metadata = InitializrMetadataBuilder.create()
.withInitializrMetadata(new UrlResource(createUrl("/metadata/config")))
@@ -68,7 +68,7 @@ public class MainControllerServiceMetadataIntegrationTests
}
@Test
public void textPlainNotAccepted() {
void textPlainNotAccepted() {
try {
execute("/metadata/config", String.class, null, "text/plain");
}
@@ -78,7 +78,7 @@ public class MainControllerServiceMetadataIntegrationTests
}
@Test
public void validateJson() throws JSONException {
void validateJson() throws JSONException {
ResponseEntity<String> response = execute("/metadata/config", String.class, null,
"application/json");
validateContentType(response, MediaType.APPLICATION_JSON);
@@ -88,7 +88,7 @@ public class MainControllerServiceMetadataIntegrationTests
}
@Test
public void metadataClientRedirect() {
void metadataClientRedirect() {
ResponseEntity<String> response = execute("/metadata/client", String.class, null,
"application/json");
validateCurrentMetadata(response);

View File

@@ -36,11 +36,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@ActiveProfiles({ "test-default", "test-ssl" })
public class MainControllerSslIntegrationTests
class MainControllerSslIntegrationTests
extends AbstractInitializrControllerIntegrationTests {
@Test
public void mainPageRedirectsToHttps() {
void mainPageRedirectsToHttps() {
ResponseEntity<Void> request = execute("/", Void.class, null,
MediaType.TEXT_HTML_VALUE);
assertThat(request.getStatusCode()).isEqualTo(HttpStatus.FOUND);
@@ -50,7 +50,7 @@ public class MainControllerSslIntegrationTests
}
@Test
public void forceSsl() {
void forceSsl() {
ResponseEntity<String> response = invokeHome("curl/1.2.4", "*/*");
String body = response.getBody();
assertThat(body).as("Must force https").contains("https://start.spring.io/");
@@ -58,7 +58,7 @@ public class MainControllerSslIntegrationTests
}
@Test
public void forceSslInMetadata() {
void forceSslInMetadata() {
ResponseEntity<String> response = invokeHome(null,
"application/vnd.initializr.v2.1+json");
validateMetadata(response, InitializrMetadataVersion.V2_1.getMediaType(),
@@ -66,7 +66,7 @@ public class MainControllerSslIntegrationTests
}
@Test
public void forceSslInMetadataV2() {
void forceSslInMetadataV2() {
ResponseEntity<String> response = invokeHome(null,
"application/vnd.initializr.v2+json");
validateMetadata(response, InitializrMetadataVersion.V2.getMediaType(),

View File

@@ -31,11 +31,11 @@ import org.springframework.test.context.ActiveProfiles;
@ActiveProfiles("test-default")
@Import(ProjectRequestPostProcessorConfiguration.class)
public class ProjectGenerationPostProcessorTests
class ProjectGenerationPostProcessorTests
extends AbstractInitializrControllerIntegrationTests {
@Test
public void postProcessorsInvoked() {
void postProcessorsInvoked() {
downloadZip("/starter.zip?bootVersion=2.0.4.RELEASE&javaVersion=1.8")
.isJavaProject().isMavenProject().pomAssert()
.hasSpringBootParent("2.2.3.RELEASE").hasProperty("java.version", "1.7");

View File

@@ -49,8 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ExtendWith(TempDirectory.class)
@ActiveProfiles("test-default")
public class ProjectGenerationSmokeTests
extends AbstractFullStackInitializrIntegrationTests {
class ProjectGenerationSmokeTests extends AbstractFullStackInitializrIntegrationTests {
private File downloadDir;
@@ -86,7 +85,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createSimpleProject() throws Exception {
void createSimpleProject() throws Exception {
HomePage page = toHome();
page.submit();
assertSimpleProject().isMavenProject().pomAssert().hasDependenciesCount(2)
@@ -94,7 +93,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createSimpleProjectWithGradle() throws Exception {
void createSimpleProjectWithGradle() throws Exception {
HomePage page = toHome();
page.type("gradle-project");
page.submit();
@@ -105,7 +104,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createSimpleProjectWithDifferentBootVersion() throws Exception {
void createSimpleProjectWithDifferentBootVersion() throws Exception {
HomePage page = toHome();
page.bootVersion("1.5.17.RELEASE");
page.submit();
@@ -116,7 +115,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createSimpleProjectWithDependencies() throws Exception {
void createSimpleProjectWithDependencies() throws Exception {
HomePage page = toHome();
selectDependency(page, "Data JPA");
selectDependency(page, "Security");
@@ -127,7 +126,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void selectDependencyTwiceRemovesIt() throws Exception {
void selectDependencyTwiceRemovesIt() throws Exception {
HomePage page = toHome();
selectDependency(page, "Data JPA");
selectDependency(page, "Security");
@@ -138,8 +137,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void selectDependencyAndChangeToIncompatibleVersionRemovesIt()
throws Exception {
void selectDependencyAndChangeToIncompatibleVersionRemovesIt() throws Exception {
HomePage page = toHome();
selectDependency(page, "Data JPA");
selectDependency(page, "org.acme:bur");
@@ -151,7 +149,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void customArtifactIdUpdateNameAutomatically() throws Exception {
void customArtifactIdUpdateNameAutomatically() throws Exception {
HomePage page = toHome();
page.groupId("org.foo");
page.submit();
@@ -160,7 +158,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void customGroupIdIdUpdatePackageAutomatically() throws Exception {
void customGroupIdIdUpdatePackageAutomatically() throws Exception {
HomePage page = toHome();
page.artifactId("my-project");
page.submit();
@@ -169,7 +167,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void customArtifactIdWithInvalidPackageNameIsHandled() throws Exception {
void customArtifactIdWithInvalidPackageNameIsHandled() throws Exception {
HomePage page = toHome();
page.artifactId("42my-project");
page.submit();
@@ -178,7 +176,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createGroovyProject() throws Exception {
void createGroovyProject() throws Exception {
HomePage page = toHome();
page.language("groovy");
page.submit();
@@ -190,7 +188,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createKotlinProject() throws Exception {
void createKotlinProject() throws Exception {
HomePage page = toHome();
page.language("kotlin");
page.submit();
@@ -203,7 +201,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createWarProject() throws Exception {
void createWarProject() throws Exception {
HomePage page = toHome();
page.advanced();
page.packaging("war");
@@ -216,7 +214,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createJavaProjectWithCustomDefaults() throws Exception {
void createJavaProjectWithCustomDefaults() throws Exception {
HomePage page = toHome();
page.groupId("com.acme");
page.artifactId("foo-bar");
@@ -238,7 +236,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createKotlinProjectWithCustomDefaults() throws Exception {
void createKotlinProjectWithCustomDefaults() throws Exception {
HomePage page = toHome();
page.groupId("com.acme");
page.artifactId("foo-bar");
@@ -261,7 +259,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void createGroovyProjectWithCustomDefaults() throws Exception {
void createGroovyProjectWithCustomDefaults() throws Exception {
HomePage page = toHome();
page.groupId("com.acme");
page.artifactId("foo-bar");
@@ -284,7 +282,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void dependencyHiddenAccordingToRange() throws Exception {
void dependencyHiddenAccordingToRange() throws Exception {
HomePage page = toHome(); // bur: [2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)
page.advanced();
assertThat(page.dependency("org.acme:bur").isEnabled()).isTrue();
@@ -300,7 +298,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void dependencyUncheckedWhenHidden() throws Exception {
void dependencyUncheckedWhenHidden() throws Exception {
HomePage page = toHome(); // bur: [2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)
page.advanced();
page.dependency("org.acme:bur").click();
@@ -313,7 +311,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void customizationShowsUpInDefaultView() throws Exception {
void customizationShowsUpInDefaultView() throws Exception {
HomePage page = toHome("/#!language=groovy&packageName=com.example.acme");
assertThat(page.value("language")).isEqualTo("groovy");
assertThat(page.value("packageName")).isEqualTo("com.example.acme");
@@ -328,7 +326,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void customizationsShowsUpWhenViewIsSwitched() throws Exception {
void customizationsShowsUpWhenViewIsSwitched() throws Exception {
HomePage page = toHome("/#!packaging=war&javaVersion=1.7");
assertThat(page.value("packaging")).isEqualTo("war");
assertThat(page.value("javaVersion")).isEqualTo("1.7");
@@ -341,7 +339,7 @@ public class ProjectGenerationSmokeTests
}
@Test
public void customizationsOnGroupIdAndArtifactId() throws Exception {
void customizationsOnGroupIdAndArtifactId() throws Exception {
HomePage page = toHome("/#!groupId=com.example.acme&artifactId=my-project");
page.submit();
ProjectAssert projectAssert = zipProjectAssert(from("my-project.zip"));

View File

@@ -30,12 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Stephane Nicoll
*/
public class DefaultDependencyMetadataProviderTests {
class DefaultDependencyMetadataProviderTests {
private final DependencyMetadataProvider provider = new DefaultDependencyMetadataProvider();
@Test
public void filterDependencies() {
void filterDependencies() {
Dependency first = Dependency.withId("first", "org.foo", "first");
first.setVersionRange("2.1.4.RELEASE");
Dependency second = Dependency.withId("second", "org.foo", "second");
@@ -53,7 +53,7 @@ public class DefaultDependencyMetadataProviderTests {
}
@Test
public void resolveDependencies() {
void resolveDependencies() {
Dependency first = Dependency.withId("first", "org.foo", "first");
first.getMappings().add(Dependency.Mapping.create(
"[1.0.0.RELEASE, 1.1.0.RELEASE)", "org.bar", "second", "0.1.0.RELEASE"));
@@ -86,7 +86,7 @@ public class DefaultDependencyMetadataProviderTests {
}
@Test
public void addRepoAndRemoveDuplicates() {
void addRepoAndRemoveDuplicates() {
Dependency first = Dependency.withId("first", "org.foo", "first");
first.setRepository("repo-foo");
Dependency second = Dependency.withId("second", "org.foo", "second");
@@ -105,7 +105,7 @@ public class DefaultDependencyMetadataProviderTests {
}
@Test
public void addBomAndRemoveDuplicates() {
void addBomAndRemoveDuplicates() {
Dependency first = Dependency.withId("first", "org.foo", "first");
first.setBom("bom-foo");
Dependency second = Dependency.withId("second", "org.foo", "second");
@@ -134,7 +134,7 @@ public class DefaultDependencyMetadataProviderTests {
}
@Test
public void repoFromBomAccordingToVersion() {
void repoFromBomAccordingToVersion() {
DependencyMetadata dependencyMetadata = testRepoFromBomAccordingToVersion(
"1.0.9.RELEASE");
assertThat(dependencyMetadata.getBootVersion())
@@ -155,7 +155,7 @@ public class DefaultDependencyMetadataProviderTests {
}
@Test
public void repoFromBomAccordingToAnotherVersion() {
void repoFromBomAccordingToAnotherVersion() {
DependencyMetadata dependencyMetadata = testRepoFromBomAccordingToVersion(
"1.1.5.RELEASE");
assertThat(dependencyMetadata.getBootVersion())

View File

@@ -41,7 +41,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
/**
* @author Stephane Nicoll
*/
public class DefaultInitializrMetadataProviderTests {
class DefaultInitializrMetadataProviderTests {
private static final ObjectMapper objectMapper = new ObjectMapper();
@@ -56,7 +56,7 @@ public class DefaultInitializrMetadataProviderTests {
}
@Test
public void bootVersionsAreReplaced() {
void bootVersionsAreReplaced() {
InitializrMetadata metadata = new InitializrMetadataTestBuilder()
.addBootVersion("0.0.9.RELEASE", true)
.addBootVersion("0.0.8.RELEASE", false).build();
@@ -79,7 +79,7 @@ public class DefaultInitializrMetadataProviderTests {
}
@Test
public void defaultBootVersionIsAlwaysSet() {
void defaultBootVersionIsAlwaysSet() {
InitializrMetadata metadata = new InitializrMetadataTestBuilder()
.addBootVersion("0.0.9.RELEASE", true)
.addBootVersion("0.0.8.RELEASE", false).build();

View File

@@ -40,7 +40,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
* @author Stephane Nicoll
* @author Dave Syer
*/
public class SpringBootMetadataReaderTests {
class SpringBootMetadataReaderTests {
private final InitializrMetadata metadata = InitializrMetadataBuilder.create()
.build();
@@ -53,7 +53,7 @@ public class SpringBootMetadataReaderTests {
.bindTo(this.restTemplate).build();
@Test
public void readAvailableVersions() throws IOException {
void readAvailableVersions() throws IOException {
this.server.expect(requestTo("https://spring.io/project_metadata/spring-boot"))
.andRespond(withSuccess(
new ClassPathResource("metadata/sagan/spring-boot.json"),

View File

@@ -31,18 +31,17 @@ import org.springframework.test.context.ActiveProfiles;
* @author Stephane Nicoll
*/
@ActiveProfiles("test-default")
public class UiControllerIntegrationTests
extends AbstractInitializrControllerIntegrationTests {
class UiControllerIntegrationTests extends AbstractInitializrControllerIntegrationTests {
@Test
public void dependenciesNoVersion() throws JSONException {
void dependenciesNoVersion() throws JSONException {
ResponseEntity<String> response = execute("/ui/dependencies", String.class, null);
validateContentType(response, MediaType.APPLICATION_JSON);
validateDependenciesOutput("all", response.getBody());
}
@Test
public void dependenciesSpecificVersion() throws JSONException {
void dependenciesSpecificVersion() throws JSONException {
ResponseEntity<String> response = execute(
"/ui/dependencies?version=1.1.2.RELEASE", String.class, null);
validateContentType(response, MediaType.APPLICATION_JSON);