brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/3] brooklyn-server git commit: Move vanilla newNodeCreator to AbstractJcloudsStubbedUnitTest
Date Tue, 11 Oct 2016 14:52:15 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 0b5c1bed6 -> 9846f6e26


Move vanilla newNodeCreator to AbstractJcloudsStubbedUnitTest

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

Branch: refs/heads/master
Commit: 9b7a0e6071acd6e850c9117fb2328056addc6509
Parents: fea8a6e
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Oct 11 12:25:05 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Oct 11 12:25:05 2016 +0100

----------------------------------------------------------------------
 .../jclouds/AbstractJcloudsStubbedUnitTest.java | 27 ++++++++++++++++++++
 .../JcloudsPortForwardingStubbedTest.java       | 25 +-----------------
 2 files changed, 28 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9b7a0e60/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsStubbedUnitTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsStubbedUnitTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsStubbedUnitTest.java
index 71111d1..0fa0e94 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsStubbedUnitTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsStubbedUnitTest.java
@@ -19,20 +19,28 @@
 package org.apache.brooklyn.location.jclouds;
 
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.location.jclouds.StubbedComputeServiceRegistry.AbstractNodeCreator;
 import org.apache.brooklyn.location.jclouds.StubbedComputeServiceRegistry.NodeCreator;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
 import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
 import org.apache.brooklyn.util.core.internal.winrm.RecordingWinRmTool;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.LoginCredentials;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 
 import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
 /**
@@ -104,4 +112,23 @@ public abstract class AbstractJcloudsStubbedUnitTest extends AbstractJcloudsLive
     protected String getLocationSpec() {
         return LOCATION_SPEC;
     }
+    
+    protected NodeCreator newVanillaNodeCreator() {
+        return new AbstractNodeCreator() {
+            private final AtomicInteger counter = new AtomicInteger(1);
+            @Override
+            protected NodeMetadata newNode(String group, Template template) {
+                int suffix = counter.getAndIncrement();
+                NodeMetadata result = new NodeMetadataBuilder()
+                        .id("mynodeid"+suffix)
+                        .credentials(LoginCredentials.builder().identity("myuser").credential("mypassword").build())
+                        .loginPort(22)
+                        .status(Status.RUNNING)
+                        .publicAddresses(ImmutableList.of("173.194.32."+suffix))
+                        .privateAddresses(ImmutableList.of("172.168.10."+suffix))
+                        .build();
+                return result;
+            }
+        };
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9b7a0e60/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwardingStubbedTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwardingStubbedTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwardingStubbedTest.java
index 4ca6765..22cea5a 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwardingStubbedTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwardingStubbedTest.java
@@ -33,10 +33,6 @@ import org.apache.brooklyn.location.jclouds.StubbedComputeServiceRegistry.Abstra
 import org.apache.brooklyn.util.net.Cidr;
 import org.apache.brooklyn.util.net.Protocol;
 import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.domain.LoginCredentials;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeMethod;
@@ -81,28 +77,9 @@ public class JcloudsPortForwardingStubbedTest extends AbstractJcloudsStubbedUnit
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        initNodeCreatorAndJcloudsLocation(newNodeCreator(), ImmutableMap.of());
+        initNodeCreatorAndJcloudsLocation(newVanillaNodeCreator(), ImmutableMap.of());
     }
     
-    protected AbstractNodeCreator newNodeCreator() {
-        return new AbstractNodeCreator() {
-            int nextIpSuffix = 2;
-            @Override
-            protected NodeMetadata newNode(String group, Template template) {
-                int ipSuffix = nextIpSuffix++;
-                NodeMetadata result = new NodeMetadataBuilder()
-                        .id("myid-"+ipSuffix)
-                        .credentials(LoginCredentials.builder().identity("myuser").credential("mypassword").build())
-                        .loginPort(22)
-                        .status(Status.RUNNING)
-                        .publicAddresses(ImmutableList.of("173.194.32."+ipSuffix))
-                        .privateAddresses(ImmutableList.of("172.168.10."+ipSuffix))
-                        .build();
-                return result;
-            }
-        };
-    }
-
     protected AbstractNodeCreator getNodeCreator() {
         return (AbstractNodeCreator) nodeCreator;
     }


Mime
View raw message