import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import org.easymock.MockControl;
import java.io.File;
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
// TODO: timestamp preservation requires support for that in wagon
// assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
}
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
long originalModificationTime = expectedFile.lastModified();
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
assertFalse( "Check file timestamp is not that of proxy", proxiedFile.lastModified() == file.lastModified() );
assertEquals( "Check file timestamp is that of original managed file", originalModificationTime,
file.lastModified() );
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetWhenInBothProxiedRepos()
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetInSecondProxiedRepo()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testNotFoundInAnyProxies()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
assertTrue( "Check failure", proxiedArtifactRepository.isCachedFailure( path ) );
}
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetInSecondProxiedRepoFirstHardFailsFromCache()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
assertFalse( "Check failure", proxiedArtifactRepository.isCachedFailure( path ) );
}
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
assertFalse( "Check failure", proxiedArtifactRepository.isCachedFailure( path ) );
}
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( expectedFile );
+ String unexpectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetAlwaysAlreadyPresentRemovedFromProxies()
{
String path = "org/apache/maven/test/get-removed-from-proxies/1.0/get-removed-from-proxies-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testGetAlwaysWithCachedFailure()
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( expectedFile );
+ String unexpectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetRemovesTemporaryFileOnSuccess()
File checksumFile = getChecksumFile( file, "sha1" );
assertTrue( "Check file created", checksumFile.exists() );
assertEquals( "Check checksum", "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar",
- FileUtils.fileRead( checksumFile ).trim() );
+ FileUtils.readFileToString( checksumFile, null ).trim() );
assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
}
File checksumFile = getChecksumFile( file, "sha1" );
assertTrue( "Check file created", checksumFile.exists() );
assertEquals( "Check checksum", "748a3a013bf5eacf2bbb40a2ac7d37889b728837 *get-checksum-sha1-only-1.0.jar",
- FileUtils.fileRead( checksumFile ).trim() );
+ FileUtils.readFileToString( checksumFile, null ).trim() );
assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
}
File checksumFile = getChecksumFile( file, "sha1" );
assertTrue( "Check file created", checksumFile.exists() );
assertEquals( "Check checksum", "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar",
- FileUtils.fileRead( checksumFile ).trim() );
+ FileUtils.readFileToString( checksumFile, null ).trim() );
assertFalse( "Check file not created", getChecksumFile( file, "md5" ).exists() );
}
File checksumFile = getChecksumFile( file, "md5" );
assertTrue( "Check file created", checksumFile.exists() );
assertEquals( "Check checksum", "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar",
- FileUtils.fileRead( checksumFile ).trim() );
+ FileUtils.readFileToString( checksumFile, null ).trim() );
assertFalse( "Check file not created", getChecksumFile( file, "sha1" ).exists() );
}
File checksumFile = getChecksumFile( file, "md5" );
assertTrue( "Check file created", checksumFile.exists() );
assertEquals( "Check checksum", "8a02aa67549d27b2a03cd4547439c6d3 *get-checksum-md5-bad-sha1-1.0.jar",
- FileUtils.fileRead( checksumFile ).trim() );
+ FileUtils.readFileToString( checksumFile, null ).trim() );
assertFalse( "Check file not created", getChecksumFile( file, "sha1" ).exists() );
}
{
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( expectedFile );
+ String unexpectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
assertFalse( "Check checksum removed", new File( file.getParentFile(), file.getName() + ".sha1" ).exists() );
assertFalse( "Check checksum removed", new File( file.getParentFile(), file.getName() + ".md5" ).exists() );
String path =
"org/apache/maven/test/get-checksum-from-managed-repo/1.0/get-checksum-from-managed-repo-1.0.jar.sha1";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetAlwaysChecksumPresentInManagedRepo()
String path =
"org/apache/maven/test/get-checksum-from-managed-repo/1.0/get-checksum-from-managed-repo-1.0.jar.sha1";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetChecksumNotPresentInManagedRepo()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
String expectedContents = getExpectedMetadata( "get-default-metadata", "1.0" );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testGetMetadataMergeRepos()
String expectedContents = getExpectedMetadata( "get-merged-metadata", getVersioning(
Arrays.asList( new String[]{"0.9", "1.0", "2.0", "3.0", "5.0", "4.0"} ) ) );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testGetMetadataRemovedFromProxies()
{
String path = "org/apache/maven/test/get-removed-metadata/1.0/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String expectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testGetReleaseMetadataNotExpired()
{
String path = "org/apache/maven/test/get-updated-metadata/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String expectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
- String unexpectedContents = FileUtils.fileRead( new File( proxiedRepository1.getBasedir(), path ) );
+ String unexpectedContents = FileUtils.readFileToString( new File( proxiedRepository1.getBasedir(), path ), null );
assertFalse( "Check content doesn't match proxy version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetSnapshotMetadataNotExpired()
{
String path = "org/apache/maven/test/get-updated-metadata/1.0-SNAPSHOT/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String expectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
- String unexpectedContents = FileUtils.fileRead( new File( proxiedRepository1.getBasedir(), path ) );
+ String unexpectedContents = FileUtils.readFileToString( new File( proxiedRepository1.getBasedir(), path ), null );
assertFalse( "Check content doesn't match proxy version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetReleaseMetadataExpired()
{
String path = "org/apache/maven/test/get-updated-metadata/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String unexpectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
String expectedContents =
getExpectedMetadata( "get-updated-metadata", getVersioning( Arrays.asList( new String[]{"1.0", "2.0"} ) ) );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
assertFalse( "Check content doesn't match proxy version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetSnapshotMetadataExpired()
{
String path = "org/apache/maven/test/get-updated-metadata/1.0-SNAPSHOT/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String unexpectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
String expectedContents =
getExpectedMetadata( "get-updated-metadata", "1.0-SNAPSHOT", getVersioning( "20050831.111213", 2 ) );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
assertFalse( "Check content doesn't match proxy version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetMetadataNotUpdated()
{
String path = "org/apache/maven/test/get-updated-metadata/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String expectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
File file = requestHandler.get( path, proxiedRepositories, defaultManagedRepository );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
assertFalse( "Check content doesn't match proxy version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetMetadataUpdated()
{
String path = "org/apache/maven/test/get-updated-metadata/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String unexpectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
String expectedContents =
getExpectedMetadata( "get-updated-metadata", getVersioning( Arrays.asList( new String[]{"1.0", "2.0"} ) ) );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
assertFalse( "Check content doesn't match old version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testGetAlwaysMetadata()
{
String path = "org/apache/maven/test/get-updated-metadata/maven-metadata.xml";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( new File( defaultManagedRepository.getBasedir(), path ) );
+ String unexpectedContents = FileUtils.readFileToString( new File( defaultManagedRepository.getBasedir(), path ), null );
assertTrue( expectedFile.exists() );
String expectedContents =
getExpectedMetadata( "get-updated-metadata", getVersioning( Arrays.asList( new String[]{"1.0", "2.0"} ) ) );
- assertEquals( "Check content matches", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check content matches", expectedContents, FileUtils.readFileToString( file, null ) );
assertFalse( "Check content doesn't match old version",
- unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testSnapshotNonExistant()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testNewerTimestampDrivenSnapshotOnFirstRepo()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testOlderTimestampDrivenSnapshotOnFirstRepo()
String path =
"org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
/* TODO: won't pass until Wagon preserves timestamp on download
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
*/
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
proxiedFile = new File( proxiedRepository2.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testTimestampDrivenSnapshotNotExpired()
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- String expectedContents = FileUtils.fileRead( expectedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testTimestampDrivenSnapshotNotUpdated()
String path =
"org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testTimestampDrivenSnapshotNotPresentAlreadyExpiredCacheFailure()
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
assertFalse( "Check failure", proxiedArtifactRepository.isCachedFailure( path ) );
}
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
}
public void testGetMetadataDrivenSnapshotRemoteUpdate()
String path =
"org/apache/maven/test/get-present-metadata-snapshot/1.0-SNAPSHOT/get-present-metadata-snapshot-1.0-20050831.101112-1.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( proxiedRepository1.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
}
public void testLegacyManagedRepoGetNotPresent()
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( proxiedRepository1.getBasedir(),
"org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar" );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
// TODO: timestamp preservation requires support for that in wagon
// assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
}
{
String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
File expectedFile = new File( legacyManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
long originalModificationTime = expectedFile.lastModified();
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( proxiedRepository1.getBasedir(),
"org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar" );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
assertFalse( "Check file timestamp is not that of proxy", proxiedFile.lastModified() == file.lastModified() );
assertEquals( "Check file timestamp is that of original managed file", originalModificationTime,
file.lastModified() );
assertTrue( "Check file created", file.exists() );
File proxiedFile =
new File( legacyProxiedRepository.getBasedir(), "org.apache.maven.test/jars/get-default-layout-1.0.jar" );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
// TODO: timestamp preservation requires support for that in wagon
// assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
}
{
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
long originalModificationTime = expectedFile.lastModified();
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( legacyProxiedRepository.getBasedir(),
"org.apache.maven.test/jars/get-default-layout-present-1.0.jar" );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
assertFalse( "Check file timestamp is not that of proxy", proxiedFile.lastModified() == file.lastModified() );
assertEquals( "Check file timestamp is that of original managed file", originalModificationTime,
file.lastModified() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
File proxiedFile = new File( legacyProxiedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( proxiedFile );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ String expectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
// TODO: timestamp preservation requires support for that in wagon
// assertEquals( "Check file timestamp", proxiedFile.lastModified(), file.lastModified() );
}
{
String path = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
File expectedFile = new File( legacyManagedRepository.getBasedir(), path );
- String expectedContents = FileUtils.fileRead( expectedFile );
+ String expectedContents = FileUtils.readFileToString( expectedFile, null );
long originalModificationTime = expectedFile.lastModified();
assertTrue( expectedFile.exists() );
assertEquals( "Check file matches", expectedFile, file );
assertTrue( "Check file created", file.exists() );
- assertEquals( "Check file contents", expectedContents, FileUtils.fileRead( file ) );
+ assertEquals( "Check file contents", expectedContents, FileUtils.readFileToString( file, null ) );
File proxiedFile = new File( legacyProxiedRepository.getBasedir(), path );
- String unexpectedContents = FileUtils.fileRead( proxiedFile );
- assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.fileRead( file ) ) );
+ String unexpectedContents = FileUtils.readFileToString( proxiedFile, null );
+ assertFalse( "Check file contents", unexpectedContents.equals( FileUtils.readFileToString( file, null ) ) );
assertFalse( "Check file timestamp is not that of proxy", proxiedFile.lastModified() == file.lastModified() );
assertEquals( "Check file timestamp is that of original managed file", originalModificationTime,
file.lastModified() );
{
destination = destination.getParentFile();
- FileUtils.copyFileToDirectory( file, destination );
+ FileUtils.copyFile(file, new File(destination, file.getName()), false);
+ // TODO: Change when there is a FileUtils.copyFileToDirectory(file, destination, boolean) option
+ //FileUtils.copyFileToDirectory( file, destination );
}
else if ( file.isDirectory() )
{