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
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,27 @@
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.repository.Repository;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* User: jdumay Date: 24/01/2008 Time: 17:17:34
*/
public class HttpWagonErrorTest extends HttpWagonHttpServerTestCase {
private int serverPort;

@BeforeEach
protected void setUp() throws Exception {
super.setUp();
ServletHolder servlets = new ServletHolder(new ErrorWithMessageServlet());
context.addServlet(servlets, "/*");
startServer();
serverPort = getPort();
}

@Test
public void testGet401() throws Exception {
Exception thrown = null;

Expand Down Expand Up @@ -73,6 +79,7 @@ public void testGet401() throws Exception {
thrown.getMessage());
}

@Test
public void testGet403() throws Exception {
Exception thrown = null;

Expand Down Expand Up @@ -104,6 +111,7 @@ public void testGet403() throws Exception {
thrown.getMessage());
}

@Test
public void testGet404() throws Exception {
Exception thrown = null;

Expand Down Expand Up @@ -135,6 +143,7 @@ public void testGet404() throws Exception {
thrown.getMessage());
}

@Test
public void testGet407() throws Exception {
Exception thrown = null;

Expand Down Expand Up @@ -166,6 +175,7 @@ public void testGet407() throws Exception {
thrown.getMessage());
}

@Test
public void testGet500() throws Exception {
Exception thrown = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,31 @@
*/
package org.apache.maven.wagon.providers.http;

import java.lang.reflect.Method;

import org.apache.maven.wagon.Wagon;
import org.codehaus.plexus.PlexusTestCase;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;

/**
* User: jdumay Date: 24/01/2008 Time: 18:15:53
*/
public abstract class HttpWagonHttpServerTestCase extends PlexusTestCase {
public abstract class HttpWagonHttpServerTestCase {
private Server server;

private String testName;

protected ResourceHandler resourceHandler;

protected ServletContextHandler context;

protected void setUp() throws Exception {
super.setUp();
@BeforeEach
protected void startTestServer(TestInfo testInfo) throws Exception {
testName = testInfo.getTestMethod().map(Method::getName).orElseGet(testInfo::getDisplayName);
server = new Server(0);

context = new ServletContextHandler(ServletContextHandler.SESSIONS);
Expand All @@ -45,8 +51,12 @@ protected void setUp() throws Exception {
server.setHandler(context);
}

protected final String getName() {
return testName;
}

protected Wagon getWagon() throws Exception {
return (Wagon) lookup(HttpWagon.ROLE);
return new HttpWagon();
}

protected void startServer() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@
import org.apache.maven.wagon.shared.http.HttpConfiguration;
import org.apache.maven.wagon.shared.http.HttpMethodConfiguration;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* User: jdumay Date: 24/01/2008 Time: 17:17:34
*/
public class HttpWagonTimeoutTest extends HttpWagonHttpServerTestCase {
@BeforeEach
protected void setUp() throws Exception {
super.setUp();
ServletHolder servlets = new ServletHolder(new WaitForeverServlet());
context.addServlet(servlets, "/*");
startServer();
}

@Test
public void testGetTimeout() throws Exception {
Exception thrown = null;

Expand Down Expand Up @@ -68,6 +75,7 @@ public void testGetTimeout() throws Exception {
assertEquals(TransferFailedException.class, thrown.getClass());
}

@Test
public void testResourceExits() throws Exception {
Exception thrown = null;

Expand All @@ -93,6 +101,7 @@ public void testResourceExits() throws Exception {
assertEquals(TransferFailedException.class, thrown.getClass());
}

@Test
public void testPutTimeout() throws Exception {
Exception thrown = null;

Expand Down Expand Up @@ -121,6 +130,7 @@ public void testPutTimeout() throws Exception {
assertEquals(TransferFailedException.class, thrown.getClass());
}

@Test
public void testConnectionTimeout() throws Exception {
Exception thrown = null;

Expand Down
Loading