use of org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub in project maven-plugins by apache.
the class DeployMojoTest method _testBasicDeployWithScpAsProtocol.
@Ignore("SCP is not part of Maven3 distribution. Aether handles transport extensions.")
public void _testBasicDeployWithScpAsProtocol() throws Exception {
String originalUserHome = System.getProperty("user.home");
// FIX THE DAMN user.home BEFORE YOU DELETE IT!!!
File altHome = new File(getBasedir(), "target/ssh-user-home");
altHome.mkdirs();
System.out.println("Testing user.home value for .ssh dir: " + altHome.getCanonicalPath());
Properties props = System.getProperties();
props.setProperty("user.home", altHome.getCanonicalPath());
System.setProperties(props);
File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-scp/plugin-config.xml");
mojo = (DeployMojo) lookupMojo("deploy", testPom);
assertNotNull(mojo);
ArtifactDeployerStub deployer = new ArtifactDeployerStub();
setVariableValueToObject(mojo, "deployer", deployer);
File file = new File(getBasedir(), "target/test-classes/unit/basic-deploy-scp/target/" + "deploy-test-file-1.0-SNAPSHOT.jar");
assertTrue(file.exists());
MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project");
setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project));
artifact = (DeployArtifactStub) project.getArtifact();
artifact.setFile(file);
String altUserHome = System.getProperty("user.home");
if (altUserHome.equals(originalUserHome)) {
// this is *very* bad!
throw new IllegalStateException("Setting 'user.home' system property to alternate value did NOT work. Aborting test.");
}
File sshFile = new File(altUserHome, ".ssh");
System.out.println("Testing .ssh dir: " + sshFile.getCanonicalPath());
//delete first the .ssh folder if existing before executing the mojo
if (sshFile.exists()) {
FileUtils.deleteDirectory(sshFile);
}
mojo.execute();
assertTrue(sshFile.exists());
FileUtils.deleteDirectory(sshFile);
}
Aggregations