archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1555669 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav: AbstractRepositoryServletTestCase.java RepositoryServletTest.java
Date Mon, 06 Jan 2014 05:31:20 GMT
Author: olamy
Date: Mon Jan  6 05:31:20 2014
New Revision: 1555669

URL: http://svn.apache.org/r1555669
Log:
refactor

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java?rev=1555669&r1=1555668&r2=1555669&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
Mon Jan  6 05:31:20 2014
@@ -35,11 +35,13 @@ import org.apache.archiva.configuration.
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.archiva.webdav.util.MavenIndexerCleaner;
 import org.apache.archiva.webdav.util.ReinitServlet;
+import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.deploy.ApplicationParameter;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runner.RunWith;
@@ -50,6 +52,7 @@ import org.springframework.test.context.
 import org.springframework.web.context.ContextLoaderListener;
 
 import javax.inject.Inject;
+import javax.servlet.Servlet;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.IOException;
@@ -60,8 +63,8 @@ import java.nio.charset.Charset;
 /**
  * AbstractRepositoryServletTestCase
  */
-@RunWith( ArchivaSpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = { "classpath*:/repository-servlet-simple.xml" } )
+@RunWith(ArchivaSpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath*:/repository-servlet-simple.xml" })
 public abstract class AbstractRepositoryServletTestCase
     extends TestCase
 {
@@ -135,14 +138,14 @@ public abstract class AbstractRepository
         applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex();
 
 
-
     }
 
     StandardContext context;
 
     UnauthenticatedRepositoryServlet servlet;
 
-    protected void startRepository() throws Exception
+    protected void startRepository()
+        throws Exception
     {
         tomcat = new Tomcat();
         tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) );
@@ -164,7 +167,6 @@ public abstract class AbstractRepository
         Tomcat.addServlet( context, "repository", servlet );
         context.addServletMapping( "/repository/*", "repository" );
 
-
         Tomcat.addServlet( context, "reinitservlet", new ReinitServlet() );
         context.addServletMapping( "/reinit/*", "reinitservlet" );
 
@@ -173,6 +175,23 @@ public abstract class AbstractRepository
         this.port = tomcat.getConnector().getLocalPort();
     }
 
+    protected Servlet findServlet( String name )
+        throws Exception
+    {
+        Container[] childs = context.findChildren();
+        for ( Container container : childs )
+        {
+            if ( StringUtils.equals( container.getName(), name ) )
+            {
+                Tomcat.ExistingStandardWrapper esw = Tomcat.ExistingStandardWrapper.class.cast(
container );
+                Servlet servlet = esw.loadServlet();
+
+                return servlet;
+            }
+        }
+        return null;
+    }
+
     protected String getSpringConfigLocation()
     {
         return "classpath*:/META-INF/spring-context.xml,classpath*:spring-context.xml";

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java?rev=1555669&r1=1555668&r2=1555669&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletTest.java
Mon Jan  6 05:31:20 2014
@@ -68,22 +68,6 @@ public class RepositoryServletTest
         assertRepositoryValid( servlet, REPOID_INTERNAL );
     }
 
-    Servlet findServlet( String name )
-        throws Exception
-    {
-        Container[] childs = context.findChildren();
-        for ( Container container : childs )
-        {
-            if ( StringUtils.equals( container.getName(), name ) )
-            {
-                Tomcat.ExistingStandardWrapper esw = Tomcat.ExistingStandardWrapper.class.cast(
container );
-                Servlet servlet = esw.loadServlet();
-
-                return servlet;
-            }
-        }
-        return null;
-    }
 
     @Test
     public void testGetRepositoryAfterDelete()
@@ -106,7 +90,7 @@ public class RepositoryServletTest
     public void testGetRepositoryAfterAdd()
         throws Exception
     {
-        RepositoryServlet servlet =RepositoryServlet.class.cast( findServlet( "repository"
) );
+        RepositoryServlet servlet = RepositoryServlet.class.cast( findServlet( "repository"
) );
         assertNotNull( servlet );
 
         ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
@@ -154,6 +138,7 @@ public class RepositoryServletTest
         WebRequest request = new GetMethodWebRequest( path );
         WebResponse response = getServletUnitClient().getResponse( request );
         assertResponseNotFound( response );
-        Assertions.assertThat( response.getContentAsString() ).contains(            "Invalid
path to Artifact: legacy paths should have an expected type ending in [s] in the second part
of the path." );
+        Assertions.assertThat( response.getContentAsString() ).contains(
+            "Invalid path to Artifact: legacy paths should have an expected type ending in
[s] in the second part of the path." );
     }
 }



Mime
View raw message