Fixed test to create the folder/file structure instead of
copying the structure by using the resource plugin which
will not work with dot files.
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1738863 13f79535-47bb-0310-9956-ffa450edef68
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 31662e7..edce207 100644
--- a/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
+++ b/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
@@ -129,7 +129,7 @@
mre.setEncoding( "UTF-8" );
mre.setMavenProject( mavenProject );
mre.setFilters( filtersFile );
- mre.setNonFilteredFileExtensions( Collections.<String>emptyList() );
+ mre.setNonFilteredFileExtensions( Collections.<String> emptyList() );
mre.setMavenSession( session );
mre.setUseDefaultFilterWrappers( true );
@@ -374,7 +374,7 @@
mre.setEncoding( "UTF-8" );
mre.setMavenProject( mavenProject );
mre.setFilters( null );
- mre.setNonFilteredFileExtensions( Collections.<String>emptyList() );
+ mre.setNonFilteredFileExtensions( Collections.<String> emptyList() );
mre.setMavenSession( new StubMavenSession() );
mavenResourcesFiltering.filterResources( mre );
@@ -459,7 +459,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String>emptyList(), new StubMavenSession() );
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = outputDirectory.listFiles();
@@ -495,7 +495,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String>emptyList(), new StubMavenSession() );
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = outputDirectory.listFiles();
@@ -536,7 +536,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String>emptyList(), new StubMavenSession() );
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = outputDirectory.listFiles();
@@ -592,7 +592,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String>emptyList(), new StubMavenSession() );
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File[] files = targetPathFile.listFiles();
@@ -626,7 +626,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile,
- Collections.<String>emptyList(), new StubMavenSession() );
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
File targetPathFile = new File( outputDirectory, "testTargetPath" );
@@ -657,7 +657,7 @@
} );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8",
- Collections.<String>emptyList(), Collections.<String>emptyList(),
+ Collections.<String> emptyList(), Collections.<String> emptyList(),
new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
@@ -697,7 +697,12 @@
public void testShouldReturnGitIgnoreFiles()
throws Exception
{
- File outputDirectory = new File( getBasedir(), "target/testGitIgnoreFile" );
+ File sourceDirectory = new File( getBasedir(), "/target/sourceTestGitIgnoreFile" );
+ FileUtils.forceDelete( sourceDirectory );
+
+ createTestDataStructure( sourceDirectory );
+
+ File outputDirectory = new File( getBasedir(), "/target/testGitIgnoreFile" );
File baseDir = new File( "c:\\foo\\bar" );
StubMavenProject mavenProject = new StubMavenProject( baseDir );
mavenProject.setVersion( "1.0" );
@@ -710,13 +715,13 @@
resources.add( new Resource()
{
{
- setDirectory( getBasedir() + "/src/test/units-files/include-git-files" );
+ setDirectory( getBasedir() + "/target/sourceTestGitIgnoreFile" );
setIncludes( Arrays.asList( "**/*" ) );
}
} );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8",
- Collections.<String>emptyList(), Collections.<String>emptyList(),
+ Collections.<String> emptyList(), Collections.<String> emptyList(),
new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setAddDefaultExcludes( false );
@@ -740,14 +745,14 @@
{
assertEquals( 1, file.list().length );
- assertTrue ( file.listFiles()[0].getName().endsWith( ".gitignore" ) );
+ assertTrue( file.listFiles()[0].getName().endsWith( ".gitignore" ) );
}
if ( file.getName().endsWith( "empty-directory-child" ) )
{
assertEquals( 1, file.list().length );
assertTrue( file.listFiles()[0].isDirectory() );
assertEquals( 1, file.listFiles()[0].listFiles().length );
-
+
assertTrue( file.listFiles()[0].listFiles()[0].getName().endsWith( ".gitignore" ) );
}
}
@@ -759,6 +764,35 @@
}
/**
+ * 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
+ */
+ private void createTestDataStructure( File sourceDirectory )
+ throws IOException
+ {
+ File dir1 = new File( sourceDirectory, "dir1" );
+
+ dir1.mkdirs();
+ FileUtils.fileWrite( new File( dir1, "foo.txt" ), "UTF-8", "This is a Test File" );
+
+ File emptyDirectory = new File( sourceDirectory, "empty-directory" );
+ emptyDirectory.mkdirs();
+
+ FileUtils.fileWrite( new File( emptyDirectory, ".gitignore" ), "UTF-8", "# .gitignore file" );
+
+ File emptyDirectoryChild = new File( sourceDirectory, "empty-directory-child" );
+ emptyDirectory.mkdirs();
+
+ File emptyDirectoryChildEmptyChild = new File( emptyDirectoryChild, "empty-child" );
+ emptyDirectoryChildEmptyChild.mkdirs();
+
+ FileUtils.fileWrite( new File( emptyDirectoryChildEmptyChild, ".gitignore" ), "UTF-8", "# .gitignore file" );
+ }
+
+ /**
* unit test for MSHARED-81 : https://issues.apache.org/jira/browse/MSHARED-81
*/
public void testMSHARED81()
@@ -792,8 +826,8 @@
} );
File output = new File( outputDirectory, "MSHARED-81" );
MavenResourcesExecution mavenResourcesExecution =
- new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.<String>emptyList(),
- Collections.<String>emptyList(), new StubMavenSession() );
+ new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.<String> emptyList(),
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setEscapeString( "\\" );
@@ -854,8 +888,8 @@
} );
File output = new File( outputDirectory, "edge-cases" );
MavenResourcesExecution mavenResourcesExecution =
- new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.<String>emptyList(),
- Collections.<String>emptyList(), new StubMavenSession() );
+ new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.<String> emptyList(),
+ Collections.<String> emptyList(), new StubMavenSession() );
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setEscapeString( "\\" );
@@ -904,7 +938,7 @@
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( Collections.singletonList( resource ), outputDirectory, mavenProject, "UTF-8",
- Collections.<String>emptyList(), Collections.<String>emptyList(),
+ Collections.<String> emptyList(), Collections.<String> emptyList(),
new StubMavenSession() );
mavenResourcesExecution.setFilterFilenames( true );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
diff --git a/src/test/units-files/include-git-files/dir1/foo.txt b/src/test/units-files/include-git-files/dir1/foo.txt
deleted file mode 100644
index 4ae1a11..0000000
--- a/src/test/units-files/include-git-files/dir1/foo.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-foo.
\ No newline at end of file
diff --git a/src/test/units-files/include-git-files/empty-directory-child/empty-child/.gitignore b/src/test/units-files/include-git-files/empty-directory-child/empty-child/.gitignore
deleted file mode 100644
index 695fc81..0000000
--- a/src/test/units-files/include-git-files/empty-directory-child/empty-child/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-# just here to make the directory non-empty
diff --git a/src/test/units-files/include-git-files/empty-directory/.gitignore b/src/test/units-files/include-git-files/empty-directory/.gitignore
deleted file mode 100644
index 695fc81..0000000
--- a/src/test/units-files/include-git-files/empty-directory/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-# just here to make the directory non-empty