brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [06/10] incubator-brooklyn git commit: Fix feed serialization and update test to catch the problem.
Date Thu, 13 Nov 2014 12:44:13 GMT
Fix feed serialization and update test to catch the problem.

Feeds are serialized with the wrong element name (BasicFeedMemento.class.getName() vs feed)
from what the code expects, allowing for only a single feed to be deserialized successfully.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d1c07820
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d1c07820
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d1c07820

Branch: refs/heads/master
Commit: d1c07820f4d3bd7cb050e56b90d5330537525534
Parents: 3b38639
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Thu Nov 13 11:13:26 2014 +0200
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Thu Nov 13 11:13:26 2014 +0200

----------------------------------------------------------------------
 .../entity/rebind/persister/XmlMementoSerializer.java    |  2 ++
 .../test/java/brooklyn/entity/rebind/RebindFeedTest.java | 11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d1c07820/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
b/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
index 881f101..a179479 100644
--- a/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
+++ b/core/src/main/java/brooklyn/entity/rebind/persister/XmlMementoSerializer.java
@@ -38,6 +38,7 @@ import brooklyn.entity.effector.EffectorTasks.EffectorTaskFactory;
 import brooklyn.entity.rebind.dto.BasicCatalogItemMemento;
 import brooklyn.entity.rebind.dto.BasicEnricherMemento;
 import brooklyn.entity.rebind.dto.BasicEntityMemento;
+import brooklyn.entity.rebind.dto.BasicFeedMemento;
 import brooklyn.entity.rebind.dto.BasicLocationMemento;
 import brooklyn.entity.rebind.dto.BasicPolicyMemento;
 import brooklyn.entity.rebind.dto.MutableBrooklynMemento;
@@ -85,6 +86,7 @@ public class XmlMementoSerializer<T> extends XmlSerializer<T>
implements Memento
         xstream.alias("entity", BasicEntityMemento.class);
         xstream.alias("location", BasicLocationMemento.class);
         xstream.alias("policy", BasicPolicyMemento.class);
+        xstream.alias("feed", BasicFeedMemento.class);
         xstream.alias("enricher", BasicEnricherMemento.class);
         xstream.alias("configKey", BasicConfigKey.class);
         xstream.alias("catalogItem", BasicCatalogItemMemento.class);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d1c07820/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
index 7692771..c0be0fb 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
@@ -50,7 +50,6 @@ import brooklyn.location.Location;
 import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.management.Task;
-import brooklyn.test.Asserts;
 import brooklyn.test.EntityTestUtils;
 import brooklyn.test.entity.TestEntity;
 import brooklyn.test.entity.TestEntityImpl.TestEntityWithoutEnrichers;
@@ -151,13 +150,13 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
     public void testFunctionFeedRegisteredInInitIsPersisted() throws Exception {
         TestEntity origEntity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class).impl(MyEntityWithFunctionFeedImpl.class));
         EntityTestUtils.assertAttributeEqualsEventually(origEntity, SENSOR_INT, (Integer)1);
-        assertEquals(origEntity.feeds().getFeeds().size(), 1);
+        assertEquals(origEntity.feeds().getFeeds().size(), 2);
 
         newApp = rebind(false);
         TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
         
         Collection<Feed> newFeeds = newEntity.feeds().getFeeds();
-        assertEquals(newFeeds.size(), 1);
+        assertEquals(newFeeds.size(), 2);
         
         // Expect the feed to still be polling
         newEntity.setAttribute(SENSOR_INT, null);
@@ -217,6 +216,12 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
                             .period(POLL_PERIOD)
                             .callable(Callables.returning(1)))
                     .build());
+            addFeed(FunctionFeed.builder()
+                    .entity(this)
+                    .poll(FunctionPollConfig.forSensor(SENSOR_STRING)
+                            .period(POLL_PERIOD)
+                            .callable(Callables.returning("OK")))
+                    .build());
         }
     }
     


Mime
View raw message