Skip to content

Commit 1f5699b

Browse files
author
Alex Huang
committed
Fixed unit tests
1 parent 8f556e6 commit 1f5699b

10 files changed

Lines changed: 181 additions & 514 deletions

File tree

engine/storage/integration-test/test/org/apache/cloudstack/storage/test/EndpointSelectorTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
5959

6060
import com.cloud.agent.AgentManager;
61-
<<<<<<< HEAD
62-
import com.cloud.server.LockMasterListener;
63-
=======
64-
>>>>>>> Made changes to configuration. Eliminated ConfigValue and only use ConfigKey
6561
import com.cloud.dc.ClusterVO;
6662
import com.cloud.dc.DataCenter;
6763
import com.cloud.dc.DataCenterVO;

framework/config/src/org/apache/cloudstack/framework/config/ConfigKey.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ public T value() {
139139
return _value;
140140
}
141141

142-
public T valueIn(long id) {
142+
public T valueIn(Long id) {
143+
if (id == null) {
144+
return value();
145+
}
146+
143147
String value = s_depot != null ? s_depot.scoped(this).getConfigValue(id, this) : null;
144148
if (value == null) {
145149
return value();

plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.log4j.Logger;
3030

3131
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
32-
import org.apache.cloudstack.framework.config.ConfigDepot;
3332
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3433
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
3534
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
@@ -88,7 +87,6 @@
8887
import com.cloud.offering.ServiceOffering;
8988
import com.cloud.offerings.dao.NetworkOfferingDao;
9089
import com.cloud.resource.ResourceManager;
91-
import com.cloud.server.ConfigurationServer;
9290
import com.cloud.service.ServiceOfferingVO;
9391
import com.cloud.service.dao.ServiceOfferingDao;
9492
import com.cloud.storage.VMTemplateVO;
@@ -148,9 +146,6 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements In
148146
@Inject NetworkOfferingDao _networkOfferingDao;
149147
@Inject VMTemplateDao _templateDao;
150148
@Inject ResourceManager _resourceMgr;
151-
@Inject ConfigurationServer _configServer;
152-
@Inject
153-
ConfigDepot _configDepot;
154149

155150
@Override
156151
public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile,

plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161

6262
@RunWith(SpringJUnit4ClassRunner.class)
6363
@ContextConfiguration(locations="classpath:/lb_svc.xml")
64-
@SuppressWarnings("unchecked")
6564
public class InternalLBVMServiceTest extends TestCase {
6665
//The interface to test
6766
@Inject InternalLoadBalancerVMService _lbVmSvc;

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Collection;
2626
import java.util.HashMap;
2727
import java.util.HashSet;
28-
import java.util.Hashtable;
2928
import java.util.Iterator;
3029
import java.util.List;
3130
import java.util.Map;
@@ -35,10 +34,6 @@
3534
import javax.ejb.Local;
3635
import javax.inject.Inject;
3736
import javax.naming.ConfigurationException;
38-
import javax.naming.Context;
39-
import javax.naming.NamingException;
40-
import javax.naming.directory.DirContext;
41-
import javax.naming.directory.InitialDirContext;
4237

4338
import org.apache.log4j.Logger;
4439

@@ -191,7 +186,6 @@
191186
import com.cloud.utils.Pair;
192187
import com.cloud.utils.StringUtils;
193188
import com.cloud.utils.component.ManagerBase;
194-
import com.cloud.utils.crypt.DBEncryptionUtil;
195189
import com.cloud.utils.db.DB;
196190
import com.cloud.utils.db.EntityManager;
197191
import com.cloud.utils.db.Filter;

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ public boolean configure(String name, Map<String, Object> params)
15211521
VirtualMachine.State.getStateMachine().registerListener(
15221522
new UserVmStateListener(_usageEventDao, _networkDao, _nicDao));
15231523

1524-
value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key());
1524+
String value = _configDao.getValue(Config.SetVmInternalNameUsingDisplayName.key());
15251525
_instanceNameFlag = (value == null)?false:Boolean.parseBoolean(value);
15261526

15271527
_scaleRetry = NumbersUtil.parseInt(configs.get(Config.ScaleRetry.key()), 2);

server/test/com/cloud/vpc/NetworkACLServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void tearDown() {
147147

148148
@Test
149149
public void testCreateACL() throws Exception {
150-
Mockito.when(_entityMgr.findById(Vpc.class, Mockito.anyLong())).thenReturn(new VpcVO());
150+
Mockito.when(_entityMgr.findById(Mockito.eq(Vpc.class), Mockito.anyLong())).thenReturn(new VpcVO());
151151
Mockito.when(_networkAclMgr.createNetworkACL("acl_new", "acl desc", 1L)).thenReturn(acl);
152152
assertNotNull(_aclService.createNetworkACL("acl_new", "acl desc", 1L));
153153
}
@@ -161,7 +161,7 @@ public void testDeleteDefaultACL() throws Exception {
161161

162162
@Test
163163
public void testCreateACLItem() throws Exception {
164-
Mockito.when(_entityMgr.findById(Vpc.class, Mockito.anyLong())).thenReturn(new VpcVO());
164+
Mockito.when(_entityMgr.findById(Mockito.eq(Vpc.class), Mockito.anyLong())).thenReturn(new VpcVO());
165165
Mockito.when(_networkAclMgr.getNetworkACL(Mockito.anyLong())).thenReturn(acl);
166166
Mockito.when(_networkAclMgr.createNetworkACLItem(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyString(), Mockito.anyList(), Mockito.anyInt(), Mockito.anyInt(),
167167
Mockito.any(NetworkACLItem.TrafficType.class), Mockito.anyLong(), Mockito.anyString(), Mockito.anyInt())).thenReturn(new NetworkACLItemVO());
@@ -171,7 +171,7 @@ public void testCreateACLItem() throws Exception {
171171

172172
@Test(expected = InvalidParameterValueException.class)
173173
public void testCreateACLItemDuplicateNumber() throws Exception {
174-
Mockito.when(_entityMgr.findById(Vpc.class, Mockito.anyLong())).thenReturn(new VpcVO());
174+
Mockito.when(_entityMgr.findById(Mockito.eq(Vpc.class), Mockito.anyLong())).thenReturn(new VpcVO());
175175
Mockito.when(_networkAclMgr.getNetworkACL(Mockito.anyLong())).thenReturn(acl);
176176
Mockito.when(_networkACLItemDao.findByAclAndNumber(Mockito.anyLong(), Mockito.anyInt())).thenReturn(new NetworkACLItemVO());
177177
_aclService.createNetworkACLItem(createACLItemCmd);

0 commit comments

Comments
 (0)