brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] git commit: Fix GroupPickUpEntitiesTest
Date Wed, 08 Oct 2014 11:18:16 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 648049689 -> 8ea4411eb


Fix GroupPickUpEntitiesTest

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

Branch: refs/heads/master
Commit: c9c61fe5d1a872397fb0cc0e103f1183e27df65c
Parents: 6480496
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Oct 8 11:16:08 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Oct 8 11:16:08 2014 +0100

----------------------------------------------------------------------
 .../entity/group/GroupPickUpEntitiesTest.java       | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c9c61fe5/core/src/test/java/brooklyn/entity/group/GroupPickUpEntitiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/GroupPickUpEntitiesTest.java b/core/src/test/java/brooklyn/entity/group/GroupPickUpEntitiesTest.java
index de2b6bf..afdb528 100644
--- a/core/src/test/java/brooklyn/entity/group/GroupPickUpEntitiesTest.java
+++ b/core/src/test/java/brooklyn/entity/group/GroupPickUpEntitiesTest.java
@@ -64,7 +64,7 @@ public class GroupPickUpEntitiesTest extends BrooklynAppUnitTestSupport
{
         Assert.assertEquals(group.getMembers().size(), 0);
         EntityTestUtils.assertAttributeEquals(group, BasicGroup.GROUP_SIZE, 0);
         
-        TestEntity e1 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
+        final TestEntity e1 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
 
         EntityTestUtils.assertAttributeEquals(group, BasicGroup.GROUP_SIZE, 0);
 
@@ -74,7 +74,7 @@ public class GroupPickUpEntitiesTest extends BrooklynAppUnitTestSupport
{
         EntityTestUtils.assertAttributeEqualsEventually(group, BasicGroup.GROUP_SIZE, 1);
         Asserts.assertEqualsIgnoringOrder(group.getAttribute(BasicGroup.GROUP_MEMBERS), ImmutableList.of(e1));
         
-        TestEntity e2 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
+        final TestEntity e2 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
 
         EntityTestUtils.assertAttributeEquals(group, BasicGroup.GROUP_SIZE, 1);
         Assert.assertEquals(group.getMembers().size(), 1);
@@ -87,7 +87,12 @@ public class GroupPickUpEntitiesTest extends BrooklynAppUnitTestSupport
{
 
         e2.setAttribute(TestEntity.NAME, "BOB");
         EntityTestUtils.assertAttributeEqualsEventually(group, BasicGroup.GROUP_SIZE, 2);
-        Asserts.assertEqualsIgnoringOrder(group.getAttribute(BasicGroup.GROUP_MEMBERS), ImmutableList.of(e1,
e2));
+        Asserts.succeedsEventually(new Runnable() {
+            public void run() {
+                // must use "succeedsEventually" because size + members attributes are set
sequentially in another thread; 
+                // just waiting for the first does not mean the second will have been set
by the time we check in this thread.
+                Asserts.assertEqualsIgnoringOrder(group.getAttribute(BasicGroup.GROUP_MEMBERS),
ImmutableList.of(e1, e2));
+            }});
     }
 
 
@@ -98,10 +103,9 @@ public class GroupPickUpEntitiesTest extends BrooklynAppUnitTestSupport
{
      */
     public static class FindUpServices extends AbstractPolicy {
 
-        @SuppressWarnings({"rawtypes"})
-        protected final SensorEventListener handler = new SensorEventListener() {
+        protected final SensorEventListener<Object> handler = new SensorEventListener<Object>()
{
             @Override
-            public void onEvent(SensorEvent event) {
+            public void onEvent(SensorEvent<Object> event) {
                 updateMembership(event.getSource());
             }
         };


Mime
View raw message