diff --git a/pom.xml b/pom.xml
index 7257670..6a869f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,6 +91,11 @@
plexus-build-api
0.0.7
+
+ commons-io
+ commons-io
+ 2.6
+
com.google.code.findbugs
diff --git a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
index 5108e0f..4e06402 100644
--- a/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
+++ b/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
@@ -28,13 +28,13 @@
import java.util.Arrays;
import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.maven.model.Resource;
import org.apache.maven.shared.utils.PathTool;
import org.apache.maven.shared.utils.ReaderFactory;
import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
-import org.apache.maven.shared.utils.io.IOUtil;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -88,8 +88,8 @@ public boolean filteredFileExtension( String fileName, List userNonFilte
{
nonFilteredFileExtensions.addAll( userNonFilteredFileExtensions );
}
- boolean filteredFileExtension =
- !nonFilteredFileExtensions.contains( StringUtils.lowerCase( FileUtils.extension( fileName ) ) );
+ String extension = StringUtils.lowerCase( FilenameUtils.getExtension( fileName ) );
+ boolean filteredFileExtension = !nonFilteredFileExtensions.contains( extension );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "file " + fileName + " has a" + ( filteredFileExtension ? " " : " non " )
@@ -359,13 +359,14 @@ static String getEncoding( File file, String encoding, String propertiesEncoding
*/
static boolean isPropertiesFile( File file )
{
- return "properties".equals( StringUtils.lowerCase( FileUtils.extension( file.getName() ) ) );
+ String extension = StringUtils.lowerCase( FilenameUtils.getExtension( ( file.getName() ) ) );
+ return "properties".equals( extension );
}
private void handleDefaultFilterWrappers( MavenResourcesExecution mavenResourcesExecution )
throws MavenFilteringException
{
- List filterWrappers = new ArrayList<>();
+ List filterWrappers = new ArrayList<>();
if ( mavenResourcesExecution.getFilterWrappers() != null )
{
filterWrappers.addAll( mavenResourcesExecution.getFilterWrappers() );
@@ -505,7 +506,7 @@ private String filterFileName( String name, List wrappers )
try ( StringWriter writer = new StringWriter() )
{
- IOUtil.copy( reader, writer );
+ IOUtils.copy( reader, writer );
String filteredFilename = writer.toString();
if ( getLogger().isDebugEnabled() )
diff --git a/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java b/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java
index e04d02d..a928869 100644
--- a/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java
+++ b/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java
@@ -31,7 +31,7 @@
import org.codehaus.plexus.interpolation.multi.DelimiterSpecification;
/**
- * A FilterReader implementation, that works with Interpolator interface instead of it's own interpolation
+ * A FilterReader implementation, that works with Interpolator interface instead of its own interpolation
* implementation. This implementation is heavily based on org.codehaus.plexus.util.InterpolationFilterReader.
*
* @author cstamas
diff --git a/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java b/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java
index 8e81598..b37f7de 100644
--- a/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java
+++ b/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java
@@ -260,7 +260,7 @@ private static String getPropertyValue( String k, Properties p, Logger logger )
/**
* Logs the detected cycle in properties resolution
- * @param valueChain the secuence of properties resolved so fa
+ * @param valueChain the sequence of properties resolved so far
* @param nk the key the closes the cycle
* @param logger Logger instance
*/
diff --git a/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java b/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java
index 706804c..eed5f9b 100644
--- a/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java
@@ -86,7 +86,6 @@ public void setDelimitersShouldAddDefaultDelimitersIfUseDefaultDelimitersIfNotNu
@Test
public void setDelimitersShouldAddDefaultDelimitersIfUseDefaultDelimitersIfSingleElementIsGiven()
{
- LinkedHashSet delimiters = new LinkedHashSet<>();
delimiters.add( "test" );
request.setDelimiters( delimiters, true );
assertThat( request.getDelimiters(), Matchers.contains( "${*}", "@", "test" ) );
@@ -95,7 +94,6 @@ public void setDelimitersShouldAddDefaultDelimitersIfUseDefaultDelimitersIfSingl
@Test
public void setDelimitersShouldAddDefaultDelimitersForNullElement()
{
- LinkedHashSet delimiters = new LinkedHashSet<>();
delimiters.add( "test" );
delimiters.add( null );
delimiters.add( "second" );
diff --git a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
index 04f58f7..249aa79 100644
--- a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java
@@ -22,6 +22,7 @@
import java.io.File;
import java.io.Reader;
import java.io.StringReader;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -31,7 +32,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper;
import org.codehaus.plexus.PlexusTestCase;
@@ -50,10 +50,7 @@ protected void setUp()
throws Exception
{
super.setUp();
- if ( to.exists() )
- {
- FileUtils.forceDelete( to );
- }
+ Files.deleteIfExists( to.toPath() );
}
public void testNotOverwriteFile()
diff --git a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
index a47fc01..0a6061e 100644
--- a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
@@ -22,17 +22,17 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
-import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Resource;
import org.apache.maven.settings.Settings;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
import org.codehaus.plexus.interpolation.ValueSource;
@@ -46,7 +46,10 @@ public class DefaultMavenResourcesFilteringTest
extends PlexusTestCase
{
- File outputDirectory = new File( getBasedir(), "target/DefaultMavenResourcesFilteringTest" );
+ private File outputDirectory = new File( getBasedir(), "target/DefaultMavenResourcesFilteringTest" );
+ private File baseDir = new File( "c:\\foo\\bar" );
+ private StubMavenProject mavenProject = new StubMavenProject( baseDir );
+ private MavenResourcesFiltering mavenResourcesFiltering;
@Override
protected void setUp()
@@ -55,25 +58,24 @@ protected void setUp()
super.setUp();
if ( outputDirectory.exists() )
{
- FileUtils.forceDelete( outputDirectory );
+ FileUtils.deleteDirectory( outputDirectory );
}
outputDirectory.mkdirs();
+
+ mavenProject.setVersion( "1.0" );
+ mavenProject.setGroupId( "org.apache" );
+ mavenProject.setName( "test project" );
+
+ mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
}
public void testSimpleFiltering()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
Properties projectProperties = new Properties();
projectProperties.put( "foo", "bar" );
projectProperties.put( "java.version", "zloug" );
mavenProject.setProperties( projectProperties );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
File initialImageFile = new File( unitFilesDir, "happy_duke.gif" );
@@ -96,16 +98,12 @@ public void testSimpleFiltering()
mavenResourcesExecution.setUseDefaultFilterWrappers( true );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
- assertFiltering( baseDir, initialImageFile, false, false );
+ assertFiltering( initialImageFile, false, false );
}
public void testSessionFiltering()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/session-filtering";
@@ -151,17 +149,10 @@ public void testSessionFiltering()
public void testWithMavenResourcesExecution()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
Properties projectProperties = new Properties();
projectProperties.put( "foo", "bar" );
projectProperties.put( "java.version", "zloug" );
mavenProject.setProperties( projectProperties );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
File initialImageFile = new File( unitFilesDir, "happy_duke.gif" );
@@ -182,23 +173,16 @@ public void testWithMavenResourcesExecution()
nonFilteredFileExtensions, new StubMavenSession() );
mavenResourcesExecution.setEscapeString( "\\" );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
- assertFiltering( baseDir, initialImageFile, true, false );
+ assertFiltering( initialImageFile, true, false );
}
- public void testWithMavenResourcesExecutionWithAdditionnalProperties()
+ public void testWithMavenResourcesExecutionWithAdditionalProperties()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
Properties projectProperties = new Properties();
projectProperties.put( "foo", "bar" );
projectProperties.put( "java.version", "zloug" );
mavenProject.setProperties( projectProperties );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
File initialImageFile = new File( unitFilesDir, "happy_duke.gif" );
@@ -223,11 +207,11 @@ public void testWithMavenResourcesExecutionWithAdditionnalProperties()
mavenResourcesExecution.setAdditionalProperties( additionalProperties );
mavenResourcesExecution.setEscapeString( "\\" );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
- assertFiltering( baseDir, initialImageFile, true, true );
+ assertFiltering( initialImageFile, true, true );
}
- private void assertFiltering( File baseDir, File initialImageFile, boolean escapeTest,
- boolean additionnalProperties )
+ private void assertFiltering( File initialImageFile, boolean escapeTest,
+ boolean additionalProperties )
throws Exception
{
assertEquals( 7, outputDirectory.listFiles().length );
@@ -249,7 +233,7 @@ private void assertFiltering( File baseDir, File initialImageFile, boolean escap
assertFalse( result.isEmpty() );
- if ( additionnalProperties )
+ if ( additionalProperties )
{
assertEquals( "1973-06-14", result.getProperty( "goodDate" ) );
assertEquals( "99.00", result.get( "version" ) );
@@ -292,17 +276,10 @@ private void assertFiltering( File baseDir, File initialImageFile, boolean escap
public void testAddingTokens()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- final StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
Properties projectProperties = new Properties();
projectProperties.put( "foo", "bar" );
projectProperties.put( "java.version", "zloug" );
mavenProject.setProperties( projectProperties );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
File initialImageFile = new File( unitFilesDir, "happy_duke.gif" );
@@ -333,17 +310,12 @@ public void testAddingTokens()
PropertyUtils.loadPropertyFile( new File( outputDirectory, "maven-resources-filtering.txt" ), null );
assertFalse( result.isEmpty() );
assertEquals( mavenProject.getName(), result.get( "pomName" ) );
- assertFiltering( baseDir, initialImageFile, false, false );
+ assertFiltering( initialImageFile, false, false );
}
public void testNoFiltering()
throws Exception
{
- StubMavenProject mavenProject = new StubMavenProject( new File( getBasedir() ) );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
File initialImageFile = new File( unitFilesDir, "happy_duke.gif" );
@@ -383,46 +355,33 @@ public void testNoFiltering()
assertTrue( filesAreIdentical( initialImageFile, imageFile ) );
}
- public static boolean filesAreIdentical( File expected, File current )
+ private static boolean filesAreIdentical( File expected, File current )
throws IOException
{
if ( expected.length() != current.length() )
{
return false;
}
-
- try ( FileInputStream expectedIn = new FileInputStream( expected );
- FileInputStream currentIn = new FileInputStream( current ) )
- {
-
- byte[] expectedBuffer = IOUtils.toByteArray( expectedIn );
- byte[] currentBuffer = IOUtils.toByteArray( currentIn );
- if ( expectedBuffer.length != currentBuffer.length )
+ byte[] expectedBuffer = Files.readAllBytes( expected.toPath() );
+ byte[] currentBuffer = Files.readAllBytes( current.toPath() );
+ if ( expectedBuffer.length != currentBuffer.length )
+ {
+ return false;
+ }
+ for ( int i = 0, size = expectedBuffer.length; i < size; i++ )
+ {
+ if ( expectedBuffer[i] != currentBuffer[i] )
{
return false;
}
- for ( int i = 0, size = expectedBuffer.length; i < size; i++ )
- {
- if ( expectedBuffer[i] != currentBuffer[i] )
- {
- return false;
- }
- }
}
- return true;
+ return true;
}
public void testIncludeOneFile()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
@@ -451,14 +410,6 @@ public void testIncludeOneFile()
public void testIncludeOneFileAndDirectory()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
-
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
Resource resource = new Resource();
@@ -492,13 +443,6 @@ public void testIncludeOneFileAndDirectory()
public void testExcludeOneFile()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
@@ -537,13 +481,6 @@ public void testExcludeOneFile()
public void testTargetAbsolutePath()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
@@ -583,13 +520,6 @@ public void testTargetAbsolutePath()
public void testTargetPath()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering";
@@ -620,13 +550,6 @@ public void testTargetPath()
public void testEmptyDirectories()
throws Exception
{
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
List resources = new ArrayList<>();
resources.add( new Resource()
@@ -679,19 +602,10 @@ Collections. emptyList(), Collections. emptyList(),
public void testShouldReturnGitIgnoreFiles()
throws Exception
{
- File sourceDirectory = new File( getBasedir(), "/target/sourceTestGitIgnoreFile" );
- FileUtils.forceDelete( sourceDirectory );
-
- createTestDataStructure( sourceDirectory );
+ createTestDataStructure();
File outputDirectory = new File( getBasedir(), "/target/testGitIgnoreFile" );
- File baseDir = new File( "c:\\foo\\bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
List resources = new ArrayList<>();
resources.add( new Resource()
@@ -709,11 +623,11 @@ Collections. emptyList(), Collections. emptyList(),
mavenResourcesExecution.setAddDefaultExcludes( false );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
- File[] childs = outputDirectory.listFiles();
- assertNotNull( childs );
- assertEquals( 3, childs.length );
+ File[] children = outputDirectory.listFiles();
+ assertNotNull( children );
+ assertEquals( 3, children.length );
- for ( File file : childs )
+ for ( File file : children )
{
if ( file.getName().endsWith( "dir1" ) || file.getName().endsWith( "empty-directory" )
|| file.getName().endsWith( "empty-directory-child" ) )
@@ -740,30 +654,33 @@ Collections. emptyList(), Collections. emptyList(),
}
else
{
- fail( "unknow child file found " + file.getName() );
+ fail( "unknown child file found " + file.getName() );
}
}
}
/**
- * The folder and file structure will be created instead of letting this resource plugin copying the structure which
- * will not work.
- *
- * @param sourceDirectory The source folder where the structure will be created.
- * @throws IOException
+ * The folder and file structure will be created instead of letting this resource plugin
+ * copy the structure which does not work.
*/
- private void createTestDataStructure( File sourceDirectory )
+ private static void createTestDataStructure()
throws IOException
{
+ File sourceDirectory = new File( getBasedir(), "/target/sourceTestGitIgnoreFile" );
+ if ( sourceDirectory.exists() )
+ {
+ FileUtils.forceDelete( sourceDirectory );
+ }
+
File dir1 = new File( sourceDirectory, "dir1" );
dir1.mkdirs();
- FileUtils.fileWrite( new File( dir1, "foo.txt" ), "UTF-8", "This is a Test File" );
+ FileUtils.write( new File( dir1, "foo.txt" ), "This is a Test File", "UTF-8" );
File emptyDirectory = new File( sourceDirectory, "empty-directory" );
emptyDirectory.mkdirs();
- FileUtils.fileWrite( new File( emptyDirectory, ".gitignore" ), "UTF-8", "# .gitignore file" );
+ FileUtils.write( new File( emptyDirectory, ".gitignore" ), "# .gitignore file", "UTF-8" );
File emptyDirectoryChild = new File( sourceDirectory, "empty-directory-child" );
emptyDirectory.mkdirs();
@@ -771,7 +688,7 @@ private void createTestDataStructure( File sourceDirectory )
File emptyDirectoryChildEmptyChild = new File( emptyDirectoryChild, "empty-child" );
emptyDirectoryChildEmptyChild.mkdirs();
- FileUtils.fileWrite( new File( emptyDirectoryChildEmptyChild, ".gitignore" ), "UTF-8", "# .gitignore file" );
+ FileUtils.write( new File( emptyDirectoryChildEmptyChild, ".gitignore" ), "# .gitignore file", "UTF-8" );
}
/**
@@ -781,16 +698,11 @@ private void createTestDataStructure( File sourceDirectory )
public void testMSHARED81()
throws Exception
{
- StubMavenProject mavenProject = new StubMavenProject( new File( "/foo/bar" ) );
-
- mavenProject.setVersion( "1.0" );
-
mavenProject.addProperty( "escaped", "this is escaped" );
mavenProject.addProperty( "escaped.at", "this is escaped.at" );
mavenProject.addProperty( "foo", "this is foo" );
mavenProject.addProperty( "bar", "this is bar" );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
List resources = new ArrayList<>();
resources.add( new Resource()
@@ -842,13 +754,9 @@ public void testMSHARED81()
// public void testCorrectlyEscapesEscapeString()
// throws Exception
// {
-// StubMavenProject mavenProject = new StubMavenProject( new File( "/foo/bar" ) );
-//
-// mavenProject.setVersion( "1.0" );
// mavenProject.addProperty( "a", "DONE_A" );
//
-// MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
-//
+////
// List resources = new ArrayList();
// resources.add( new Resource()
// {
@@ -884,17 +792,12 @@ public void testMSHARED81()
public void testEdgeCases()
throws Exception
{
- StubMavenProject mavenProject = new StubMavenProject( new File( "/foo/bar" ) );
-
- mavenProject.setVersion( "1.0" );
-
mavenProject.addProperty( "escaped", "this is escaped" );
mavenProject.addProperty( "escaped.at", "this is escaped.at" );
mavenProject.addProperty( "foo", "this is foo" );
mavenProject.addProperty( "bar", "this is bar" );
mavenProject.addProperty( "domain", "this.is.domain.com" );
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
List resources = new ArrayList<>();
resources.add( new Resource()
@@ -945,14 +848,6 @@ public void testFilterFileName()
throws Exception
{
- File baseDir = new File( "/foo/bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
-
String unitFilesDir = getBasedir() + "/src/test/units-files/maven-filename-filtering";
Resource resource = new Resource();
@@ -981,13 +876,6 @@ Collections. emptyList(), Collections. emptyList(),
public void testFilterPropertiesFiles()
throws Exception
{
- File baseDir = new File( "/foo/bar" );
- StubMavenProject mavenProject = new StubMavenProject( baseDir );
- mavenProject.setVersion( "1.0" );
- mavenProject.setGroupId( "org.apache" );
- mavenProject.setName( "test project" );
-
- MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class );
String unitFilesDir = getBasedir() + "/src/test/units-files/MRESOURCES-171";
@@ -1012,19 +900,17 @@ Collections. emptyList(), Collections. emptyList(),
public void testGetEncoding()
{
- String ISO88591 = "ISO-8859-1";
- String UTF8 = "UTF-8";
File propertiesFile = new File( "file.properties" );
File regularFile = new File( "file.xml" );
// Properties files
assertEquals( null, DefaultMavenResourcesFiltering.getEncoding( propertiesFile, null, null ) );
- assertEquals( UTF8, DefaultMavenResourcesFiltering.getEncoding( propertiesFile, "UTF-8", null ) );
- assertEquals( ISO88591, DefaultMavenResourcesFiltering.getEncoding( propertiesFile, "UTF-8", ISO88591 ) );
+ assertEquals( "UTF-8", DefaultMavenResourcesFiltering.getEncoding( propertiesFile, "UTF-8", null ) );
+ assertEquals( "ISO-8859-1", DefaultMavenResourcesFiltering.getEncoding( propertiesFile, "UTF-8", "ISO-8859-1" ) );
// Regular files
assertEquals( null, DefaultMavenResourcesFiltering.getEncoding( regularFile, null, null ) );
- assertEquals( UTF8, DefaultMavenResourcesFiltering.getEncoding( regularFile, "UTF-8", null ) );
- assertEquals( UTF8, DefaultMavenResourcesFiltering.getEncoding( regularFile, "UTF-8", ISO88591 ) );
+ assertEquals( "UTF-8", DefaultMavenResourcesFiltering.getEncoding( regularFile, "UTF-8", null ) );
+ assertEquals( "UTF-8", DefaultMavenResourcesFiltering.getEncoding( regularFile, "UTF-8", "ISO-8859-1" ) );
}
public void testIsPropertiesFile()
diff --git a/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java b/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java
index d755f6c..7d0b426 100644
--- a/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java
@@ -20,16 +20,14 @@
*/
import java.io.File;
-import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
-import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.model.Resource;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.PlexusTestCase;
/**
@@ -50,7 +48,7 @@ protected void setUp()
super.setUp();
if ( outputDirectory.exists() )
{
- FileUtils.forceDelete( outputDirectory );
+ FileUtils.deleteDirectory( outputDirectory );
}
outputDirectory.mkdirs();
}
@@ -90,11 +88,9 @@ public void testEscape()
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
- try ( FileInputStream in = new FileInputStream( new File( outputDirectory, "content.xml" ) ) )
- {
- String content = IOUtils.toString( in, StandardCharsets.UTF_8 );
- assertTrue( content.contains( "Content with replacement: I am the replacement !" ) );
- assertTrue( content.contains( "Content with escaped replacement: Do not ${replaceThis} !" ) );
- }
+ File file = new File( outputDirectory, "content.xml" );
+ String content = FileUtils.readFileToString( file, StandardCharsets.UTF_8 );
+ assertTrue( content.contains( "Content with replacement: I am the replacement !" ) );
+ assertTrue( content.contains( "Content with escaped replacement: Do not ${replaceThis} !" ) );
}
}
diff --git a/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java b/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java
index 2234dc5..0353ec5 100644
--- a/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java
@@ -30,8 +30,8 @@
import java.util.Properties;
import java.util.Set;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.model.Resource;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.PlexusTestCase;
import org.sonatype.plexus.build.incremental.ThreadBuildContext;
import org.sonatype.plexus.build.incremental.test.TestIncrementalBuildContext;
@@ -51,7 +51,7 @@ protected void setUp()
super.setUp();
if ( outputDirectory.exists() )
{
- FileUtils.forceDelete( outputDirectory );
+ FileUtils.deleteDirectory( outputDirectory );
}
outputDirectory.mkdirs();
}
diff --git a/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java b/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java
index 0fd9042..324e94c 100644
--- a/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java
@@ -22,8 +22,8 @@
import java.io.File;
import java.util.Collections;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.model.Resource;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.PlexusTestCase;
/**
@@ -41,7 +41,7 @@ protected void setUp()
super.setUp();
if ( outputDirectory.exists() )
{
- FileUtils.forceDelete( outputDirectory );
+ FileUtils.deleteDirectory( outputDirectory );
}
outputDirectory.mkdirs();
}
diff --git a/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java b/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java
index 32a6b66..c3eef47 100644
--- a/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java
@@ -26,8 +26,8 @@
import java.util.List;
import java.util.Properties;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.model.Resource;
-import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.PlexusTestCase;
/**
@@ -47,7 +47,7 @@ protected void setUp()
super.setUp();
if ( outputDirectory.exists() )
{
- FileUtils.forceDelete( outputDirectory );
+ FileUtils.deleteDirectory( outputDirectory );
}
outputDirectory.mkdirs();
}
diff --git a/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java b/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java
index 3e3c66e..42062a8 100644
--- a/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java
@@ -30,9 +30,9 @@
import java.util.Collections;
import java.util.HashSet;
+import org.apache.commons.io.IOUtils;
import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.RecursionInterceptor;
-import org.codehaus.plexus.util.IOUtil;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -102,7 +102,7 @@ public void testLineWithSingleAtAndExpression()
new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true );
reader.setDelimiterSpecs( new HashSet<>( Arrays.asList( "${*}", "@" ) ) );
- assertEquals( "toto@titi.com bar", IOUtil.toString( reader ) );
+ assertEquals( "toto@titi.com bar", IOUtils.toString( reader ) );
}
// http://stackoverflow.com/questions/21786805/maven-war-plugin-customize-filter-delimitters-in-webresources/
@@ -120,6 +120,6 @@ public void testAtDollarExpression()
reader.setEscapeString( "\\" );
reader.setDelimiterSpecs( new HashSet<>( Arrays.asList( "${*}", "@" ) ) );
- assertEquals( " url=\"jdbc:oracle:thin:@DB_SERVER:DB_PORT:DB_NAME\"", IOUtil.toString( reader ) );
+ assertEquals( " url=\"jdbc:oracle:thin:@DB_SERVER:DB_PORT:DB_NAME\"", IOUtils.toString( reader ) );
}
}