Fix catalog item disabled/deprecated test
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/e56b0962 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/e56b0962 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/e56b0962 Branch: refs/heads/master Commit: e56b0962ad381a4f5810662d227b1fe55450e876 Parents: e3553a1 Author: Svetoslav Neykov <[email protected]> Authored: Wed Oct 21 17:53:07 2015 +0300 Committer: Svetoslav Neykov <[email protected]> Committed: Wed Oct 21 17:53:07 2015 +0300 ---------------------------------------------------------------------- .../brooklyn/catalog/CatalogYamlRebindTest.java | 24 +++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e56b0962/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java ---------------------------------------------------------------------- diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java index cfc8ae1..67ef06c 100644 --- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java +++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java @@ -48,11 +48,13 @@ import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.entity.StartableApplication; import org.apache.brooklyn.core.mgmt.persist.BrooklynMementoPersisterToObjectStore; import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore; +import org.apache.brooklyn.core.mgmt.persist.PersistenceObjectStore.StoreObjectAccessor; import org.apache.brooklyn.core.mgmt.rebind.RebindOptions; import org.apache.brooklyn.core.test.policy.TestEnricher; import org.apache.brooklyn.core.test.policy.TestPolicy; import org.apache.brooklyn.entity.stock.BasicEntity; import org.apache.brooklyn.util.exceptions.Exceptions; +import org.apache.brooklyn.util.text.Strings; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -196,6 +198,14 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest { addCatalogItems(String.format(locCatalogFormat, locVersion)); break; case STRIP_DEPRECATION_AND_ENABLEMENT_FROM_CATALOG_ITEM: + //Make sure that the flags are actually removed from the XML instead of still being there with false values + appItem.setDeprecated(true); + appItem.setDisabled(true); + mgmt().getCatalog().persist(appItem); + locItem.setDisabled(true); + locItem.setDeprecated(true); + mgmt().getCatalog().persist(locItem); + break; case NO_OP: break; // no-op default: @@ -209,19 +219,21 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest { .stateTransformer(new Function<BrooklynMementoPersister, Void>() { @Override public Void apply(BrooklynMementoPersister input) { PersistenceObjectStore objectStore = ((BrooklynMementoPersisterToObjectStore)input).getObjectStore(); - String appItemMemento = checkNotNull(objectStore.newAccessor("catalog/"+appItemId.replace(":", "_")).get(), "appItem in catalog"); - String locItemMemento = checkNotNull(objectStore.newAccessor("catalog/"+locItemId.replace(":", "_")).get(), "locItem in catalog"); + StoreObjectAccessor appItemAccessor = objectStore.newAccessor("catalog/"+Strings.makeValidFilename(appItemId)); + StoreObjectAccessor locItemAccessor = objectStore.newAccessor("catalog/"+Strings.makeValidFilename(locItemId)); + String appItemMemento = checkNotNull(appItemAccessor.get(), "appItem in catalog"); + String locItemMemento = checkNotNull(locItemAccessor.get(), "locItem in catalog"); String newAppItemMemento = removeFromXml(appItemMemento, ImmutableList.of("catalogItem/deprecated", "catalogItem/disabled")); - String newLocItemMemento = removeFromXml(appItemMemento, ImmutableList.of("catalogItem/deprecated", "catalogItem/disabled")); - objectStore.newAccessor("catalog/"+appItemId).put(newAppItemMemento); - objectStore.newAccessor("catalog/"+locItemId).put(newLocItemMemento); + String newLocItemMemento = removeFromXml(locItemMemento, ImmutableList.of("catalogItem/deprecated", "catalogItem/disabled")); + appItemAccessor.put(newAppItemMemento); + locItemAccessor.put(newLocItemMemento); return null; }})); } else { rebind(); } - // Ensure app is still there, and that it is usabe - e.g. "stop" effector functions as expected + // Ensure app is still there, and that it is usable - e.g. "stop" effector functions as expected BasicEntity newEntity = (BasicEntity) Iterables.getOnlyElement(newApp.getChildren()); Policy newPolicy = Iterables.getOnlyElement(newEntity.policies()); Enricher newEnricher = Iterables.tryFind(newEntity.enrichers(), Predicates.instanceOf(TestEnricher.class)).get();
