From: Olivier Lamy Date: Mon, 6 Jan 2014 05:31:33 +0000 (+0000) Subject: fix unit test X-Git-Tag: archiva-2.0.0-RC1~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3bef8aec700a2f1bf6a572f2b68bc74762f2d191;p=archiva.git fix unit test git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1555671 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java index 8767cacce..0da0394af 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java @@ -20,8 +20,10 @@ package org.apache.archiva.webdav; */ +import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebRequest; import com.gargoylesoftware.htmlunit.WebResponse; +import com.google.common.io.Files; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.policies.CachedFailuresPolicy; @@ -34,9 +36,11 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; +import org.fest.assertions.api.Assertions; import org.junit.After; import org.junit.Before; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.nio.charset.Charset; @@ -117,7 +121,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase RemoteRepoInfo repo = new RemoteRepoInfo(); repo.id = id; repo.context = "/" + id; - repo.root = new File( "target/remote-repos/" + id + "/" ); + repo.root = Files.createTempDir();// new File( System.getProperty( "basedir" ) + "target/remote-repos/" + id + "/" ); // Remove exising root contents. if ( repo.root.exists() ) @@ -160,10 +164,11 @@ public abstract class AbstractRepositoryServletProxiedTestCase protected void assertServerSetupCorrectly( RemoteRepoInfo remoteRepo ) throws Exception { - //WebConversation wc = new WebConversation(); - WebRequest request = new GetMethodWebRequest( remoteRepo.url ); - WebResponse response = getServletUnitClient().getResponse( request ); - assertResponseOK( response ); + + WebClient client = newClient(); + int status = client.getPage( remoteRepo.url ).getWebResponse().getStatusCode(); + Assertions.assertThat( status ).isEqualTo( HttpServletResponse.SC_OK ); + } private void setupConnector( String repoId, RemoteRepoInfo remoteRepo, String releasesPolicy, @@ -255,6 +260,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase { remoteSnapshots = createServer( "snapshots" ); + assertServerSetupCorrectly( remoteSnapshots ); RemoteRepositoryConfiguration remoteRepositoryConfiguration = archivaConfiguration.getConfiguration().getRemoteRepositoriesAsMap().get( remoteSnapshots.id ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java index 7e7a78396..5197688d3 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java @@ -43,8 +43,8 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest public void setup() throws Exception { - archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList() ); super.setUp(); + archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList() ); } @After