modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
| 4
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
| 61 +-
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
| 20
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
| 19
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
| 272 +++++++++-
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
| 156 +++++
modules/common/ant-bundle/src/test/resources/file.zip
|binary
modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties
| 1
modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml
| 21
modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml
| 14
modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
| 134 ++++
modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
| 32 -
modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
| 28 -
modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
| 62 +-
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
| 51 -
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
| 51 -
modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
| 62 +-
17 files changed, 807 insertions(+), 181 deletions(-)
New commits:
commit d31fc63f7d6ea1116ef1884941ed869213fe3600
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Dec 23 03:59:41 2010 -0500
BZ 638730 - ant bundle deployment now supports provisioning archive files in exploded
or compressed form
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
index 4e7d3bf..b7705e1 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/DeployPropertyNames.java
@@ -6,7 +6,7 @@ package org.rhq.bundle.ant;
public class DeployPropertyNames {
/** System property that should always be available to Ant scripts - it's the
location where the deployment should be installed */
public static final String DEPLOY_DIR = "rhq.deploy.dir";
-
+
/** System property that should always be available to Ant scripts - it's the ID
of the bundle deployment */
public static final String DEPLOY_ID = "rhq.deploy.id";
@@ -32,7 +32,7 @@ public class DeployPropertyNames {
* Optional deploy property - if true, this is a dry run or preview (that is, it
should log what steps would occur
* but not actually perform any of the steps); if not specified, the default is
false
*/
- public static final Object DEPLOY_DRY_RUN = "rhq.deploy.dryRun";
+ public static final String DEPLOY_DRY_RUN = "rhq.deploy.dryRun";
private DeployPropertyNames() {
}
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
index cea5df4..44daf4c 100644
---
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
+++
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
@@ -1,21 +1,22 @@
package org.rhq.bundle.ant.type;
-import org.apache.tools.ant.types.DataType;
-import org.rhq.bundle.ant.BundleAntProject;
-
import java.io.File;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.tools.ant.types.DataType;
+
+import org.rhq.bundle.ant.BundleAntProject;
+
/**
*
*/
public abstract class AbstractBundleType extends DataType {
@Override
public BundleAntProject getProject() {
- return (BundleAntProject)super.getProject();
+ return (BundleAntProject) super.getProject();
}
-
+
protected static Pattern getPattern(List<FileSet> fileSets) {
if (fileSets == null || fileSets.isEmpty()) {
return null;
@@ -45,25 +46,7 @@ public abstract class AbstractBundleType extends DataType {
firstIncludePattern = false;
}
regex.append("(");
- for (int i = 0; i < includePattern.length(); i++) {
- char c = includePattern.charAt(i);
- if (c == '?') {
- regex.append('.');
- } else if (c == '*') {
- if (i + 1 < includePattern.length()) {
- char c2 = includePattern.charAt(++i);
- if (c2 == '*') {
- regex.append(".*");
- i++;
- continue;
- }
- }
- regex.append("[^/]*");
- } else {
- regex.append(c);
- }
- // TODO: Escape backslashes.
- }
+ buildIncludePatternRegex(includePattern, regex);
regex.append(")");
}
}
@@ -71,4 +54,34 @@ public abstract class AbstractBundleType extends DataType {
}
return Pattern.compile(regex.toString());
}
+
+ /**
+ * Builds a regex expression for a single include pattern.
+ *
+ * @param includePattern the single include pattern to build a regex for
+ * @param regex appends all regex characters to this regex string
+ */
+ protected static void buildIncludePatternRegex(String includePattern, StringBuilder
regex) {
+ for (int i = 0; i < includePattern.length(); i++) {
+ char c = includePattern.charAt(i);
+ if (c == '?') {
+ regex.append('.');
+ } else if (c == '*') {
+ if (i + 1 < includePattern.length()) {
+ char c2 = includePattern.charAt(i + 1);
+ if (c2 == '*') {
+ regex.append(".*");
+ i += 2;
+ continue;
+ }
+ }
+ regex.append("[^/]*");
+ } else if (c == '.') {
+ regex.append("\\.");
+ } else {
+ regex.append(c);
+ }
+ // TODO: Escape backslashes.
+ }
+ }
}
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
index 19aaaf6..d531801 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/ArchiveType.java
@@ -25,15 +25,18 @@ package org.rhq.bundle.ant.type;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.tools.ant.BuildException;
+
/**
- * An archive file to be exploded during the bundle deployment. Can optionally contain a
rhq:replace child element
- * that specifies the set of files that contain template variables (e.g. @@http.port(a)@)
which need to be replaced with
- * the value of the corresponding property.
+ * An archive file to be exploded during the bundle deployment (it could remain
compressed if exploded="false" is specified)
+ * Can optionally contain a rhq:replace child element that specifies the set of files
that contain
+ * template variables (e.g. @@http.port(a)@) which need to be replaced with the value of
the corresponding property.
*
* @author Ian Springer
*/
public class ArchiveType extends AbstractFileType {
private Pattern replacePattern;
+ private String exploded = Boolean.TRUE.toString();
public void addConfigured(ReplaceType replace) {
List<FileSet> fileSets = replace.getFileSets();
@@ -43,4 +46,15 @@ public class ArchiveType extends AbstractFileType {
public Pattern getReplacePattern() {
return replacePattern;
}
+
+ public String getExploded() {
+ return exploded;
+ }
+
+ public void setExploded(String exploded) {
+ if (!Boolean.TRUE.toString().equalsIgnoreCase(exploded) &&
!Boolean.FALSE.toString().equalsIgnoreCase(exploded)) {
+ throw new BuildException("'exploded' attribute must be
'true' or 'false': " + exploded);
+ }
+ this.exploded = exploded;
+ }
}
\ No newline at end of file
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
index 3727adb..31a52bc 100644
---
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
+++
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/DeploymentUnitType.java
@@ -51,6 +51,7 @@ public class DeploymentUnitType extends AbstractBundleType {
private Map<File, File> files = new LinkedHashMap<File, File>();
private Set<File> rawFilesToReplace = new LinkedHashSet<File>();
private Set<File> archives = new LinkedHashSet<File>();
+ private Map<File, Boolean> archivesExploded = new HashMap<File,
Boolean>();
private Map<File, Pattern> archiveReplacePatterns = new HashMap<File,
Pattern>();
private SystemServiceType systemService;
private Pattern ignorePattern;
@@ -98,8 +99,9 @@ public class DeploymentUnitType extends AbstractBundleType {
Project.MSG_VERBOSE);
}
- DeploymentData deploymentData = new DeploymentData(deploymentProps,
this.archives, this.files, deployDir,
- this.archiveReplacePatterns, this.rawFilesToReplace, templateEngine,
this.ignorePattern, willManageRootDir);
+ DeploymentData deploymentData = new DeploymentData(deploymentProps,
this.archives, this.files, getProject()
+ .getBaseDir(), deployDir, this.archiveReplacePatterns,
this.rawFilesToReplace, templateEngine,
+ this.ignorePattern, willManageRootDir, this.archivesExploded);
Deployer deployer = new Deployer(deploymentData);
try {
DeployDifferences diffs = getProject().getDeployDifferences();
@@ -181,6 +183,17 @@ public class DeploymentUnitType extends AbstractBundleType {
return archives;
}
+ /**
+ * Returns a map keyed on {@link #getArchives() archive names} whose values
+ * are either true or false, where true means the archive is to be deployed exploded
+ * and false means the archive should be deployed in compressed form.
+ *
+ * @return map showing how an archive should be deployed in its final form
+ */
+ public Map<File, Boolean> getArchivesExploded() {
+ return archivesExploded;
+ }
+
public String getPreinstallTarget() {
return preinstallTarget;
}
@@ -231,6 +244,8 @@ public class DeploymentUnitType extends AbstractBundleType {
if (replacePattern != null) {
this.archiveReplacePatterns.put(archive.getSource(), replacePattern);
}
+ Boolean exploded = Boolean.valueOf(archive.getExploded());
+ this.archivesExploded.put(archive.getSource(), exploded);
}
public void addConfigured(IgnoreType ignore) {
diff --git
a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
index a9edfc1..2c41874 100644
--- a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
+++ b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/AntLauncherTest.java
@@ -23,6 +23,7 @@
package org.rhq.bundle.ant;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -30,18 +31,25 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.updater.DeploymentsMetadata;
+import org.rhq.core.util.updater.FileHashcodeMap;
/**
* @author John Mazzitelli
@@ -50,6 +58,14 @@ import org.rhq.core.util.file.FileUtil;
@Test
public class AntLauncherTest {
private static final File DEPLOY_DIR = new
File("target/test-ant-bundle").getAbsoluteFile();
+ private static final String ANT_BASEDIR = "target/test-classes";
+
+ private int deploymentId;
+
+ @BeforeClass
+ public void beforeClass() {
+ deploymentId = 0;
+ }
@AfterClass
public void afterClass() {
@@ -135,17 +151,12 @@ public class AntLauncherTest {
assert new File(DEPLOY_DIR, "subdir/test.properties").exists() :
"missing file";
assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() :
"missing archived bundle file";
+ assert new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties").exists() : "missing
subdir archive file";
assert unrelatedFile.exists() : "unrelated file was removed during the
install";
- }
-
- private List<BuildListener> createBuildListeners() {
- List<BuildListener> buildListeners = new ArrayList<BuildListener>();
- DefaultLogger logger = new DefaultLogger();
- logger.setMessageOutputLevel(Project.MSG_DEBUG);
- logger.setOutputPrintStream(System.out);
- logger.setErrorPrintStream(System.err);
- buildListeners.add(logger);
- return buildListeners;
+ assert readPropsFile(new File(DEPLOY_DIR,
"subdir/test.properties")).getProperty("junk.listener.port").equals(
+ "10000");
+ assert readPropsFile(new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties")).getProperty(
+ "templatized.variable").equals("10000");
}
@Test(dependsOnMethods = "testInstall")
@@ -193,7 +204,12 @@ public class AntLauncherTest {
assert new File(DEPLOY_DIR, "subdir/test.properties").exists() :
"missing file";
assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() :
"missing archived bundle file";
+ assert new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties").exists() : "missing
subdir archive file";
assert !unrelatedFile.exists() : "we are managing root dir so unrelated file
should be removed during upgrade";
+ assert readPropsFile(new File(DEPLOY_DIR,
"subdir/test.properties")).getProperty("junk.listener.port").equals(
+ "20000");
+ assert readPropsFile(new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties")).getProperty(
+ "templatized.variable").equals("20000");
}
public void testUpgradeNoManageRootDir() throws Exception {
@@ -244,25 +260,223 @@ public class AntLauncherTest {
assert new File(DEPLOY_DIR, "subdir/test.properties").exists() :
"missing file";
assert new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() :
"missing archived bundle file";
+ assert new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties").exists() : "missing
subdir archive file";
assert unrelatedFile.exists() : "we are NOT managing root dir so unrelated
file should NOT be removed during upgrade";
+ assert readPropsFile(new File(DEPLOY_DIR,
"subdir/test.properties")).getProperty("junk.listener.port").equals(
+ "20000");
+ assert readPropsFile(new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties")).getProperty(
+ "templatized.variable").equals("20000");
+ }
+
+ public void testInstallCompressedZipNoDryRun() throws Exception {
+ testInstallCompressedZip(false);
+ }
+
+ public void testInstallCompressedZipDryRun() throws Exception {
+ testInstallCompressedZip(true);
+ }
+
+ private void testInstallCompressedZip(boolean dryRun) throws Exception {
+ // We want to test a fresh install, so make sure the deploy dir doesn't
pre-exist.
+ FileUtil.purge(DEPLOY_DIR, true);
+
+ AntLauncher ant = new AntLauncher();
+ Properties inputProps =
createInputProperties("/test-bundle-compressed-archives-input.properties",
dryRun);
+ List<BuildListener> buildListeners = createBuildListeners();
+
+ BundleAntProject project =
ant.executeBundleDeployFile(getBuildXml("test-bundle-compressed-archives.xml"),
+ inputProps, buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
+ assert bundleFiles != null;
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+
+ assert project.getBundleName().equals("test compressed archive
files");
+ assert project.getBundleVersion().equals("1.0");
+ assert project.getBundleDescription() == null;
+
+ // while we are here, let's see that we have 0 config props
+ ConfigurationDefinition configDef = project.getConfigurationDefinition();
+ assert configDef.getPropertyDefinitions().size() == 0 :
configDef.getPropertyDefinitions();
+ Configuration config = project.getConfiguration();
+ assert config.getProperties().size() == 0 : config.getProperties();
+
+ if (!dryRun) {
+ assert new File(DEPLOY_DIR, "file.zip").exists() : "should be
here, we told it to stay compressed";
+ } else {
+ assert !new File(DEPLOY_DIR, "file.zip").exists() : "dry run -
should not be here";
+ }
+
+ assert !new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() :
"should not have exploded this";
+ assert !new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties").exists() : "should
not have exploded this";
+ assert !new File(DEPLOY_DIR, "archived-subdir").isDirectory() :
"should not still have the exploded dir";
+
+ DeploymentsMetadata dm = new DeploymentsMetadata(DEPLOY_DIR);
+ if (!dryRun) {
+ FileHashcodeMap fhm = dm.getCurrentDeploymentFileHashcodes();
+ assert !fhm.containsKey("archived-bundle-file.txt") : "should
not have metadata - this is inside the compressed zip";
+ assert
!fhm.containsKey("archived-subdir/archived-file-in-subdir.properties") :
"should not have metadata - this is inside the compressed zip";
+ assert fhm.containsKey("file.zip") : "should have metadata for
this - we didn't explode it, we just have this compressed file";
+
+ // test that we created the zip OK. Note that our test did not do any file
replacing/realization of templates
+ final String[] templateVarValue = new String[] { null };
+ final Integer[] entries = new Integer[] { 0 };
+ ZipUtil.walkZipFile(new File(DEPLOY_DIR, "file.zip"), new
ZipUtil.ZipEntryVisitor() {
+ @Override
+ public boolean visit(ZipEntry entry, ZipInputStream stream) throws
Exception {
+ if
(entry.getName().equals("archived-subdir/archived-file-in-subdir.properties"))
{
+ Properties props = new Properties();
+ props.load(stream);
+ templateVarValue[0] =
props.getProperty("templatized.variable");
+ }
+ if (!entry.isDirectory()) {
+ entries[0] = Integer.valueOf(entries[0].intValue() + 1);
+ }
+ return true;
+ }
+ });
+ assert templateVarValue[0] != null &&
templateVarValue[0].equals("@@listener.port@(a)") : templateVarValue[0];
+ assert entries[0].intValue() == 2 : entries[0]; // we only counted the file
entries
+ } else {
+ try {
+ dm.getCurrentDeploymentFileHashcodes();
+ assert false : "this was a dry run, we should not have written our
metadata to the filesystem";
+ } catch (Exception e) {
+ // expected
+ }
+ }
+ }
+
+ public void testInstallCompressedZipWithTemplatizedFilesNoDryRun() throws Exception
{
+ testInstallCompressedZipWithTemplatizedFiles(false);
+ }
+
+ public void testInstallCompressedZipWithTemplatizedFilesDryRun() throws Exception {
+ testInstallCompressedZipWithTemplatizedFiles(true);
+ }
+
+ private void testInstallCompressedZipWithTemplatizedFiles(boolean dryRun) throws
Exception {
+ // We want to test a fresh install, so make sure the deploy dir doesn't
pre-exist.
+ FileUtil.purge(DEPLOY_DIR, true);
+
+ AntLauncher ant = new AntLauncher();
+ Properties inputProps =
createInputProperties("/test-bundle-compressed-archives-input.properties",
dryRun);
+ List<BuildListener> buildListeners = createBuildListeners();
+
+ BundleAntProject project = ant.executeBundleDeployFile(
+ getBuildXml("test-bundle-compressed-archives-with-replace.xml"),
inputProps, buildListeners);
+ assert project != null;
+ Set<String> bundleFiles = project.getBundleFileNames();
+ assert bundleFiles != null;
+ assert bundleFiles.size() == 1 : bundleFiles;
+ assert bundleFiles.contains("file.zip") : bundleFiles;
+
+ assert project.getBundleName().equals("test compressed archive
files");
+ assert project.getBundleVersion().equals("1.0");
+ assert project.getBundleDescription() == null;
+
+ // we have one property that we use to realize our content
+ ConfigurationDefinition configDef = project.getConfigurationDefinition();
+ assert configDef.getPropertyDefinitions().size() == 1 :
configDef.getPropertyDefinitions();
+ PropertyDefinitionSimple propDef =
configDef.getPropertyDefinitionSimple("listener.port");
+ assert propDef != null;
+ assert propDef.getType() == PropertySimpleType.INTEGER;
+ assert propDef.getDefaultValue() == null : "recipe didn't define a
default for our property";
+ assert propDef.getDescription() == null : "recipe didn't define a
description for our property";
+ assert propDef.isRequired() : "recipe didn't make the property required,
but the default should be required";
+
+ if (!dryRun) {
+ assert new File(DEPLOY_DIR, "file.zip").exists() : "should be
here, we told it to stay compressed";
+ } else {
+ assert !new File(DEPLOY_DIR, "file.zip").exists() : "this was
a dry run, should not be here";
+ }
+ assert !new File(DEPLOY_DIR, "archived-bundle-file.txt").exists() :
"should not have exploded this";
+ assert !new File(DEPLOY_DIR,
"archived-subdir/archived-file-in-subdir.properties").exists() : "should
not have exploded this";
+ assert !new File(DEPLOY_DIR, "archived-subdir").isDirectory() :
"should not still have the exploded dir";
+
+ DeploymentsMetadata dm = new DeploymentsMetadata(DEPLOY_DIR);
+ if (!dryRun) {
+ FileHashcodeMap fhm = dm.getCurrentDeploymentFileHashcodes();
+ assert !fhm.containsKey("archived-bundle-file.txt") : "should
not have metadata - this is inside the compressed zip";
+ assert
!fhm.containsKey("archived-subdir/archived-file-in-subdir.properties") :
"should not have metadata - this is inside the compressed zip";
+ assert fhm.containsKey("file.zip") : "should have metadata for
this - we didn't explode it, we just have this compressed file";
+
+ // test that the file in the zip is realized
+ final String[] templateVarValue = new String[] { null };
+ final Integer[] entries = new Integer[] { 0 };
+ ZipUtil.walkZipFile(new File(DEPLOY_DIR, "file.zip"), new
ZipUtil.ZipEntryVisitor() {
+ @Override
+ public boolean visit(ZipEntry entry, ZipInputStream stream) throws
Exception {
+ if
(entry.getName().equals("archived-subdir/archived-file-in-subdir.properties"))
{
+ Properties props = new Properties();
+ props.load(stream);
+ templateVarValue[0] =
props.getProperty("templatized.variable");
+ }
+ if (!entry.isDirectory()) {
+ entries[0] = Integer.valueOf(entries[0].intValue() + 1);
+ }
+ return true;
+ }
+ });
+ assert templateVarValue[0] != null &&
templateVarValue[0].equals("12345") : templateVarValue[0];
+ assert entries[0].intValue() == 2 : entries[0]; // we only counted the file
entries
+ } else {
+ try {
+ dm.getCurrentDeploymentFileHashcodes();
+ assert false : "this was a dry run, we should not have written our
metadata to the filesystem";
+ } catch (Exception e) {
+ // expected
+ }
+ }
+ }
+
+ private List<BuildListener> createBuildListeners() {
+ List<BuildListener> buildListeners = new ArrayList<BuildListener>();
+ DefaultLogger logger = new DefaultLogger();
+ logger.setMessageOutputLevel(Project.MSG_DEBUG);
+ logger.setOutputPrintStream(System.out);
+ logger.setErrorPrintStream(System.err);
+ buildListeners.add(logger);
+ return buildListeners;
}
private Properties createInputProperties(String resourcePath) throws IOException {
+ return createInputProperties(resourcePath, false);
+ }
+
+ private Properties createInputProperties(String resourcePath, boolean dryRun) throws
IOException {
Properties inputProps = new Properties();
inputProps.setProperty(DeployPropertyNames.DEPLOY_DIR, DEPLOY_DIR.getPath());
- inputProps.setProperty(DeployPropertyNames.DEPLOY_ID, "100");
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_ID,
String.valueOf(++this.deploymentId));
inputProps.setProperty(DeployPropertyNames.DEPLOY_PHASE,
DeploymentPhase.INSTALL.name());
- InputStream inputStream = this.getClass().getResourceAsStream(resourcePath);
+ if (dryRun) {
+ inputProps.setProperty(DeployPropertyNames.DEPLOY_DRY_RUN,
Boolean.TRUE.toString());
+ }
+ if (resourcePath != null) {
+ InputStream inputStream = this.getClass().getResourceAsStream(resourcePath);
+ try {
+ inputProps.load(inputStream);
+ } finally {
+ inputStream.close();
+ }
+ }
+ return inputProps;
+ }
+
+ private Properties readPropsFile(File propFile) throws Exception {
+ Properties props = new Properties();
+ InputStream inputStream = new FileInputStream(propFile);
try {
- inputProps.load(inputStream);
+ props.load(inputStream);
} finally {
inputStream.close();
}
- return inputProps;
+ return props;
}
private File getBuildXml(String name) throws Exception {
- File file = new File("target/test-classes", name);
+ File file = new File(ANT_BASEDIR, name);
assert file.exists() : "The test Ant build script doesn't exist: "
+ file.getAbsolutePath();
return file;
}
@@ -286,4 +500,32 @@ public class AntLauncherTest {
File destFile = new File(destDir, fileName);
return writeFile(content, destFile);
}
+
+ private File createZip(String[] content, File destDir, String zipName, String[]
entryName) throws Exception {
+ FileOutputStream stream = null;
+ ZipOutputStream out = null;
+
+ try {
+ destDir.mkdirs();
+ File zipFile = new File(destDir, zipName);
+ stream = new FileOutputStream(zipFile);
+ out = new ZipOutputStream(stream);
+
+ assert content.length == entryName.length;
+ for (int i = 0; i < content.length; i++) {
+ ZipEntry zipAdd = new ZipEntry(entryName[i]);
+ zipAdd.setTime(System.currentTimeMillis());
+ out.putNextEntry(zipAdd);
+ out.write(content[i].getBytes());
+ }
+ return zipFile;
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ }
}
diff --git
a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
new file mode 100644
index 0000000..8757540
--- /dev/null
+++
b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
@@ -0,0 +1,156 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.bundle.ant.type;
+
+import java.util.regex.Pattern;
+
+import org.testng.annotations.Test;
+
+@Test
+public class AbstractBundleTypeTest {
+ public void testGetPattern() {
+ Pattern regex;
+
+ regex = assertIncludePatternRegex("easy.txt", "easy\\.txt",
"easy.txt");
+ assert !regex.matcher("easyXtxt").matches() : "should not have
matched, is the . escaped?";
+ assert !regex.matcher("Xeasy.txt").matches();
+ assert !regex.matcher("easy.txtX").matches();
+ assert !regex.matcher("/easy.txt").matches();
+ assert !regex.matcher("easy.txt/").matches();
+
+ regex = assertIncludePatternRegex("another.one/easy.txt",
"another\\.one/easy\\.txt", "another.one/easy.txt");
+ assert !regex.matcher("anotherXone/easyXtxt").matches() : "should
not have matched, is the . escaped?";
+ assert !regex.matcher("another.one/easy.txtX").matches();
+ assert !regex.matcher("another.one/easy.txt/X").matches();
+ assert !regex.matcher("Xanother.one/easy.txt").matches();
+ assert !regex.matcher("X/another.one/easy.txt").matches();
+ assert !regex.matcher("/another.one/easy.txt").matches();
+ assert !regex.matcher("another.one/easy.txt/").matches();
+
+ regex = assertIncludePatternRegex("*.properties",
"[^/]*\\.properties", "any.properties");
+ assert !regex.matcher("anyXproperties").matches() : "should not
have matched, is the . escaped?";
+ assert regex.matcher("with space.properties").matches();
+ assert !regex.matcher("subdir/any.properties").matches();
+ assert !regex.matcher("any.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("a*b.properties",
"a[^/]*b\\.properties", "a123b.properties");
+ assert !regex.matcher("a123bXproperties").matches() : "should not
have matched, is the . escaped?";
+ assert regex.matcher("a b.properties").matches();
+ assert regex.matcher("ab.properties").matches();
+ assert !regex.matcher("subdir/a123b.properties").matches();
+ assert !regex.matcher("a123b.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("/*.properties",
"/[^/]*\\.properties", "/any.properties");
+ assert !regex.matcher("/anyXproperties").matches() : "should not
have matched, is the . escaped?";
+ assert regex.matcher("/with space.properties").matches();
+ assert !regex.matcher("subdir/any.properties").matches();
+ assert !regex.matcher("/any.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("?.properties",
".\\.properties", "a.properties");
+ assert !regex.matcher("aXproperties").matches() : "should not have
matched, is the . escaped?";
+ assert !regex.matcher("ab.properties").matches();
+ assert regex.matcher(" .properties").matches();
+ assert !regex.matcher(".properties").matches();
+ assert !regex.matcher("subdir/a.properties").matches();
+ assert !regex.matcher("a.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("a?b.properties",
"a.b\\.properties", "aNb.properties");
+ assert !regex.matcher("aNbXproperties").matches() : "should not
have matched, is the . escaped?";
+ assert regex.matcher("a b.properties").matches();
+ assert !regex.matcher("ab.properties").matches();
+ assert !regex.matcher("subdir/aNb.properties").matches();
+ assert !regex.matcher("aNb.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("/?.properties",
"/.\\.properties", "/a.properties");
+ assert !regex.matcher("/aXproperties").matches() : "should not
have matched, is the . escaped?";
+ assert !regex.matcher("/ab.properties").matches();
+ assert regex.matcher("/ .properties").matches();
+ assert !regex.matcher("/.properties").matches();
+ assert !regex.matcher("subdir/a.properties").matches();
+ assert !regex.matcher("/a.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("file*.xml",
"file[^/]*\\.xml", "fileANY.xml");
+ assert !regex.matcher("fileANYXxml").matches() : "should not have
matched, is the . escaped?";
+ assert regex.matcher("fileWITH SPACE.xml").matches();
+ assert !regex.matcher("subdir/fileANY.xml").matches();
+ assert !regex.matcher("fileANY.xml/foo").matches();
+ assert regex.matcher("file.xml").matches();
+
+ regex = assertIncludePatternRegex("*/*.properties",
"[^/]*/[^/]*\\.properties", "aaa/bbb.properties");
+ assert !regex.matcher("aaa/bbbXproperties").matches() : "should
not have matched, is the . escaped?";
+ assert !regex.matcher("bbb.properties").matches();
+ assert regex.matcher("subdir1/abc.properties").matches();
+ assert !regex.matcher("subdir2/subdir1/abc.properties").matches();
+ assert !regex.matcher("subdir1/abc.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("*/*/*.properties",
"[^/]*/[^/]*/[^/]*\\.properties",
+ "aaa/bbb/ccc.properties");
+ assert !regex.matcher("aaa/bbb/cccXproperties").matches() :
"should not have matched, is the . escaped?";
+ assert !regex.matcher("ccc.properties").matches();
+ assert !regex.matcher("bbb/ccc.properties").matches();
+ assert !regex.matcher("toomany/aaa/bbb/ccc.properties").matches();
+ assert !regex.matcher("aaa/bbb/ccc.properties/foo").matches();
+
+ // ** = any level, including root level
+ regex = assertIncludePatternRegex("**/*.properties",
".*[^/]*\\.properties", "aaa/bbb/ccc.properties");
+ assert !regex.matcher("aaa/bbb/cccXproperties").matches() :
"should not have matched, is the . escaped?";
+ assert regex.matcher("bbb.properties").matches();
+ assert regex.matcher("subdir1/abc.properties").matches();
+ assert regex.matcher("subdir2/subdir1/abc.properties").matches();
+ assert !regex.matcher("subdir1/abc.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("abc/**/*.properties",
"abc/.*[^/]*\\.properties", "abc/aaa/bbb.properties");
+ assert !regex.matcher("abc/aaa/bbbXproperties").matches() :
"should not have matched, is the . escaped?";
+ assert !regex.matcher("bbb.properties").matches();
+ assert regex.matcher("abc/aaa.properties").matches();
+ assert regex.matcher("abc/aaa/bbb/ccc.properties").matches();
+ assert !regex.matcher("abc/aaa/bbb/ccc.properties/foo").matches();
+
+ regex = assertIncludePatternRegex("abc/**/xyz/*.properties",
"abc/.*xyz/[^/]*\\.properties",
+ "abc/aaa/xyz/bbb.properties");
+ assert !regex.matcher("abc/aaa/xyz/bbbXproperties").matches() :
"should not have matched, is the . escaped?";
+ assert !regex.matcher("bbb.properties").matches();
+ assert regex.matcher("abc/xyz/ccc.properties").matches();
+ assert regex.matcher("abc/aaa/bbb/xyz/ccc.properties").matches();
+ assert !regex.matcher("abc/aaa/bbb/xyz/ccc.properties/foo").matches();
+ }
+
+ /**
+ * @param patternToTest the include pattern to test - this is the string in the ant
script like "*.properties"
+ * @param expectedRegex this is the regex pattern that we expect to result from the
patternToTest
+ * @param valueToTest this is a value that should match the expectedRegex
+ * @return the compiled Pattern, for further testing by the caller
+ */
+ private Pattern assertIncludePatternRegex(String patternToTest, String expectedRegex,
String valueToTest) {
+ StringBuilder regex = new StringBuilder();
+ AbstractBundleType.buildIncludePatternRegex(patternToTest, regex);
+ assert regex.toString().equals(expectedRegex) : "Tested={" +
patternToTest + "}; Expected={" + expectedRegex
+ + "}; Actual={" + regex + "}";
+
+ assert Pattern.compile(regex.toString()).matcher(valueToTest).matches() :
"The ExpectedRegex {" + expectedRegex
+ + "} did not match the ValueToTest {" + valueToTest + "} -
this unit test does not appear valid";
+
+ return Pattern.compile(regex.toString());
+ }
+}
diff --git a/modules/common/ant-bundle/src/test/resources/file.zip
b/modules/common/ant-bundle/src/test/resources/file.zip
index 922658a..969a6c1 100644
Binary files a/modules/common/ant-bundle/src/test/resources/file.zip and
b/modules/common/ant-bundle/src/test/resources/file.zip differ
diff --git
a/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties
b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties
new file mode 100644
index 0000000..b66ba1d
--- /dev/null
+++
b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-input.properties
@@ -0,0 +1 @@
+listener.port = 12345
diff --git
a/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml
b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml
new file mode 100644
index 0000000..ea4255a
--- /dev/null
+++
b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives-with-replace.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<project name="test-bundle" default="main"
xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="test compressed archive files"
version="1.0">
+
+ <rhq:input-property name="listener.port"
type="integer"/>
+
+ <rhq:deployment-unit name="appserver">
+ <rhq:archive name="file.zip" exploded="false">
+ <rhq:replace>
+ <rhq:fileset includes="**/*.foo"/>
+ <rhq:fileset includes="**/*.properties"/>
+ </rhq:replace>
+ </rhq:archive>
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+</project>
\ No newline at end of file
diff --git
a/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml
b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml
new file mode 100644
index 0000000..a35b6ac
--- /dev/null
+++ b/modules/common/ant-bundle/src/test/resources/test-bundle-compressed-archives.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<project name="test-bundle" default="main"
xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="test compressed archive files"
version="1.0">
+
+ <rhq:deployment-unit name="appserver">
+ <rhq:archive name="file.zip" exploded="false"/>
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+</project>
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
index 5116631..652bcda 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/Deployer.java
@@ -35,6 +35,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -566,22 +567,76 @@ public class Deployer {
boolean dryRun) throws Exception {
// NOTE: right now, this only adds to the "realized" set of files is
diff, no need to track "added" or "changed" here
-
FileHashcodeMap newFileHashCodeMap = new FileHashcodeMap();
+ // get information about the source dir - will be needed if we were told to not
explode a zip
+ String sourceDirAbsPath = this.deploymentData.getSourceDir().getAbsolutePath();
+ int sourceDirLength = sourceDirAbsPath.length();
+
// extract all zip files
ExtractorZipFileVisitor visitor;
for (File zipFile : this.deploymentData.getZipFiles()) {
- debug("Extracting zip [", zipFile, "] entries. dryRun=",
dryRun);
+ Boolean exploded = this.deploymentData.getZipsExploded().get(zipFile);
+ if (exploded == null) {
+ exploded = Boolean.TRUE; // the default is to explode the archive
+ }
+
+ debug("Extracting zip [", zipFile, "] entries.
exploded=", exploded, ", dryRun=", dryRun);
Pattern realizeRegex = null;
if (this.deploymentData.getZipEntriesToRealizeRegex() != null) {
realizeRegex =
this.deploymentData.getZipEntriesToRealizeRegex().get(zipFile);
}
- visitor = new
ExtractorZipFileVisitor(this.deploymentData.getDestinationDir(), realizeRegex,
- this.deploymentData.getTemplateEngine(),
currentFilesToLeaveAlone.keySet(), diff, dryRun);
- ZipUtil.walkZipFile(zipFile, visitor);
- newFileHashCodeMap.putAll(visitor.getFileHashcodeMap());
+
+ if (exploded.booleanValue()) {
+ // EXPLODED
+ visitor = new
ExtractorZipFileVisitor(this.deploymentData.getDestinationDir(), realizeRegex,
+ this.deploymentData.getTemplateEngine(),
currentFilesToLeaveAlone.keySet(), diff, dryRun);
+ ZipUtil.walkZipFile(zipFile, visitor);
+ newFileHashCodeMap.putAll(visitor.getFileHashcodeMap()); // exploded into
individual files
+ } else {
+ // COMPRESSED
+
+ // Note: there is a requirement that all zip files must be located in the
sourceDir - this is why. We need
+ // the path of the zip relative to the source dir so we can copy it to
the same relative location
+ // under the destination dir. Without doing this, if the zip is in a
subdirectory, we won't know where to
+ // put it under the destination dir.
+ String zipRelativePath =
zipFile.getAbsolutePath().substring(sourceDirLength);
+ if (zipRelativePath.startsWith("/") ||
zipRelativePath.startsWith("\\")) {
+ zipRelativePath = zipRelativePath.substring(1);
+ }
+ File compressedFile = new File(this.deploymentData.getDestinationDir(),
zipRelativePath);
+
+ if (this.deploymentData.getTemplateEngine() != null &&
realizeRegex != null) {
+ // we need to explode it to perform the realization of templatized
variables
+ // TODO: can we do this in another tmp location and build the zip in
the dest dir?
+ visitor = new
ExtractorZipFileVisitor(this.deploymentData.getDestinationDir(), realizeRegex,
+ this.deploymentData.getTemplateEngine(),
currentFilesToLeaveAlone.keySet(), diff, dryRun);
+ ZipUtil.walkZipFile(zipFile, visitor);
+ // we have to compress the file again - our new compressed file will
have the new realized files in them
+ if (!dryRun) {
+ createZipFile(compressedFile,
this.deploymentData.getDestinationDir(), visitor
+ .getFileHashcodeMap());
+ }
+ }
+
+ // Copy the archive to the destination dir if we need to. Generate its
hashcode and add it to the new file hashcode map
+ MessageDigestGenerator hashcodeGenerator = new MessageDigestGenerator();
+ String compressedFileHashcode;
+ if (!dryRun) {
+ if (!compressedFile.exists()) {
+ if (compressedFile.getParentFile() != null) {
+ compressedFile.getParentFile().mkdirs();
+ }
+ FileUtil.copyFile(zipFile, compressedFile);
+ }
+ compressedFileHashcode =
hashcodeGenerator.calcDigestString(compressedFile);
+ } else {
+ // use source zip for hash - should be the same as the would-be
compressed file since we aren't realizing files in it
+ compressedFileHashcode =
hashcodeGenerator.calcDigestString(zipFile);
+ }
+ newFileHashCodeMap.put(zipRelativePath, compressedFileHashcode);
+ }
}
// copy all raw files
@@ -681,6 +736,73 @@ public class Deployer {
}
/**
+ * Create a zip file by adding all the files found in the file hashcode map. The
+ * relative paths found in the map's key set are relative to the rootDir
directory.
+ * The files are stored in the given zipFile.
+ *
+ * @param zipFile where to zip up all the files
+ * @param rootDir all relative file paths are relative to this root directory
+ * @param fileHashcodeMap the key set tells us all the files that need to be zipped
up
+ *
+ * @throws Exception
+ */
+ private void createZipFile(File zipFile, File rootDir, FileHashcodeMap
fileHashcodeMap) throws Exception {
+ if (zipFile.getParentFile() != null) {
+ zipFile.getParentFile().mkdirs();
+ }
+
+ Set<File> childrenOfRootToDelete = new HashSet<File>();
+
+ ZipOutputStream zos = null;
+ try {
+ zos = new ZipOutputStream(new FileOutputStream(zipFile));
+
+ for (String relativeFileToZip : fileHashcodeMap.keySet()) {
+ File fileToZip = new File(rootDir, relativeFileToZip);
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(fileToZip);
+ ZipEntry zipEntry = new ZipEntry(relativeFileToZip);
+ zos.putNextEntry(zipEntry);
+ StreamUtil.copy(fis, zos, false);
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+
+ // Remember the location to delete it later. To speed up the deletes,
we only remember
+ // the locations of the direct children under the rootDir. Since we
know all zip content
+ // is located under those locations, we'll recursively delete
everything under those
+ // rootDir children. We obviously can't delete everything under
rootDir because there
+ // could be files in there not related to our zip file.
+ File childOfRoot = fileToZip;
+ while (childOfRoot != null) {
+ File parent = childOfRoot.getParentFile();
+ if (parent.equals(rootDir)) {
+ childrenOfRootToDelete.add(childOfRoot);
+ break;
+ } else {
+ childOfRoot = parent;
+ }
+ }
+ }
+ }
+
+ } finally {
+ if (zos != null) {
+ zos.close();
+ }
+ }
+
+ // we are done zipping up all files, delete all the individual files that are
exploded that are now in the zip
+ for (File childOfRootToDelete : childrenOfRootToDelete) {
+ FileUtil.purge(childOfRootToDelete, true);
+ }
+
+ return;
+ }
+
+ /**
* Performs in-memory-only calculations to determine where new files would go and
what
* their new hashcodes would be.
*
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
index b1fac47..e81fbaa 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
@@ -43,11 +43,13 @@ public class DeploymentData {
private final Set<File> zipFiles;
private final Map<File, File> rawFiles;
private final File destinationDir;
+ private final File sourceDir;
private final Map<File, Pattern> zipEntriesToRealizeRegex;
private final Set<File> rawFilesToRealize;
private final TemplateEngine templateEngine;
private final Pattern ignoreRegex;
private final boolean manageRootDir;
+ private final Map<File, Boolean> zipsExploded;
/**
* Constructors that prepares this object with the data that is necessary in order to
deploy archive/file content
@@ -60,6 +62,7 @@ public class DeploymentData {
* in which case they are relative to destDir and can have
subdirectories and/or a different filename
* than what the file is named currently)
* @param destinationDir the root directory where the content is to be deployed
+ * @param sourceDir the root directory where the source files (zips and raw files)
are located
* @param zipEntriesToRealizeRegex the patterns of files (whose paths are relative to
destDir) that
* must have replacement variables within them
replaced with values
* obtained via the given template engine. The key is
the name of the zip file
@@ -77,34 +80,45 @@ public class DeploymentData {
* The purpose of this is to be able to write files to an
existing directory that has other
* unrelated files in it that need to remain intact. e.g. the
deploy/ directory of JBossAS.
* Note: regardless of this setting, all subdirectories under
the root dir will be managed.
+ * @param zipsExploded if not <code>null</code>, this is a map keyed on
zip files whose values indicate
+ * if the zips should be exploded (true) or remain compressed
after the deployment
+ * is finished (false). If a zip file is not found in this map,
true is the default.
*/
public DeploymentData(DeploymentProperties deploymentProps, Set<File> zipFiles,
Map<File, File> rawFiles,
- File destinationDir, Map<File, Pattern> zipEntriesToRealizeRegex,
Set<File> rawFilesToRealize,
- TemplateEngine templateEngine, Pattern ignoreRegex, boolean manageRootDir) {
+ File sourceDir, File destinationDir, Map<File, Pattern>
zipEntriesToRealizeRegex, Set<File> rawFilesToRealize,
+ TemplateEngine templateEngine, Pattern ignoreRegex, boolean manageRootDir,
Map<File, Boolean> zipsExploded) {
if (deploymentProps == null) {
throw new IllegalArgumentException("deploymentProps == null");
}
if (destinationDir == null) {
- throw new IllegalArgumentException("destDir == null");
+ throw new IllegalArgumentException("destinationDir == null");
+ }
+ if (sourceDir == null) {
+ throw new IllegalArgumentException("sourceDir == null");
}
if (zipFiles == null) {
- zipFiles = new HashSet<File>();
+ zipFiles = new HashSet<File>(0);
}
if (rawFiles == null) {
- rawFiles = new HashMap<File, File>();
+ rawFiles = new HashMap<File, File>(0);
}
if ((zipFiles.size() == 0) && (rawFiles.size() == 0)) {
throw new IllegalArgumentException("zipFiles/rawFiles are empty -
nothing to do");
}
+ if (zipsExploded == null) {
+ zipsExploded = new HashMap<File, Boolean>(0);
+ }
this.deploymentProps = deploymentProps;
this.zipFiles = zipFiles;
this.rawFiles = rawFiles;
this.destinationDir = destinationDir;
+ this.sourceDir = sourceDir;
this.ignoreRegex = ignoreRegex;
this.manageRootDir = manageRootDir;
+ this.zipsExploded = zipsExploded;
// if there is nothing to realize or we have no template engine to obtain
replacement values, then we null things out
if (templateEngine == null || (zipEntriesToRealizeRegex == null &&
rawFilesToRealize == null)) {
@@ -136,6 +150,10 @@ public class DeploymentData {
return destinationDir;
}
+ public File getSourceDir() {
+ return sourceDir;
+ }
+
public Map<File, Pattern> getZipEntriesToRealizeRegex() {
return zipEntriesToRealizeRegex;
}
@@ -155,4 +173,8 @@ public class DeploymentData {
public boolean isManageRootDir() {
return manageRootDir;
}
+
+ public Map<File, Boolean> getZipsExploded() {
+ return zipsExploded;
+ }
}
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
index 5f0fca6..69d6d53 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerTest.java
@@ -255,8 +255,8 @@ public class DeployerTest {
File destDir = tmpDir;
Map<File, Pattern> filesToRealizeRegex1 = new HashMap<File,
Pattern>(1);
filesToRealizeRegex1.put(testZipFile1, realizeRegex);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
destDir, filesToRealizeRegex1,
- null, templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
tmpDir, destDir,
+ filesToRealizeRegex1, null, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
diff = new DeployDifferences();
@@ -291,8 +291,8 @@ public class DeployerTest {
rawFiles.put(testRawFileB, updaterBabsolute); // raw file to absolute path
Map<File, Pattern> filesToRealizeRegex2 = new HashMap<File,
Pattern>(1);
filesToRealizeRegex2.put(testZipFile2, realizeRegex);
- dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir,
filesToRealizeRegex2, null,
- templateEngine, ignoreRegex, true);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir,
filesToRealizeRegex2, null,
+ templateEngine, ignoreRegex, true, null);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -419,8 +419,8 @@ public class DeployerTest {
rawFiles = new HashMap<File, File>(2);
rawFiles.put(testRawFileA, updaterAabsolute); // source raw file to absolute
path
rawFiles.put(testRawFileBChange1, updaterBabsolute); // source raw file to
absolute path
- dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir,
filesToRealizeRegex2, null,
- templateEngine, ignoreRegex, true);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir,
filesToRealizeRegex2, null,
+ templateEngine, ignoreRegex, true, null);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -459,8 +459,8 @@ public class DeployerTest {
rawFiles = new HashMap<File, File>(2);
rawFiles.put(testRawFileAChange, updaterAabsolute); // source raw file to
absolute path
rawFiles.put(testRawFileBChange2, updaterBabsolute); // source raw file to
absolute path
- dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, destDir,
filesToRealizeRegex2, null,
- templateEngine, ignoreRegex, true);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDir, destDir,
filesToRealizeRegex2, null,
+ templateEngine, ignoreRegex, true, null);
deployer = new Deployer(dd);
diff = new DeployDifferences();
deployer.deploy(diff);
@@ -525,8 +525,8 @@ public class DeployerTest {
Pattern ignoreRegex = null;
Set<File> realizeRawFiles1 = new HashSet<File>(1);
realizeRawFiles1.add(testRawFileB);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
destDir, null,
- realizeRawFiles1, templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
tmpDir, destDir, null,
+ realizeRawFiles1, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
DeployDifferences diff = new DeployDifferences();
FileHashcodeMap map = deployer.deploy(diff);
@@ -579,8 +579,8 @@ public class DeployerTest {
realizeRawFiles1.add(testZipFile1);
realizeRawFiles1.add(testZipFile2);
realizeRawFiles1.add(testRawFileB);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
destDir, null,
- realizeRawFiles1, templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
tmpDir, destDir, null,
+ realizeRawFiles1, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
DeployDifferences listener = new DeployDifferences();
deployer.deploy(listener);
@@ -677,8 +677,8 @@ public class DeployerTest {
Map<File, Pattern> realizeRegex1 = new HashMap<File,
Pattern>(1);
realizeRegex1.put(testZipFile1, filesToRealizeRegex);
- DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
destDir, realizeRegex1, null,
- templateEngine, ignoreRegex, true);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles,
tmpDir, destDir, realizeRegex1,
+ null, templateEngine, ignoreRegex, true, null);
Deployer deployer = new Deployer(dd);
DeployDifferences listener = new DeployDifferences();
deployer.deploy(listener);
diff --git
a/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
b/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
index 88d2731..4ef558b 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/ManageRootDirTest.java
@@ -101,8 +101,8 @@ public class ManageRootDirTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple",
"1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, deployDir, null, null,
- null, null, false);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, tmpDir, deployDir, null,
+ null, null, null, false, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = new File(deployDir, originalFileName);
@@ -241,8 +241,8 @@ public class ManageRootDirTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple",
"1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, deployDir, null, null,
- null, null, false);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, tmpDir, deployDir, null,
+ null, null, null, false, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
assert new File(this.deployDir, origFileName1).exists();
@@ -261,7 +261,8 @@ public class ManageRootDirTest {
new String[] { newFileName1, newFileName2 });
HashSet<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null,
null, null, false);
+ dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir,
null, null, null, null, false,
+ null);
deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap = deployer.deploy(this.diff);
assert new File(this.deployDir, newFileName1).exists();
@@ -275,8 +276,8 @@ public class ManageRootDirTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
deployDir, null, null, null,
- null, false);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
tmpDir, deployDir, null, null,
+ null, null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -319,8 +320,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -367,8 +368,8 @@ public class ManageRootDirTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
deployDir, null, null, null,
- null, false);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
tmpDir, deployDir, null, null,
+ null, null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -417,8 +418,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -467,8 +468,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -531,8 +532,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -594,8 +595,8 @@ public class ManageRootDirTest {
String inTheWayHashcode =
MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -650,8 +651,8 @@ public class ManageRootDirTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFile.delete() : "Failed to delete the current file,
cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
deployDir, null, null, null,
- null, false);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
tmpDir, deployDir, null, null,
+ null, null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -702,8 +703,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -767,8 +768,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -842,8 +843,8 @@ public class ManageRootDirTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do
this to force backup file creation
@@ -883,7 +884,8 @@ public class ManageRootDirTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique
deployment ID
- dd = new DeploymentData(v1Duplicate, originalZipFiles, null, deployDir, null,
null, null, null, false);
+ dd = new DeploymentData(v1Duplicate, originalZipFiles, null, tmpDir, deployDir,
null, null, null, null, false,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
@@ -933,8 +935,8 @@ public class ManageRootDirTest {
Pattern iRegex = Pattern.compile(".*ignoreSubdir.*"); // this matches
the subdirectory name, thus everything under it is ignored
assert ignoredFile.exists() : "for some reason we couldn't create our
test file; cannot know if clean worked";
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, iRegex,
- false);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ iRegex, false, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff, true, dryRun); // note: clean is
true
diff --git
a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
index 16275ef..6b6bcdf 100644
---
a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
+++
b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawFileTest.java
@@ -92,8 +92,8 @@ public class SimpleDeployerRawFileTest {
this.sourceRawFiles = new HashMap<File, File>(1);
this.sourceRawFiles.put(sourceRawFile, new File(extDir, originalFileName)); //
note we name it different than the source file
this.originalDeployProps = new DeploymentProperties(1, "simple",
"1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles,
deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = sourceRawFiles.get(sourceRawFile);
@@ -206,8 +206,8 @@ public class SimpleDeployerRawFileTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -249,8 +249,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -296,8 +296,8 @@ public class SimpleDeployerRawFileTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -345,8 +345,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -394,8 +394,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -458,8 +458,8 @@ public class SimpleDeployerRawFileTest {
File newDestRawFile = new File(extDir, newFileName);
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -521,8 +521,8 @@ public class SimpleDeployerRawFileTest {
String inTheWayHashcode =
MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -582,8 +582,8 @@ public class SimpleDeployerRawFileTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFile.delete() : "Failed to delete the current file,
cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -634,8 +634,8 @@ public class SimpleDeployerRawFileTest {
File newDestRawFile = new File(extDir, newFileName);
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -699,8 +699,8 @@ public class SimpleDeployerRawFileTest {
File newDestRawFile = new File(extDir, newFileName);
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -773,8 +773,8 @@ public class SimpleDeployerRawFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do
this to force backup file creation
@@ -813,7 +813,8 @@ public class SimpleDeployerRawFileTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique
deployment ID
- dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, deployDir, null, null,
null, null, true);
+ dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, tmpDir, deployDir,
null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
diff --git
a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
index 5a0f842..148aa08 100644
---
a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
+++
b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerRawRelativeFileTest.java
@@ -90,8 +90,8 @@ public class SimpleDeployerRawRelativeFileTest {
this.sourceRawFiles = new HashMap<File, File>(1);
this.sourceRawFiles.put(sourceRawFile, new File(originalFileName)); // RELATIVE!
note we name it different than the source file
this.originalDeployProps = new DeploymentProperties(1, "simple",
"1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles,
deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = sourceRawFiles.get(sourceRawFile);
@@ -205,8 +205,8 @@ public class SimpleDeployerRawRelativeFileTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -248,8 +248,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -295,8 +295,8 @@ public class SimpleDeployerRawRelativeFileTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -344,8 +344,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -393,8 +393,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -457,8 +457,8 @@ public class SimpleDeployerRawRelativeFileTest {
File newDestRawFile = new File(newFileName); // RELATIVE!
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -520,8 +520,8 @@ public class SimpleDeployerRawRelativeFileTest {
String inTheWayHashcode =
MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -580,8 +580,8 @@ public class SimpleDeployerRawRelativeFileTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFileWithAbsolutePath.delete() : "Failed to delete the
current file, cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, sourceRawFiles,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -632,8 +632,8 @@ public class SimpleDeployerRawRelativeFileTest {
File newDestRawFile = new File(newFileName); // RELATIVE!
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -697,8 +697,8 @@ public class SimpleDeployerRawRelativeFileTest {
File newDestRawFile = new File(newFileName); // RELATIVE!
newRawFiles.put(newRawFile, newDestRawFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -771,8 +771,8 @@ public class SimpleDeployerRawRelativeFileTest {
Map<File, File> newRawFiles = new HashMap<File, File>(1);
newRawFiles.put(newRawFile, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, null, newRawFiles, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do
this to force backup file creation
@@ -811,7 +811,8 @@ public class SimpleDeployerRawRelativeFileTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique
deployment ID
- dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, deployDir, null, null,
null, null, true);
+ dd = new DeploymentData(v1Duplicate, null, sourceRawFiles, tmpDir, deployDir,
null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
diff --git
a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
index 712a984..f875576 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/SimpleDeployerTest.java
@@ -86,8 +86,8 @@ public class SimpleDeployerTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple",
"1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, deployDir, null, null,
- null, null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
this.currentFile = new File(deployDir, originalFileName);
@@ -226,8 +226,8 @@ public class SimpleDeployerTest {
this.originalZipFiles = new HashSet<File>(1);
this.originalZipFiles.add(originalZipFile);
this.originalDeployProps = new DeploymentProperties(1, "simple",
"1.0", "original test deployment");
- DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, deployDir, null, null,
- null, null, true);
+ DeploymentData dd = new DeploymentData(originalDeployProps, originalZipFiles,
null, tmpDir, deployDir, null,
+ null, null, null, true, null);
Deployer deployer = new Deployer(dd);
this.originalFileHashcodeMap = deployer.deploy(null);
assert new File(this.deployDir, origFileName1).exists();
@@ -246,7 +246,8 @@ public class SimpleDeployerTest {
new String[] { newFileName1, newFileName2 });
HashSet<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- dd = new DeploymentData(newDeployProps, newZipFiles, null, deployDir, null, null,
null, null, true);
+ dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir, deployDir,
null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap = deployer.deploy(this.diff);
assert new File(this.deployDir, newFileName1).exists();
@@ -261,8 +262,8 @@ public class SimpleDeployerTest {
}
private void baseX_X_X(boolean dryRun) throws Exception {
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -304,8 +305,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -351,8 +352,8 @@ public class SimpleDeployerTest {
String newHashcode = MessageDigestGenerator.getDigestString(newContent);
writeFile(newContent, this.currentFile);
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -400,8 +401,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -449,8 +450,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -512,8 +513,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -574,8 +575,8 @@ public class SimpleDeployerTest {
String inTheWayHashcode =
MessageDigestGenerator.getDigestString(inTheWayContent);
writeFile(inTheWayContent, inTheWayFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -634,8 +635,8 @@ public class SimpleDeployerTest {
private void baseNoCurrent(boolean dryRun) throws Exception {
assert this.currentFile.delete() : "Failed to delete the current file,
cannot prepare the test";
- DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
deployDir, null, null, null,
- null, true);
+ DeploymentData dd = new DeploymentData(newDeployProps, originalZipFiles, null,
tmpDir, deployDir, null, null,
+ null, null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -685,8 +686,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -749,8 +750,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
if (dryRun) {
@@ -823,8 +824,8 @@ public class SimpleDeployerTest {
Set<File> newZipFiles = new HashSet<File>(1);
newZipFiles.add(newZipFile);
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, null,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ null, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff); // no dry run - we need to do
this to force backup file creation
@@ -863,7 +864,8 @@ public class SimpleDeployerTest {
DeploymentProperties v1Duplicate = new DeploymentProperties();
v1Duplicate.putAll(this.originalDeployProps);
v1Duplicate.setDeploymentId(3); // this is the same as v1, but it needs a unique
deployment ID
- dd = new DeploymentData(v1Duplicate, originalZipFiles, null, deployDir, null,
null, null, null, true);
+ dd = new DeploymentData(v1Duplicate, originalZipFiles, null, tmpDir, deployDir,
null, null, null, null, true,
+ null);
deployer = new Deployer(dd);
this.diff = new DeployDifferences();
FileHashcodeMap restoreFileHashcodeMap;
@@ -912,8 +914,8 @@ public class SimpleDeployerTest {
Pattern iRegex = Pattern.compile(".*ignoreSubdir.*"); // this matches
the subdirectory name, thus everything under it is ignored
assert ignoredFile.exists() : "for some reason we couldn't create our
test file; cannot know if clean worked";
- DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null,
deployDir, null, null, null, iRegex,
- true);
+ DeploymentData dd = new DeploymentData(newDeployProps, newZipFiles, null, tmpDir,
deployDir, null, null, null,
+ iRegex, true, null);
Deployer deployer = new Deployer(dd);
FileHashcodeMap newFileHashcodeMap;
newFileHashcodeMap = deployer.deploy(this.diff, true, dryRun); // note: clean is
true