Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void setUp() throws Exception {
}

@Test
void testDownload() throws Exception {
void download() throws Exception {
assertTrue(Files.notExists(downloadFile));
download.download(sourceRoot, downloadFile);
assertTrue(Files.exists(downloadFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

public class HashAlgorithmVerifierTest {
class HashAlgorithmVerifierTest {

@TempDir
private File temporaryFolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
Expand All @@ -45,6 +44,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -145,7 +145,7 @@ public void testCreateDist() throws Exception {
}

@Test
void testCreateDistWithExistingDistribution() throws Exception {
void createDistWithExistingDistribution() throws Exception {

createTestZip(zipDestination);
Files.createDirectories(mavenHomeDir);
Expand All @@ -165,7 +165,7 @@ void testCreateDistWithExistingDistribution() throws Exception {
}

@Test
void testCreateDistWithExistingDistAndZipAndAlwaysUnpackTrue() throws Exception {
void createDistWithExistingDistAndZipAndAlwaysUnpackTrue() throws Exception {

createTestZip(zipDestination);
Files.createDirectories(mavenHomeDir);
Expand All @@ -186,7 +186,7 @@ void testCreateDistWithExistingDistAndZipAndAlwaysUnpackTrue() throws Exception
}

@Test
void testCreateDistWithExistingZipAndDistAndAlwaysDownloadTrue() throws Exception {
void createDistWithExistingZipAndDistAndAlwaysDownloadTrue() throws Exception {

createTestZip(zipDestination);
Path garbage = mavenHomeDir.resolve("garbage");
Expand All @@ -210,7 +210,7 @@ void testCreateDistWithExistingZipAndDistAndAlwaysDownloadTrue() throws Exceptio
}

@Test
void testZipSlip() throws URISyntaxException {
void zipSlip() throws Exception {
URL resource = getClass().getClassLoader().getResource("zip-slip.zip");
Path zipSlip = Paths.get(resource.toURI());
when(localDistribution.getZipFile()).thenReturn(zipSlip);
Expand All @@ -220,7 +220,7 @@ void testZipSlip() throws URISyntaxException {
install.createDist(configuration);
fail("Should fail as it contains a zip slip.");
} catch (Exception ex) {
assertTrue(ex instanceof ZipException);
assertInstanceOf(ZipException.class, ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

Expand Down Expand Up @@ -58,7 +57,7 @@ void distributionDirWithMavenUserHomeBase() throws Exception {

Path distributionDir = pathAssembler.getDistribution(configuration).getDistributionDir();
assertThat(distributionDir.getFileName().toString(), matchesRegexp("[a-z0-9]+"));
assertThat(distributionDir.getParent(), equalTo(file(TEST_MAVEN_USER_HOME + "/somePath/maven-0.9-bin")));
assertEquals(distributionDir.getParent(), file(TEST_MAVEN_USER_HOME + "/somePath/maven-0.9-bin"));
}

@Test
Expand All @@ -68,7 +67,7 @@ void distributionDirWithProjectBase() throws Exception {

Path distributionDir = pathAssembler.getDistribution(configuration).getDistributionDir();
assertThat(distributionDir.getFileName().toString(), matchesRegexp("[a-z0-9]+"));
assertThat(distributionDir.getParent(), equalTo(file(currentDirPath() + "/somePath/maven-0.9-bin")));
assertEquals(distributionDir.getParent(), file(currentDirPath() + "/somePath/maven-0.9-bin"));
}

@Test
Expand All @@ -89,9 +88,9 @@ void distZipWithMavenUserHomeBase() throws Exception {
configuration.setDistribution(new URI("http://server/dist/maven-1.0.zip"));

Path dist = pathAssembler.getDistribution(configuration).getZipFile();
assertThat(dist.getFileName().toString(), equalTo("maven-1.0.zip"));
assertEquals("maven-1.0.zip", dist.getFileName().toString());
assertThat(dist.getParent().getFileName().toString(), matchesRegexp("[a-z0-9]+"));
assertThat(dist.getParent().getParent(), equalTo(file(TEST_MAVEN_USER_HOME + "/somePath/maven-1.0")));
assertEquals(dist.getParent().getParent(), file(TEST_MAVEN_USER_HOME + "/somePath/maven-1.0"));
}

@Test
Expand All @@ -100,9 +99,9 @@ void distZipWithProjectBase() throws Exception {
configuration.setDistribution(new URI("http://server/dist/maven-1.0.zip"));

Path dist = pathAssembler.getDistribution(configuration).getZipFile();
assertThat(dist.getFileName().toString(), equalTo("maven-1.0.zip"));
assertEquals("maven-1.0.zip", dist.getFileName().toString());
assertThat(dist.getParent().getFileName().toString(), matchesRegexp("[a-z0-9]+"));
assertThat(dist.getParent().getParent(), equalTo(file(currentDirPath() + "/somePath/maven-1.0")));
assertEquals(dist.getParent().getParent(), file(currentDirPath() + "/somePath/maven-1.0"));
}

@Test
Expand All @@ -111,9 +110,9 @@ void distZipWithLocalWindowsPath() throws Exception {
configuration.setDistribution(new URI("file:///C:/maven-1.0.zip"));

Path dist = pathAssembler.getDistribution(configuration).getZipFile();
assertThat(dist.getFileName().toString(), equalTo("maven-1.0.zip"));
assertEquals("maven-1.0.zip", dist.getFileName().toString());
assertThat(dist.getParent().getFileName().toString(), matchesRegexp("[a-z0-9]+"));
assertThat(dist.getParent().getParent(), equalTo(file(currentDirPath() + "/somePath/maven-1.0")));
assertEquals(dist.getParent().getParent(), file(currentDirPath() + "/somePath/maven-1.0"));
}

private Path file(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void setUp() throws IOException {
}

@Test
void testSnapshotUrlParsing() throws Exception {
void snapshotUrlParsing() throws Exception {
// Test that PathAssembler can handle snapshot URLs
String snapshotUrl =
"https://repository.apache.org/content/repositories/snapshots/org/apache/maven/apache-maven/4.1.0-SNAPSHOT/apache-maven-4.1.0-20250710.120440-1-bin.zip";
Expand All @@ -70,7 +70,7 @@ void testSnapshotUrlParsing() throws Exception {
}

@Test
void testWrapperExecutorWithSnapshotUrl() throws Exception {
void wrapperExecutorWithSnapshotUrl() throws Exception {
// Create properties file with snapshot URL
String snapshotUrl =
"https://repository.apache.org/content/repositories/snapshots/org/apache/maven/apache-maven/4.1.0-SNAPSHOT/apache-maven-4.1.0-20250710.120440-1-bin.zip";
Expand All @@ -94,7 +94,7 @@ void testWrapperExecutorWithSnapshotUrl() throws Exception {
}

@Test
void testRegularReleaseUrlStillWorks() throws Exception {
void regularReleaseUrlStillWorks() throws Exception {
// Ensure regular releases still work as before
String releaseUrl =
"https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import java.util.Properties;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

class SystemPropertiesHandlerTest {

Expand All @@ -43,7 +42,7 @@ void setupTempDir() throws IOException {
}

@Test
void testParsePropertiesFile() throws Exception {
void parsePropertiesFile() throws Exception {
Path propFile = tmpDir.resolve("props");
Properties props = new Properties();
props.put("a", "b");
Expand All @@ -57,12 +56,12 @@ void testParsePropertiesFile() throws Exception {
Map<String, String> expected = new HashMap<>();
expected.put("c", "d");

assertThat(SystemPropertiesHandler.getSystemProperties(propFile), equalTo(expected));
assertEquals(SystemPropertiesHandler.getSystemProperties(propFile), expected);
}

@Test
void ifNoPropertyFileExistShouldReturnEmptyMap() {
Map<String, String> expected = new HashMap<>();
assertThat(SystemPropertiesHandler.getSystemProperties(tmpDir.resolve("unknown")), equalTo(expected));
assertEquals(SystemPropertiesHandler.getSystemProperties(tmpDir.resolve("unknown")), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void failWhenPropertiesFileDoesNotExist() {
}

@Test
void testRelativeDistUrl() throws Exception {
void relativeDistUrl() throws Exception {

properties = new Properties();
properties.put("distributionUrl", "some/relative/url/to/bin.zip");
Expand All @@ -191,7 +191,7 @@ void testRelativeDistUrl() throws Exception {
}

@Test
void testEnvironmentVariableOverwriteSimpleCase() throws Exception {
void environmentVariableOverwriteSimpleCase() throws Exception {
final Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.put(MVNW_REPOURL, "https://repo/test");

Expand All @@ -206,7 +206,7 @@ void testEnvironmentVariableOverwriteSimpleCase() throws Exception {
}

@Test
void testEnvironmentVariableOverwriteMvnwRepoUrlTrailingSlash() throws Exception {
void environmentVariableOverwriteMvnwRepoUrlTrailingSlash() throws Exception {
final Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.put(MVNW_REPOURL, "https://repo/test/");
properties = new Properties();
Expand All @@ -220,7 +220,7 @@ void testEnvironmentVariableOverwriteMvnwRepoUrlTrailingSlash() throws Exception
}

@Test
void testEnvironmentVariableOverwritePackageName() throws Exception {
void environmentVariableOverwritePackageName() throws Exception {
final Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.put(MVNW_REPOURL, "https://repo/test");
properties = new Properties();
Expand All @@ -235,7 +235,7 @@ void testEnvironmentVariableOverwritePackageName() throws Exception {
}

@Test
void testEnvironmentVariableOverwritePackageNameTrailingSpace() throws Exception {
void environmentVariableOverwritePackageNameTrailingSpace() throws Exception {
final Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.put(MVNW_REPOURL, "https://repo/test/");
properties = new Properties();
Expand Down
Loading