use of org.apache.maven.plugins.clean.CleanMojo in project maven-plugins by apache.
the class CleanMojoTest method testCleanEmptyDirectories.
/**
* Tests that no exception is thrown when all internal variables are empty and that it doesn't
* just remove whats there
*
* @throws Exception
*/
public void testCleanEmptyDirectories() throws Exception {
String pluginPom = getBasedir() + "/src/test/resources/unit/empty-clean-test/plugin-pom.xml";
// safety
FileUtils.copyDirectory(new File(getBasedir(), "src/test/resources/unit/empty-clean-test"), new File(getBasedir(), "target/test-classes/unit/empty-clean-test"), null, "**/.svn,**/.svn/**");
CleanMojo mojo = (CleanMojo) lookupEmptyMojo("clean", pluginPom);
assertNotNull(mojo);
mojo.execute();
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/empty-clean-test/testDirectoryStructure"));
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/empty-clean-test/" + "testDirectoryStructure/file.txt"));
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/empty-clean-test/" + "testDirectoryStructure/outputDirectory"));
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/empty-clean-test/" + "testDirectoryStructure/outputDirectory/file.txt"));
}
use of org.apache.maven.plugins.clean.CleanMojo in project maven-plugins by apache.
the class CleanMojoTest method testCleanNestedStructure.
/**
* Tests the removal of files and nested directories
*
* @throws Exception
*/
public void testCleanNestedStructure() throws Exception {
String pluginPom = getBasedir() + "/src/test/resources/unit/nested-clean-test/plugin-pom.xml";
// safety
FileUtils.copyDirectory(new File(getBasedir(), "src/test/resources/unit/nested-clean-test"), new File(getBasedir(), "target/test-classes/unit/nested-clean-test"), null, "**/.svn,**/.svn/**");
CleanMojo mojo = (CleanMojo) lookupMojo("clean", pluginPom);
assertNotNull(mojo);
mojo.execute();
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/nested-clean-test/target"));
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/nested-clean-test/target/classes"));
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/nested-clean-test/target/test-classes"));
}
use of org.apache.maven.plugins.clean.CleanMojo in project maven-plugins by apache.
the class CleanMojoTest method testCleanInvalidDirectory.
/**
* Tests the removal of a directory as file
*
* @throws Exception
*/
public void testCleanInvalidDirectory() throws Exception {
String pluginPom = getBasedir() + "/src/test/resources/unit/invalid-directory-test/plugin-pom.xml";
// safety
FileUtils.copyDirectory(new File(getBasedir(), "src/test/resources/unit/invalid-directory-test"), new File(getBasedir(), "target/test-classes/unit/invalid-directory-test"), null, "**/.svn,**/.svn/**");
CleanMojo mojo = (CleanMojo) lookupMojo("clean", pluginPom);
assertNotNull(mojo);
try {
mojo.execute();
fail("Should fail to delete a file treated as a directory");
} catch (MojoExecutionException expected) {
assertTrue(true);
}
}
use of org.apache.maven.plugins.clean.CleanMojo in project maven-plugins by apache.
the class CleanMojoTest method testBasicClean.
/**
* Tests the simple removal of directories
*
* @throws Exception
*/
public void testBasicClean() throws Exception {
String pluginPom = getBasedir() + "/src/test/resources/unit/basic-clean-test/plugin-pom.xml";
// safety
FileUtils.copyDirectory(new File(getBasedir(), "src/test/resources/unit/basic-clean-test"), new File(getBasedir(), "target/test-classes/unit/basic-clean-test"), null, "**/.svn,**/.svn/**");
CleanMojo mojo = (CleanMojo) lookupMojo("clean", pluginPom);
assertNotNull(mojo);
mojo.execute();
assertFalse("Directory exists", checkExists(getBasedir() + "/target/test-classes/unit/" + "basic-clean-test/buildDirectory"));
assertFalse("Directory exists", checkExists(getBasedir() + "/target/test-classes/unit/basic-clean-test/" + "buildOutputDirectory"));
assertFalse("Directory exists", checkExists(getBasedir() + "/target/test-classes/unit/basic-clean-test/" + "buildTestDirectory"));
}
use of org.apache.maven.plugins.clean.CleanMojo in project maven-plugins by apache.
the class CleanMojoTest method testFilesetsClean.
/**
* Tests the removal of files using fileset
*
* @throws Exception
*/
public void testFilesetsClean() throws Exception {
String pluginPom = getBasedir() + "/src/test/resources/unit/fileset-clean-test/plugin-pom.xml";
// safety
FileUtils.copyDirectory(new File(getBasedir(), "src/test/resources/unit/fileset-clean-test"), new File(getBasedir(), "target/test-classes/unit/fileset-clean-test"), null, "**/.svn,**/.svn/**");
CleanMojo mojo = (CleanMojo) lookupMojo("clean", pluginPom);
assertNotNull(mojo);
mojo.execute();
// fileset 1
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target"));
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/classes"));
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/test-classes"));
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/subdir"));
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/classes/file.txt"));
assertTrue(checkEmpty(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/classes"));
assertFalse(checkEmpty(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/subdir"));
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/target/subdir/file.txt"));
// fileset 2
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/" + "buildOutputDirectory"));
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/fileset-clean-test/" + "buildOutputDirectory/file.txt"));
}
Aggregations