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.
|
||||
@@ -55,7 +55,7 @@ class JarCommandIT {
|
||||
invocation.await();
|
||||
assertThat(invocation.getStandardOutput()).isEqualTo("");
|
||||
assertThat(invocation.getErrorOutput())
|
||||
.contains("The name of the resulting jar and at least one source file must be specified");
|
||||
.contains("The name of the resulting jar and at least one source file must be specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,7 +64,7 @@ class JarCommandIT {
|
||||
invocation.await();
|
||||
assertThat(invocation.getStandardOutput()).isEqualTo("");
|
||||
assertThat(invocation.getErrorOutput())
|
||||
.contains("The name of the resulting jar and at least one source file must be specified");
|
||||
.contains("The name of the resulting jar and at least one source file must be specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,9 +109,12 @@ class JarCommandIT {
|
||||
assertThat(invocation.getErrorOutput()).isEqualTo("");
|
||||
}
|
||||
assertThat(invocation.getStandardOutput()).contains("Hello World!")
|
||||
.contains("/BOOT-INF/classes!/public/public.txt").contains("/BOOT-INF/classes!/resources/resource.txt")
|
||||
.contains("/BOOT-INF/classes!/static/static.txt").contains("/BOOT-INF/classes!/templates/template.txt")
|
||||
.contains("/BOOT-INF/classes!/root.properties").contains("Goodbye Mama");
|
||||
.contains("/BOOT-INF/classes!/public/public.txt")
|
||||
.contains("/BOOT-INF/classes!/resources/resource.txt")
|
||||
.contains("/BOOT-INF/classes!/static/static.txt")
|
||||
.contains("/BOOT-INF/classes!/templates/template.txt")
|
||||
.contains("/BOOT-INF/classes!/root.properties")
|
||||
.contains("Goodbye Mama");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,9 +135,12 @@ class JarCommandIT {
|
||||
if (!JAVA_9_OR_LATER) {
|
||||
assertThat(invocation.getErrorOutput()).isEqualTo("");
|
||||
}
|
||||
assertThat(invocation.getStandardOutput()).contains("Hello World!").doesNotContain("/public/public.txt")
|
||||
.doesNotContain("/resources/resource.txt").contains("/static/static.txt")
|
||||
.contains("/templates/template.txt").contains("Goodbye Mama");
|
||||
assertThat(invocation.getStandardOutput()).contains("Hello World!")
|
||||
.doesNotContain("/public/public.txt")
|
||||
.doesNotContain("/resources/resource.txt")
|
||||
.contains("/static/static.txt")
|
||||
.contains("/templates/template.txt")
|
||||
.contains("Goodbye Mama");
|
||||
}
|
||||
|
||||
private static boolean isClassPresent(String name) {
|
||||
|
||||
@@ -133,9 +133,9 @@ public final class CommandLineInvoker {
|
||||
public Invocation(Process process) {
|
||||
this.process = process;
|
||||
this.streamReaders
|
||||
.add(new Thread(new StreamReadingRunnable(this.process.getErrorStream(), this.err, this.combined)));
|
||||
.add(new Thread(new StreamReadingRunnable(this.process.getErrorStream(), this.err, this.combined)));
|
||||
this.streamReaders
|
||||
.add(new Thread(new StreamReadingRunnable(this.process.getInputStream(), this.out, this.combined)));
|
||||
.add(new Thread(new StreamReadingRunnable(this.process.getInputStream(), this.out, this.combined)));
|
||||
for (Thread streamReader : this.streamReaders) {
|
||||
streamReader.start();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
|
||||
public class CommandRunner implements Iterable<Command> {
|
||||
|
||||
private static final Set<CommandException.Option> NO_EXCEPTION_OPTIONS = EnumSet
|
||||
.noneOf(CommandException.Option.class);
|
||||
.noneOf(CommandException.Option.class);
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -110,10 +110,14 @@ abstract class ArchiveCommand extends OptionParsingCommand {
|
||||
protected void doOptions() {
|
||||
this.includeOption = option("include",
|
||||
"Pattern applied to directories on the classpath to find files to include in the resulting ")
|
||||
.withRequiredArg().withValuesSeparatedBy(",").defaultsTo("");
|
||||
.withRequiredArg()
|
||||
.withValuesSeparatedBy(",")
|
||||
.defaultsTo("");
|
||||
this.excludeOption = option("exclude", "Pattern applied to directories on the classpath to find files to "
|
||||
+ "exclude from the resulting " + this.type).withRequiredArg().withValuesSeparatedBy(",")
|
||||
.defaultsTo("");
|
||||
+ "exclude from the resulting " + this.type)
|
||||
.withRequiredArg()
|
||||
.withValuesSeparatedBy(",")
|
||||
.defaultsTo("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +154,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
|
||||
|
||||
private GroovyCompiler createCompiler(OptionSet options) {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
.createDefaultRepositoryConfiguration();
|
||||
GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration(options, this,
|
||||
repositoryConfiguration);
|
||||
GroovyCompiler groovyCompiler = new GroovyCompiler(configuration);
|
||||
@@ -206,8 +210,8 @@ abstract class ArchiveCommand extends OptionParsingCommand {
|
||||
private void addManifest(JarWriter writer, Class<?>[] compiledClasses) throws IOException {
|
||||
Manifest manifest = new Manifest();
|
||||
manifest.getMainAttributes().putValue("Manifest-Version", "1.0");
|
||||
manifest.getMainAttributes().putValue(PackagedSpringApplicationLauncher.SOURCE_ENTRY,
|
||||
commaDelimitedClassNames(compiledClasses));
|
||||
manifest.getMainAttributes()
|
||||
.putValue(PackagedSpringApplicationLauncher.SOURCE_ENTRY, commaDelimitedClassNames(compiledClasses));
|
||||
writer.writeManifest(manifest);
|
||||
}
|
||||
|
||||
@@ -226,7 +230,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
|
||||
addClass(writer, PackagedSpringApplicationLauncher.class);
|
||||
addClass(writer, SpringApplicationLauncher.class);
|
||||
Resource[] resources = new PathMatchingResourcePatternResolver()
|
||||
.getResources("org/springframework/boot/groovy/**");
|
||||
.getResources("org/springframework/boot/groovy/**");
|
||||
for (Resource resource : resources) {
|
||||
String url = resource.getURL().toString();
|
||||
addResource(writer, resource, url.substring(url.indexOf("org/springframework/boot/groovy/")));
|
||||
|
||||
@@ -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.
|
||||
@@ -70,8 +70,8 @@ public class EncodePasswordCommand extends OptionParsingCommand {
|
||||
@Override
|
||||
public Collection<HelpExample> getExamples() {
|
||||
List<HelpExample> examples = new ArrayList<>();
|
||||
examples.add(
|
||||
new HelpExample("To encode a password with the default encoder", "spring encodepassword mypassword"));
|
||||
examples
|
||||
.add(new HelpExample("To encode a password with the default encoder", "spring encodepassword mypassword"));
|
||||
examples.add(new HelpExample("To encode a password with pbkdf2", "spring encodepassword -a pbkdf2 mypassword"));
|
||||
return examples;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class EncodePasswordCommand extends OptionParsingCommand {
|
||||
@Override
|
||||
protected void options() {
|
||||
this.algorithm = option(Arrays.asList("algorithm", "a"), "The algorithm to use").withRequiredArg()
|
||||
.defaultsTo("default");
|
||||
.defaultsTo("default");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -49,7 +49,7 @@ public class GrabCommand extends OptionParsingCommand {
|
||||
protected ExitStatus run(OptionSet options) throws Exception {
|
||||
SourceOptions sourceOptions = new SourceOptions(options);
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
.createDefaultRepositoryConfiguration();
|
||||
GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration(options, this,
|
||||
repositoryConfiguration);
|
||||
if (System.getProperty("grape.root") == null) {
|
||||
|
||||
@@ -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.
|
||||
@@ -139,7 +139,7 @@ public class InitCommand extends OptionParsingCommand {
|
||||
@Override
|
||||
protected void options() {
|
||||
this.target = option(Arrays.asList("target"), "URL of the service to use").withRequiredArg()
|
||||
.defaultsTo(ProjectGenerationRequest.DEFAULT_SERVICE_URL);
|
||||
.defaultsTo(ProjectGenerationRequest.DEFAULT_SERVICE_URL);
|
||||
this.listCapabilities = option(Arrays.asList("list"),
|
||||
"List the capabilities of the service. Use it to discover the "
|
||||
+ "dependencies and the types that are available");
|
||||
@@ -149,33 +149,37 @@ public class InitCommand extends OptionParsingCommand {
|
||||
|
||||
private void projectGenerationOptions() {
|
||||
this.groupId = option(Arrays.asList("group-id", "g"), "Project coordinates (for example 'org.test')")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
this.artifactId = option(Arrays.asList("artifact-id", "a"),
|
||||
"Project coordinates; infer archive name (for example 'test')").withRequiredArg();
|
||||
"Project coordinates; infer archive name (for example 'test')")
|
||||
.withRequiredArg();
|
||||
this.version = option(Arrays.asList("version", "v"), "Project version (for example '0.0.1-SNAPSHOT')")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
this.name = option(Arrays.asList("name", "n"), "Project name; infer application name").withRequiredArg();
|
||||
this.description = option("description", "Project description").withRequiredArg();
|
||||
this.packageName = option(Arrays.asList("package-name"), "Package name").withRequiredArg();
|
||||
this.type = option(Arrays.asList("type", "t"),
|
||||
"Project type. Not normally needed if you use --build "
|
||||
+ "and/or --format. Check the capabilities of the service (--list) for more details")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
this.packaging = option(Arrays.asList("packaging", "p"), "Project packaging (for example 'jar')")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
this.build = option("build", "Build system to use (for example 'maven' or 'gradle')").withRequiredArg()
|
||||
.defaultsTo("maven");
|
||||
.defaultsTo("maven");
|
||||
this.format = option("format", "Format of the generated content (for example 'build' for a build file, "
|
||||
+ "'project' for a project archive)").withRequiredArg().defaultsTo("project");
|
||||
+ "'project' for a project archive)")
|
||||
.withRequiredArg()
|
||||
.defaultsTo("project");
|
||||
this.javaVersion = option(Arrays.asList("java-version", "j"), "Language level (for example '1.8')")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
this.language = option(Arrays.asList("language", "l"), "Programming language (for example 'java')")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
this.bootVersion = option(Arrays.asList("boot-version", "b"),
|
||||
"Spring Boot version (for example '1.2.0.RELEASE')").withRequiredArg();
|
||||
"Spring Boot version (for example '1.2.0.RELEASE')")
|
||||
.withRequiredArg();
|
||||
this.dependencies = option(Arrays.asList("dependencies", "d"),
|
||||
"Comma-separated list of dependency identifiers to include in the generated project")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
}
|
||||
|
||||
private void otherOptions() {
|
||||
|
||||
@@ -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 @@ class Installer {
|
||||
private static GroovyCompilerConfiguration createCompilerConfiguration(OptionSet options,
|
||||
CompilerOptionHandler compilerOptionHandler) {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
.createDefaultRepositoryConfiguration();
|
||||
return new OptionSetGroovyCompilerConfiguration(options, compilerOptionHandler, repositoryConfiguration) {
|
||||
@Override
|
||||
public boolean isAutoconfigure() {
|
||||
|
||||
@@ -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.
|
||||
@@ -43,9 +43,11 @@ public class CompilerOptionHandler extends OptionHandler {
|
||||
this.noGuessImportsOption = option("no-guess-imports", "Do not attempt to guess imports");
|
||||
this.noGuessDependenciesOption = option("no-guess-dependencies", "Do not attempt to guess dependencies");
|
||||
this.autoconfigureOption = option("autoconfigure", "Add autoconfigure compiler transformations")
|
||||
.withOptionalArg().ofType(Boolean.class).defaultsTo(true);
|
||||
.withOptionalArg()
|
||||
.ofType(Boolean.class)
|
||||
.defaultsTo(true);
|
||||
this.classpathOption = option(Arrays.asList("classpath", "cp"), "Additional classpath entries")
|
||||
.withRequiredArg();
|
||||
.withRequiredArg();
|
||||
doOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -152,7 +152,7 @@ public class OptionHandler {
|
||||
@Override
|
||||
public String format(Map<String, ? extends OptionDescriptor> options) {
|
||||
Comparator<OptionDescriptor> comparator = Comparator
|
||||
.comparing((optionDescriptor) -> optionDescriptor.options().iterator().next());
|
||||
.comparing((optionDescriptor) -> optionDescriptor.options().iterator().next());
|
||||
Set<OptionDescriptor> sorted = new TreeSet<>(comparator);
|
||||
sorted.addAll(options.values());
|
||||
for (OptionDescriptor descriptor : sorted) {
|
||||
|
||||
@@ -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.
|
||||
@@ -99,7 +99,7 @@ public class RunCommand extends OptionParsingCommand {
|
||||
SourceOptions sourceOptions = new SourceOptions(options);
|
||||
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
.createDefaultRepositoryConfiguration();
|
||||
repositoryConfiguration.add(0,
|
||||
new RepositoryConfiguration("local", new File("repository").toURI(), true));
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -165,7 +165,7 @@ public class SpringApplicationRunner {
|
||||
synchronized (this.monitor) {
|
||||
try {
|
||||
this.applicationContext = new SpringApplicationLauncher(getContextClassLoader())
|
||||
.launch(this.compiledSources, SpringApplicationRunner.this.args);
|
||||
.launch(this.compiledSources, SpringApplicationRunner.this.args);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
@@ -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.
|
||||
@@ -114,7 +114,7 @@ public class Shell {
|
||||
this.consoleReader.setBellEnabled(false);
|
||||
this.consoleReader.setExpandEvents(false);
|
||||
this.consoleReader
|
||||
.addCompleter(new CommandCompleter(this.consoleReader, this.argumentDelimiter, this.commandRunner));
|
||||
.addCompleter(new CommandCompleter(this.consoleReader, this.argumentDelimiter, this.commandRunner));
|
||||
this.consoleReader.setCompletionHandler(new CandidateListCompletionHandler());
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -67,9 +67,9 @@ public abstract class AnnotatedNodeASTTransformation implements ASTTransformatio
|
||||
visitAnnotatedNode(importNode, annotationNodes);
|
||||
}
|
||||
module.getStaticImports()
|
||||
.forEach((name, importNode) -> visitAnnotatedNode(importNode, annotationNodes));
|
||||
.forEach((name, importNode) -> visitAnnotatedNode(importNode, annotationNodes));
|
||||
module.getStaticStarImports()
|
||||
.forEach((name, importNode) -> visitAnnotatedNode(importNode, annotationNodes));
|
||||
.forEach((name, importNode) -> visitAnnotatedNode(importNode, annotationNodes));
|
||||
for (ClassNode classNode : module.getClasses()) {
|
||||
visitAnnotatedNode(classNode, annotationNodes);
|
||||
classNode.visitContents(classVisitor);
|
||||
|
||||
@@ -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.
|
||||
@@ -217,7 +217,7 @@ public class DependencyCustomizer {
|
||||
public DependencyCustomizer add(String module, String classifier, String type, boolean transitive) {
|
||||
if (canAdd()) {
|
||||
ArtifactCoordinatesResolver artifactCoordinatesResolver = this.dependencyResolutionContext
|
||||
.getArtifactCoordinatesResolver();
|
||||
.getArtifactCoordinatesResolver();
|
||||
this.classNode.addAnnotation(createGrabAnnotation(artifactCoordinatesResolver.getGroupId(module),
|
||||
artifactCoordinatesResolver.getArtifactId(module), artifactCoordinatesResolver.getVersion(module),
|
||||
classifier, type, transitive));
|
||||
|
||||
@@ -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.
|
||||
@@ -71,8 +71,8 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans
|
||||
public static final int ORDER = Ordered.HIGHEST_PRECEDENCE + 100;
|
||||
|
||||
private static final Set<String> DEPENDENCY_MANAGEMENT_BOM_ANNOTATION_NAMES = Collections
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList(DependencyManagementBom.class.getName(),
|
||||
DependencyManagementBom.class.getSimpleName())));
|
||||
.unmodifiableSet(new HashSet<>(
|
||||
Arrays.asList(DependencyManagementBom.class.getName(), DependencyManagementBom.class.getSimpleName())));
|
||||
|
||||
private final DependencyResolutionContext resolutionContext;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -249,8 +249,10 @@ public class GroovyCompiler {
|
||||
|
||||
private int getIndexOfASTTransformationVisitor(List<?> conversionOperations) {
|
||||
for (int index = 0; index < conversionOperations.size(); index++) {
|
||||
if (conversionOperations.get(index).getClass().getName()
|
||||
.startsWith(ASTTransformationVisitor.class.getName())) {
|
||||
if (conversionOperations.get(index)
|
||||
.getClass()
|
||||
.getName()
|
||||
.startsWith(ASTTransformationVisitor.class.getName())) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -47,7 +47,7 @@ public class ResolveDependencyCoordinatesTransformation extends AnnotatedNodeAST
|
||||
public static final int ORDER = DependencyManagementBomTransformation.ORDER + 300;
|
||||
|
||||
private static final Set<String> GRAB_ANNOTATION_NAMES = Collections
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList(Grab.class.getName(), Grab.class.getSimpleName())));
|
||||
.unmodifiableSet(new HashSet<>(Arrays.asList(Grab.class.getName(), Grab.class.getSimpleName())));
|
||||
|
||||
private final DependencyResolutionContext resolutionContext;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -41,7 +41,7 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.integration.config.EnableIntegration")
|
||||
.add("spring-boot-starter-integration");
|
||||
.add("spring-boot-starter-integration");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -41,7 +41,7 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.web.servlet.mvc.Controller")
|
||||
.add("spring-boot-starter-web");
|
||||
.add("spring-boot-starter-web");
|
||||
dependencies.ifAnyMissingClasses("groovy.text.TemplateEngine").add("groovy-templates");
|
||||
}
|
||||
|
||||
|
||||
@@ -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,8 +38,8 @@ public class SpringRetryCompilerAutoConfiguration extends CompilerAutoConfigurat
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.retry.annotation.EnableRetry").add("spring-retry",
|
||||
"spring-boot-starter-aop");
|
||||
dependencies.ifAnyMissingClasses("org.springframework.retry.annotation.EnableRetry")
|
||||
.add("spring-retry", "spring-boot-starter-aop");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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,20 +38,21 @@ public class SpringSecurityCompilerAutoConfiguration extends CompilerAutoConfigu
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses(
|
||||
"org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity")
|
||||
.add("spring-boot-starter-security");
|
||||
dependencies
|
||||
.ifAnyMissingClasses(
|
||||
"org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity")
|
||||
.add("spring-boot-starter-security");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addImports("org.springframework.security.core.Authentication",
|
||||
"org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity",
|
||||
"org.springframework.security.core.authority.AuthorityUtils")
|
||||
.addStarImports("org.springframework.security.config.annotation.web.configuration",
|
||||
"org.springframework.security.authentication",
|
||||
"org.springframework.security.config.annotation.web",
|
||||
"org.springframework.security.config.annotation.web.builders");
|
||||
imports
|
||||
.addImports("org.springframework.security.core.Authentication",
|
||||
"org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity",
|
||||
"org.springframework.security.core.authority.AuthorityUtils")
|
||||
.addStarImports("org.springframework.security.config.annotation.web.configuration",
|
||||
"org.springframework.security.authentication", "org.springframework.security.config.annotation.web",
|
||||
"org.springframework.security.config.annotation.web.builders");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -62,12 +62,13 @@ public class SpringTestCompilerAutoConfiguration extends CompilerAutoConfigurati
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.junit.runner", "org.springframework.boot.test",
|
||||
"org.springframework.boot.test.context", "org.springframework.boot.test.web.client",
|
||||
"org.springframework.http", "org.springframework.test.context.junit4",
|
||||
"org.springframework.test.annotation")
|
||||
.addImports("org.springframework.boot.test.context.SpringBootTest.WebEnvironment",
|
||||
"org.springframework.boot.test.web.client.TestRestTemplate");
|
||||
imports
|
||||
.addStarImports("org.junit.runner", "org.springframework.boot.test",
|
||||
"org.springframework.boot.test.context", "org.springframework.boot.test.web.client",
|
||||
"org.springframework.http", "org.springframework.test.context.junit4",
|
||||
"org.springframework.test.annotation")
|
||||
.addImports("org.springframework.boot.test.context.SpringBootTest.WebEnvironment",
|
||||
"org.springframework.boot.test.web.client.TestRestTemplate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -39,16 +39,18 @@ public class SpringWebsocketCompilerAutoConfiguration extends CompilerAutoConfig
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.web.socket.config.annotation.EnableWebSocket")
|
||||
.add("spring-boot-starter-websocket").add("spring-messaging");
|
||||
.add("spring-boot-starter-websocket")
|
||||
.add("spring-messaging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) {
|
||||
imports.addStarImports("org.springframework.messaging.handler.annotation",
|
||||
"org.springframework.messaging.simp.config", "org.springframework.web.socket.handler",
|
||||
"org.springframework.web.socket.sockjs.transport.handler",
|
||||
"org.springframework.web.socket.config.annotation")
|
||||
.addImports("org.springframework.web.socket.WebSocketHandler");
|
||||
imports
|
||||
.addStarImports("org.springframework.messaging.handler.annotation",
|
||||
"org.springframework.messaging.simp.config", "org.springframework.web.socket.handler",
|
||||
"org.springframework.web.socket.sockjs.transport.handler",
|
||||
"org.springframework.web.socket.config.annotation")
|
||||
.addImports("org.springframework.web.socket.WebSocketHandler");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -39,8 +39,8 @@ public class TransactionManagementCompilerAutoConfiguration extends CompilerAuto
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies) {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.transaction.annotation.Transactional").add("spring-tx",
|
||||
"spring-boot-starter-aop");
|
||||
dependencies.ifAnyMissingClasses("org.springframework.transaction.annotation.Transactional")
|
||||
.add("spring-tx", "spring-boot-starter-aop");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -43,7 +43,7 @@ public class SpringBootDependenciesDependencyManagement extends MavenModelDepend
|
||||
|
||||
try {
|
||||
return modelProcessor.read(SpringBootDependenciesDependencyManagement.class
|
||||
.getResourceAsStream("spring-boot-dependencies-effective-bom.xml"), null);
|
||||
.getResourceAsStream("spring-boot-dependencies-effective-bom.xml"), null);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException("Failed to build model from effective pom", ex);
|
||||
|
||||
@@ -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.
|
||||
@@ -52,7 +52,7 @@ public abstract class AetherGrapeEngineFactory {
|
||||
RepositorySystem repositorySystem = createServiceLocator().getService(RepositorySystem.class);
|
||||
DefaultRepositorySystemSession repositorySystemSession = MavenRepositorySystemUtils.newSession();
|
||||
ServiceLoader<RepositorySystemSessionAutoConfiguration> autoConfigurations = ServiceLoader
|
||||
.load(RepositorySystemSessionAutoConfiguration.class);
|
||||
.load(RepositorySystemSessionAutoConfiguration.class);
|
||||
for (RepositorySystemSessionAutoConfiguration autoConfiguration : autoConfigurations) {
|
||||
autoConfiguration.apply(repositorySystemSession, repositorySystem);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -85,10 +85,10 @@ public class DependencyResolutionContext {
|
||||
|
||||
public void addDependencyManagement(DependencyManagement dependencyManagement) {
|
||||
for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement
|
||||
.getDependencies()) {
|
||||
.getDependencies()) {
|
||||
List<Exclusion> aetherExclusions = new ArrayList<>();
|
||||
for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency
|
||||
.getExclusions()) {
|
||||
.getExclusions()) {
|
||||
aetherExclusions.add(new Exclusion(exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*"));
|
||||
}
|
||||
Dependency aetherDependency = new Dependency(new DefaultArtifact(dependency.getGroupId(),
|
||||
|
||||
@@ -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.
|
||||
@@ -49,7 +49,7 @@ public abstract class MavenResolverGrapeEngineFactory {
|
||||
RepositorySystem repositorySystem = createServiceLocator().getService(RepositorySystem.class);
|
||||
DefaultRepositorySystemSession repositorySystemSession = MavenRepositorySystemUtils.newSession();
|
||||
ServiceLoader<RepositorySystemSessionAutoConfiguration> autoConfigurations = ServiceLoader
|
||||
.load(RepositorySystemSessionAutoConfiguration.class);
|
||||
.load(RepositorySystemSessionAutoConfiguration.class);
|
||||
for (RepositorySystemSessionAutoConfiguration autoConfiguration : autoConfigurations) {
|
||||
autoConfiguration.apply(repositorySystemSession, repositorySystem);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -114,7 +114,8 @@ public class MavenSettings {
|
||||
DefaultProxySelector selector = new DefaultProxySelector();
|
||||
for (Proxy proxy : decryptedSettings.getProxies()) {
|
||||
Authentication authentication = new AuthenticationBuilder().addUsername(proxy.getUsername())
|
||||
.addPassword(proxy.getPassword()).build();
|
||||
.addPassword(proxy.getPassword())
|
||||
.build();
|
||||
selector.add(new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(),
|
||||
authentication), proxy.getNonProxyHosts());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -98,7 +98,7 @@ public abstract class ResourceUtils {
|
||||
private static List<String> getUrlsFromPrefixedWildcardPath(String path, ClassLoader classLoader)
|
||||
throws IOException {
|
||||
Resource[] resources = new PathMatchingResourcePatternResolver(new FileSearchResourceLoader(classLoader))
|
||||
.getResources(path);
|
||||
.getResources(path);
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Resource resource : resources) {
|
||||
if (resource.exists()) {
|
||||
|
||||
@@ -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