Skip to content
Merged
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
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
import org.apache.maven.wagon.events.TransferListener;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusTestCase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.anyString;
Expand All @@ -47,24 +48,29 @@
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class DefaultDownloadManagerTest extends PlexusTestCase {
public class DefaultDownloadManagerTest {

private WagonManager wagonManager;

private Wagon wagon;

@BeforeEach
public void setUp() throws Exception {
super.setUp();

wagonManager = createMock(WagonManager.class);
wagon = createMock(Wagon.class);
}

@Test
public void testShouldConstructWithNoParamsAndHaveNonNullMessageHolder() {
new DefaultDownloadManager();
}

@Test
public void testShouldConstructWithWagonManager() {
replay(wagonManager);

Expand All @@ -73,10 +79,7 @@ public void testShouldConstructWithWagonManager() {
verify(wagonManager);
}

public void testShouldLookupInstanceDefaultRoleHint() throws Exception {
lookup(DownloadManager.ROLE, DefaultDownloadManager.ROLE_HINT);
}

@Test
public void testShouldFailToDownloadMalformedURL() {
replay(wagonManager);

Expand All @@ -93,6 +96,7 @@ public void testShouldFailToDownloadMalformedURL() {
verify(wagonManager);
}

@Test
public void testShouldDownloadFromTempFileWithNoTransferListeners() throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -108,6 +112,7 @@ public void testShouldDownloadFromTempFileWithNoTransferListeners() throws IOExc
verify(wagon, wagonManager);
}

@Test
public void testShouldDownloadFromTempFileTwiceAndUseCache() throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -131,6 +136,7 @@ public void testShouldDownloadFromTempFileTwiceAndUseCache() throws IOException,
verify(wagon, wagonManager);
}

@Test
public void testShouldDownloadFromTempFileWithOneTransferListener() throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -155,6 +161,7 @@ public void testShouldDownloadFromTempFileWithOneTransferListener() throws IOExc
verify(wagon, wagonManager, transferListener);
}

@Test
public void testShouldFailToDownloadWhenWagonProtocolNotFound() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -176,6 +183,7 @@ public void testShouldFailToDownloadWhenWagonProtocolNotFound() throws IOExcepti
verify(wagon, wagonManager);
}

@Test
public void testShouldFailToDownloadWhenWagonConnectThrowsConnectionException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -197,6 +205,7 @@ public void testShouldFailToDownloadWhenWagonConnectThrowsConnectionException()
verify(wagon, wagonManager);
}

@Test
public void testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -218,6 +227,7 @@ public void testShouldFailToDownloadWhenWagonConnectThrowsAuthenticationExceptio
verify(wagon, wagonManager);
}

@Test
public void testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -239,6 +249,7 @@ public void testShouldFailToDownloadWhenWagonGetThrowsTransferFailedException()
verify(wagon, wagonManager);
}

@Test
public void testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -260,6 +271,7 @@ public void testShouldFailToDownloadWhenWagonGetThrowsResourceDoesNotExistExcept
verify(wagon, wagonManager);
}

@Test
public void testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException() throws IOException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
tempFile.deleteOnExit();
Expand All @@ -281,6 +293,7 @@ public void testShouldFailToDownloadWhenWagonGetThrowsAuthorizationException() t
verify(wagon, wagonManager);
}

@Test
public void testShouldFailToDownloadWhenWagonDisconnectThrowsConnectionException()
throws IOException, DownloadFailedException {
File tempFile = Files.createTempFile("download-source", "test").toFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@
*/
package org.apache.maven.shared.io.download;

import junit.framework.TestCase;
import org.junit.jupiter.api.Test;

public class DownloadFailedExceptionTest extends TestCase {
import static org.junit.jupiter.api.Assertions.assertEquals;

public class DownloadFailedExceptionTest {

@Test
public void testShouldConstructWithUrlAndMessage() {
new DownloadFailedException("http://www.google.com", "can't find.");
}

@Test
public void testShouldConstructWithUrlMessageAndException() {
new DownloadFailedException("http://www.google.com", "can't find.", new NullPointerException());
}

@Test
public void testShouldRetrieveUrlFromConstructor() {
String url = "http://www.google.com";
assertEquals(url, new DownloadFailedException(url, "can't find.").getUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
import java.io.IOException;
import java.nio.file.Files;

import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
import org.junit.jupiter.api.Test;

public class ArtifactLocationTest extends TestCase {
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

public class ArtifactLocationTest {

@Test
public void testShouldConstructFromTempFileSpecification() throws IOException {
File f = Files.createTempFile("artifact-location.", ".test").toFile();
f.deleteOnExit();
Expand All @@ -51,6 +55,7 @@ public void testShouldConstructFromTempFileSpecification() throws IOException {
assertSame(f, location.getFile());
}

@Test
public void testShouldRead() throws IOException {
File f = Files.createTempFile("url-location.", ".test").toFile();
f.deleteOnExit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.nio.file.Files;
import java.util.Collections;

import junit.framework.TestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
Expand All @@ -32,23 +31,28 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.easymock.EasyMock.*;
import static org.junit.jupiter.api.Assertions.*;

public class ArtifactLocatorStrategyTest extends TestCase {
public class ArtifactLocatorStrategyTest {

private ArtifactFactory factory;

private ArtifactResolver resolver;

private ArtifactRepository localRepository;

@BeforeEach
public void setUp() {
factory = createMock(ArtifactFactory.class);
resolver = createMock(ArtifactResolver.class);
localRepository = createMock(ArtifactRepository.class);
}

@Test
public void testShouldConstructWithoutDefaultArtifactType() {
replay(factory, resolver, localRepository);

Expand All @@ -57,6 +61,7 @@ public void testShouldConstructWithoutDefaultArtifactType() {
verify(factory, resolver, localRepository);
}

@Test
public void testShouldConstructWithDefaultArtifactType() {
replay(factory, resolver, localRepository);

Expand All @@ -65,6 +70,7 @@ public void testShouldConstructWithDefaultArtifactType() {
verify(factory, resolver, localRepository);
}

@Test
public void testShouldFailToResolveSpecWithOneToken() {
replay(factory, resolver, localRepository);

Expand All @@ -80,6 +86,7 @@ public void testShouldFailToResolveSpecWithOneToken() {
verify(factory, resolver, localRepository);
}

@Test
public void testShouldFailToResolveSpecWithTwoTokens() {
replay(factory, resolver, localRepository);

Expand All @@ -95,6 +102,7 @@ public void testShouldFailToResolveSpecWithTwoTokens() {
verify(factory, resolver, localRepository);
}

@Test
public void testShouldResolveSpecWithThreeTokensUsingDefaultType() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
Expand Down Expand Up @@ -133,6 +141,7 @@ public void testShouldResolveSpecWithThreeTokensUsingDefaultType() throws IOExce
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
Expand Down Expand Up @@ -171,6 +180,7 @@ public void testShouldResolveSpecWithThreeTokensUsingCustomizedDefaultType() thr
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldResolveSpecWithFourTokens() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
Expand Down Expand Up @@ -209,6 +219,7 @@ public void testShouldResolveSpecWithFourTokens() throws IOException {
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldResolveSpecWithFiveTokens() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
Expand Down Expand Up @@ -247,6 +258,7 @@ public void testShouldResolveSpecWithFiveTokens() throws IOException {
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
Expand Down Expand Up @@ -285,6 +297,7 @@ public void testShouldResolveSpecWithFiveTokensAndEmptyTypeToken() throws IOExce
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldResolveSpecWithMoreThanFiveTokens() throws IOException {
File tempFile = Files.createTempFile("artifact-location.", ".temp").toFile();
tempFile.deleteOnExit();
Expand Down Expand Up @@ -325,6 +338,7 @@ public void testShouldResolveSpecWithMoreThanFiveTokens() throws IOException {
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldNotResolveSpecToArtifactWithNullFile() throws IOException {
Artifact artifact = createMock(Artifact.class);

Expand Down Expand Up @@ -360,6 +374,7 @@ public void testShouldNotResolveSpecToArtifactWithNullFile() throws IOException
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown() throws IOException {
Artifact artifact = createMock(Artifact.class);

Expand Down Expand Up @@ -407,6 +422,7 @@ public void testShouldNotResolveWhenArtifactNotFoundExceptionThrown() throws IOE
verify(factory, resolver, localRepository, artifact);
}

@Test
public void testShouldNotResolveWhenArtifactResolutionExceptionThrown() throws IOException {
Artifact artifact = createMock(Artifact.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@
*/
package org.apache.maven.shared.io.location;

import junit.framework.TestCase;
import org.apache.maven.shared.io.logging.DefaultMessageHolder;
import org.apache.maven.shared.io.logging.MessageHolder;
import org.junit.jupiter.api.Test;

public class ClasspathResourceLocatorStrategyTest extends TestCase {
import static org.junit.jupiter.api.Assertions.*;

public class ClasspathResourceLocatorStrategyTest {

@Test
public void testShouldConstructWithNoParams() {
new ClasspathResourceLocatorStrategy();
}

@Test
public void testShouldConstructWithTempFileOptions() {
new ClasspathResourceLocatorStrategy("prefix.", ".suffix", true);
}

@Test
public void testShouldFailToResolveMissingClasspathResource() {
MessageHolder mh = new DefaultMessageHolder();
Location location = new ClasspathResourceLocatorStrategy().resolve("/some/missing/path", mh);
Expand All @@ -40,6 +45,7 @@ public void testShouldFailToResolveMissingClasspathResource() {
assertEquals(1, mh.size());
}

@Test
public void testShouldResolveExistingClasspathResourceWithoutPrecedingSlash() {
MessageHolder mh = new DefaultMessageHolder();
Location location = new ClasspathResourceLocatorStrategy().resolve("META-INF/maven/test.properties", mh);
Expand Down
Loading
Loading