archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sk...@apache.org
Subject svn commit: r1370368 - in /archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository: AbstractRepositoryAdminTest.java ValidatorTest.java
Date Tue, 07 Aug 2012 17:04:27 GMT
Author: skygo
Date: Tue Aug  7 17:04:26 2012
New Revision: 1370368

URL: http://svn.apache.org/viewvc?rev=1370368&view=rev
Log:
Make unit test able to run on path with space. Warn dev to relocate.
Verify that Validator will fail with a space in reponame.

Added:
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/ValidatorTest.java
      - copied, changed from r1370142, archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java?rev=1370368&r1=1370367&r2=1370368&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
Tue Aug  7 17:04:26 2012
@@ -51,7 +51,7 @@ public abstract class AbstractRepository
 {
     protected Logger log = LoggerFactory.getLogger( getClass() );
 
-    public static final String APPSERVER_BASE_PATH = System.getProperty( "appserver.base"
);
+    public static final String APPSERVER_BASE_PATH = AbstractRepositoryAdminTest.fixPath(
System.getProperty( "appserver.base" ) );
 
     @Inject
     protected MockAuditListener mockAuditListener;
@@ -73,7 +73,19 @@ public abstract class AbstractRepository
         AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost"
);
         return auditInformation;
     }
-
+    
+   // make a nice repo path to allow unit test to run
+    private static String fixPath ( String path ) 
+    {
+        String SPACE = " ";
+        if ( path.contains( SPACE ) )
+        {
+            LoggerFactory.getLogger( AbstractRepositoryAdminTest.class.getName() ).error(

+                    "You are building and testing  with {appserver.base}: \n " + path + "
containing space. Consider relocating." );
+        }
+        return path.replaceAll( SPACE, "&20");
+    }
+    
     protected User getFakeUser()
     {
         SimpleUser user = new SimpleUser()

Copied: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/ValidatorTest.java
(from r1370142, archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java)
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/ValidatorTest.java?p2=archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/ValidatorTest.java&p1=archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java&r1=1370142&r2=1370368&rev=1370368&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/AbstractRepositoryAdminTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/ValidatorTest.java
Tue Aug  7 17:04:26 2012
@@ -18,124 +18,25 @@ package org.apache.archiva.admin.reposit
  * under the License.
  */
 
-import junit.framework.TestCase;
-import org.apache.archiva.admin.mock.MockAuditListener;
-import org.apache.archiva.admin.model.AuditInformation;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
-import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.redback.users.User;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.archiva.redback.role.RoleManager;
-import org.apache.archiva.redback.users.memory.SimpleUser;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.test.context.ContextConfiguration;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.util.List;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import org.apache.commons.validator.GenericValidator;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 /**
- * @author Olivier Lamy
+ * @author Eric Barboni
  */
 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml"
} )
-public abstract class AbstractRepositoryAdminTest
-    extends TestCase
+public  class ValidatorTest
+    extends AbstractRepositoryAdminTest
 {
-    protected Logger log = LoggerFactory.getLogger( getClass() );
-
-    public static final String APPSERVER_BASE_PATH = System.getProperty( "appserver.base"
);
-
-    @Inject
-    protected MockAuditListener mockAuditListener;
-
-    @Inject
-    protected RoleManager roleManager;
-
-    @Inject
-    protected RemoteRepositoryAdmin remoteRepositoryAdmin;
-
-    @Inject
-    protected ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    protected ProxyConnectorAdmin proxyConnectorAdmin;
-
-    protected AuditInformation getFakeAuditInformation()
-    {
-        AuditInformation auditInformation = new AuditInformation( getFakeUser(), "archiva-localhost"
);
-        return auditInformation;
-    }
-
-    protected User getFakeUser()
-    {
-        SimpleUser user = new SimpleUser()
-        {
-            @Override
-            public Object getPrincipal()
-            {
-                return "root";
-            }
-
-        };
-
-        user.setUsername( "root" );
-        user.setFullName( "The top user" );
-        return user;
-    }
-
-    protected ManagedRepository getTestManagedRepository( String repoId, String repoLocation
)
-    {
-        return new ManagedRepository( repoId, "test repo", repoLocation, "default", false,
true, true, "0 0 * * * ?",
-                                      repoLocation + "/.index", false, 1, 2, true, false
);
-    }
-
-    protected File clearRepoLocation( String path )
-        throws Exception
-    {
-        File repoDir = new File( path );
-        if ( repoDir.exists() )
-        {
-            FileUtils.deleteDirectory( repoDir );
-        }
-        assertFalse( repoDir.exists() );
-        return repoDir;
-    }
-
-    protected ManagedRepository findManagedRepoById( List<ManagedRepository> repos,
String id )
-    {
-        for ( ManagedRepository repo : repos )
-        {
-            if ( StringUtils.equals( id, repo.getId() ) )
-            {
-                return repo;
-            }
-        }
-        return null;
-    }
-
-    protected RemoteRepository getRemoteRepository()
-    {
-        return getRemoteRepository( "foo" );
-    }
-
-    protected RemoteRepository getRemoteRepository(String id)
+    @Test
+    public void testGenericValidator() 
     {
-        RemoteRepository remoteRepository = new RemoteRepository();
-        remoteRepository.setUrl( "http://foo.com/maven-it-rocks" );
-        remoteRepository.setTimeout( 10 );
-        remoteRepository.setName( "maven foo" );
-        remoteRepository.setUserName( "foo-name" );
-        remoteRepository.setPassword( "toto" );
-        remoteRepository.setId( id );
-        remoteRepository.setRemoteDownloadNetworkProxyId( "foo" );
-        return remoteRepository;
+        // Be sure M
+        assertFalse("A repo location cannot contains space",GenericValidator.matchRegexp(
"/opt/ testme/",
+                     ManagedRepositoryAdmin.REPOSITORY_LOCATION_VALID_EXPRESSION ));
+        
     }
 }



Mime
View raw message