use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testInstallFileWithClassifier.
public void testInstallFileWithClassifier() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-with-classifier/plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
assertNotNull(mojo);
setVariableValueToObject(mojo, "session", createMavenSession());
assignValuesForParameter(mojo);
assertNotNull(classifier);
mojo.execute();
File pomFile = (File) getVariableValueFromObject(mojo, "pomFile");
org.codehaus.plexus.util.FileUtils.forceDelete(pomFile);
File installedArtifact = new File(getBasedir(), LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "-" + classifier + "." + packaging);
assertTrue(installedArtifact.exists());
assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
use of org.apache.maven.plugins.install.InstallFileMojo in project maven-plugins by apache.
the class InstallFileMojoTest method testInstallFileWithChecksum.
public void testInstallFileWithChecksum() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + "plugin-config.xml");
InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom);
assertNotNull(mojo);
setVariableValueToObject(mojo, "session", createMavenSession());
assignValuesForParameter(mojo);
boolean createChecksum = (Boolean) getVariableValueFromObject(mojo, "createChecksum");
assertTrue(createChecksum);
mojo.execute();
String localPath = getBasedir() + "/" + LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version;
File installedArtifact = new File(localPath + "." + "jar");
//get the actual checksum of the artifact
Map<String, Object> csums = ChecksumUtils.calc(file, Utils.CHECKSUM_ALGORITHMS);
for (Map.Entry<String, Object> csum : csums.entrySet()) {
Object actualSum = csum.getValue();
File sum = new File(localPath + ".jar." + csum.getKey().toLowerCase().replace("-", ""));
assertTrue(sum.exists());
String generatedSum = FileUtils.fileRead(sum, "UTF-8");
assertEquals(actualSum, generatedSum);
}
assertTrue(installedArtifact.exists());
assertEquals(9, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size());
}
Aggregations