]> source.dussan.org Git - archiva.git/commitdiff
fix unit test
authorOlivier Lamy <olamy@apache.org>
Mon, 6 Jan 2014 05:31:33 +0000 (05:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 6 Jan 2014 05:31:33 +0000 (05:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1555671 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletProxiedTestCase.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletProxiedTimestampedSnapshotPolicyTest.java

index 8767cacceb43237913a62a72632ade9c8472f450..0da0394affa8d87c851522976f6abb2f681179e9 100644 (file)
@@ -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 );
index 7e7a783965af4a5ee15a3498d35db5fd62807b7e..5197688d3af94f756dc0e7006839016118d55c1a 100644 (file)
@@ -43,8 +43,8 @@ public class RepositoryServletProxiedTimestampedSnapshotPolicyTest
     public void setup()
         throws Exception
     {
-        archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
         super.setUp();
+        archivaConfiguration.getConfiguration().setProxyConnectors( new ArrayList<ProxyConnectorConfiguration>() );
     }
 
     @After