Reformat code following spring-javaformat upgrade
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -68,8 +68,8 @@ class GrabCommandIntegrationTests {
|
||||
@Test
|
||||
void duplicateDependencyManagementBomAnnotationsProducesAnError() {
|
||||
assertThatExceptionOfType(Exception.class)
|
||||
.isThrownBy(() -> this.cli.grab("duplicateDependencyManagementBom.groovy"))
|
||||
.withMessageContaining("Duplicate @DependencyManagementBom annotation");
|
||||
.isThrownBy(() -> this.cli.grab("duplicateDependencyManagementBom.groovy"))
|
||||
.withMessageContaining("Duplicate @DependencyManagementBom annotation");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -66,8 +66,8 @@ class ReproIntegrationTests {
|
||||
@Test
|
||||
void jarFileExtensionNeeded() {
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(() -> this.cli.jar("secure.groovy", "data-jpa.groovy"))
|
||||
.withMessageContaining("is not a JAR file");
|
||||
.isThrownBy(() -> this.cli.jar("secure.groovy", "data-jpa.groovy"))
|
||||
.withMessageContaining("is not a JAR file");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -76,8 +76,8 @@ class SpringApplicationLauncherTests {
|
||||
assertThat(args == TestSpringApplication.args).isTrue();
|
||||
|
||||
Map<String, String> defaultProperties = TestSpringApplication.defaultProperties;
|
||||
assertThat(defaultProperties).hasSize(1).containsEntry("spring.groovy.template.check-template-location",
|
||||
"false");
|
||||
assertThat(defaultProperties).hasSize(1)
|
||||
.containsEntry("spring.groovy.template.check-template-location", "false");
|
||||
}
|
||||
|
||||
private Set<String> launch() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -160,7 +160,7 @@ class CommandRunnerTests {
|
||||
@Test
|
||||
void exceptionMessages() {
|
||||
assertThat(new NoSuchCommandException("name").getMessage())
|
||||
.isEqualTo("'name' is not a valid command. See 'help'.");
|
||||
.isEqualTo("'name' is not a valid command. See 'help'.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -172,13 +172,13 @@ class CommandRunnerTests {
|
||||
@Test
|
||||
void helpNoCommand() {
|
||||
assertThatExceptionOfType(NoHelpCommandArgumentsException.class)
|
||||
.isThrownBy(() -> this.commandRunner.run("help"));
|
||||
.isThrownBy(() -> this.commandRunner.run("help"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void helpUnknownCommand() {
|
||||
assertThatExceptionOfType(NoSuchCommandException.class)
|
||||
.isThrownBy(() -> this.commandRunner.run("help", "missing"));
|
||||
.isThrownBy(() -> this.commandRunner.run("help", "missing"));
|
||||
}
|
||||
|
||||
private enum Call {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -104,7 +104,7 @@ class ResourceMatcherTests {
|
||||
void jarFileAlwaysMatches() throws Exception {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"), Arrays.asList("**/*.jar"));
|
||||
List<MatchedResource> found = resourceMatcher
|
||||
.find(Arrays.asList(new File("src/test/resources/templates"), new File("src/test/resources/foo.jar")));
|
||||
.find(Arrays.asList(new File("src/test/resources/templates"), new File("src/test/resources/foo.jar")));
|
||||
assertThat(found).areAtLeastOne(new Condition<MatchedResource>() {
|
||||
|
||||
@Override
|
||||
@@ -120,9 +120,9 @@ class ResourceMatcherTests {
|
||||
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("alpha/**", "bravo/*", "*"),
|
||||
Arrays.asList(".*", "alpha/**/excluded"));
|
||||
List<MatchedResource> matchedResources = resourceMatcher
|
||||
.find(Arrays.asList(new File("src/test/resources/resource-matcher/one"),
|
||||
new File("src/test/resources/resource-matcher/two"),
|
||||
new File("src/test/resources/resource-matcher/three")));
|
||||
.find(Arrays.asList(new File("src/test/resources/resource-matcher/one"),
|
||||
new File("src/test/resources/resource-matcher/two"),
|
||||
new File("src/test/resources/resource-matcher/three")));
|
||||
List<String> paths = new ArrayList<>();
|
||||
for (MatchedResource resource : matchedResources) {
|
||||
paths.add(resource.getName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -63,7 +63,7 @@ class EncodePasswordCommandTests {
|
||||
then(this.log).should().info(this.message.capture());
|
||||
assertThat(this.message.getValue()).startsWith("{bcrypt}");
|
||||
assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder().matches("boot", this.message.getValue()))
|
||||
.isTrue();
|
||||
.isTrue();
|
||||
assertThat(status).isEqualTo(ExitStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -77,7 +77,7 @@ class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
request.getDependencies().add("foo:bar");
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.invoker.generate(request))
|
||||
.withMessageContaining(jsonMessage);
|
||||
.withMessageContaining(jsonMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,7 +85,7 @@ class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
mockProjectGenerationError(400, null);
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.invoker.generate(request))
|
||||
.withMessageContaining("unexpected 400 error");
|
||||
.withMessageContaining("unexpected 400 error");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +96,7 @@ class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
given(this.http.execute(isA(HttpGet.class))).willReturn(response);
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.invoker.generate(request))
|
||||
.withMessageContaining("No content received from server");
|
||||
.withMessageContaining("No content received from server");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +105,7 @@ class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
mockMetadataGetError(500, jsonMessage);
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.invoker.generate(request))
|
||||
.withMessageContaining(jsonMessage);
|
||||
.withMessageContaining(jsonMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,7 +116,7 @@ class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
given(this.http.execute(isA(HttpGet.class))).willReturn(response);
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.invoker.generate(request))
|
||||
.withMessageContaining("Invalid content received from server");
|
||||
.withMessageContaining("Invalid content received from server");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,7 +126,7 @@ class InitializrServiceTests extends AbstractHttpClientMockTests {
|
||||
given(this.http.execute(isA(HttpGet.class))).willReturn(response);
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.invoker.generate(request))
|
||||
.withMessageContaining("No content received from server");
|
||||
.withMessageContaining("No content received from server");
|
||||
}
|
||||
|
||||
private ProjectGenerationResponse generateProject(ProjectGenerationRequest request,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -57,21 +57,21 @@ class ProjectGenerationRequestTests {
|
||||
this.request.setServiceUrl(customServerUrl);
|
||||
this.request.getDependencies().add("security");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(new URI(customServerUrl + "/starter.zip?dependencies=security&type=test-type"));
|
||||
.isEqualTo(new URI(customServerUrl + "/starter.zip?dependencies=security&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customBootVersion() {
|
||||
this.request.setBootVersion("1.2.0.RELEASE");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&bootVersion=1.2.0.RELEASE"));
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&bootVersion=1.2.0.RELEASE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void singleDependency() {
|
||||
this.request.getDependencies().add("web");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?dependencies=web&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?dependencies=web&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,21 +79,21 @@ class ProjectGenerationRequestTests {
|
||||
this.request.getDependencies().add("web");
|
||||
this.request.getDependencies().add("data-jpa");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?dependencies=web%2Cdata-jpa&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?dependencies=web%2Cdata-jpa&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customJavaVersion() {
|
||||
this.request.setJavaVersion("1.8");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&javaVersion=1.8"));
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&javaVersion=1.8"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customPackageName() {
|
||||
this.request.setPackageName("demo.foo");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?packageName=demo.foo&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?packageName=demo.foo&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,14 +110,14 @@ class ProjectGenerationRequestTests {
|
||||
void customPackaging() {
|
||||
this.request.setPackaging("war");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&packaging=war"));
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&packaging=war"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void customLanguage() {
|
||||
this.request.setLanguage("groovy");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&language=groovy"));
|
||||
.isEqualTo(createDefaultUrl("?type=test-type&language=groovy"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,29 +127,29 @@ class ProjectGenerationRequestTests {
|
||||
this.request.setVersion("1.0.1-SNAPSHOT");
|
||||
this.request.setDescription("Spring Boot Test");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?groupId=org.acme&artifactId=sample&version=1.0.1-SNAPSHOT"
|
||||
+ "&description=Spring+Boot+Test&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?groupId=org.acme&artifactId=sample&version=1.0.1-SNAPSHOT"
|
||||
+ "&description=Spring+Boot+Test&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void outputCustomizeArtifactId() {
|
||||
this.request.setOutput("my-project");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my-project&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my-project&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void outputArchiveCustomizeArtifactId() {
|
||||
this.request.setOutput("my-project.zip");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my-project&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my-project&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void outputArchiveWithDotsCustomizeArtifactId() {
|
||||
this.request.setOutput("my.nice.project.zip");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my.nice.project&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my.nice.project&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,7 +157,7 @@ class ProjectGenerationRequestTests {
|
||||
this.request.setOutput("my-project");
|
||||
this.request.setArtifactId("my-id");
|
||||
assertThat(this.request.generateUrl(createDefaultMetadata()))
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my-id&type=test-type"));
|
||||
.isEqualTo(createDefaultUrl("?artifactId=my-id&type=test-type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,7 +165,7 @@ class ProjectGenerationRequestTests {
|
||||
InitializrServiceMetadata metadata = readMetadata();
|
||||
setBuildAndFormat("does-not-exist", null);
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.request.generateUrl(metadata))
|
||||
.withMessageContaining("does-not-exist");
|
||||
.withMessageContaining("does-not-exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,7 +173,8 @@ class ProjectGenerationRequestTests {
|
||||
InitializrServiceMetadata metadata = readMetadata("types-conflict");
|
||||
setBuildAndFormat("gradle", null);
|
||||
assertThatExceptionOfType(ReportableException.class).isThrownBy(() -> this.request.generateUrl(metadata))
|
||||
.withMessageContaining("gradle-project").withMessageContaining("gradle-project-2");
|
||||
.withMessageContaining("gradle-project")
|
||||
.withMessageContaining("gradle-project-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -195,14 +196,14 @@ class ProjectGenerationRequestTests {
|
||||
void invalidType() {
|
||||
this.request.setType("does-not-exist");
|
||||
assertThatExceptionOfType(ReportableException.class)
|
||||
.isThrownBy(() -> this.request.generateUrl(createDefaultMetadata()));
|
||||
.isThrownBy(() -> this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void noTypeAndNoDefault() {
|
||||
assertThatExceptionOfType(ReportableException.class)
|
||||
.isThrownBy(() -> this.request.generateUrl(readMetadata("types-conflict")))
|
||||
.withMessageContaining("no default is defined");
|
||||
.isThrownBy(() -> this.request.generateUrl(readMetadata("types-conflict")))
|
||||
.withMessageContaining("no default is defined");
|
||||
}
|
||||
|
||||
private static URI createUrl(String actionAndParam) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -112,7 +112,7 @@ class GroovyGrabDependencyResolverTests {
|
||||
@Test
|
||||
void resolveMultipleArtifacts() throws Exception {
|
||||
List<File> resolved = this.resolver
|
||||
.resolve(Arrays.asList("junit:junit:4.11", "commons-logging:commons-logging:1.1.3"));
|
||||
.resolve(Arrays.asList("junit:junit:4.11", "commons-logging:commons-logging:1.1.3"));
|
||||
assertThat(resolved).hasSize(4);
|
||||
assertThat(getNames(resolved)).containsOnly("junit-4.11.jar", "commons-logging-1.1.3.jar",
|
||||
"hamcrest-core-2.2.jar", "hamcrest-2.2.jar");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -37,9 +37,8 @@ class SpringApplicationRunnerTests {
|
||||
given(configuration.getClasspath()).willReturn(new String[] { "foo", "bar" });
|
||||
given(configuration.getLogLevel()).willReturn(Level.INFO);
|
||||
assertThatExceptionOfType(RuntimeException.class)
|
||||
.isThrownBy(
|
||||
() -> new SpringApplicationRunner(configuration, new String[] { "foo", "bar" }).compileAndRun())
|
||||
.withMessage("No classes found in '[foo, bar]'");
|
||||
.isThrownBy(() -> new SpringApplicationRunner(configuration, new String[] { "foo", "bar" }).compileAndRun())
|
||||
.withMessage("No classes found in '[foo, bar]'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -116,7 +116,7 @@ class DependencyCustomizerTests {
|
||||
@Test
|
||||
void anyMissingClassesWithMixtureOfClassesPerformsAdd() {
|
||||
this.dependencyCustomizer.ifAnyMissingClasses(getClass().getName(), "does.not.Exist")
|
||||
.add("spring-boot-starter-logging");
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -135,56 +135,68 @@ class DependencyCustomizerTests {
|
||||
@Test
|
||||
void allMissingClassesWithMixtureOfClassesDoesNotPerformAdd() {
|
||||
this.dependencyCustomizer.ifAllMissingClasses(getClass().getName(), "does.not.Exist")
|
||||
.add("spring-boot-starter-logging");
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void allMissingClassesWithAllClassesMissingPerformsAdd() {
|
||||
this.dependencyCustomizer.ifAllMissingClasses("does.not.Exist", "does.not.exist.Either")
|
||||
.add("spring-boot-starter-logging");
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void allResourcesPresentWithAllResourcesPresentPerformsAdd() {
|
||||
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/resource2.txt").add("spring-boot-starter-logging");
|
||||
this.dependencyCustomizer
|
||||
.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/resource2.txt")
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void allResourcesPresentWithSomeResourcesPresentDoesNotPerformAdd() {
|
||||
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/does-not-exist.txt").add("spring-boot-starter-logging");
|
||||
this.dependencyCustomizer
|
||||
.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/does-not-exist.txt")
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void allResourcesPresentWithNoResourcesPresentDoesNotPerformAdd() {
|
||||
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/does-not-exist",
|
||||
"dependency-customizer-tests/does-not-exist-either.txt").add("spring-boot-starter-logging");
|
||||
this.dependencyCustomizer
|
||||
.ifAllResourcesPresent("dependency-customizer-tests/does-not-exist",
|
||||
"dependency-customizer-tests/does-not-exist-either.txt")
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void anyResourcesPresentWithAllResourcesPresentPerformsAdd() {
|
||||
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/resource2.txt").add("spring-boot-starter-logging");
|
||||
this.dependencyCustomizer
|
||||
.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/resource2.txt")
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anyResourcesPresentWithSomeResourcesPresentPerforms() {
|
||||
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/does-not-exist.txt").add("spring-boot-starter-logging");
|
||||
this.dependencyCustomizer
|
||||
.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
|
||||
"dependency-customizer-tests/does-not-exist.txt")
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anyResourcesPresentWithNoResourcesPresentDoesNotPerformAdd() {
|
||||
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/does-not-exist",
|
||||
"dependency-customizer-tests/does-not-exist-either.txt").add("spring-boot-starter-logging");
|
||||
this.dependencyCustomizer
|
||||
.ifAnyResourcesPresent("dependency-customizer-tests/does-not-exist",
|
||||
"dependency-customizer-tests/does-not-exist-either.txt")
|
||||
.add("spring-boot-starter-logging");
|
||||
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -38,7 +38,7 @@ class RepositoryConfigurationFactoryTests {
|
||||
void defaultRepositories() {
|
||||
TestPropertyValues.of("user.home:src/test/resources/maven-settings/basic").applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone");
|
||||
return null;
|
||||
@@ -48,49 +48,49 @@ class RepositoryConfigurationFactoryTests {
|
||||
@Test
|
||||
void snapshotRepositoriesDisabled() {
|
||||
TestPropertyValues.of("user.home:src/test/resources/maven-settings/basic", "disableSpringSnapshotRepos:true")
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local");
|
||||
return null;
|
||||
});
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local");
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void activeByDefaultProfileRepositories() {
|
||||
TestPropertyValues.of("user.home:src/test/resources/maven-settings/active-profile-repositories")
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone", "active-by-default");
|
||||
return null;
|
||||
});
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone", "active-by-default");
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void activeByPropertyProfileRepositories() {
|
||||
TestPropertyValues.of("user.home:src/test/resources/maven-settings/active-profile-repositories", "foo:bar")
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone", "active-by-property");
|
||||
return null;
|
||||
});
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone", "active-by-property");
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void interpolationProfileRepositories() {
|
||||
TestPropertyValues
|
||||
.of("user.home:src/test/resources/maven-settings/active-profile-repositories", "interpolate:true")
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone", "interpolate-releases", "interpolate-snapshots");
|
||||
return null;
|
||||
});
|
||||
.of("user.home:src/test/resources/maven-settings/active-profile-repositories", "interpolate:true")
|
||||
.applyToSystemProperties(() -> {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
assertRepositoryConfiguration(repositoryConfiguration, "central", "local", "spring-snapshot",
|
||||
"spring-milestone", "interpolate-releases", "interpolate-snapshots");
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private void assertRepositoryConfiguration(List<RepositoryConfiguration> configurations, String... expectedNames) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -45,14 +45,14 @@ class CompositeDependencyManagementTests {
|
||||
given(this.dependencyManagement1.getSpringBootVersion()).willReturn(null);
|
||||
given(this.dependencyManagement2.getSpringBootVersion()).willReturn(null);
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2)
|
||||
.getSpringBootVersion()).isNull();
|
||||
.getSpringBootVersion()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void knownSpringBootVersion() {
|
||||
given(this.dependencyManagement1.getSpringBootVersion()).willReturn("1.2.3");
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2)
|
||||
.getSpringBootVersion()).isEqualTo("1.2.3");
|
||||
.getSpringBootVersion()).isEqualTo("1.2.3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,25 +60,25 @@ class CompositeDependencyManagementTests {
|
||||
given(this.dependencyManagement1.find("artifact")).willReturn(null);
|
||||
given(this.dependencyManagement2.find("artifact")).willReturn(null);
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2)
|
||||
.find("artifact")).isNull();
|
||||
.find("artifact")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void knownDependency() {
|
||||
given(this.dependencyManagement1.find("artifact")).willReturn(new Dependency("test", "artifact", "1.2.3"));
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2)
|
||||
.find("artifact")).isEqualTo(new Dependency("test", "artifact", "1.2.3"));
|
||||
.find("artifact")).isEqualTo(new Dependency("test", "artifact", "1.2.3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDependencies() {
|
||||
given(this.dependencyManagement1.getDependencies())
|
||||
.willReturn(Arrays.asList(new Dependency("test", "artifact", "1.2.3")));
|
||||
.willReturn(Arrays.asList(new Dependency("test", "artifact", "1.2.3")));
|
||||
given(this.dependencyManagement2.getDependencies())
|
||||
.willReturn(Arrays.asList(new Dependency("test", "artifact", "1.2.4")));
|
||||
.willReturn(Arrays.asList(new Dependency("test", "artifact", "1.2.4")));
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1, this.dependencyManagement2)
|
||||
.getDependencies()).containsOnly(new Dependency("test", "artifact", "1.2.3"),
|
||||
new Dependency("test", "artifact", "1.2.4"));
|
||||
.getDependencies())
|
||||
.containsOnly(new Dependency("test", "artifact", "1.2.3"), new Dependency("test", "artifact", "1.2.4"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -57,7 +57,7 @@ final class DetailedProgressReporterTests {
|
||||
TransferEvent startedEvent = new TransferEvent.Builder(this.session, this.resource).build();
|
||||
this.session.getTransferListener().transferStarted(startedEvent);
|
||||
assertThat(new String(this.baos.toByteArray()))
|
||||
.isEqualTo(String.format("Downloading: %s%s%n", REPOSITORY, ARTIFACT));
|
||||
.isEqualTo(String.format("Downloading: %s%s%n", REPOSITORY, ARTIFACT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,7 +65,7 @@ final class DetailedProgressReporterTests {
|
||||
// Ensure some transfer time
|
||||
Thread.sleep(100);
|
||||
TransferEvent completedEvent = new TransferEvent.Builder(this.session, this.resource).addTransferredBytes(4096)
|
||||
.build();
|
||||
.build();
|
||||
this.session.getTransferListener().transferSucceeded(completedEvent);
|
||||
String message = new String(this.baos.toByteArray()).replace("\\", "/");
|
||||
assertThat(message).startsWith("Downloaded: " + REPOSITORY + ARTIFACT);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -54,15 +54,15 @@ class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
@Test
|
||||
void noLocalRepositoryWhenNoGrapeRoot() {
|
||||
new GrapeRootRepositorySystemSessionAutoConfiguration().apply(this.session, this.repositorySystem);
|
||||
then(this.repositorySystem).should(never()).newLocalRepositoryManager(eq(this.session),
|
||||
any(LocalRepository.class));
|
||||
then(this.repositorySystem).should(never())
|
||||
.newLocalRepositoryManager(eq(this.session), any(LocalRepository.class));
|
||||
assertThat(this.session.getLocalRepository()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void grapeRootConfiguresLocalRepositoryLocation() {
|
||||
given(this.repositorySystem.newLocalRepositoryManager(eq(this.session), any(LocalRepository.class)))
|
||||
.willAnswer(new LocalRepositoryManagerAnswer());
|
||||
.willAnswer(new LocalRepositoryManagerAnswer());
|
||||
|
||||
System.setProperty("grape.root", "foo");
|
||||
try {
|
||||
@@ -76,7 +76,7 @@ class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
|
||||
assertThat(this.session.getLocalRepository()).isNotNull();
|
||||
assertThat(this.session.getLocalRepository().getBasedir().getAbsolutePath())
|
||||
.endsWith(File.separatorChar + "foo" + File.separatorChar + "repository");
|
||||
.endsWith(File.separatorChar + "foo" + File.separatorChar + "repository");
|
||||
}
|
||||
|
||||
private class LocalRepositoryManagerAnswer implements Answer<LocalRepositoryManager> {
|
||||
@@ -85,7 +85,7 @@ class GrapeRootRepositorySystemSessionAutoConfigurationTests {
|
||||
public LocalRepositoryManager answer(InvocationOnMock invocation) throws Throwable {
|
||||
LocalRepository localRepository = invocation.getArgument(1);
|
||||
return new SimpleLocalRepositoryManagerFactory()
|
||||
.newInstance(GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session, localRepository);
|
||||
.newInstance(GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session, localRepository);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class MavenResolverGrapeEngineTests {
|
||||
private GrapeEngine createGrapeEngine(RepositoryConfiguration... additionalRepositories) {
|
||||
List<RepositoryConfiguration> repositoryConfigurations = new ArrayList<>();
|
||||
repositoryConfigurations
|
||||
.add(new RepositoryConfiguration("central", URI.create("https://repo.maven.apache.org/maven2"), false));
|
||||
.add(new RepositoryConfiguration("central", URI.create("https://repo.maven.apache.org/maven2"), false));
|
||||
repositoryConfigurations.addAll(Arrays.asList(additionalRepositories));
|
||||
DependencyResolutionContext dependencyResolutionContext = new DependencyResolutionContext();
|
||||
dependencyResolutionContext.addDependencyManagement(new SpringBootDependenciesDependencyManagement());
|
||||
@@ -78,7 +78,7 @@ class MavenResolverGrapeEngineTests {
|
||||
doWithCustomUserHome(() -> {
|
||||
GrapeEngine grapeEngine = createGrapeEngine();
|
||||
DefaultRepositorySystemSession session = (DefaultRepositorySystemSession) ReflectionTestUtils
|
||||
.getField(grapeEngine, "session");
|
||||
.getField(grapeEngine, "session");
|
||||
|
||||
assertThat(session.getProxySelector() instanceof CompositeProxySelector).isTrue();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -64,18 +64,18 @@ class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
|
||||
void propertyInterpolation() {
|
||||
final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
||||
given(this.repositorySystem.newLocalRepositoryManager(eq(session), any(LocalRepository.class)))
|
||||
.willAnswer((invocation) -> {
|
||||
LocalRepository localRepository = invocation.getArgument(1);
|
||||
return new SimpleLocalRepositoryManagerFactory().newInstance(session, localRepository);
|
||||
});
|
||||
.willAnswer((invocation) -> {
|
||||
LocalRepository localRepository = invocation.getArgument(1);
|
||||
return new SimpleLocalRepositoryManagerFactory().newInstance(session, localRepository);
|
||||
});
|
||||
TestPropertyValues.of("user.home:src/test/resources/maven-settings/property-interpolation", "foo:bar")
|
||||
.applyToSystemProperties(() -> {
|
||||
new SettingsXmlRepositorySystemSessionAutoConfiguration().apply(session,
|
||||
SettingsXmlRepositorySystemSessionAutoConfigurationTests.this.repositorySystem);
|
||||
return null;
|
||||
});
|
||||
.applyToSystemProperties(() -> {
|
||||
new SettingsXmlRepositorySystemSessionAutoConfiguration().apply(session,
|
||||
SettingsXmlRepositorySystemSessionAutoConfigurationTests.this.repositorySystem);
|
||||
return null;
|
||||
});
|
||||
assertThat(session.getLocalRepository().getBasedir().getAbsolutePath())
|
||||
.endsWith(File.separatorChar + "bar" + File.separatorChar + "repository");
|
||||
.endsWith(File.separatorChar + "bar" + File.separatorChar + "repository");
|
||||
}
|
||||
|
||||
private void assertSessionCustomization(String userHome) {
|
||||
@@ -86,7 +86,7 @@ class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
|
||||
return null;
|
||||
});
|
||||
RemoteRepository repository = new RemoteRepository.Builder("my-server", "default", "https://maven.example.com")
|
||||
.build();
|
||||
.build();
|
||||
assertMirrorSelectorConfiguration(session, repository);
|
||||
assertProxySelectorConfiguration(session, repository);
|
||||
assertAuthenticationSelectorConfiguration(session, repository);
|
||||
|
||||
Reference in New Issue
Block a user