fixed up unit test

This commit is contained in:
Alex Huang 2011-11-11 14:14:53 -08:00
parent 9ca379fc61
commit ddbcd01f56
6 changed files with 117 additions and 101 deletions

View File

@ -1,8 +1,6 @@
package com.cloud.agent;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
@ -12,24 +10,13 @@ import com.cloud.agent.api.Command;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.manager.AgentAttache;
import com.cloud.agent.manager.Commands;
import com.cloud.api.commands.UpdateHostPasswordCmd;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.PodCluster;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConnectionException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.Host;
import com.cloud.host.Host.Type;
import com.cloud.host.HostStats;
import com.cloud.host.HostVO;
import com.cloud.host.Status.Event;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ServerResource;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.User;
import com.cloud.utils.Pair;
@Local(value = { AgentManager.class })
public class MockAgentManagerImpl implements AgentManager {
@ -102,7 +89,7 @@ public class MockAgentManagerImpl implements AgentManager {
@Override
public void unregisterForHostEvents(int id) {
// TODO Auto-generated method stub
}
@Override
@ -133,46 +120,52 @@ public class MockAgentManagerImpl implements AgentManager {
return null;
}
@Override
@Override
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
// TODO Auto-generated method stub
return false;
// TODO Auto-generated method stub
return false;
}
@Override
@Override
public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
// TODO Auto-generated method stub
return null;
// TODO Auto-generated method stub
return null;
}
@Override
@Override
public boolean agentStatusTransitTo(HostVO host, Event e, long msId) {
// TODO Auto-generated method stub
return false;
// TODO Auto-generated method stub
return false;
}
@Override
@Override
public AgentAttache findAttache(long hostId) {
// TODO Auto-generated method stub
return null;
// TODO Auto-generated method stub
return null;
}
@Override
@Override
public void pullAgentToMaintenance(long hostId) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
@Override
public void disconnectWithoutInvestigation(long hostId, Event event) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
@Override
public void pullAgentOutMaintenance(long hostId) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public Answer sendToSSVM(Long dcId, Command cmd) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -168,7 +168,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
return null;
}
@Override
public PublicIp assignSourceNatIpAddress(Account owner, Network network, long callerId) throws ConcurrentOperationException, InsufficientAddressCapacityException {
@ -216,7 +216,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
@Override
public void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException,
ResourceUnavailableException {
ResourceUnavailableException {
// TODO Auto-generated method stub
}
@ -277,7 +277,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
@Override
public Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
InsufficientCapacityException {
// TODO Auto-generated method stub
return null;
}
@ -315,7 +315,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
@Override
public boolean associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId, Network networkToAssociateWith) throws InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
ConcurrentOperationException, ResourceUnavailableException {
// TODO Auto-generated method stub
return false;
}
@ -433,12 +433,12 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Set<String>> listNetworkOfferingServices(long networkOfferingId) {
return null;
}
@Override
public List<? extends RemoteAccessVPNServiceProvider> getRemoteAccessVpnElements() {
return null;
@ -570,17 +570,17 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
return null;
}
@Override
@Override
public boolean restartNetwork(RestartNetworkCmd cmd, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException {
// TODO Auto-generated method stub
return false;
InsufficientCapacityException {
// TODO Auto-generated method stub
return false;
}
@Override
@Override
public Long getPodIdForVlan(long vlanDbId) {
// TODO Auto-generated method stub
return null;
// TODO Auto-generated method stub
return null;
}
@Override
@ -708,4 +708,10 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
// TODO Auto-generated method stub
return false;
}
@Override
public Long getPhysicalNetworkId(Network network) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -23,12 +23,6 @@ import com.cloud.utils.component.Manager;
@Local(value = { AccountManager.class, AccountService.class })
public class MockAccountManagerImpl implements Manager, AccountManager {
@Override
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean deleteUserAccount(long accountId) {
// TODO Auto-generated method stub
@ -229,45 +223,53 @@ public class MockAccountManagerImpl implements Manager, AccountManager {
public void checkAccess(Account account, AccessType accessType, ControlledEntity... entities) throws PermissionDeniedException {
// TODO Auto-generated method stub
}
@Override
public void logoutUser(Long userId) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
@Override
public UserAccount getUserAccount(String username, Long domainId) {
return null;
}
@Override
public UserAccount authenticateUser(String username, String password, Long domainId, Map<String, Object[]> requestParameters) {
return null;
}
@Override
public Pair<User, Account> findUserByApiKey(String apiKey) {
return null;
}
@Override
public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone) {
return null;
}
@Override
public Account createAccount(String accountName, short accountType, Long domainId, String networkDomain) {
return null;
}
@Override
public String[] createApiKeyAndSecretKey(RegisterCmd cmd) {
return null;
}
@Override
public boolean lockAccount(long accountId) {
return true;
}
@Override
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
Map details) {
// TODO Auto-generated method stub
return null;
}
@Override
public Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -10,6 +10,7 @@ import javax.naming.ConfigurationException;
import com.cloud.agent.api.StopAnswer;
import com.cloud.agent.api.VmStatsEntry;
import com.cloud.agent.manager.Commands;
import com.cloud.api.commands.AssignVMCmd;
import com.cloud.api.commands.AttachVolumeCmd;
import com.cloud.api.commands.CreateTemplateCmd;
import com.cloud.api.commands.CreateVMGroupCmd;
@ -18,10 +19,10 @@ import com.cloud.api.commands.DeployVMCmd;
import com.cloud.api.commands.DestroyVMCmd;
import com.cloud.api.commands.DetachVolumeCmd;
import com.cloud.api.commands.ListVMsCmd;
import com.cloud.api.commands.MoveUserVMCmd;
import com.cloud.api.commands.RebootVMCmd;
import com.cloud.api.commands.RecoverVMCmd;
import com.cloud.api.commands.ResetVMPasswordCmd;
import com.cloud.api.commands.RestoreVMCmd;
import com.cloud.api.commands.StartVMCmd;
import com.cloud.api.commands.UpdateVMCmd;
import com.cloud.api.commands.UpgradeVMCmd;
@ -38,6 +39,7 @@ import com.cloud.host.Host;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.Criteria;
import com.cloud.storage.StoragePool;
import com.cloud.storage.Volume;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.Account;
@ -234,7 +236,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
@Override
public UserVm startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException, ResourceAllocationException {
InsufficientCapacityException, ResourceAllocationException {
// TODO Auto-generated method stub
return null;
}
@ -269,7 +271,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
return null;
}
@Override
public UserVm startVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
@ -310,7 +312,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
@Override
public void deletePrivateTemplateRecord(Long templateId) {
// TODO Auto-generated method stub
}
@Override
@ -327,7 +329,7 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
@Override
public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException,
ResourceAllocationException {
ResourceAllocationException {
// TODO Auto-generated method stub
return null;
}
@ -365,14 +367,26 @@ public class MockUserVmManagerImpl implements UserVmManager, UserVmService, Mana
}
@Override
public UserVm moveVMToUser(MoveUserVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
public VirtualMachine migrateVirtualMachine(Long vmId, Host destinationHost) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
VirtualMachineMigrationException {
// TODO Auto-generated method stub
return null;
}
@Override
public VirtualMachine migrateVirtualMachine(Long vmId, Host destinationHost) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
VirtualMachineMigrationException {
public UserVm moveVMToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
// TODO Auto-generated method stub
return null;
}
@Override
public VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool) {
// TODO Auto-generated method stub
return null;
}
@Override
public UserVm restoreVM(RestoreVMCmd cmd) {
// TODO Auto-generated method stub
return null;
}

View File

@ -21,6 +21,7 @@ import com.cloud.network.NetworkVO;
import com.cloud.offering.ServiceOffering;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO;
import com.cloud.user.Account;
import com.cloud.user.User;
@ -82,7 +83,7 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
@Override
public <T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException,
ConcurrentOperationException {
ConcurrentOperationException {
// TODO Auto-generated method stub
return false;
}
@ -113,7 +114,7 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
@Override
public <T extends VMInstanceVO> T migrate(T vm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
VirtualMachineMigrationException {
VirtualMachineMigrationException {
// TODO Auto-generated method stub
return null;
}
@ -133,7 +134,7 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
@Override
public <T extends VMInstanceVO> T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings, List<Pair<NetworkVO, NicProfile>> networks, Map<Param, Object> params, DeploymentPlan plan, HypervisorType hyperType, Account owner)
throws InsufficientCapacityException {
throws InsufficientCapacityException {
// TODO Auto-generated method stub
return null;
}
@ -160,21 +161,21 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
@Override
public <T extends VMInstanceVO> T start(T vm, Map<Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
ResourceUnavailableException {
ResourceUnavailableException {
// TODO Auto-generated method stub
return null;
}
@Override
public <T extends VMInstanceVO> T advanceStart(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException,
ConcurrentOperationException, OperationTimedoutException {
ConcurrentOperationException, OperationTimedoutException {
// TODO Auto-generated method stub
return null;
}
@Override
public <T extends VMInstanceVO> T advanceStart(T vm, Map<Param, Object> params, User caller, Account account, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException {
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException {
// TODO Auto-generated method stub
return null;
}
@ -187,7 +188,7 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
@Override
public <T extends VMInstanceVO> T advanceReboot(T vm, Map<Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException,
ConcurrentOperationException, OperationTimedoutException {
ConcurrentOperationException, OperationTimedoutException {
// TODO Auto-generated method stub
return null;
}
@ -198,10 +199,10 @@ public class MockVirtualMachineManagerImpl implements VirtualMachineManager {
return null;
}
@Override
public VMInstanceVO findById(long vmId) {
// TODO Auto-generated method stub
return null;
@Override
public <T extends VMInstanceVO> T storageMigration(T vm, StoragePool storagePoolId) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -38,37 +38,37 @@ import com.cloud.utils.db.GenericDao;
*/
public class MockComponentLocator extends ComponentLocator {
MockComponentLibrary _library = new MockComponentLibrary();
public MockComponentLocator(String server) {
super(server);
}
public ComponentInfo<? extends GenericDao<?, ? extends Serializable>> addDao(String name, Class<? extends GenericDao<?, ? extends Serializable>> dao) {
return _library.addDao(name, dao);
}
public ComponentInfo<Manager> addManager(String name, Class<? extends Manager> manager) {
return _library.addManager(name, manager);
}
public <T> ComponentInfo<Adapter> addOneAdapter(Class<T> interphace, String name, Class<? extends T> adapterClass) {
return _library.addOneAdapter(interphace, name, adapterClass);
}
public <T> List<ComponentInfo<Adapter>> addAdapterChain(Class<T> interphace, List<Pair<String, Class<? extends T>>> adapters) {
return _library.addAdapterChain(interphace, adapters);
}
public <T> ComponentInfo<PluggableService> addService(String name, Class<T> serviceInterphace, Class<? extends PluggableService> service) {
return _library.addService(name, serviceInterphace, service);
}
@Override
protected Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>> parse2(String filename) {
Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>> result = new Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>>(new XmlHandler("fake"), new HashMap<String, List<ComponentInfo<Adapter>>>());
_daoMap = new LinkedHashMap<String, ComponentInfo<GenericDao<?, ? extends Serializable>>>();
_managerMap = new LinkedHashMap<String, ComponentInfo<Manager>>();
_checkerMap = new HashMap<String, ComponentInfo<SystemIntegrityChecker>>();
_checkerMap = new LinkedHashMap<String, ComponentInfo<SystemIntegrityChecker>>();
_adapterMap = new HashMap<String, Adapters<? extends Adapter>>();
_factories = new HashMap<Class<?>, Class<?>>();
_daoMap.putAll(_library.getDaos());
@ -77,7 +77,7 @@ public class MockComponentLocator extends ComponentLocator {
_factories.putAll(_library.getFactories());
return result;
}
public void makeActive(InterceptorLibrary interceptors) {
s_singletons.clear();
s_locators.clear();
@ -86,24 +86,24 @@ public class MockComponentLocator extends ComponentLocator {
s_callbackFilter = new DatabaseCallbackFilter();
s_interceptors.clear();
if (interceptors != null) {
resetInterceptors(interceptors);
resetInterceptors(interceptors);
}
s_tl.set(this);
parse("fake file");
}
protected class MockComponentLibrary extends ComponentLibraryBase implements ComponentLibrary {
@Override
public Map<String, List<ComponentInfo<Adapter>>> getAdapters() {
return _adapters;
}
@Override
public Map<Class<?>, Class<?>> getFactories() {
return new HashMap<Class<?>, Class<?>>();
}
@Override
public Map<String, ComponentInfo<GenericDao<?, ?>>> getDaos() {
return _daos;
@ -116,7 +116,7 @@ public class MockComponentLocator extends ComponentLocator {
@Override
public Map<String, ComponentInfo<PluggableService>> getPluggableServices() {
return _pluggableServices;
return _pluggableServices;
}
}
}