}
}
public void testInitialDeploymentGlossesOverSymlinksInParents() throws Exception {
//java7 API, but we're in tests, and require java7 to build anyway
Path root = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".symlink-root", null).toPath();
Path symlinkTarget = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".symlink-target", null)
.toPath();
File src = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".src", null);
Path parent = root.resolve("parent");
parent.toFile().mkdirs();
try {
File destination = null;
try {
destination = Files.createSymbolicLink(parent.resolve("destination"), symlinkTarget).toFile();
} catch (UnsupportedOperationException e) {
LOG.info("Skipping testInitialDeploymentGlossesOverSymlinksInParents. The current filesystem doesn't support symlinks");
return;
}
// put some source files in our tmpDirSrc location
File testRawFileA = new File(src, "updater-testA.txt");
File testRawFileA2 = new File(src, "updater-testA2.txt");
File testRawFileB = new File(src, "updater-testB.txt");
File testRawFileADest = new File(destination, "../realDest/rawA.txt");
File testRawFileA2Dest = new File(destination, "../realDest/rawA2.txt");
File testRawFileBDest = new File(destination, "../../realDest/rawB.txt");
FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA);
FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA2);
FileUtil.copyFile(new File("target/test-classes/updater-testB.txt"), testRawFileB);
DeploymentProperties deploymentProps = new DeploymentProperties(0, "testbundle", "1.0.test", null,
DestinationComplianceMode.full);
HashMap<File, File> zipFiles = null;
Map<File, File> rawFiles = new HashMap<File, File>(3);
rawFiles.put(testRawFileA, testRawFileADest);
rawFiles.put(testRawFileA2, testRawFileA2Dest);
rawFiles.put(testRawFileB, testRawFileBDest);
DeploymentData dd = new DeploymentData(deploymentProps, src, destination, rawFiles, null, zipFiles, null,
templateEngine, null, null);
Deployer deployer = new Deployer(dd);
DeployDifferences diff = new DeployDifferences();
FileHashcodeMap map = deployer.deploy(diff);
System.out.println("map-->\n" + map);
System.out.println("diff->\n" + diff);
assert map.size() == 3 : map;
assert parent.resolve("realDest/rawA.txt").toFile().exists() : "rawA.txt not deployed correctly";
assert parent.resolve("realDest/rawA2.txt").toFile().exists() : "rawA2.txt not deployed correctly";
assert root.resolve("realDest/rawB.txt").toFile().exists() : "rawB.txt not deployed correctly";
//the symlink target, being the destination of the deployment should have the .rhqdeployments directory
//specified. No other files should exist there though.
assert symlinkTarget.resolve(".rhqdeployments").toFile().exists() : "Could not find .rhqdeployments on the expected location";