Move tests to JUnit 5 wherever possible
This commit is contained in:
@@ -26,8 +26,8 @@ import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
@@ -48,7 +48,7 @@ import static org.mockito.Mockito.verify;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ArtifactsLibrariesTests {
|
||||
class ArtifactsLibrariesTests {
|
||||
|
||||
@Mock
|
||||
private Artifact artifact;
|
||||
@@ -68,7 +68,7 @@ public class ArtifactsLibrariesTests {
|
||||
@Captor
|
||||
private ArgumentCaptor<Library> libraryCaptor;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.artifacts = Collections.singleton(this.artifact);
|
||||
@@ -79,7 +79,7 @@ public class ArtifactsLibrariesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callbackForJars() throws Exception {
|
||||
void callbackForJars() throws Exception {
|
||||
given(this.artifact.getType()).willReturn("jar");
|
||||
given(this.artifact.getScope()).willReturn("compile");
|
||||
this.libs.doWithLibraries(this.callback);
|
||||
@@ -91,7 +91,7 @@ public class ArtifactsLibrariesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callbackWithUnpack() throws Exception {
|
||||
void callbackWithUnpack() throws Exception {
|
||||
given(this.artifact.getGroupId()).willReturn("gid");
|
||||
given(this.artifact.getArtifactId()).willReturn("aid");
|
||||
given(this.artifact.getType()).willReturn("jar");
|
||||
@@ -106,7 +106,7 @@ public class ArtifactsLibrariesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renamesDuplicates() throws Exception {
|
||||
void renamesDuplicates() throws Exception {
|
||||
Artifact artifact1 = mock(Artifact.class);
|
||||
Artifact artifact2 = mock(Artifact.class);
|
||||
given(artifact1.getType()).willReturn("jar");
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@@ -37,10 +37,10 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DependencyFilterMojoTests {
|
||||
class DependencyFilterMojoTests {
|
||||
|
||||
@Test
|
||||
public void filterDependencies() throws MojoExecutionException {
|
||||
void filterDependencies() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "com.foo");
|
||||
|
||||
Artifact artifact = createArtifact("com.bar", "one");
|
||||
@@ -51,7 +51,7 @@ public class DependencyFilterMojoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterGroupIdExactMatch() throws MojoExecutionException {
|
||||
void filterGroupIdExactMatch() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "com.foo");
|
||||
|
||||
Artifact artifact = createArtifact("com.foo.bar", "one");
|
||||
@@ -62,7 +62,7 @@ public class DependencyFilterMojoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterScopeKeepOrder() throws MojoExecutionException {
|
||||
void filterScopeKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "",
|
||||
new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
@@ -73,7 +73,7 @@ public class DependencyFilterMojoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterGroupIdKeepOrder() throws MojoExecutionException {
|
||||
void filterGroupIdKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(Collections.emptyList(), "com.foo");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
@@ -84,7 +84,7 @@ public class DependencyFilterMojoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterExcludeKeepOrder() throws MojoExecutionException {
|
||||
void filterExcludeKeepOrder() throws MojoExecutionException {
|
||||
Exclude exclude = new Exclude();
|
||||
exclude.setGroupId("com.bar");
|
||||
exclude.setArtifactId("two");
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.maven;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
@@ -29,22 +29,22 @@ import static org.assertj.core.api.Assertions.entry;
|
||||
*
|
||||
* @author Dmytro Nosan
|
||||
*/
|
||||
public class EnvVariablesTests {
|
||||
class EnvVariablesTests {
|
||||
|
||||
@Test
|
||||
public void asNull() {
|
||||
void asNull() {
|
||||
Map<String, String> args = new EnvVariables(null).asMap();
|
||||
assertThat(args).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asArray() {
|
||||
void asArray() {
|
||||
assertThat(new EnvVariables(getTestArgs()).asArray()).contains("key=My Value", "key1= tt ", "key2= ",
|
||||
"key3=");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asMap() {
|
||||
void asMap() {
|
||||
assertThat(new EnvVariables(getTestArgs()).asMap()).containsExactly(entry("key", "My Value"),
|
||||
entry("key1", " tt "), entry("key2", " "), entry("key3", ""));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@@ -36,17 +36,17 @@ import static org.mockito.Mockito.mock;
|
||||
* @author David Turanski
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class ExcludeFilterTests {
|
||||
class ExcludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void excludeSimple() throws ArtifactFilterException {
|
||||
void excludeSimple() throws ArtifactFilterException {
|
||||
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 {
|
||||
void excludeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.baz", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -55,7 +55,7 @@ public class ExcludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
void excludeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "biz");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -64,14 +64,14 @@ public class ExcludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeClassifier() throws ArtifactFilterException {
|
||||
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")));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
void excludeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -80,7 +80,7 @@ public class ExcludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeClassifierNoMatch() throws ArtifactFilterException {
|
||||
void excludeClassifierNoMatch() throws ArtifactFilterException {
|
||||
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));
|
||||
@@ -89,7 +89,7 @@ public class ExcludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeMulti() throws ArtifactFilterException {
|
||||
void excludeMulti() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo", "bar"),
|
||||
createExclude("com.foo", "bar2"), createExclude("org.acme", "app")));
|
||||
Set<Artifact> artifacts = new HashSet<>();
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@@ -35,10 +35,10 @@ import static org.mockito.Mockito.mock;
|
||||
* @author David Turanski
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class IncludeFilterTests {
|
||||
class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeSimple() throws ArtifactFilterException {
|
||||
void includeSimple() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -47,7 +47,7 @@ public class IncludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
void includeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.baz", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -55,7 +55,7 @@ public class IncludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
void includeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "biz");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -63,7 +63,7 @@ public class IncludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeClassifier() throws ArtifactFilterException {
|
||||
void includeClassifier() throws ArtifactFilterException {
|
||||
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));
|
||||
@@ -72,7 +72,7 @@ public class IncludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
void includeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
@@ -80,7 +80,7 @@ public class IncludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeClassifierNoMatch() throws ArtifactFilterException {
|
||||
void includeClassifierNoMatch() throws ArtifactFilterException {
|
||||
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));
|
||||
@@ -88,7 +88,7 @@ public class IncludeFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeMulti() throws ArtifactFilterException {
|
||||
void includeMulti() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo", "bar"),
|
||||
createInclude("com.foo", "bar2"), createInclude("org.acme", "app")));
|
||||
Set<Artifact> artifacts = new HashSet<>();
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -29,26 +29,26 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class PropertiesMergingResourceTransformerTests {
|
||||
class PropertiesMergingResourceTransformerTests {
|
||||
|
||||
private final PropertiesMergingResourceTransformer transformer = new PropertiesMergingResourceTransformer();
|
||||
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
void testProcess() throws Exception {
|
||||
assertThat(this.transformer.hasTransformedResource()).isFalse();
|
||||
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
assertThat(this.transformer.hasTransformedResource()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMerge() throws Exception {
|
||||
void testMerge() throws Exception {
|
||||
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 {
|
||||
void testOutput() throws Exception {
|
||||
this.transformer.setResource("foo");
|
||||
this.transformer.processResource("foo", new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -25,45 +25,45 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class RunArgumentsTests {
|
||||
class RunArgumentsTests {
|
||||
|
||||
@Test
|
||||
public void parseNull() {
|
||||
void parseNull() {
|
||||
String[] args = parseArgs(null);
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseNullArray() {
|
||||
void parseNullArray() {
|
||||
String[] args = new RunArguments((String[]) null).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseArrayContainingNullValue() {
|
||||
void parseArrayContainingNullValue() {
|
||||
String[] args = new RunArguments(new String[] { "foo", null, "bar" }).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args).containsOnly("foo", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseArrayContainingEmptyValue() {
|
||||
void parseArrayContainingEmptyValue() {
|
||||
String[] args = new RunArguments(new String[] { "foo", "", "bar" }).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args).containsOnly("foo", "", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseEmpty() {
|
||||
void parseEmpty() {
|
||||
String[] args = parseArgs(" ");
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDebugFlags() {
|
||||
void parseDebugFlags() {
|
||||
String[] args = parseArgs("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Xdebug");
|
||||
@@ -71,7 +71,7 @@ public class RunArgumentsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithExtraSpaces() {
|
||||
void parseWithExtraSpaces() {
|
||||
String[] args = parseArgs(" -Dfoo=bar -Dfoo2=bar2 ");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Dfoo=bar");
|
||||
@@ -79,7 +79,7 @@ public class RunArgumentsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithNewLinesAndTabs() {
|
||||
void parseWithNewLinesAndTabs() {
|
||||
String[] args = parseArgs(" -Dfoo=bar \n" + "\t\t -Dfoo2=bar2 ");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Dfoo=bar");
|
||||
@@ -87,7 +87,7 @@ public class RunArgumentsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quoteHandledProperly() {
|
||||
void quoteHandledProperly() {
|
||||
String[] args = parseArgs("-Dvalue=\"My Value\" ");
|
||||
assertThat(args.length).isEqualTo(1);
|
||||
assertThat(args[0]).isEqualTo("-Dvalue=My Value");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.maven.AbstractRunMojo.SystemPropertyFormatter;
|
||||
|
||||
@@ -25,30 +25,30 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* Tests for {@link AbstractRunMojo.SystemPropertyFormatter}.
|
||||
*/
|
||||
public class SystemPropertyFormatterTests {
|
||||
class SystemPropertyFormatterTests {
|
||||
|
||||
@Test
|
||||
public void parseEmpty() {
|
||||
void parseEmpty() {
|
||||
assertThat(SystemPropertyFormatter.format(null, null)).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseOnlyKey() {
|
||||
void parseOnlyKey() {
|
||||
assertThat(SystemPropertyFormatter.format("key1", null)).isEqualTo("-Dkey1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseKeyWithValue() {
|
||||
void parseKeyWithValue() {
|
||||
assertThat(SystemPropertyFormatter.format("key1", "value1")).isEqualTo("-Dkey1=\"value1\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseKeyWithEmptyValue() {
|
||||
void parseKeyWithEmptyValue() {
|
||||
assertThat(SystemPropertyFormatter.format("key1", "")).isEqualTo("-Dkey1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseKeyWithOnlySpaces() {
|
||||
void parseKeyWithOnlySpaces() {
|
||||
assertThat(SystemPropertyFormatter.format("key1", " ")).isEqualTo("-Dkey1=\" \"");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user