Skip tests if module is installed in a path with space. (Repository will be invalid)

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1371207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
skygo 2012-08-09 13:37:38 +00:00
parent 1c0fae86e8
commit 2284bc1635
1 changed files with 20 additions and 7 deletions

View File

@ -46,7 +46,10 @@ import java.io.File;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.LoggerFactory;
/** /**
* @author Olivier Lamy * @author Olivier Lamy
@ -67,22 +70,31 @@ public abstract class AbstractArchivaRestTest
// END SNIPPET: authz-header // END SNIPPET: authz-header
@BeforeClass
public static void chekRepo() {
Assume.assumeTrue( !System.getProperty( "appserver.base" ).contains(" ") );
LoggerFactory.getLogger( AbstractArchivaRestTest.class.getName() ).
error( "Rest services unit test must be run in a folder with no space" );
// skygo: was not possible to fix path in this particular module
// Skip test if not in proper folder , otherwise test are not fair coz repository
// cannot have space in their name.
}
@Override @Override
@Before @Before
public void startServer() public void startServer()
throws Exception throws Exception
{ {
File appServerBase = new File( System.getProperty( "appserver.base" ) ); File appServerBase = new File( System.getProperty( "appserver.base" ) );
File jcrDirectory = new File( appServerBase, "jcr" ); File jcrDirectory = new File( appServerBase, "jcr" );
if ( jcrDirectory.exists() ) if ( jcrDirectory.exists() )
{ {
FileUtils.deleteDirectory( jcrDirectory ); FileUtils.deleteDirectory( jcrDirectory );
} }
super.startServer(); super.startServer();
} }
@Override @Override
@ -91,6 +103,7 @@ public abstract class AbstractArchivaRestTest
return "classpath*:META-INF/spring-context.xml,classpath:META-INF/spring-context-test.xml"; return "classpath*:META-INF/spring-context.xml,classpath:META-INF/spring-context-test.xml";
} }
@Override
protected String getRestServicesPath() protected String getRestServicesPath()
{ {
return "restServices"; return "restServices";
@ -233,7 +246,7 @@ public abstract class AbstractArchivaRestTest
protected SearchService getSearchService( String authzHeader ) protected SearchService getSearchService( String authzHeader )
{ {
// START SNIPPET: cxf-searchservice-creation // START SNIPPET: cxf-searchservice-creation
SearchService service = SearchService service =
JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
SearchService.class, SearchService.class,
@ -373,7 +386,7 @@ public abstract class AbstractArchivaRestTest
} }
} }
protected void createAndIndexRepo( String testRepoId, String repoPath, boolean scan ) protected void createAndIndexRepo( String testRepoId, String repoPath, boolean scan )
throws Exception throws Exception
{ {
@ -391,7 +404,7 @@ public abstract class AbstractArchivaRestTest
{ {
FileUtils.deleteDirectory( badContent ); FileUtils.deleteDirectory( badContent );
} }
managedRepository.setLocation( new File( repoPath ).getPath() ); managedRepository.setLocation( new File( repoPath ).getPath() );
managedRepository.setIndexDirectory( managedRepository.setIndexDirectory(
System.getProperty( "java.io.tmpdir" ) + "/target/.index-" + Long.toString( new Date().getTime() ) ); System.getProperty( "java.io.tmpdir" ) + "/target/.index-" + Long.toString( new Date().getTime() ) );