Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2019 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,8 +99,7 @@ public class ArtifactsLibrariesTests {
|
||||
Dependency unpack = new Dependency();
|
||||
unpack.setGroupId("gid");
|
||||
unpack.setArtifactId("aid");
|
||||
this.libs = new ArtifactsLibraries(this.artifacts, Collections.singleton(unpack),
|
||||
mock(Log.class));
|
||||
this.libs = new ArtifactsLibraries(this.artifacts, Collections.singleton(unpack), mock(Log.class));
|
||||
this.libs.doWithLibraries(this.callback);
|
||||
verify(this.callback).library(this.libraryCaptor.capture());
|
||||
assertThat(this.libraryCaptor.getValue().isUnpackRequired()).isTrue();
|
||||
@@ -128,10 +127,8 @@ public class ArtifactsLibrariesTests {
|
||||
this.libs = new ArtifactsLibraries(this.artifacts, null, mock(Log.class));
|
||||
this.libs.doWithLibraries(this.callback);
|
||||
verify(this.callback, times(2)).library(this.libraryCaptor.capture());
|
||||
assertThat(this.libraryCaptor.getAllValues().get(0).getName())
|
||||
.isEqualTo("g1-artifact-1.0.jar");
|
||||
assertThat(this.libraryCaptor.getAllValues().get(1).getName())
|
||||
.isEqualTo("g2-artifact-1.0.jar");
|
||||
assertThat(this.libraryCaptor.getAllValues().get(0).getName()).isEqualTo("g1-artifact-1.0.jar");
|
||||
assertThat(this.libraryCaptor.getAllValues().get(1).getName()).isEqualTo("g2-artifact-1.0.jar");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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,34 +41,29 @@ public class DependencyFilterMojoTests {
|
||||
|
||||
@Test
|
||||
public void filterDependencies() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "com.foo");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "com.foo");
|
||||
|
||||
Artifact artifact = createArtifact("com.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
createArtifact("com.foo", "one"), createArtifact("com.foo", "two"),
|
||||
artifact);
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(createArtifact("com.foo", "one"),
|
||||
createArtifact("com.foo", "two"), artifact);
|
||||
assertThat(artifacts).hasSize(1);
|
||||
assertThat(artifacts.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterGroupIdExactMatch() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "com.foo");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "com.foo");
|
||||
|
||||
Artifact artifact = createArtifact("com.foo.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
createArtifact("com.foo", "one"), createArtifact("com.foo", "two"),
|
||||
artifact);
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(createArtifact("com.foo", "one"),
|
||||
createArtifact("com.foo", "two"), artifact);
|
||||
assertThat(artifacts).hasSize(1);
|
||||
assertThat(artifacts.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterScopeKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "",
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "",
|
||||
new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.foo", "two", Artifact.SCOPE_SYSTEM);
|
||||
@@ -79,8 +74,7 @@ public class DependencyFilterMojoTests {
|
||||
|
||||
@Test
|
||||
public void filterGroupIdKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.emptyList(), "com.foo");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "com.foo");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
Artifact three = createArtifact("com.bar", "three");
|
||||
@@ -94,8 +88,7 @@ public class DependencyFilterMojoTests {
|
||||
Exclude exclude = new Exclude();
|
||||
exclude.setGroupId("com.bar");
|
||||
exclude.setArtifactId("two");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.singletonList(exclude), "");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.singletonList(exclude), "");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
Artifact three = createArtifact("com.bar", "three");
|
||||
@@ -108,8 +101,7 @@ public class DependencyFilterMojoTests {
|
||||
return createArtifact(groupId, artifactId, null);
|
||||
}
|
||||
|
||||
private static Artifact createArtifact(String groupId, String artifactId,
|
||||
String scope) {
|
||||
private static Artifact createArtifact(String groupId, String artifactId, String scope) {
|
||||
Artifact a = mock(Artifact.class);
|
||||
given(a.getGroupId()).willReturn(groupId);
|
||||
given(a.getArtifactId()).willReturn(artifactId);
|
||||
@@ -119,20 +111,18 @@ public class DependencyFilterMojoTests {
|
||||
return a;
|
||||
}
|
||||
|
||||
private static final class TestableDependencyFilterMojo
|
||||
extends AbstractDependencyFilterMojo {
|
||||
private static final class TestableDependencyFilterMojo extends AbstractDependencyFilterMojo {
|
||||
|
||||
private final ArtifactsFilter[] additionalFilters;
|
||||
|
||||
private TestableDependencyFilterMojo(List<Exclude> excludes,
|
||||
String excludeGroupIds, ArtifactsFilter... additionalFilters) {
|
||||
private TestableDependencyFilterMojo(List<Exclude> excludes, String excludeGroupIds,
|
||||
ArtifactsFilter... additionalFilters) {
|
||||
setExcludes(excludes);
|
||||
setExcludeGroupIds(excludeGroupIds);
|
||||
this.additionalFilters = additionalFilters;
|
||||
}
|
||||
|
||||
public Set<Artifact> filterDependencies(Artifact... artifacts)
|
||||
throws MojoExecutionException {
|
||||
public Set<Artifact> filterDependencies(Artifact... artifacts) throws MojoExecutionException {
|
||||
Set<Artifact> input = new LinkedHashSet<>(Arrays.asList(artifacts));
|
||||
return filterDependencies(input, getFilters(this.additionalFilters));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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,15 +39,14 @@ public class EnvVariablesTests {
|
||||
|
||||
@Test
|
||||
public void asArray() {
|
||||
assertThat(new EnvVariables(getTestArgs()).asArray()).contains("key=My Value",
|
||||
"key1= tt ", "key2= ", "key3=");
|
||||
assertThat(new EnvVariables(getTestArgs()).asArray()).contains("key=My Value", "key1= tt ", "key2= ",
|
||||
"key3=");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asMap() {
|
||||
assertThat(new EnvVariables(getTestArgs()).asMap()).containsExactly(
|
||||
entry("key", "My Value"), entry("key1", " tt "), entry("key2", " "),
|
||||
entry("key3", ""));
|
||||
assertThat(new EnvVariables(getTestArgs()).asMap()).containsExactly(entry("key", "My Value"),
|
||||
entry("key1", " tt "), entry("key2", " "), entry("key3", ""));
|
||||
}
|
||||
|
||||
private Map<String, String> getTestArgs() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2019 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,17 +40,14 @@ public class ExcludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludeSimple() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Set result = filter
|
||||
.filter(Collections.singleton(createArtifact("com.foo", "bar")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Set result = filter.filter(Collections.singleton(createArtifact("com.foo", "bar")));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.baz", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
@@ -59,8 +56,7 @@ public class ExcludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "biz");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
@@ -69,17 +65,14 @@ public class ExcludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludeClassifier() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
Set result = filter
|
||||
.filter(Collections.singleton(createArtifact("com.foo", "bar", "jdk5")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
Set result = filter.filter(Collections.singleton(createArtifact("com.foo", "bar", "jdk5")));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
@@ -88,8 +81,7 @@ public class ExcludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludeClassifierNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar", "jdk6");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
@@ -98,9 +90,8 @@ public class ExcludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludeMulti() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(
|
||||
createExclude("com.foo", "bar"), createExclude("com.foo", "bar2"),
|
||||
createExclude("org.acme", "app")));
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar"),
|
||||
createExclude("com.foo", "bar2"), createExclude("org.acme", "app")));
|
||||
Set<Artifact> artifacts = new HashSet<>();
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
@@ -125,8 +116,7 @@ public class ExcludeFilterTests {
|
||||
return exclude;
|
||||
}
|
||||
|
||||
private Artifact createArtifact(String groupId, String artifactId,
|
||||
String classifier) {
|
||||
private Artifact createArtifact(String groupId, String artifactId, String classifier) {
|
||||
Artifact a = mock(Artifact.class);
|
||||
given(a.getGroupId()).willReturn(groupId);
|
||||
given(a.getArtifactId()).willReturn(artifactId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2019 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,7 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeSimple() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
@@ -49,8 +48,7 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.baz", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
@@ -58,8 +56,7 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "biz");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
@@ -67,8 +64,7 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeClassifier() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar", "jdk5");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
@@ -77,8 +73,7 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
@@ -86,8 +81,7 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeClassifierNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar", "jdk6");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
@@ -95,9 +89,8 @@ public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeMulti() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(
|
||||
createInclude("com.foo", "bar"), createInclude("com.foo", "bar2"),
|
||||
createInclude("org.acme", "app")));
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar"),
|
||||
createInclude("com.foo", "bar2"), createInclude("org.acme", "app")));
|
||||
Set<Artifact> artifacts = new HashSet<>();
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
@@ -121,8 +114,7 @@ public class IncludeFilterTests {
|
||||
return include;
|
||||
}
|
||||
|
||||
private Artifact createArtifact(String groupId, String artifactId,
|
||||
String classifier) {
|
||||
private Artifact createArtifact(String groupId, String artifactId, String classifier) {
|
||||
Artifact a = mock(Artifact.class);
|
||||
given(a.getGroupId()).willReturn(groupId);
|
||||
given(a.getArtifactId()).willReturn(artifactId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -36,25 +36,21 @@ public class PropertiesMergingResourceTransformerTests {
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
assertThat(this.transformer.hasTransformedResource()).isFalse();
|
||||
this.transformer.processResource("foo",
|
||||
new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
assertThat(this.transformer.hasTransformedResource()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMerge() throws Exception {
|
||||
this.transformer.processResource("foo",
|
||||
new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
this.transformer.processResource("bar",
|
||||
new ByteArrayInputStream("foo=spam".getBytes()), null);
|
||||
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
this.transformer.processResource("bar", new ByteArrayInputStream("foo=spam".getBytes()), null);
|
||||
assertThat(this.transformer.getData().getProperty("foo")).isEqualTo("bar,spam");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutput() throws Exception {
|
||||
this.transformer.setResource("foo");
|
||||
this.transformer.processResource("foo",
|
||||
new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
JarOutputStream os = new JarOutputStream(out);
|
||||
this.transformer.modifyOutputStream(os);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2019 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,12 +64,10 @@ public class RunArgumentsTests {
|
||||
|
||||
@Test
|
||||
public void parseDebugFlags() {
|
||||
String[] args = parseArgs(
|
||||
"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
String[] args = parseArgs("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Xdebug");
|
||||
assertThat(args[1]).isEqualTo(
|
||||
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
assertThat(args[1]).isEqualTo("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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,7 @@ public class SystemPropertyFormatterTests {
|
||||
|
||||
@Test
|
||||
public void parseKeyWithValue() {
|
||||
assertThat(SystemPropertyFormatter.format("key1", "value1"))
|
||||
.isEqualTo("-Dkey1=\"value1\"");
|
||||
assertThat(SystemPropertyFormatter.format("key1", "value1")).isEqualTo("-Dkey1=\"value1\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,8 +49,7 @@ public class SystemPropertyFormatterTests {
|
||||
|
||||
@Test
|
||||
public void parseKeyWithOnlySpaces() {
|
||||
assertThat(SystemPropertyFormatter.format("key1", " "))
|
||||
.isEqualTo("-Dkey1=\" \"");
|
||||
assertThat(SystemPropertyFormatter.format("key1", " ")).isEqualTo("-Dkey1=\" \"");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -51,13 +51,12 @@ public final class Verify {
|
||||
new JarArchiveVerification(file, SAMPLE_APP).verify();
|
||||
}
|
||||
|
||||
public static void verifyJar(File file, String main, String... scriptContents)
|
||||
throws Exception {
|
||||
public static void verifyJar(File file, String main, String... scriptContents) throws Exception {
|
||||
verifyJar(file, main, true, scriptContents);
|
||||
}
|
||||
|
||||
public static void verifyJar(File file, String main, boolean executable,
|
||||
String... scriptContents) throws Exception {
|
||||
public static void verifyJar(File file, String main, boolean executable, String... scriptContents)
|
||||
throws Exception {
|
||||
new JarArchiveVerification(file, main).verify(executable, scriptContents);
|
||||
}
|
||||
|
||||
@@ -73,8 +72,8 @@ public final class Verify {
|
||||
new ModuleArchiveVerification(file).verify();
|
||||
}
|
||||
|
||||
public static Properties verifyBuildInfo(File file, String group, String artifact,
|
||||
String name, String version) throws IOException {
|
||||
public static Properties verifyBuildInfo(File file, String group, String artifact, String name, String version)
|
||||
throws IOException {
|
||||
FileSystemResource resource = new FileSystemResource(file);
|
||||
Properties properties = PropertiesLoaderUtils.loadProperties(resource);
|
||||
assertThat(properties.get("build.group")).isEqualTo(group);
|
||||
@@ -112,21 +111,18 @@ public final class Verify {
|
||||
public void assertHasNoEntryNameStartingWith(String entry) {
|
||||
for (String name : this.content.keySet()) {
|
||||
if (name.startsWith(entry)) {
|
||||
throw new IllegalStateException("Entry starting with " + entry
|
||||
+ " should not have been found");
|
||||
throw new IllegalStateException("Entry starting with " + entry + " should not have been found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void assertHasNonUnpackEntry(String entryName) {
|
||||
assertThat(hasNonUnpackEntry(entryName))
|
||||
.as("Entry starting with " + entryName + " was an UNPACK entry")
|
||||
assertThat(hasNonUnpackEntry(entryName)).as("Entry starting with " + entryName + " was an UNPACK entry")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
public void assertHasUnpackEntry(String entryName) {
|
||||
assertThat(hasUnpackEntry(entryName))
|
||||
.as("Entry starting with " + entryName + " was not an UNPACK entry")
|
||||
assertThat(hasUnpackEntry(entryName)).as("Entry starting with " + entryName + " was not an UNPACK entry")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@@ -140,11 +136,9 @@ public final class Verify {
|
||||
}
|
||||
|
||||
private ZipEntry getEntryStartingWith(String entryName) {
|
||||
return this.content.entrySet().stream()
|
||||
.filter((entry) -> entry.getKey().startsWith(entryName))
|
||||
return this.content.entrySet().stream().filter((entry) -> entry.getKey().startsWith(entryName))
|
||||
.map(Map.Entry::getValue).findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"Unable to find entry starting with " + entryName));
|
||||
.orElseThrow(() -> new IllegalStateException("Unable to find entry starting with " + entryName));
|
||||
}
|
||||
|
||||
public boolean hasEntry(String entry) {
|
||||
@@ -177,14 +171,12 @@ public final class Verify {
|
||||
verify(true);
|
||||
}
|
||||
|
||||
public void verify(boolean executable, String... scriptContents)
|
||||
throws Exception {
|
||||
public void verify(boolean executable, String... scriptContents) throws Exception {
|
||||
assertThat(this.file).exists().isFile();
|
||||
|
||||
if (scriptContents.length > 0 && executable) {
|
||||
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
|
||||
contents = contents.substring(0, contents
|
||||
.indexOf(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
|
||||
contents = contents.substring(0, contents.indexOf(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
|
||||
for (String content : scriptContents) {
|
||||
assertThat(contents).contains(content);
|
||||
}
|
||||
@@ -192,8 +184,7 @@ public final class Verify {
|
||||
|
||||
if (!executable) {
|
||||
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
|
||||
assertThat(contents).as("Is executable")
|
||||
.startsWith(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 }));
|
||||
assertThat(contents).as("Is executable").startsWith(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 }));
|
||||
}
|
||||
|
||||
try (ZipFile zipFile = new ZipFile(this.file)) {
|
||||
@@ -207,8 +198,7 @@ public final class Verify {
|
||||
}
|
||||
|
||||
private void verifyManifest(ArchiveVerifier verifier) throws Exception {
|
||||
Manifest manifest = new Manifest(
|
||||
verifier.getEntryContent("META-INF/MANIFEST.MF"));
|
||||
Manifest manifest = new Manifest(verifier.getEntryContent("META-INF/MANIFEST.MF"));
|
||||
verifyManifest(manifest);
|
||||
}
|
||||
|
||||
@@ -231,22 +221,18 @@ public final class Verify {
|
||||
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-context");
|
||||
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-core");
|
||||
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/javax.servlet-api-4");
|
||||
assertThat(verifier
|
||||
.hasEntry("org/springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isTrue();
|
||||
assertThat(verifier
|
||||
.hasEntry("BOOT-INF/classes/org/test/SampleApplication.class"))
|
||||
.as("Own classes").isTrue();
|
||||
assertThat(verifier.hasEntry("org/springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isTrue();
|
||||
assertThat(verifier.hasEntry("BOOT-INF/classes/org/test/SampleApplication.class")).as("Own classes")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
assertThat(manifest.getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.JarLauncher");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo(this.main);
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used"))
|
||||
.isEqualTo("Foo");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class")).isEqualTo(this.main);
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used")).isEqualTo("Foo");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -262,14 +248,11 @@ public final class Verify {
|
||||
super.verifyZipEntries(verifier);
|
||||
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-context");
|
||||
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-core");
|
||||
verifier.assertHasEntryNameStartingWith(
|
||||
"WEB-INF/lib-provided/javax.servlet-api-4");
|
||||
assertThat(verifier
|
||||
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isTrue();
|
||||
assertThat(verifier
|
||||
.hasEntry("WEB-INF/classes/org/" + "test/SampleApplication.class"))
|
||||
.as("Own classes").isTrue();
|
||||
verifier.assertHasEntryNameStartingWith("WEB-INF/lib-provided/javax.servlet-api-4");
|
||||
assertThat(verifier.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isTrue();
|
||||
assertThat(verifier.hasEntry("WEB-INF/classes/org/" + "test/SampleApplication.class")).as("Own classes")
|
||||
.isTrue();
|
||||
assertThat(verifier.hasEntry("index.html")).as("Web content").isTrue();
|
||||
}
|
||||
|
||||
@@ -277,10 +260,8 @@ public final class Verify {
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
assertThat(manifest.getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.WarLauncher");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("org.test.SampleApplication");
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used"))
|
||||
.isEqualTo("Foo");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class")).isEqualTo("org.test.SampleApplication");
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used")).isEqualTo("Foo");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -295,10 +276,8 @@ public final class Verify {
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
assertThat(manifest.getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.PropertiesLauncher");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("org.test.SampleApplication");
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used"))
|
||||
.isEqualTo("Foo");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class")).isEqualTo("org.test.SampleApplication");
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used")).isEqualTo("Foo");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -315,11 +294,9 @@ public final class Verify {
|
||||
verifier.assertHasEntryNameStartingWith("lib/spring-context");
|
||||
verifier.assertHasEntryNameStartingWith("lib/spring-core");
|
||||
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api");
|
||||
assertThat(verifier
|
||||
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isFalse();
|
||||
assertThat(verifier.hasEntry("org/" + "test/SampleModule.class"))
|
||||
.as("Own classes").isTrue();
|
||||
assertThat(verifier.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isFalse();
|
||||
assertThat(verifier.hasEntry("org/" + "test/SampleModule.class")).as("Own classes").isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user