Commit 8ee8ff1e authored by Daniel Bluhm's avatar Daniel Bluhm

Increase coverage by hitting IOException cases

Now at 98% coverage
Signed-off-by: Daniel Bluhm's avatarDaniel Bluhm <bluhmdj@ornl.gov>
parent c8b992dc
......@@ -99,6 +99,14 @@ public class DependencyScraper extends AbstractMojo {
*/
private Set<File> jarFiles;
/**
* Setter for outputDirectory.
* @param outputDirectory to set.
*/
public void setOutputDirectory(File outputDirectory) {
this.outputDirectory = outputDirectory;
}
/**
* Setter for includes.
* @param includes to set.
......
......@@ -3,6 +3,7 @@ package org.org.eclipse.ice.dev.dependencyscraper;
import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.plugin.MojoFailureException;
import org.junit.After;
import org.junit.Rule;
import static org.junit.Assert.*;
......@@ -190,4 +191,31 @@ public class DependencyScraperTest
assertTrue(OUTPUT.resolve("test.txt").toFile().exists());
assertTrue(OUTPUT.resolve("test.json").toFile().exists());
}
/**
* Test that IOExceptions are handled properly.
* @throws Exception if any
*/
@Test(expected=MojoFailureException.class)
public void testNonExistentJar() throws Exception {
DependencyScraper mojo = getMojo();
mojo.setJarFiles(Set.of(
PROJECT.resolve("non_existent.jar").toFile()
));
mojo.execute();
}
/**
* Test that a destination that already exists is used and it's a directory
* throws an error.
* @throws Exception if any
*/
@Test(expected=MojoFailureException.class)
public void testDestinationExistsAndIsDirectory() throws Exception {
DependencyScraper mojo = getMojo();
mojo.setOutputDirectory(OUTPUT.toFile());
mojo.setClobber(true);
Files.createDirectories(OUTPUT.resolve("test.txt"));
mojo.execute();
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment