import org.codehaus.plexus.digest.Digester;
import org.codehaus.plexus.digest.DigesterException;
import org.codehaus.plexus.i18n.I18N;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
}
// Even if the checksums for the POM are invalid we should still convert the POM
- contents = FileUtils.fileRead( file );
+ contents = FileUtils.readFileToString( file, null );
}
catch ( IOException e )
{
boolean matching = false;
if ( !force && targetFile.exists() )
{
- String targetContents = FileUtils.fileRead( targetFile );
+ String targetContents = FileUtils.readFileToString( targetFile, null );
matching = targetContents.equals( contents );
}
if ( force || !matching )
File checksumFile = new File( file.getParentFile(), fileName );
if ( checksumFile.exists() )
{
- String checksum = FileUtils.fileRead( checksumFile );
+ String checksum = FileUtils.readFileToString( checksumFile, null );
try
{
digester.verify( file, checksum );
* limitations under the License.
*/
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
if ( dir.isDirectory() && dir.list().length == 0 )
{
- FileUtils.deleteDirectory( dir.getAbsolutePath() );
+ FileUtils.deleteDirectory( dir );
}
else
{
* limitations under the License.
*/
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
public void rollback()
throws IOException
{
- FileUtils.fileDelete( destination.getAbsolutePath() );
+ destination.delete();
revertMkDirs();
* limitations under the License.
*/
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
throw new IOException( "Unable to create new file" );
}
- FileUtils.fileWrite( destination.getAbsolutePath(), content );
+ FileUtils.writeStringToFile( destination, content, null );
}
public void rollback()
throws IOException
{
- FileUtils.fileDelete( destination.getAbsolutePath() );
+ destination.delete();
revertMkDirs();
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.i18n.I18N;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
private static void compareFiles( File expectedPomFile, File pomFile )
throws IOException
{
- String expectedContent = normalizeString( FileUtils.fileRead( expectedPomFile ) );
- String targetContent = normalizeString( FileUtils.fileRead( pomFile ) );
+ String expectedContent = normalizeString( FileUtils.readFileToString( expectedPomFile, null ) );
+ String targetContent = normalizeString( FileUtils.readFileToString( pomFile, null ) );
assertEquals( "Check file match between " + expectedPomFile + " and " + pomFile, expectedContent,
targetContent );
}
*/
import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import java.io.File;
testSource.createNewFile();
- FileUtils.fileWrite( testSource.getAbsolutePath(), "source contents" );
+ FileUtils.writeStringToFile( testSource, "source contents", null );
}
public void testCopyCommitRollback()
{
assertTrue( "Test if the source exists", testSource.exists() );
- String source = FileUtils.fileRead( testSource.getAbsolutePath() );
+ String source = FileUtils.readFileToString( testSource, null );
CopyFileEvent event = new CopyFileEvent( testSource, testDest );
assertTrue( "Test that the destination is created", testDest.exists() );
- String target = FileUtils.fileRead( testDest.getAbsolutePath() );
+ String target = FileUtils.readFileToString( testDest, null );
assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) );
{
assertTrue( "Test if the source exists", testSource.exists() );
- String source = FileUtils.fileRead( testSource.getAbsolutePath() );
+ String source = FileUtils.readFileToString( testSource, null );
testDest.getParentFile().mkdirs();
testDest.createNewFile();
- FileUtils.fileWrite( testDest.getAbsolutePath(), "overwritten contents" );
+ FileUtils.writeStringToFile( testDest, "overwritten contents", null );
assertTrue( "Test that the destination exists", testDest.exists() );
CopyFileEvent event = new CopyFileEvent( testSource, testDest );
- String target = FileUtils.fileRead( testDest.getAbsolutePath() );
+ String target = FileUtils.readFileToString( testDest, null );
assertTrue( "Test that the destination contents have not changed", target.equals( "overwritten contents" ) );
event.commit();
- target = FileUtils.fileRead( testDest.getAbsolutePath() );
+ target = FileUtils.readFileToString( testDest, null );
assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) );
event.rollback();
- target = FileUtils.fileRead( testDest.getAbsolutePath() );
+ target = FileUtils.readFileToString( testDest, null );
assertTrue( "Test the destination file contents have been restored", target.equals( "overwritten contents" ) );
}
{
assertTrue( "Test if the source exists", testSource.exists() );
- String source = FileUtils.fileRead( testSource.getAbsolutePath() );
+ String source = FileUtils.readFileToString( testSource, null );
CopyFileEvent event = new CopyFileEvent( testSource, testDest );
assertTrue( "Test that the destination is created", testDest.exists() );
- String target = FileUtils.fileRead( testDest.getAbsolutePath() );
+ String target = FileUtils.readFileToString( testDest, null );
assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) );
}
{
super.tearDown();
- FileUtils.deleteDirectory(
- new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ).getAbsolutePath() );
+ FileUtils.deleteDirectory( new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ) );
}
}
*/
import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.commons.io.FileUtils;
import java.io.File;
testFile.createNewFile();
- FileUtils.fileWrite( testFile.getAbsolutePath(), "original contents" );
+ FileUtils.writeStringToFile( testFile, "original contents", null );
CreateFileEvent event = new CreateFileEvent( "modified contents", testFile );
- String contents = FileUtils.fileRead( testFile.getAbsolutePath() );
+ String contents = FileUtils.readFileToString( testFile, null );
assertEquals( "Test contents have not changed", "original contents", contents );
event.commit();
- contents = FileUtils.fileRead( testFile.getAbsolutePath() );
+ contents = FileUtils.readFileToString( testFile, null );
assertEquals( "Test contents have not changed", "modified contents", contents );
event.rollback();
- contents = FileUtils.fileRead( testFile.getAbsolutePath() );
+ contents = FileUtils.readFileToString( testFile, null );
assertEquals( "Test contents have not changed", "original contents", contents );
}
{
super.tearDown();
- FileUtils.deleteDirectory(
- new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ).getAbsolutePath() );
+ FileUtils.deleteDirectory( new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ) );
}
}