You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ge...@apache.org on 2017/04/28 13:53:42 UTC

[04/10] brooklyn-server git commit: remove some "continually" assertions not in integration tests

remove some "continually" assertions not in integration tests

a simple assertion is probably sufficient; if continual assertion is really required a new integration test variant should be added


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

Branch: refs/heads/master
Commit: cca032fc09135de8bd57791b67dd6de10fa6b82a
Parents: ce061af
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Apr 25 20:41:17 2017 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Apr 28 14:09:51 2017 +0100

----------------------------------------------------------------------
 .../network/OnPublicNetworkEnricherTest.java    | 29 ++++++++++----------
 1 file changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cca032fc/core/src/test/java/org/apache/brooklyn/core/network/OnPublicNetworkEnricherTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/network/OnPublicNetworkEnricherTest.java b/core/src/test/java/org/apache/brooklyn/core/network/OnPublicNetworkEnricherTest.java
index 0bf40c7..533ea34 100644
--- a/core/src/test/java/org/apache/brooklyn/core/network/OnPublicNetworkEnricherTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/network/OnPublicNetworkEnricherTest.java
@@ -38,7 +38,6 @@ import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.time.Duration;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
@@ -159,7 +158,7 @@ public class OnPublicNetworkEnricherTest extends BrooklynAppUnitTestSupport {
         entity.enrichers().add(EnricherSpec.create(OnPublicNetworkEnricher.class)
                 .configure(OnPublicNetworkEnricher.SENSORS, ImmutableList.of(sensor)));
 
-        EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", VERY_SHORT_WAIT), entity, Sensors.newStringSensor(sensor.getName()+".mapped.public"), null);
+        EntityAsserts.assertAttributeEquals(entity, Sensors.newStringSensor(sensor.getName()+".mapped.public"), null);
     }
 
     @Test
@@ -199,7 +198,7 @@ public class OnPublicNetworkEnricherTest extends BrooklynAppUnitTestSupport {
         entity.enrichers().add(EnricherSpec.create(OnPublicNetworkEnricher.class)
                 .configure(OnPublicNetworkEnricher.SENSORS, ImmutableList.of(Attributes.HTTP_PORT)));
 
-        EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", VERY_SHORT_WAIT), entity, Sensors.newStringSensor(Attributes.HTTP_PORT.getName()+".mapped.public"), null);
+        EntityAsserts.assertAttributeEquals(entity, Sensors.newStringSensor(Attributes.HTTP_PORT.getName()+".mapped.public"), null);
     }
     
     @Test
@@ -212,7 +211,7 @@ public class OnPublicNetworkEnricherTest extends BrooklynAppUnitTestSupport {
         entity.enrichers().add(EnricherSpec.create(OnPublicNetworkEnricher.class)
                 .configure(OnPublicNetworkEnricher.SENSORS, ImmutableList.of(Attributes.HTTP_PORT)));
 
-        EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", VERY_SHORT_WAIT), entity, Sensors.newStringSensor(Attributes.HTTP_PORT.getName()+".mapped.public"), null);
+        EntityAsserts.assertAttributeEquals(entity, Sensors.newStringSensor(Attributes.HTTP_PORT.getName()+".mapped.public"), null);
     }
     
     @Test
@@ -225,7 +224,7 @@ public class OnPublicNetworkEnricherTest extends BrooklynAppUnitTestSupport {
         entity.enrichers().add(EnricherSpec.create(OnPublicNetworkEnricher.class)
                 .configure(OnPublicNetworkEnricher.SENSORS, ImmutableList.of(TestEntity.NAME)));
 
-        EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", VERY_SHORT_WAIT), entity, Sensors.newStringSensor(TestEntity.NAME.getName()+".mapped.public"), null);
+        EntityAsserts.assertAttributeEquals(entity, Sensors.newStringSensor(TestEntity.NAME.getName()+".mapped.public"), null);
     }
     
     @Test
@@ -291,15 +290,12 @@ public class OnPublicNetworkEnricherTest extends BrooklynAppUnitTestSupport {
         
         entity.enrichers().add(EnricherSpec.create(OnPublicNetworkEnricher.class));
 
-        Asserts.succeedsContinually(ImmutableMap.of("timeout", VERY_SHORT_WAIT), new Runnable() {
-            @Override public void run() {
-                Map<AttributeSensor<?>, Object> allSensors = entity.sensors().getAll();
-                String errMsg = "sensors="+allSensors;
-                for (AttributeSensor<?> sensor : allSensors.keySet()) {
-                    String name = sensor.getName();
-                    assertFalse(name.startsWith("my.different") && sensor.getName().contains("public"), errMsg);
-                }
-            }});
+        Map<AttributeSensor<?>, Object> allSensors = entity.sensors().getAll();
+        String errMsg = "sensors="+allSensors;
+        for (AttributeSensor<?> sensor : allSensors.keySet()) {
+            String name = sensor.getName();
+            assertFalse(name.startsWith("my.different") && sensor.getName().contains("public"), errMsg);
+        }
     }
 
     @Test
@@ -446,7 +442,10 @@ public class OnPublicNetworkEnricherTest extends BrooklynAppUnitTestSupport {
     
     protected void assertAttributeEqualsContinually(String sensorName, String expectedVal, Duration duration) throws Exception {
         try {
-            EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", duration), entity, Sensors.newStringSensor(sensorName), expectedVal);
+            // EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", duration), entity, Sensors.newStringSensor(sensorName), expectedVal);
+            // TODO "continually" not actually asserted here because these aren't integration tests;
+            // ideally would have two variants of such tests
+            EntityAsserts.assertAttributeEquals(entity, Sensors.newStringSensor(sensorName), expectedVal);
         } catch (Exception e) {
             throw new Exception("Failed assertion for sensor '"+sensorName+"'; attributes are "+entity.sensors().getAll(), e);
         }