modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java | 7 -
modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java | 57 +++++-----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 7 -
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 5
modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java | 14 +-
6 files changed, 52 insertions(+), 43 deletions(-)
New commits:
commit 0a830f22ba3c81d74b11264ee28ac3f870543e8c
Merge: 6bc7cb3... d9c400d...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 31 17:34:34 2010 -0400
Merge branch 'gwt-jay' into gwt
commit d9c400da11052832f2842232c54791052b7289fd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 31 17:34:03 2010 -0400
A change in the Bundle constructor to include the required Repo and
PackageType. This is a safer way to go and is part of fixing up
some domain tests.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
index 261a54e..1a59123 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -101,14 +101,11 @@ public class Bundle implements Serializable {
// for JPA use
}
- public Bundle(String name, BundleType type) {
+ public Bundle(String name, BundleType type, Repo repo, PackageType packageType) {
setName(name);
setBundleType(type);
- // add implicit Repo
- Repo repo = new Repo(name);
- repo.setCandidate(false);
- repo.setSyncSchedule(null);
setRepo(repo);
+ setPackageType(packageType);
}
public int getId() {
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
index 2004766..7e041ab 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -36,6 +36,8 @@ import org.rhq.core.domain.bundle.BundleVersionRepo;
import org.rhq.core.domain.bundle.BundleVersionRepoPK;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.DistributionType;
+import org.rhq.core.domain.content.PackageCategory;
+import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -67,12 +69,8 @@ public class BundleTest extends AbstractEJB3Test {
assert q.getResultList().size() == 0 : "should not have repo2 mapping in the db yet";
BundleType bundleType = createBundleType(em, name + "-Type", createResourceType(em));
+ Bundle bundle = createBundle(em, name + "-Bundle", bundleType);
- Repo bundleRepo = new Repo(name + "-Bundle");
- em.persist(bundleRepo);
- Bundle bundle = new Bundle(name + "-Bundle", bundleType);
- bundle.setRepo(bundleRepo);
- em.persist(bundle);
BundleVersion bundleVersion = new BundleVersion(name, "1.0.0.BETA", bundle, recipe);
bundleVersion.setVersionOrder(0);
em.persist(bundleVersion);
@@ -133,13 +131,8 @@ public class BundleTest extends AbstractEJB3Test {
String name = "BundleTest-testBundleVersion";
String recipe = "action/script/recipe is here";
- Repo repo1 = new Repo(name + "-Repo1");
- em.persist(repo1);
-
BundleType bundleType = createBundleType(em, name + "-Type", createResourceType(em));
- Bundle bundle = new Bundle(name + "-Bundle", bundleType);
- bundle.setRepo(repo1);
- em.persist(bundle);
+ Bundle bundle = createBundle(em, name + "-Bundle", bundleType);
id = bundle.getId();
assert id > 0;
assert bundle.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
@@ -207,12 +200,15 @@ public class BundleTest extends AbstractEJB3Test {
assert q.getResultList().size() == 1;
bundle = (Bundle) q.getSingleResult();
bundleType = bundle.getBundleType();
+ Repo repo = bundle.getRepo();
em.remove(bundle);
- em.remove(bundleType);
+ em.remove(repo);
+
+ deleteResourceType(em, bundleType.getResourceType());
+
assert q.getResultList().size() == 0 : "didn't clean up test bundle";
assert em.find(BundleType.class, bundleType.getId()) == null : "didn't clean up bundle type";
- deleteResourceType(em, bundleType.getResourceType());
em.close();
} catch (Throwable t) {
@@ -232,13 +228,8 @@ public class BundleTest extends AbstractEJB3Test {
String name = "BundleTest-testMultipleBundleVersions";
String recipe = "action/script/recipe is here";
- Repo repo1 = new Repo(name + "-Repo1");
- em.persist(repo1);
-
BundleType bundleType = createBundleType(em, name + "-Type", createResourceType(em));
- Bundle bundle = new Bundle(name + "-Bundle", bundleType);
- bundle.setRepo(repo1);
- em.persist(bundle);
+ Bundle bundle = createBundle(em, name + "-Bundle", bundleType);
id = bundle.getId();
assert id > 0;
assert bundle.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
@@ -350,25 +341,19 @@ public class BundleTest extends AbstractEJB3Test {
try {
int id;
- String name = "BundleTest-testBundle";
+ String name = "BundleTest-testBundle-Bundle";
Query q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
q.setParameter("name", name);
assert q.getResultList().size() == 0; // not in the db yet
BundleType bundleType = createBundleType(em, name + "-Type", createResourceType(em));
-
- Repo bundleRepo = new Repo(name);
- em.persist(bundleRepo);
-
- Bundle b = new Bundle(name, bundleType);
- b.setRepo(bundleRepo);
- em.persist(b);
+ Bundle b = createBundle(em, name, bundleType);
id = b.getId();
assert id > 0;
assert b.getBundleType().getId() != 0 : "bundleType should have been persisted independently";
assert b.getRepo().getId() != 0 : "bundle's repo should have been cascade persisted with the bundle";
- assert name.equals(b.getRepo().getName()) : "bundle's repo should have same name as bundle";
+ assert b.getName().equals(b.getRepo().getName()) : "bundle's repo should have same name as bundle";
q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
q.setParameter("name", name);
@@ -483,6 +468,22 @@ public class BundleTest extends AbstractEJB3Test {
return bt;
}
+ private Bundle createBundle(EntityManager em, String name, BundleType bt) throws Exception {
+ // implicit Bundle'sRepo
+ Repo repo = new Repo(name);
+ repo.setCandidate(false);
+ repo.setSyncSchedule(null);
+ em.persist(repo);
+
+ // Bundle's packageType
+ PackageType pt = new PackageType(name, bt.getResourceType());
+ pt.setCategory(PackageCategory.BUNDLE);
+
+ Bundle bundle = new Bundle(name, bt, repo, pt);
+ em.persist(bundle);
+ return bundle;
+ }
+
private ResourceType deleteResourceType(EntityManager em, ResourceType rt) {
rt = em.find(ResourceType.class, rt.getId());
em.remove(rt);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index ec2e788..642c843 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -142,16 +142,12 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
throw new IllegalArgumentException("Invalid bundleTypeId: " + bundleTypeId);
}
- Bundle bundle = new Bundle(name, bundleType);
- bundle.setDescription(description);
-
// create and add the required Repo. the Repo is a detached object which helps in its eventual
// removal.
Repo repo = new Repo(name);
repo.setCandidate(false);
repo.setSyncSchedule(null);
repo = repoManager.createRepo(subject, repo);
- bundle.setRepo(repo);
// add the required PackageType. the PackageType is an attached object which helps in cascade removal
// of packages in the bundle's repo.
@@ -164,6 +160,9 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
packageType.setDiscoveryInterval(-1L);
packageType.setCreationData(false);
packageType.setDeploymentConfigurationDefinition(null);
+
+ Bundle bundle = new Bundle(name, bundleType, repo, packageType);
+ bundle.setDescription(description);
bundle.setPackageType(packageType);
log.info("Creating bundle: " + bundle);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 427714b..e9594f4 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -176,7 +176,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
em.remove(em.getReference(BundleDeployDefinition.class, ((BundleDeployDefinition) removeMe).getId()));
}
- // remove bundles which cascade remove repos and packageTypes
+ // remove bundles which cascade remove packageTypes
// packagetypes cascade remove packages
// package cascade remove packageversions
q = em.createQuery("SELECT b FROM Bundle b WHERE b.name LIKE '" + TEST_PREFIX + "%'");
@@ -204,7 +204,8 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
for (Object removeMe : doomed) {
em.remove(em.getReference(PackageType.class, ((PackageType) removeMe).getId()));
}
- // remove any orphaned repos
+
+ // remove repos no longer referenced by bundles
q = em.createQuery("SELECT r FROM Repo r WHERE r.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
for (Object removeMe : doomed) {
diff --git a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
index 4f2f28b..07c48fc 100644
--- a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
+++ b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
@@ -38,6 +38,8 @@ import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -81,7 +83,9 @@ public class AntBundlePluginComponentTest {
public void testSimpleBundle() throws Exception {
ResourceType resourceType = new ResourceType("testSimpleBundle", "plugin", ResourceCategory.SERVER, null);
BundleType bundleType = new BundleType("testSimpleBundle", resourceType);
- Bundle bundle = new Bundle("testSimpleBundle", bundleType);
+ Repo repo = new Repo("testSimpleBundle");
+ PackageType packageType = new PackageType("testSimpleBundle", resourceType);
+ Bundle bundle = new Bundle("testSimpleBundle", bundleType, repo, packageType);
BundleVersion bundleVersion = new BundleVersion("testSimpleBundle", "1.0", bundle,
getRecipeFromFile("simple-build.xml"));
@@ -107,7 +111,9 @@ public class AntBundlePluginComponentTest {
public void testAntBundle() throws Exception {
ResourceType resourceType = new ResourceType("testSimpleBundle", "plugin", ResourceCategory.SERVER, null);
BundleType bundleType = new BundleType("testSimpleBundle", resourceType);
- Bundle bundle = new Bundle("testSimpleBundle", bundleType);
+ Repo repo = new Repo("testSimpleBundle");
+ PackageType packageType = new PackageType("testSimpleBundle", resourceType);
+ Bundle bundle = new Bundle("testSimpleBundle", bundleType, repo, packageType);
BundleVersion bundleVersion = new BundleVersion("testSimpleBundle", "1.0", bundle,
getRecipeFromFile("test-build.xml"));
@@ -141,7 +147,9 @@ public class AntBundlePluginComponentTest {
assert props.getProperty("f.exists").equals("true") : props;
assert props.getProperty("pkg.exists").equals("true") : props;
assert props.getProperty("hostname").equals(SystemInfoFactory.createSystemInfo().getHostname()) : props;
- assert props.getProperty("tmpdir").equals(System.getProperty("java.io.tmpdir")) : props;
+ String javaIoTmpDir = System.getProperty("java.io.tmpdir");
+ String val = props.getProperty("tmpdir");
+ assert val.equals(javaIoTmpDir) : props;
}
private void assertResultsSuccess(BundleDeployResult results) {
commit 041c4a4f1f0131eded7795941af36f20179d9590
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 31 17:32:12 2010 -0400
**MAZZ REVIEW** Escape backslashes in properties being sent to Ant. I'm not
positive about this but in the tests the props are echoed to a file and
when read in via Properties.load() the backslashes are eaten. This solves
that problem but is it the right thing to do?
diff --git a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
index 86e397f..cd18395 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/AntLauncher.java
@@ -94,7 +94,10 @@ public class AntLauncher {
if (properties != null) {
for (Map.Entry<Object, Object> property : properties.entrySet()) {
- project.setProperty(property.getKey().toString(), property.getValue().toString());
+ // On the assumption that these properties will be slurped in via Properties.load we
+ // need to escape backslashes to have them treated as literals
+ project.setProperty(property.getKey().toString(), property.getValue().toString().replace("\\",
+ "\\\\"));
}
}