stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject stratos git commit: Fixing cloud controller context unit test issue
Date Fri, 26 Jun 2015 09:40:32 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 38c0714d6 -> a42e84da8


Fixing cloud controller context unit test issue


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

Branch: refs/heads/master
Commit: a42e84da8a9abe08177e4c39d63062fb03e3eb38
Parents: 38c0714
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Fri Jun 26 15:10:12 2015 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Fri Jun 26 15:10:26 2015 +0530

----------------------------------------------------------------------
 .../cloud/controller/context/CloudControllerContext.java     | 8 ++++++--
 .../autoscaler/service/axiom/CloudControllerContextTest.java | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a42e84da/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
index 626f3c8..708a24b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
@@ -52,6 +52,8 @@ public class CloudControllerContext implements Serializable {
     private static final long serialVersionUID = -2662307358852779897L;
     private static final Log log = LogFactory.getLog(CloudControllerContext.class);
 
+    public static boolean unitTest = false;
+
     private static final String CC_CLUSTER_ID_TO_MEMBER_CTX_MAP = "CC_CLUSTER_ID_TO_MEMBER_CTX_MAP";
     private static final String CC_CLUSTER_ID_TO_CLUSTER_CTX = "CC_CLUSTER_ID_TO_CLUSTER_CTX";
     private static final String CC_MEMBER_ID_TO_MEMBER_CTX_MAP = "CC_MEMBER_ID_TO_MEMBER_CTX_MAP";
@@ -203,8 +205,10 @@ public class CloudControllerContext implements Serializable {
         cartridgeTypeToIaasProviders = distributedObjectProvider.getMap(CC_CARTRIDGE_TYPE_TO_IAAS_PROVIDER_MAP);
         applicationIdToClusterIdToPortMappings = distributedObjectProvider.getMap(CC_APPLICATION_ID_TO_CLUSTER_ID_TO_PORT_MAPPING_MAP);
 
-        // Update context from the registry
-        updateContextFromRegistry();
+        if(!unitTest) {
+            // Update context from the registry
+            updateContextFromRegistry();
+        }
     }
 
     public static CloudControllerContext getInstance() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/a42e84da/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
index 164e239..8974a63 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/cartridge/autoscaler/service/axiom/CloudControllerContextTest.java
@@ -42,6 +42,7 @@ public class CloudControllerContextTest extends TestCase {
         ServiceReferenceHolder.getInstance().setDistributedObjectProvider(new HazelcastDistributedObjectProvider());
         ServiceReferenceHolder.getInstance().setAxisConfiguration(axisConfiguration);
 
+        CloudControllerContext.unitTest = true;
         CloudControllerContext cloudControllerContext = CloudControllerContext.getInstance();
 
         Thread t1 = new Thread(new MemberAdder(cloudControllerContext));
@@ -53,7 +54,6 @@ public class CloudControllerContextTest extends TestCase {
         t2.start();
         t2.join();
         assertEquals(1, cloudControllerContext.getMemberContextsOfClusterId("cluster-1").size());
-
     }
 
     class MemberAdder implements Runnable {


Mime
View raw message