loadProperties(props, new FileInputStream(new File(this.destDir, "subdir1/one.properties")));
assert "1".equals(props.getProperty("one")) : "did not deploy bundle correctly 1";
loadProperties(props, new FileInputStream(new File(this.destDir, "subdir2/two.properties")));
assert "2".equals(props.getProperty("two")) : "did not deploy bundle correctly 2";
DeploymentsMetadata metadata = new DeploymentsMetadata(this.destDir);
assert metadata.isManaged() == true : "missing metadata directory";
assert metadata.getCurrentDeploymentProperties().getManageRootDir() == false : "should not be managing root dir";
// make sure our unmanaged files/directories weren't removed
props.clear();
loadProperties(props, new FileInputStream(new File(this.destDir, "external1.properties")));
assert "1".equals(props.getProperty("external1")) : "bundle deployment removed our unmanaged file 1";
loadProperties(props, new FileInputStream(new File(this.destDir, "extdir/external2.properties")));
assert "2".equals(props.getProperty("external2")) : "bundle deployment removed our unmanaged file 2";
// make sure that extra file that was underneath the dest dir was removed
assert !extraSubdirFile.exists() : "the extra file in subdir1 was not removed during initial deploy";
// now purge the bundle - this should only purge those files that were laid down by the bundle plus the metadata directory
BundlePurgeRequest purgeRequest = new BundlePurgeRequest();
purgeRequest.setLiveResourceDeployment(createNewBundleDeployment(deployment));
purgeRequest.setBundleManagerProvider(new MockBundleManagerProvider());
purgeRequest.setAbsoluteDestinationDirectory(this.destDir);
BundlePurgeResult purgeResults = plugin.purgeBundle(purgeRequest);
assertResultsSuccess(purgeResults);
// make sure our bundle files have been completely purged; the metadata directory should have been purged too
assert new File(this.destDir, "zero.properties").exists() == false;
assert new File(this.destDir, "subdir1/one.properties").exists() == false;
assert new File(this.destDir, "subdir2/two.properties").exists() == false;
assert new File(this.destDir, "subdir1").exists() == false;
assert new File(this.destDir, "subdir2").exists() == false;
assert this.destDir.exists() == true : "deploy dir should still exist, we were told not to fully manage it";
metadata = new DeploymentsMetadata(this.destDir);
assert metadata.getMetadataDirectory().exists() == false : "metadata directory should not exist";
// make sure our external, unmanaged files still exist - the purge should not have deleted these
props.clear();
loadProperties(props, new FileInputStream(new File(this.destDir, "external1.properties")));
assert "1".equals(props.getProperty("external1")) : "bundle purge removed our unmanaged file 1";