Fixed up the unit tests

This commit is contained in:
Alex Huang 2013-08-15 19:46:05 -07:00
parent 45d239882b
commit 9f62df580e
6 changed files with 46 additions and 17 deletions

View File

@ -740,6 +740,12 @@
<property name="DhcpProviders" value="#{dhcpProviders.Adapters}" />
</bean>
<bean id="ipAddressManagerImpl" class="com.cloud.network.IpAddressManagerImpl" >
<property name="NetworkGurus" value="#{networkGurus.Adapters}" />
<property name="NetworkElements" value="#{networkElements.Adapters}" />
<property name="IpDeployers" value="#{ipDeployers.Adapters}" />
<property name="DhcpProviders" value="#{dhcpProviders.Adapters}" />
</bean>
<bean id="networkModelImpl" class="com.cloud.network.NetworkModelImpl">
<property name="NetworkElements" value="#{networkElements.Adapters}" />
</bean>

View File

@ -5,7 +5,7 @@
// 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,
@ -18,9 +18,6 @@ package org.apache.cloudstack.internallbelement;
import java.io.IOException;
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
import org.apache.cloudstack.test.utils.SpringUtils;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@ -31,9 +28,13 @@ import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
import org.apache.cloudstack.test.utils.SpringUtils;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.dao.AccountVlanMapDaoImpl;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.network.IpAddressManager;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkModel;
import com.cloud.network.dao.NetworkServiceMapDao;
@ -53,7 +54,7 @@ import com.cloud.vm.dao.DomainRouterDao;
)
public class ElementChildTestConfiguration {
public static class Library implements TypeFilter {
public static class Library implements TypeFilter {
@Bean
public AccountManager accountManager() {
return Mockito.mock(AccountManager.class);
@ -81,6 +82,10 @@ public class ElementChildTestConfiguration {
return Mockito.mock(NetworkManager.class);
}
@Bean
public IpAddressManager ipAddressManager() {
return Mockito.mock(IpAddressManager.class);
}
@Bean
public PhysicalNetworkServiceProviderDao physicalNetworkServiceProviderDao() {

View File

@ -5,7 +5,7 @@
// 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,
@ -18,10 +18,6 @@ package org.apache.cloudstack.internallbvmmgr;
import java.io.IOException;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
import org.apache.cloudstack.test.utils.SpringUtils;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@ -32,9 +28,13 @@ import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
import org.apache.cloudstack.test.utils.SpringUtils;
import com.cloud.agent.AgentManager;
import com.cloud.dc.dao.AccountVlanMapDaoImpl;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.network.IpAddressManager;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkModel;
import com.cloud.network.dao.NetworkDao;
@ -47,11 +47,11 @@ import com.cloud.server.ConfigurationServer;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.user.AccountManager;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.user.dao.AccountDao;
@Configuration
@ -124,6 +124,11 @@ import com.cloud.user.dao.AccountDao;
}
@Bean
public IpAddressManager ipAddressManager() {
return Mockito.mock(IpAddressManager.class);
}
@Bean
public ServiceOfferingDao serviceOfferingDao() {
return Mockito.mock(ServiceOfferingDao.class);
}

View File

@ -107,6 +107,7 @@ public class ConfigurationManagerTest {
configurationMgr._publicIpAddressDao = _publicIpAddressDao;
configurationMgr._zoneDao = _zoneDao;
configurationMgr._firewallDao = _firewallDao;
configurationMgr._ipAddrMgr = _ipAddrMgr;
Account account = new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
when(configurationMgr._accountMgr.getAccount(anyLong())).thenReturn(account);

View File

@ -5,7 +5,7 @@
// 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,
@ -18,8 +18,6 @@ package org.apache.cloudstack.lb;
import java.io.IOException;
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
import org.apache.cloudstack.test.utils.SpringUtils;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@ -30,8 +28,11 @@ import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;
import com.cloud.dc.dao.AccountVlanMapDaoImpl;
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
import org.apache.cloudstack.test.utils.SpringUtils;
import com.cloud.event.dao.UsageEventDao;
import com.cloud.network.IpAddressManager;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkModel;
import com.cloud.network.dao.FirewallRulesDao;
@ -59,6 +60,11 @@ import com.cloud.utils.net.NetUtils;
return Mockito.mock(ApplicationLoadBalancerRuleDao.class);
}
@Bean
IpAddressManager ipAddressManager() {
return Mockito.mock(IpAddressManager.class);
}
@Bean
public NetworkModel networkModel() {
return Mockito.mock(NetworkModel.class);

View File

@ -62,6 +62,7 @@ import com.cloud.event.dao.UsageEventDaoImpl;
import com.cloud.host.dao.HostDaoImpl;
import com.cloud.host.dao.HostDetailsDaoImpl;
import com.cloud.host.dao.HostTagsDaoImpl;
import com.cloud.network.IpAddressManager;
import com.cloud.network.Ipv6AddressManager;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkModel;
@ -308,6 +309,11 @@ public class ChildTestConfiguration {
return Mockito.mock(NetworkManager.class);
}
@Bean
public IpAddressManager ipAddressManager() {
return Mockito.mock(IpAddressManager.class);
}
@Bean
public NetworkOfferingDao networkOfferingDao() {
return Mockito.mock(NetworkOfferingDao.class);