brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [06/10] git commit: fix the orig uni ttest
Date Fri, 06 Jun 2014 22:05:24 GMT
fix the orig uni ttest


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

Branch: refs/heads/master
Commit: 11e381c64e5cc8ffd827adfc9da7d50fb8b4226a
Parents: ab222ff
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Mon Jun 2 17:49:36 2014 +0100
Committer: Andrew Kennedy <adk@magnesium.(none)>
Committed: Fri Jun 6 20:50:57 2014 +0100

----------------------------------------------------------------------
 .../access/PortForwardManagerRebindTest.java    | 28 +++++++++++++++-----
 1 file changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/11e381c6/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
b/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
index 1da0fc0..72b18e8 100644
--- a/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
+++ b/core/src/test/java/brooklyn/location/access/PortForwardManagerRebindTest.java
@@ -14,6 +14,8 @@ import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.rebind.RebindTestFixtureWithApp;
 import brooklyn.entity.rebind.RebindTestUtils;
+import brooklyn.event.AttributeSensor;
+import brooklyn.event.basic.Sensors;
 import brooklyn.location.Location;
 import brooklyn.location.LocationSpec;
 import brooklyn.location.basic.SshMachineLocation;
@@ -52,7 +54,7 @@ public class PortForwardManagerRebindTest extends RebindTestFixtureWithApp
{
         String publicAddress = "5.6.7.8";
 
         TestEntity origEntity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class).impl(MyEntity.class));
-        PortForwardManager origPortForwardManager = origEntity.getConfig(MyEntity.PORT_FORWARDING_MANAGER);
+        PortForwardManager origPortForwardManager = origEntity.getConfig(MyEntity.PORT_FORWARD_MANAGER);
 
         // We first wait for persisted, to ensure that it is the PortForwardManager.onChanged
that is causing persistence.
         RebindTestUtils.waitForPersisted(origApp);
@@ -64,23 +66,37 @@ public class PortForwardManagerRebindTest extends RebindTestFixtureWithApp
{
         
         TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class));
         Location newSimulatedMachine = newApp.getManagementContext().getLocationManager().getLocation(origSimulatedMachine.getId());
-        PortForwardManager newPortForwardManager = newEntity.getConfig(MyEntity.PORT_FORWARDING_MANAGER);
+        PortForwardManager newPortForwardManager = newEntity.getConfig(MyEntity.PORT_FORWARD_MANAGER);
         
         assertEquals(newPortForwardManager.getPublicIpHostname(publicIpId), publicAddress);
         assertEquals(newPortForwardManager.lookup(newSimulatedMachine, 80), HostAndPort.fromParts(publicAddress,
40080));
     }
     
-    public static class MyEntity extends TestEntityImpl {
-        public static final ConfigKey<PortForwardManager> PORT_FORWARDING_MANAGER =
ConfigKeys.newConfigKey(PortForwardManager.class, "myentity.portForwardingManager");
+    public interface HasPfm {
+        PortForwardManager getPfm();
+    }
+    
+    public static class MyEntity extends TestEntityImpl implements HasPfm {
+        public static final ConfigKey<PortForwardManager> PORT_FORWARD_MANAGER = ConfigKeys.newConfigKey(PortForwardManager.class,
"myentity.portForwardManager");
+        public static final AttributeSensor<PortForwardManager> PORT_FORWARD_MANAGER_LIVE
= Sensors.newSensor(PortForwardManager.class, "myentity.portForwardManager.live");
 
         @Override
         public void init() {
             super.init();
             
-            if (getConfig(PORT_FORWARDING_MANAGER) == null) {
-                setConfig(PORT_FORWARDING_MANAGER, new PortForwardManager(this));
+            if (getConfig(PORT_FORWARD_MANAGER) == null) {
+                PortForwardManagerAuthority pfm = new PortForwardManagerAuthority();
+                pfm.injectOwningEntity(this);
+                setAttribute(PORT_FORWARD_MANAGER_LIVE, pfm);
+                setConfig(PORT_FORWARD_MANAGER, PortForwardManagerClient.fromMethodOnEntity(this,
"getPfm"));
             }
         }
+        
+        @Override
+        public PortForwardManager getPfm() {
+            return getAttribute(PORT_FORWARD_MANAGER_LIVE);
+        }
+        
         @SetFromFlag("myconfigflagname")
         public static final ConfigKey<String> MY_CONFIG_WITH_FLAGNAME = ConfigKeys.newStringConfigKey("myentity.myconfigwithflagname");
     }


Mime
View raw message