Skip to content
Draft
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
46 changes: 21 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,11 @@ under the License.
<artifactId>wagon-ssh-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
<version>2.1.1</version>
</dependency>
<!-- for slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -217,6 +207,19 @@ under the License.
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-testing</artifactId>
<version>1.4.0</version>
<!-- <version>1.5.1-SNAPSHOT</version>-->
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
Expand Down Expand Up @@ -244,6 +247,11 @@ under the License.
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.9.3</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -254,6 +262,7 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useModulePath>false</useModulePath>
<forkedProcessTimeoutInSeconds>800</forkedProcessTimeoutInSeconds>
<systemPropertyVariables>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
Expand Down Expand Up @@ -286,25 +295,12 @@ under the License.
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>2.2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate-metadata</goal>
</goals>
</execution>
</executions>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
4 changes: 2 additions & 2 deletions wagon-provider-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ under the License.
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*
*/
public interface CommandExecutor extends Wagon {
String ROLE = CommandExecutor.class.getName();

void executeCommand(String command) throws CommandExecutionException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
*
*/
public interface Wagon {
String ROLE = Wagon.class.getName();

/**
* default 60s approximately 1 minute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import junit.framework.TestCase;
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException;
Expand All @@ -38,6 +37,8 @@
import org.apache.maven.wagon.repository.RepositoryPermissions;
import org.apache.maven.wagon.resource.Resource;
import org.easymock.IAnswer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.easymock.EasyMock.anyInt;
import static org.easymock.EasyMock.anyObject;
Expand All @@ -48,11 +49,18 @@
import static org.easymock.EasyMock.getCurrentArguments;
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.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
*/
public class AbstractWagonTest extends TestCase {
public class AbstractWagonTest {
private static class TestWagon extends AbstractWagon {
protected void closeConnection() throws ConnectionException {}

Expand Down Expand Up @@ -84,48 +92,34 @@ public void put(File source, String destination)

private TransferListener transferListener = null;

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

basedir = System.getProperty("basedir");

destination = new File(basedir, "target/folder/subfolder");

source = new File(basedir, "pom.xml");

wagon = new WagonMock();

sessionListener = createMock(SessionListener.class);

wagon.addSessionListener(sessionListener);

transferListener = createMock(TransferListener.class);

wagon.addTransferListener(transferListener);
}

// https://github.com/apache/maven-wagon/issues/178
@Test
public void testCreateParentDirectories() throws TransferFailedException {
wagon.createParentDirectories(new File("foo")); // file has no parent
}

@Test
public void testCalculationOfTransferBufferSize() {
// 1 KiB -> Default buffer size (4 KiB)
assertEquals(4096, wagon.getBufferCapacityForTransfer(1024L));

// 1 MiB -> Twice the default buffer size (8 KiB)
assertEquals(4096 * 2, wagon.getBufferCapacityForTransfer(1024L * 1024));

// 100 MiB -> Maximum buffer size (512 KiB)
assertEquals(4096 * 128, wagon.getBufferCapacityForTransfer(1024L * 1024 * 100));

// 1 GiB -> Maximum buffer size (512 KiB)
assertEquals(4096 * 128, wagon.getBufferCapacityForTransfer(1024L * 1024 * 1024));

// 100 GiB -> Maximum buffer size (512 KiB)
assertEquals(4096 * 128, wagon.getBufferCapacityForTransfer(1024L * 1024 * 1024 * 100));
}

@Test
public void testSessionListenerRegistration() {
assertTrue(wagon.hasSessionListener(sessionListener));

Expand All @@ -134,6 +128,7 @@ public void testSessionListenerRegistration() {
assertFalse(wagon.hasSessionListener(sessionListener));
}

@Test
public void testTransferListenerRegistration() {
assertTrue(wagon.hasTransferListener(transferListener));

Expand All @@ -142,6 +137,7 @@ public void testTransferListenerRegistration() {
assertFalse(wagon.hasTransferListener(transferListener));
}

@Test
public void testNoProxyConfiguration() throws ConnectionException, AuthenticationException {
Repository repository = new Repository();
wagon.connect(repository);
Expand All @@ -153,6 +149,7 @@ public void testNoProxyConfiguration() throws ConnectionException, Authenticatio
assertNull(wagon.getProxyInfo("http", "localhost"));
}

@Test
public void testNullProxyConfiguration() throws ConnectionException, AuthenticationException {
Repository repository = new Repository();
wagon.connect(repository, (ProxyInfo) null);
Expand Down Expand Up @@ -180,6 +177,7 @@ public void testNullProxyConfiguration() throws ConnectionException, Authenticat
assertNull(wagon.getProxyInfo("http", "localhost"));
}

@Test
public void testLegacyProxyConfiguration() throws ConnectionException, AuthenticationException {
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setType("http");
Expand All @@ -193,6 +191,7 @@ public void testLegacyProxyConfiguration() throws ConnectionException, Authentic
assertNull(wagon.getProxyInfo("ftp", "www.example.com"));
}

@Test
public void testProxyConfiguration() throws ConnectionException, AuthenticationException {
final ProxyInfo httpProxyInfo = new ProxyInfo();
httpProxyInfo.setType("http");
Expand Down Expand Up @@ -220,6 +219,7 @@ public ProxyInfo getProxyInfo(String protocol) {
assertNull(wagon.getProxyInfo("ftp", "www.example.com"));
}

@Test
public void testSessionOpenEvents() throws Exception {
Repository repository = new Repository();

Expand All @@ -234,17 +234,16 @@ public void testSessionOpenEvents() throws Exception {
assertEquals(repository, wagon.getRepository());
}

@Test
public void testSessionConnectionRefusedEventConnectionException() throws Exception {
final WagonException exception = new ConnectionException("");
WagonException exception = new ConnectionException("");

try {
runTestSessionConnectionRefusedEvent(exception);
fail();
} catch (ConnectionException e) {
assertNotNull(e.getMessage());
}
ConnectionException e =
assertThrows(ConnectionException.class, () -> runTestSessionConnectionRefusedEvent(exception));
assertNotNull(e.getMessage());
}

@Test
public void testSessionConnectionRefusedEventAuthenticationException() throws Exception {
final WagonException exception = new AuthenticationException("");

Expand Down Expand Up @@ -286,6 +285,7 @@ protected void openConnectionInternal() throws ConnectionException, Authenticati
}
}

@Test
public void testSessionCloseEvents() throws Exception {
sessionListener.sessionDisconnecting(anyObject(SessionEvent.class));
sessionListener.sessionDisconnected(anyObject(SessionEvent.class));
Expand All @@ -296,6 +296,7 @@ public void testSessionCloseEvents() throws Exception {
verify(sessionListener);
}

@Test
public void testSessionCloseRefusedEventConnectionException() throws Exception {
sessionListener.sessionDisconnecting(anyObject(SessionEvent.class));
sessionListener.sessionError(anyObject(SessionEvent.class));
Expand All @@ -308,16 +309,12 @@ protected void closeConnection() throws ConnectionException {
};
wagon.addSessionListener(sessionListener);

try {
wagon.disconnect();
fail();
} catch (ConnectionException e) {
assertNotNull(e.getMessage());
} finally {
verify(sessionListener);
}
ConnectionException e = assertThrows(ConnectionException.class, () -> wagon.disconnect());
assertNotNull(e.getMessage());
verify(sessionListener);
}

@Test
public void testGetTransferEvents() throws Exception {
transferListener.debug("fetch debug message");
transferListener.transferInitiated(anyObject(TransferEvent.class));
Expand All @@ -339,6 +336,7 @@ public void testGetTransferEvents() throws Exception {
verify(transferListener);
}

@Test
public void testGetError() throws Exception {
transferListener.transferInitiated(anyObject(TransferEvent.class));
transferListener.transferStarted(anyObject(TransferEvent.class));
Expand Down Expand Up @@ -366,6 +364,7 @@ public void testGetError() throws Exception {
verify(transferListener);
}

@Test
public void testPutTransferEvents()
throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
AuthorizationException {
Expand All @@ -387,6 +386,7 @@ public void testPutTransferEvents()
verify(transferListener);
}

@Test
public void testRepositoryPermissionsOverride() throws ConnectionException, AuthenticationException {
Repository repository = new Repository();

Expand All @@ -404,6 +404,7 @@ public void testRepositoryPermissionsOverride() throws ConnectionException, Auth
assertEquals("644", repository.getPermissions().getFileMode());
}

@Test
public void testRepositoryUserName() throws ConnectionException, AuthenticationException {
Repository repository = new Repository("id", "http://bporter:password@www.example.com/path/to/resource");

Expand All @@ -417,6 +418,7 @@ public void testRepositoryUserName() throws ConnectionException, AuthenticationE
assertEquals("pass", authenticationInfo.getPassword());
}

@Test
public void testRepositoryUserNameNotGivenInCredentials() throws ConnectionException, AuthenticationException {
Repository repository = new Repository("id", "http://bporter:password@www.example.com/path/to/resource");

Expand All @@ -428,6 +430,7 @@ public void testRepositoryUserNameNotGivenInCredentials() throws ConnectionExcep
assertEquals("password", authenticationInfo.getPassword());
}

@Test
public void testConnectNullRepository() throws ConnectionException, AuthenticationException {
try {
wagon.connect(null);
Expand All @@ -437,6 +440,7 @@ public void testConnectNullRepository() throws ConnectionException, Authenticati
}
}

@Test
public void testPostProcessListeners() throws TransferFailedException, IOException {
File tempFile = File.createTempFile("wagon", "tmp");
tempFile.deleteOnExit();
Expand Down
Loading
Loading