mirror of https://github.com/apache/archiva.git
Fix tests for windows
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@511809 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dee0d5a300
commit
43bb7a6d9a
|
@ -20,6 +20,7 @@ package org.apache.maven.archiva.common.consumers;
|
|||
*/
|
||||
|
||||
import org.apache.maven.archiva.common.utils.BaseFile;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -29,7 +30,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* FileProblemsTracker
|
||||
* FileProblemsTracker
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
|
@ -46,6 +47,7 @@ public class FileProblemsTracker
|
|||
|
||||
private void addProblem( String path, String message )
|
||||
{
|
||||
path = StringUtils.replace( path, "\\", "/" );
|
||||
List problems = getProblems( path );
|
||||
problems.add( message );
|
||||
problemMap.put( path, problems );
|
||||
|
|
|
@ -19,12 +19,13 @@ package org.apache.maven.archiva.common.utils;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* BaseFileTest
|
||||
* BaseFileTest
|
||||
*
|
||||
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
|
@ -38,9 +39,9 @@ public class BaseFileTest
|
|||
String pathFile = "path/to/resource.xml";
|
||||
BaseFile file = new BaseFile( repoDir, pathFile );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
public void testFileFile()
|
||||
|
@ -49,9 +50,9 @@ public class BaseFileTest
|
|||
File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" );
|
||||
BaseFile file = new BaseFile( repoDir, pathFile );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
public void testStringFile()
|
||||
|
@ -60,9 +61,9 @@ public class BaseFileTest
|
|||
File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" );
|
||||
BaseFile file = new BaseFile( repoDir, pathFile );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
public void testFileThenSetBaseString()
|
||||
|
@ -72,9 +73,9 @@ public class BaseFileTest
|
|||
BaseFile file = new BaseFile( pathFile );
|
||||
file.setBaseDir( repoDir );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
public void testFileThenSetBaseFile()
|
||||
|
@ -84,11 +85,11 @@ public class BaseFileTest
|
|||
BaseFile file = new BaseFile( pathFile );
|
||||
file.setBaseDir( repoDir );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
|
||||
public void testStringThenSetBaseString()
|
||||
{
|
||||
String repoDir = "/home/user/foo/repository";
|
||||
|
@ -96,9 +97,9 @@ public class BaseFileTest
|
|||
BaseFile file = new BaseFile( pathFile );
|
||||
file.setBaseDir( repoDir );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
public void testStringThenSetBaseFile()
|
||||
|
@ -108,8 +109,23 @@ public class BaseFileTest
|
|||
BaseFile file = new BaseFile( pathFile );
|
||||
file.setBaseDir( repoDir );
|
||||
|
||||
assertEquals( "/home/user/foo/repository/path/to/resource.xml", file.getAbsolutePath() );
|
||||
assertEquals( "path/to/resource.xml", file.getRelativePath() );
|
||||
assertEquals( new File( "/home/user/foo/repository" ), file.getBaseDir() );
|
||||
}
|
||||
assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file );
|
||||
assertRelativePath( "path/to/resource.xml", file );
|
||||
assertBasedir( "/home/user/foo/repository", file );
|
||||
}
|
||||
|
||||
private void assertAbsolutePath( String expectedPath, BaseFile actualFile )
|
||||
{
|
||||
assertEquals( new File( expectedPath ).getAbsolutePath(), actualFile.getAbsolutePath() );
|
||||
}
|
||||
|
||||
private void assertRelativePath( String expectedPath, BaseFile actualFile )
|
||||
{
|
||||
assertEquals( expectedPath, StringUtils.replace( actualFile.getRelativePath(), "\\", "/" ) );
|
||||
}
|
||||
|
||||
private void assertBasedir( String expectedPath, BaseFile actualFile )
|
||||
{
|
||||
assertEquals( new File( expectedPath ), actualFile.getBaseDir() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue