You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/05/31 14:06:46 UTC
[06/14] Moved UserContext to its proper place as CallContext
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
index 44802e0..ecb3931 100644
--- a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
+++ b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
@@ -25,7 +25,6 @@ import com.cloud.region.ha.GlobalLoadBalancerRule;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
-import com.cloud.user.UserContext;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.net.Ip;
import junit.framework.Assert;
@@ -34,6 +33,7 @@ import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadB
import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.RemoveFromGlobalLoadBalancerRuleCmd;
+import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.region.RegionVO;
import org.apache.cloudstack.region.dao.RegionDao;
import org.apache.log4j.Logger;
@@ -499,7 +499,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -564,7 +564,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 3, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -651,7 +651,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -710,7 +710,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -783,7 +783,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -845,7 +845,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -891,7 +891,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
@@ -939,7 +939,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Account account = (Account) new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(gslbServiceImpl._accountMgr.getAccount(anyLong())).thenReturn(account);
- UserContext.register(1, account, null, true);
+ CallContext.register(1, account, null, true);
Field gslbRuleId = _class.getDeclaredField("id");
gslbRuleId.setAccessible(true);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8261b87/utils/src/com/cloud/utils/UuidUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/UuidUtils.java b/utils/src/com/cloud/utils/UuidUtils.java
new file mode 100644
index 0000000..7831bea
--- /dev/null
+++ b/utils/src/com/cloud/utils/UuidUtils.java
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.utils;
+
+public class UuidUtils {
+ public final static String first(String uuid) {
+ return uuid.substring(0, uuid.indexOf('-'));
+ }
+}