You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/07/09 23:46:20 UTC

[07/50] git commit: fix integration test where assumption had been not notified on benign changes

fix integration test where assumption had been not notified on benign changes


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

Branch: refs/heads/master
Commit: 0868c2fa73c438c53d04a3e48990044bf68c8231
Parents: 57b2612
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Jul 4 14:30:10 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Jul 9 22:34:42 2014 +0100

----------------------------------------------------------------------
 .../webapp/ControlledDynamicWebAppClusterTest.java | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0868c2fa/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
index a3d53ac..d5d960b 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
@@ -201,7 +201,7 @@ public class ControlledDynamicWebAppClusterTest {
                 .configure("initialSize", 1)
                 .configure("factory", new BasicConfigurableEntityFactory<TestJavaWebAppEntity>(TestJavaWebAppEntity.class)));
         
-        RecordingSensorEventListener<Lifecycle> listener = new RecordingSensorEventListener<Lifecycle>();
+        RecordingSensorEventListener<Lifecycle> listener = new RecordingSensorEventListener<Lifecycle>(true);
         app.subscribe(cluster, Attributes.SERVICE_STATE, listener);
         app.start(locs);
 
@@ -241,11 +241,24 @@ public class ControlledDynamicWebAppClusterTest {
     public static class RecordingSensorEventListener<T> implements SensorEventListener<T> {
         private final List<SensorEvent<T>> events = Lists.newCopyOnWriteArrayList();
         private final List<T> values = Lists.newCopyOnWriteArrayList();
+        private boolean skipDuplicateValues;
 
+        public RecordingSensorEventListener() {
+            this(false);
+        }
+        
+        public RecordingSensorEventListener(boolean skipDuplicateValues) {
+            this.skipDuplicateValues = skipDuplicateValues;
+        }
+        
         @Override
         public void onEvent(SensorEvent<T> event) {
             events.add(event);
-            values.add(event.getValue());
+            if (skipDuplicateValues && !values.isEmpty() && values.get(values.size()-1).equals(event.getValue())) {
+                // skip
+            } else {
+                values.add(event.getValue());
+            }
         }
         
         public List<SensorEvent<T>> getEvents() {