You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/01/21 11:57:51 UTC

[2/4] incubator-brooklyn git commit: Add more tests. Correct typo.

Add more tests. Correct typo.


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

Branch: refs/heads/master
Commit: 9f178a63bf14a62c9c7d266542164f24a887c386
Parents: 6b43665
Author: Guglielmo Nigri <gu...@cloudsoftcorp.com>
Authored: Tue Jan 19 15:34:12 2016 +0100
Committer: Guglielmo Nigri <gu...@cloudsoftcorp.com>
Committed: Tue Jan 19 15:34:12 2016 +0100

----------------------------------------------------------------------
 .../entity/software/base/SoftwareProcess.java   |  2 +-
 ...eServerDriverLifecycleEffectorTasksTest.java | 52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9f178a63/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
index 0478677..c0e87bd 100644
--- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
+++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
@@ -66,7 +66,7 @@ public interface SoftwareProcess extends Entity, Startable {
             ImmutableSet.of(22));
 
     ConfigKey<String> INBOUND_PORTS_CONFIG_REGEX = ConfigKeys.newStringConfigKey("inboundPorts.configRegex",
-            "Regex governing the opening of ports based on sensor names",
+            "Regex governing the opening of ports based on config names",
             ".*\\.port");
 
     ConfigKey<Boolean> INBOUND_PORTS_AUTO_INFER = ConfigKeys.newBooleanConfigKey("inboundPorts.autoInfer",

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/9f178a63/brooklyn-server/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerDriverLifecycleEffectorTasksTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerDriverLifecycleEffectorTasksTest.java b/brooklyn-server/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerDriverLifecycleEffectorTasksTest.java
index 6aa8122..d79274e 100644
--- a/brooklyn-server/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerDriverLifecycleEffectorTasksTest.java
+++ b/brooklyn-server/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerDriverLifecycleEffectorTasksTest.java
@@ -49,6 +49,8 @@ public class SameServerDriverLifecycleEffectorTasksTest extends BrooklynAppUnitT
                 "test.double", "double", 2.0);
         ConfigKey<String> STRING = ConfigKeys.newStringConfigKey(
                 "test.string", "string", "3");
+        ConfigKey<Integer> REGEX_PORT = ConfigKeys.newIntegerConfigKey(
+                "my.port", "int", null);
     }
 
     public static class EntityWithConfigImpl extends AbstractEntity implements EntityWithConfig {
@@ -69,4 +71,54 @@ public class SameServerDriverLifecycleEffectorTasksTest extends BrooklynAppUnitT
                 "expected=" + Iterables.toString(expected) + ", actual=" + Iterables.toString(requiredPorts));
     }
 
+    @Test
+    public void testGetRequiredOpenPortsByConfigName() {
+        SameServerEntity entity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class).child(
+                EntitySpec.create(EntityWithConfig.class)
+                        // Previously SSDLET coerced everything TypeCoercions could handle to a port!
+                        .configure(EntityWithConfig.INTEGER, 1)
+                        .configure(EntityWithConfig.DOUBLE, 2.0)
+                        .configure(EntityWithConfig.STRING, "3")
+                        .configure(EntityWithConfig.REGEX_PORT, 4321)));
+        SameServerDriverLifecycleEffectorTasks effectorTasks = new SameServerDriverLifecycleEffectorTasks();
+        Collection<Integer> requiredPorts = effectorTasks.getRequiredOpenPorts(entity);
+        final ImmutableSet<Integer> expected = ImmutableSet.of(22, 1234, 4321);
+        assertEquals(requiredPorts, expected,
+                "expected=" + Iterables.toString(expected) + ", actual=" + Iterables.toString(requiredPorts));
+    }
+
+    @Test
+    public void testGetRequiredOpenPortsNoAutoInfer() {
+        SameServerEntity entity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class)
+                .child(
+                        EntitySpec.create(EntityWithConfig.class)
+                                // Previously SSDLET coerced everything TypeCoercions could handle to a port!
+                                .configure(EntityWithConfig.INTEGER, 1)
+                                .configure(EntityWithConfig.DOUBLE, 2.0)
+                                .configure(EntityWithConfig.STRING, "3")
+                                .configure(EntityWithConfig.REGEX_PORT, 4321)
+                                .configure(SameServerEntity.INBOUND_PORTS_AUTO_INFER, false)));
+        SameServerDriverLifecycleEffectorTasks effectorTasks = new SameServerDriverLifecycleEffectorTasks();
+        Collection<Integer> requiredPorts = effectorTasks.getRequiredOpenPorts(entity);
+        final ImmutableSet<Integer> expected = ImmutableSet.of(22);
+        assertEquals(requiredPorts, expected,
+                "expected=" + Iterables.toString(expected) + ", actual=" + Iterables.toString(requiredPorts));
+    }
+
+    @Test
+    public void testGetRequiredOpenPortsWithCustomLoginPort() {
+        SameServerEntity entity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class)
+                .configure(SameServerEntity.REQUIRED_OPEN_LOGIN_PORTS, ImmutableSet.of(2022))
+                .child(
+                        EntitySpec.create(EntityWithConfig.class)
+                                // Previously SSDLET coerced everything TypeCoercions could handle to a port!
+                                .configure(EntityWithConfig.INTEGER, 1)
+                                .configure(EntityWithConfig.DOUBLE, 2.0)
+                                .configure(EntityWithConfig.STRING, "3")));
+        SameServerDriverLifecycleEffectorTasks effectorTasks = new SameServerDriverLifecycleEffectorTasks();
+        Collection<Integer> requiredPorts = effectorTasks.getRequiredOpenPorts(entity);
+        final ImmutableSet<Integer> expected = ImmutableSet.of(2022, 1234);
+        assertEquals(requiredPorts, expected,
+                "expected=" + Iterables.toString(expected) + ", actual=" + Iterables.toString(requiredPorts));
+    }
 }