You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ni...@apache.org on 2013/05/11 11:59:47 UTC
[22/51] [partial] merge master
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/src/com/cloud/vm/VMInstanceVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/vm/VMInstanceVO.java b/core/src/com/cloud/vm/VMInstanceVO.java
deleted file mode 100644
index 5f93019..0000000
--- a/core/src/com/cloud/vm/VMInstanceVO.java
+++ /dev/null
@@ -1,494 +0,0 @@
-// 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.vm;
-
-import java.util.Date;
-import java.util.Map;
-import java.util.Random;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.DiscriminatorColumn;
-import javax.persistence.DiscriminatorType;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.utils.db.Encrypt;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.StateMachine;
-import com.cloud.utils.fsm.FiniteStateObject;
-import com.cloud.vm.VirtualMachine.State;
-
-@Entity
-@Table(name="vm_instance")
-@Inheritance(strategy=InheritanceType.JOINED)
-@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING, length=32)
-public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, VirtualMachine.Event> {
- @Id
- @TableGenerator(name="vm_instance_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="vm_instance_seq", allocationSize=1)
- @Column(name="id", updatable=false, nullable = false)
- protected long id;
-
- @Column(name="name", updatable=false, nullable=false, length=255)
- protected String hostName = null;
-
- @Encrypt
- @Column(name="vnc_password", updatable=true, nullable=false, length=255)
- protected String vncPassword;
-
- @Column(name="proxy_id", updatable=true, nullable=true)
- protected Long proxyId;
-
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name="proxy_assign_time", updatable=true, nullable=true)
- protected Date proxyAssignTime;
-
- /**
- * Note that state is intentionally missing the setter. Any updates to
- * the state machine needs to go through the DAO object because someone
- * else could be updating it as well.
- */
- @Enumerated(value=EnumType.STRING)
- @StateMachine(state=State.class, event=Event.class)
- @Column(name="state", updatable=true, nullable=false, length=32)
- protected State state = null;
-
- @Column(name="private_ip_address", updatable=true)
- protected String privateIpAddress;
-
- @Column(name="instance_name", updatable=true, nullable=false)
- protected String instanceName;
-
- @Column(name="vm_template_id", updatable=true, nullable=true, length=17)
- protected Long templateId = new Long(-1);
-
- @Column(name="guest_os_id", nullable=false, length=17)
- protected long guestOSId;
-
- @Column(name="host_id", updatable=true, nullable=true)
- protected Long hostId;
-
- @Column(name="last_host_id", updatable=true, nullable=true)
- protected Long lastHostId;
-
- @Column(name="pod_id", updatable=true, nullable=false)
- protected Long podIdToDeployIn;
-
- @Column(name="private_mac_address", updatable=true, nullable=true)
- protected String privateMacAddress;
-
- @Column(name="data_center_id", updatable=true, nullable=false)
- protected long dataCenterId;
-
- @Column(name="vm_type", updatable=false, nullable=false, length=32)
- @Enumerated(value=EnumType.STRING)
- protected Type type;
-
- @Column(name="ha_enabled", updatable=true, nullable=true)
- protected boolean haEnabled;
-
- @Column(name="display_vm", updatable=true, nullable=false)
- protected boolean displayVm = true;
-
- @Column(name="limit_cpu_use", updatable=true, nullable=true)
- private boolean limitCpuUse;
-
- @Column(name="update_count", updatable = true, nullable=false)
- protected long updated; // This field should be updated everytime the state is updated. There's no set method in the vo object because it is done with in the dao code.
-
- @Column(name=GenericDao.CREATED_COLUMN)
- protected Date created;
-
- @Column(name=GenericDao.REMOVED_COLUMN)
- protected Date removed;
-
- @Column(name="update_time", updatable=true)
- @Temporal(value=TemporalType.TIMESTAMP)
- protected Date updateTime;
-
- @Column(name="domain_id")
- protected long domainId;
-
- @Column(name="account_id")
- protected long accountId;
-
- @Column(name="service_offering_id")
- protected long serviceOfferingId;
-
- @Column(name="reservation_id")
- protected String reservationId;
-
- @Column(name="hypervisor_type")
- @Enumerated(value=EnumType.STRING)
- protected HypervisorType hypervisorType;
-
-/*
- @Column(name="tags")
- protected String tags;
-*/
-
- @Transient
- Map<String, String> details;
-
- @Column(name="uuid")
- protected String uuid = UUID.randomUUID().toString();
- ;
-
- @Column(name="disk_offering_id")
- protected Long diskOfferingId;
-
- public VMInstanceVO(long id,
- long serviceOfferingId,
- String name,
- String instanceName,
- Type type,
- Long vmTemplateId,
- HypervisorType hypervisorType,
- long guestOSId,
- long domainId,
- long accountId,
- boolean haEnabled) {
- this.id = id;
- this.hostName = name != null ? name : this.uuid;
- if (vmTemplateId != null) {
- this.templateId = vmTemplateId;
- }
- this.instanceName = instanceName;
- this.type = type;
- this.guestOSId = guestOSId;
- this.haEnabled = haEnabled;
- this.vncPassword = Long.toHexString(new Random().nextLong());
- this.state = State.Stopped;
- this.accountId = accountId;
- this.domainId = domainId;
- this.serviceOfferingId = serviceOfferingId;
- this.hypervisorType = hypervisorType;
- this.limitCpuUse = false;
- }
-
- public VMInstanceVO(long id,
- long serviceOfferingId,
- String name,
- String instanceName,
- Type type,
- Long vmTemplateId,
- HypervisorType hypervisorType,
- long guestOSId,
- long domainId,
- long accountId,
- boolean haEnabled,
- boolean limitResourceUse, Long diskOfferingId) {
- this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
- this.limitCpuUse = limitResourceUse;
- this.diskOfferingId = diskOfferingId;
- }
-
- protected VMInstanceVO() {
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- @Override
- public long getDomainId() {
- return domainId;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- @Override
- public Type getType() {
- return type;
- }
-
- public long getUpdated() {
- return updated;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- @Override
- public HypervisorType getHypervisorType() {
- return hypervisorType;
- }
-
- @Override
- public Date getCreated() {
- return created;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- @Override
- public long getDataCenterId() {
- return dataCenterId;
- }
-
- @Override
- public String getHostName() {
- return hostName;
- }
-
- @Override
- public String getInstanceName() {
- return instanceName;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- // don't use this directly, use VM state machine instead, this method is added for migration tool only
- @Override
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public String getPrivateIpAddress() {
- return privateIpAddress;
- }
-
- public void setPrivateIpAddress(String address) {
- privateIpAddress = address;
- }
-
- public void setVncPassword(String vncPassword) {
- this.vncPassword = vncPassword;
- }
-
- @Override
- public String getVncPassword() {
- return vncPassword;
- }
-
- @Override
- public long getServiceOfferingId() {
- return serviceOfferingId;
- }
-
- public Long getProxyId() {
- return proxyId;
- }
-
- public void setProxyId(Long proxyId) {
- this.proxyId = proxyId;
- }
-
- public Date getProxyAssignTime() {
- return this.proxyAssignTime;
- }
-
- public void setProxyAssignTime(Date time) {
- this.proxyAssignTime = time;
- }
-
- @Override
- public long getTemplateId() {
- if (templateId == null) {
- return -1;
- } else {
- return templateId;
- }
- }
-
- public void setTemplateId(Long templateId) {
- this.templateId = templateId;
- }
-
- @Override
- public long getGuestOSId() {
- return guestOSId;
- }
-
- public void setGuestOSId(long guestOSId) {
- this.guestOSId = guestOSId;
- }
-
- public void incrUpdated() {
- updated++;
- }
-
- public void decrUpdated() {
- updated--;
- }
-
- @Override
- public Long getHostId() {
- return hostId;
- }
-
- @Override
- public Long getLastHostId() {
- return lastHostId;
- }
-
- public void setLastHostId(Long lastHostId) {
- this.lastHostId = lastHostId;
- }
-
- public void setHostId(Long hostId) {
- this.hostId = hostId;
- }
-
- @Override
- public boolean isHaEnabled() {
- return haEnabled;
- }
-
- public boolean isDisplayVm() {
- return displayVm;
- }
-
- public void setDisplayVm(boolean displayVm) {
- this.displayVm = displayVm;
- }
-
- @Override
- public boolean limitCpuUse() {
- return limitCpuUse;
- }
-
- public void setLimitCpuUse(boolean value) {
- limitCpuUse = value;
- }
-
- @Override
- public String getPrivateMacAddress() {
- return privateMacAddress;
- }
-
- @Override
- public Long getPodIdToDeployIn() {
- return podIdToDeployIn;
- }
-
- public void setPodId(long podId) {
- this.podIdToDeployIn = podId;
- }
-
- public void setPrivateMacAddress(String privateMacAddress) {
- this.privateMacAddress = privateMacAddress;
- }
-
- public void setDataCenterId(long dataCenterId) {
- this.dataCenterId = dataCenterId;
- }
-
- public boolean isRemoved() {
- return removed != null;
- }
-
- public void setHaEnabled(boolean value) {
- haEnabled = value;
- }
-
- public void setReservationId(String reservationId) {
- this.reservationId = reservationId;
- }
-
- public String getReservationId() {
- return this.reservationId;
- }
-
- @Override
- public Map<String, String> getDetails() {
- return details;
- }
-
- public void setDetail(String name, String value) {
- assert (details != null) : "Did you forget to load the details?";
-
- details.put(name, value);
- }
-
- public void setDetails(Map<String, String> details) {
- this.details = details;
- }
-
- transient String toString;
- @Override
- public String toString() {
- if (toString == null) {
- toString = new StringBuilder("VM[").append(type.toString()).append("|").append(hostName).append("]").toString();
- }
- return toString;
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (id ^ (id >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- VMInstanceVO other = (VMInstanceVO) obj;
- if (id != other.id)
- return false;
- return true;
- }
-
-
- public void setServiceOfferingId(long serviceOfferingId) {
- this.serviceOfferingId = serviceOfferingId;
- }
-
- @Override
- public Long getDiskOfferingId() {
- return diskOfferingId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/src/com/cloud/vm/VirtualDisk.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/vm/VirtualDisk.java b/core/src/com/cloud/vm/VirtualDisk.java
deleted file mode 100644
index ad7bb43..0000000
--- a/core/src/com/cloud/vm/VirtualDisk.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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.vm;
-
-import com.cloud.storage.Storage;
-
-/**
- * VirtualDisk describes the disks that are plugged into
- * the virtual machine.
- *
- */
-public class VirtualDisk {
- public Storage.ImageFormat format;
- public String url;
- public boolean bootable;
- public long size;
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/src/com/cloud/vm/VirtualMachineName.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/vm/VirtualMachineName.java b/core/src/com/cloud/vm/VirtualMachineName.java
deleted file mode 100755
index 81838b9..0000000
--- a/core/src/com/cloud/vm/VirtualMachineName.java
+++ /dev/null
@@ -1,190 +0,0 @@
-// 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.vm;
-
-import java.util.Formatter;
-
-import com.cloud.dc.Vlan;
-
-/**
- * VM Name.
- */
-public class VirtualMachineName {
- public static final String SEPARATOR = "-";
-
- public static String getVnetName(long vnetId) {
- StringBuilder vnet = new StringBuilder();
- Formatter formatter = new Formatter(vnet);
- formatter.format("%04x", vnetId);
- return vnet.toString();
- }
-
- public static boolean isValidVmName(String vmName) {
- return isValidVmName(vmName, null);
- }
-
- public static boolean isValidVmName(String vmName, String instance) {
- String[] tokens = vmName.split(SEPARATOR);
- /*Some vms doesn't have vlan/vnet id*/
- if (tokens.length != 5 && tokens.length != 4) {
- return false;
- }
-
- if (!tokens[0].equals("i")) {
- return false;
- }
-
- try {
- Long.parseLong(tokens[1]);
- Long.parseLong(tokens[2]);
- if (tokens.length == 5 && !Vlan.UNTAGGED.equalsIgnoreCase(tokens[4])) {
- Long.parseLong(tokens[4], 16);
- }
- } catch (NumberFormatException e) {
- return false;
- }
-
- return instance == null || instance.equals(tokens[3]);
- }
-
- public static String getVmName(long vmId, long userId, String instance) {
- StringBuilder vmName = new StringBuilder("i");
- vmName.append(SEPARATOR).append(userId).append(SEPARATOR).append(vmId);
- vmName.append(SEPARATOR).append(instance);
- return vmName.toString();
- }
-
- public static long getVmId(String vmName) {
- int begin = vmName.indexOf(SEPARATOR);
- begin = vmName.indexOf(SEPARATOR, begin + SEPARATOR.length());
- int end = vmName.indexOf(SEPARATOR, begin + SEPARATOR.length());
- return Long.parseLong(vmName.substring(begin + 1, end));
- }
-
- public static long getRouterId(String routerName) {
- int begin = routerName.indexOf(SEPARATOR);
- int end = routerName.indexOf(SEPARATOR, begin + SEPARATOR.length());
- return Long.parseLong(routerName.substring(begin + 1, end));
- }
-
- public static long getConsoleProxyId(String vmName) {
- int begin = vmName.indexOf(SEPARATOR);
- int end = vmName.indexOf(SEPARATOR, begin + SEPARATOR.length());
- return Long.parseLong(vmName.substring(begin + 1, end));
- }
-
- public static long getSystemVmId(String vmName) {
- int begin = vmName.indexOf(SEPARATOR);
- int end = vmName.indexOf(SEPARATOR, begin + SEPARATOR.length());
- return Long.parseLong(vmName.substring(begin + 1, end));
- }
-
- public static String getVnet(String vmName) {
- return vmName.substring(vmName.lastIndexOf(SEPARATOR) + SEPARATOR.length());
- }
-
- public static String getRouterName(long routerId, String instance) {
- StringBuilder builder = new StringBuilder("r");
- builder.append(SEPARATOR).append(routerId).append(SEPARATOR).append(instance);
- return builder.toString();
- }
-
- public static String getConsoleProxyName(long vmId, String instance) {
- StringBuilder builder = new StringBuilder("v");
- builder.append(SEPARATOR).append(vmId).append(SEPARATOR).append(instance);
- return builder.toString();
- }
-
- public static String getSystemVmName(long vmId, String instance, String prefix) {
- StringBuilder builder = new StringBuilder(prefix);
- builder.append(SEPARATOR).append(vmId).append(SEPARATOR).append(instance);
- return builder.toString();
- }
-
- public static String attachVnet(String name, String vnet) {
- return name + SEPARATOR + vnet;
- }
-
- public static boolean isValidRouterName(String name) {
- return isValidRouterName(name, null);
- }
-
- public static boolean isValidRouterName(String name, String instance) {
- String[] tokens = name.split(SEPARATOR);
- if (tokens.length != 3 && tokens.length != 4 ) {
- return false;
- }
-
- if (!tokens[0].equals("r")) {
- return false;
- }
-
- try {
- Long.parseLong(tokens[1]);
- } catch (NumberFormatException ex) {
- return false;
- }
-
- return instance == null || tokens[2].equals(instance);
- }
-
- public static boolean isValidConsoleProxyName(String name) {
- return isValidConsoleProxyName(name, null);
- }
-
- public static boolean isValidConsoleProxyName(String name, String instance) {
- String[] tokens = name.split(SEPARATOR);
- if (tokens.length != 3) {
- return false;
- }
-
- if (!tokens[0].equals("v")) {
- return false;
- }
-
- try {
- Long.parseLong(tokens[1]);
- } catch (NumberFormatException ex) {
- return false;
- }
-
- return instance == null || tokens[2].equals(instance);
- }
-
- public static boolean isValidSecStorageVmName(String name, String instance) {
- return isValidSystemVmName(name, instance, "s");
- }
-
- public static boolean isValidSystemVmName(String name, String instance, String prefix) {
- String[] tokens = name.split(SEPARATOR);
- if (tokens.length != 3) {
- return false;
- }
-
- if (!tokens[0].equals(prefix)) {
- return false;
- }
-
- try {
- Long.parseLong(tokens[1]);
- } catch (NumberFormatException ex) {
- return false;
- }
-
- return instance == null || tokens[2].equals(instance);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/src/com/cloud/vm/VmDetailConstants.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/vm/VmDetailConstants.java b/core/src/com/cloud/vm/VmDetailConstants.java
deleted file mode 100644
index 5ff3ce0..0000000
--- a/core/src/com/cloud/vm/VmDetailConstants.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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.vm;
-
-public interface VmDetailConstants {
- public static final String KEYBOARD = "keyboard";
- public static final String NIC_ADAPTER = "nicAdapter";
- public static final String ROOK_DISK_CONTROLLER = "rootDiskController";
- public static final String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java b/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java
deleted file mode 100644
index 03d4945..0000000
--- a/core/src/com/cloud/vm/snapshot/VMSnapshotVO.java
+++ /dev/null
@@ -1,224 +0,0 @@
-// 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.vm.snapshot;
-
-import java.util.Date;
-import java.util.UUID;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name = "vm_snapshots")
-public class VMSnapshotVO implements VMSnapshot {
- @Id
- @TableGenerator(name = "vm_snapshots_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "vm_snapshots_seq", allocationSize = 1)
- @GeneratedValue(strategy = GenerationType.TABLE)
- @Column(name = "id")
- long id;
-
- @Column(name = "uuid")
- String uuid = UUID.randomUUID().toString();
-
- @Column(name = "name")
- String name;
-
- @Column(name = "display_name")
- String displayName;
-
- @Column(name = "description")
- String description;
-
- @Column(name = "vm_id")
- long vmId;
-
- @Column(name = "account_id")
- long accountId;
-
- @Column(name = "domain_id")
- long domainId;
-
- @Column(name = "vm_snapshot_type")
- @Enumerated(EnumType.STRING)
- VMSnapshot.Type type;
-
- @Column(name = "state", updatable = true, nullable = false)
- @Enumerated(value = EnumType.STRING)
- private State state;
-
- @Column(name = GenericDao.CREATED_COLUMN)
- Date created;
-
- @Column(name = GenericDao.REMOVED_COLUMN)
- Date removed;
-
- @Column(name = "current")
- Boolean current;
-
- @Column(name = "parent")
- Long parent;
-
- @Column(name = "updated")
- @Temporal(value = TemporalType.TIMESTAMP)
- Date updated;
-
- @Column(name="update_count", updatable = true, nullable=false)
- protected long updatedCount;
-
- public Long getParent() {
- return parent;
- }
-
- public void setParent(Long parent) {
- this.parent = parent;
- }
-
- public VMSnapshotVO() {
-
- }
-
- public Date getRemoved() {
- return removed;
- }
-
- public VMSnapshotVO(Long accountId, Long domainId, Long vmId,
- String description, String vmSnapshotName, String vsDisplayName,
- Long serviceOfferingId, Type type, Boolean current) {
- this.accountId = accountId;
- this.domainId = domainId;
- this.vmId = vmId;
- this.state = State.Allocated;
- this.description = description;
- this.name = vmSnapshotName;
- this.displayName = vsDisplayName;
- this.type = type;
- this.current = current;
- }
-
- public String getDescription() {
- return description;
- }
-
- @Override
- public Date getCreated() {
- return created;
- }
-
- public void setCreated(Date created) {
- this.created = created;
- }
-
- @Override
- public long getId() {
- return id;
- }
-
- @Override
- public Long getVmId() {
- return vmId;
- }
-
- public void setVmId(Long vmId) {
- this.vmId = vmId;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public State getState() {
- return state;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
- @Override
- public long getAccountId() {
- return accountId;
- }
-
- @Override
- public long getDomainId() {
- return domainId;
- }
-
- @Override
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public Boolean getCurrent() {
- return current;
- }
-
- public void setCurrent(Boolean current) {
- this.current = current;
- }
-
- @Override
- public long getUpdatedCount() {
- return updatedCount;
- }
-
- @Override
- public void incrUpdatedCount() {
- this.updatedCount++;
- }
-
- @Override
- public Date getUpdated() {
- return updated;
- }
-
- @Override
- public Type getType() {
- return type;
- }
-
- public void setRemoved(Date removed) {
- this.removed = removed;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/AgentControlAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/AgentControlAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/AgentControlAnswerTest.java
new file mode 100644
index 0000000..d0e8b4c
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/AgentControlAnswerTest.java
@@ -0,0 +1,35 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.AgentControlAnswer;
+import com.cloud.agent.api.AgentControlCommand;
+
+public class AgentControlAnswerTest {
+ AgentControlCommand acc = new AgentControlCommand();
+ AgentControlAnswer aca = new AgentControlAnswer(acc);
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = acc.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/AgentControlCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/AgentControlCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/AgentControlCommandTest.java
new file mode 100644
index 0000000..24d0fe5
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/AgentControlCommandTest.java
@@ -0,0 +1,33 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.AgentControlCommand;
+
+public class AgentControlCommandTest {
+ AgentControlCommand acc = new AgentControlCommand();
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = acc.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/AnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/AnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/AnswerTest.java
new file mode 100644
index 0000000..343a3ce
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/AnswerTest.java
@@ -0,0 +1,73 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.AgentControlCommand;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.UnsupportedAnswer;
+
+public class AnswerTest {
+ AgentControlCommand acc = new AgentControlCommand();
+ Answer a = new Answer(acc, true, "details");
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = a.executeInSequence();
+ assertFalse(b);
+ }
+
+ @Test
+ public void testGetResult() {
+ boolean b = a.getResult();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testGetDetails() {
+ String d = a.getDetails();
+ assertTrue(d.equals("details"));
+ }
+
+ @Test
+ public void testCreateUnsupportedCommandAnswer() {
+ UnsupportedAnswer usa = Answer.createUnsupportedCommandAnswer(acc);
+ boolean b = usa.executeInSequence();
+ assertFalse(b);
+
+ b = usa.getResult();
+ assertFalse(b);
+
+ String d = usa.getDetails();
+ assertTrue(d.equals("Unsupported command issued:" + acc.toString()
+ + ". Are you sure you got the right type of server?"));
+
+ usa = Answer.createUnsupportedVersionAnswer(acc);
+ b = usa.executeInSequence();
+ assertFalse(b);
+
+ b = usa.getResult();
+ assertFalse(b);
+
+ d = usa.getDetails();
+ assertTrue(d.equals("Unsuppored Version."));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/AttachIsoCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/AttachIsoCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/AttachIsoCommandTest.java
new file mode 100644
index 0000000..d189d9c
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/AttachIsoCommandTest.java
@@ -0,0 +1,80 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.AttachIsoCommand;
+
+public class AttachIsoCommandTest {
+ AttachIsoCommand aic = new AttachIsoCommand("vmname", "isopath", false);
+
+ @Test
+ public void testGetVmName() {
+ String vmName = aic.getVmName();
+ assertTrue(vmName.equals("vmname"));
+ }
+
+ @Test
+ public void testGetIsoPath() {
+ String isoPath = aic.getIsoPath();
+ assertTrue(isoPath.equals("isopath"));
+ }
+
+ @Test
+ public void testIsAttach() {
+ boolean b = aic.isAttach();
+ assertFalse(b);
+ }
+
+ @Test
+ public void testGetStoreUrl() {
+ aic.setStoreUrl("http://incubator.apache.org/cloudstack/");
+ String url = aic.getStoreUrl();
+ assertTrue(url.equals("http://incubator.apache.org/cloudstack/"));
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = aic.executeInSequence();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testAllowCaching() {
+ boolean b = aic.allowCaching();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testGetWait() {
+ int b;
+ aic.setWait(5);
+ b = aic.getWait();
+ assertEquals(b, 5);
+ aic.setWait(-3);
+ b = aic.getWait();
+ assertEquals(b, -3);
+ aic.setWait(0);
+ b = aic.getWait();
+ assertEquals(b, 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeAnswerTest.java
new file mode 100644
index 0000000..251a6cb
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeAnswerTest.java
@@ -0,0 +1,65 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.AttachVolumeAnswer;
+import com.cloud.agent.api.AttachVolumeCommand;
+import com.cloud.storage.Storage.StoragePoolType;
+
+public class AttachVolumeAnswerTest {
+ AttachVolumeCommand avc = new AttachVolumeCommand(true, "vmname",
+ StoragePoolType.Filesystem, "vFolder", "vPath", "vName",
+ 123456789L, "chainInfo");
+ AttachVolumeAnswer ava1 = new AttachVolumeAnswer(avc);
+ String results = "";
+ AttachVolumeAnswer ava2 = new AttachVolumeAnswer(avc, results);
+ Long deviceId = 10L;
+ AttachVolumeAnswer ava3 = new AttachVolumeAnswer(avc, deviceId);
+
+ @Test
+ public void testGetDeviceId() {
+ Long dId = ava1.getDeviceId();
+ assertTrue(dId == null);
+
+ dId = ava2.getDeviceId();
+ assertTrue(dId == null);
+
+ dId = ava3.getDeviceId();
+ Long expected = 10L;
+ assertEquals(expected, dId);
+ }
+
+ @Test
+ public void testGetChainInfo() {
+ ava1.setChainInfo("chainInfo");
+ String chainInfo = ava1.getChainInfo();
+ assertTrue(chainInfo.equals("chainInfo"));
+
+ ava2.setChainInfo("chainInfo");
+ chainInfo = ava2.getChainInfo();
+ assertTrue(chainInfo.equals("chainInfo"));
+
+ ava3.setChainInfo("chainInfo");
+ chainInfo = ava3.getChainInfo();
+ assertTrue(chainInfo.equals("chainInfo"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeCommandTest.java
new file mode 100644
index 0000000..1ec416a
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/AttachVolumeCommandTest.java
@@ -0,0 +1,120 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.AttachVolumeCommand;
+import com.cloud.storage.Storage.StoragePoolType;
+
+public class AttachVolumeCommandTest {
+ AttachVolumeCommand avc = new AttachVolumeCommand(true, "vmname",
+ StoragePoolType.Filesystem, "vFolder", "vPath", "vName",
+ 123456789L, "chainInfo");
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = avc.executeInSequence();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testGetAttach() {
+ boolean b = avc.getAttach();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testGetVmName() {
+ String vmName = avc.getVmName();
+ assertTrue(vmName.equals("vmname"));
+ }
+
+ @Test
+ public void testGetPooltype() {
+ StoragePoolType pt = avc.getPooltype();
+ assertTrue(pt.equals(StoragePoolType.Filesystem));
+
+ avc.setPooltype(StoragePoolType.NetworkFilesystem);
+ pt = avc.getPooltype();
+ assertTrue(pt.equals(StoragePoolType.NetworkFilesystem));
+
+ avc.setPooltype(StoragePoolType.IscsiLUN);
+ pt = avc.getPooltype();
+ assertTrue(pt.equals(StoragePoolType.IscsiLUN));
+
+ avc.setPooltype(StoragePoolType.Iscsi);
+ pt = avc.getPooltype();
+ assertTrue(pt.equals(StoragePoolType.Iscsi));
+ }
+
+ @Test
+ public void testGetVolumeFolder() {
+ String vFolder = avc.getVolumeFolder();
+ assertTrue(vFolder.equals("vFolder"));
+ }
+
+ @Test
+ public void testGetVolumePath() {
+ String vPath = avc.getVolumePath();
+ assertTrue(vPath.equals("vPath"));
+ }
+
+ @Test
+ public void testGetVolumeName() {
+ String vName = avc.getVolumeName();
+ assertTrue(vName.equals("vName"));
+ }
+
+ @Test
+ public void testGetDeviceId() {
+ Long dId = avc.getDeviceId();
+ Long expected = 123456789L;
+ assertEquals(expected, dId);
+
+ avc.setDeviceId(5L);
+ dId = avc.getDeviceId();
+ expected = 5L;
+ assertEquals(expected, dId);
+
+ avc.setDeviceId(0L);
+ dId = avc.getDeviceId();
+ expected = 0L;
+ assertEquals(expected, dId);
+
+ avc.setDeviceId(-5L);
+ dId = avc.getDeviceId();
+ expected = -5L;
+ assertEquals(expected, dId);
+ }
+
+ @Test
+ public void testGetPoolUuid() {
+ avc.setPoolUuid("420fa39c-4ef1-a83c-fd93-46dc1ff515ae");
+ String pUuid = avc.getPoolUuid();
+ assertTrue(pUuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
+ }
+
+ @Test
+ public void testGetWait() {
+ String cInfo = avc.getChainInfo();
+ assertTrue(cInfo.equals("chainInfo"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotAnswerTest.java
new file mode 100644
index 0000000..7fd6e0b
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotAnswerTest.java
@@ -0,0 +1,75 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.cloud.agent.api.BackupSnapshotAnswer;
+import com.cloud.agent.api.BackupSnapshotCommand;
+import com.cloud.storage.StoragePool;
+
+public class BackupSnapshotAnswerTest {
+ private BackupSnapshotCommand bsc;
+ private BackupSnapshotAnswer bsa;
+
+ @Before
+ public void setUp() {
+
+ StoragePool pool = Mockito.mock(StoragePool.class);
+
+ bsc = new BackupSnapshotCommand(
+ "secondaryStoragePoolURL", 101L, 102L, 103L, 104L, 105L,
+ "volumePath", pool, "snapshotUuid", "snapshotName",
+ "prevSnapshotUuid", "prevBackupUuid", false, "vmName", 5);
+ bsa = new BackupSnapshotAnswer(bsc, true, "results", "bussname", false);
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = bsa.executeInSequence();
+ assertFalse(b);
+ }
+
+ @Test
+ public void testIsFull() {
+ boolean b = bsa.isFull();
+ assertFalse(b);
+ }
+
+ @Test
+ public void testGetBackupSnapshotName() {
+ String name = bsa.getBackupSnapshotName();
+ assertTrue(name.equals("bussname"));
+ }
+
+ @Test
+ public void testGetResult() {
+ boolean b = bsa.getResult();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testDetails() {
+ String details = bsa.getDetails();
+ assertTrue(details.equals("results"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
new file mode 100644
index 0000000..44d53aa
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java
@@ -0,0 +1,301 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.BackupSnapshotCommand;
+import com.cloud.agent.api.to.StorageFilerTO;
+import com.cloud.agent.api.to.SwiftTO;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.StoragePoolStatus;
+
+public class BackupSnapshotCommandTest {
+ public StoragePool pool = new StoragePool() {
+ @Override
+ public long getId() {
+ return 1L;
+ };
+
+ @Override
+ public String getName() {
+ return "name";
+ };
+
+ @Override
+ public String getUuid() {
+ return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
+ };
+
+ @Override
+ public StoragePoolType getPoolType() {
+ return StoragePoolType.Filesystem;
+ };
+
+ @Override
+ public Date getCreated() {
+ Date date = null;
+ try {
+ date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
+ .parse("01/01/1970 12:12:12");
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return date;
+ }
+
+ @Override
+ public Date getUpdateTime() {
+ return new Date();
+ };
+
+ @Override
+ public long getDataCenterId() {
+ return 0L;
+ };
+
+ @Override
+ public long getCapacityBytes() {
+ return 0L;
+ };
+
+ @Override
+ public long getAvailableBytes() {
+ return 0L;
+ };
+
+ @Override
+ public Long getClusterId() {
+ return 0L;
+ };
+
+ @Override
+ public String getHostAddress() {
+ return "hostAddress";
+ };
+
+ @Override
+ public String getPath() {
+ return "path";
+ };
+
+ @Override
+ public String getUserInfo() {
+ return "userInfo";
+ };
+
+ @Override
+ public boolean isShared() {
+ return false;
+ };
+
+ @Override
+ public boolean isLocal() {
+ return false;
+ };
+
+ @Override
+ public StoragePoolStatus getStatus() {
+ return StoragePoolStatus.Up;
+ };
+
+ @Override
+ public int getPort() {
+ return 25;
+ };
+
+ @Override
+ public Long getPodId() {
+ return 0L;
+ }
+
+ @Override
+ public String getStorageProviderName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isInMaintenance() {
+ // TODO Auto-generated method stub
+ return false;
+ };
+ };
+
+ BackupSnapshotCommand bsc = new BackupSnapshotCommand(
+ "http://secondary.Storage.Url",
+ 101L, 102L, 103L, 104L, 105L, "vPath", pool,
+ "420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "sName",
+ "9012793e-0657-11e2-bebc-0050568b0057",
+ "7167e0b2-f5b0-11e1-8414-0050568b0057", false, "vmName", 5);
+
+ BackupSnapshotCommand bsc1 = new BackupSnapshotCommand(
+ "http://secondary.Storage.Url",
+ 101L, 102L, 103L, 104L, 105L,"vPath", pool,
+ "420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "sName",
+ "9012793e-0657-11e2-bebc-0050568b0057",
+ "7167e0b2-f5b0-11e1-8414-0050568b0057", false, "vmName", 5);
+
+ @Test
+ public void testGetPrimaryStoragePoolNameLabel() {
+ String label = bsc.getPrimaryStoragePoolNameLabel();
+ assertTrue(label.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
+ }
+
+ @Test
+ public void testGetSecondaryStorageUrl() {
+ String url = bsc.getSecondaryStorageUrl();
+ assertTrue(url.equals("http://secondary.Storage.Url"));
+ }
+
+ @Test
+ public void testGetDataCenterId() {
+ Long dcId = bsc.getDataCenterId();
+ Long expected = 101L;
+ assertEquals(expected, dcId);
+ }
+
+ @Test
+ public void testGetAccountId() {
+ Long aId = bsc.getAccountId();
+ Long expected = 102L;
+ assertEquals(expected, aId);
+ }
+
+ @Test
+ public void testGetVolumeId() {
+ Long vId = bsc.getVolumeId();
+ Long expected = 103L;
+ assertEquals(expected, vId);
+ }
+
+ @Test
+ public void testGetSnapshotId() {
+ Long ssId = bsc.getSnapshotId();
+ Long expected = 104L;
+ assertEquals(expected, ssId);
+ }
+
+ @Test
+ public void testGetPool() {
+ StorageFilerTO pool = bsc.getPool();
+
+ Long id = pool.getId();
+ Long expectedL = 1L;
+ assertEquals(expectedL, id);
+
+ String uuid = pool.getUuid();
+ assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
+
+ String host = pool.getHost();
+ assertTrue(host.equals("hostAddress"));
+
+ String path = pool.getPath();
+ assertTrue(path.equals("path"));
+
+ String userInfo = pool.getUserInfo();
+ assertTrue(userInfo.equals("userInfo"));
+
+ Integer port = pool.getPort();
+ Integer expectedI = 25;
+ assertEquals(expectedI, port);
+
+ StoragePoolType type = pool.getType();
+ assertEquals(StoragePoolType.Filesystem, type);
+
+ String str = pool.toString();
+ assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":"
+ + port.toString() + "|" + path + "]"));
+ }
+
+ @Test
+ public void testGetCreated() {
+ try {
+ Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
+ .parse("01/01/1970 12:12:12");
+ Date d = pool.getCreated();
+ assertTrue(d.compareTo(date) == 0);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetSwift() {
+ SwiftTO s1 = new SwiftTO();
+ bsc.setSwift(s1);
+ SwiftTO s2 = bsc.getSwift();
+ assertEquals(s1, s2);
+ }
+
+ @Test
+ public void testGetSnapshotName() {
+ String ssName = bsc.getSnapshotName();
+ assertTrue(ssName.equals("sName"));
+ }
+
+ @Test
+ public void testGetSnapshotUuid() {
+ String uuid = bsc.getSnapshotUuid();
+ assertTrue(uuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
+ }
+
+ @Test
+ public void testGetPrevSnapshotUuid() {
+ String uuid = bsc.getPrevSnapshotUuid();
+ assertTrue(uuid.equals("9012793e-0657-11e2-bebc-0050568b0057"));
+ }
+
+ @Test
+ public void testGetPrevBackupUuid() {
+ String uuid = bsc.getPrevBackupUuid();
+ assertTrue(uuid.equals("7167e0b2-f5b0-11e1-8414-0050568b0057"));
+ }
+
+ @Test
+ public void testGetVolumePath() {
+ String path = bsc.getVolumePath();
+ assertTrue(path.equals("vPath"));
+
+ bsc.setVolumePath("vPath1");
+ path = bsc.getVolumePath();
+ assertTrue(path.equals("vPath1"));
+
+ bsc1.setVolumePath("vPath2");
+ path = bsc1.getVolumePath();
+ assertTrue(path.equals("vPath2"));
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = bsc.executeInSequence();
+ assertFalse(b);
+
+ b = bsc1.executeInSequence();
+ assertFalse(b);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/BumpUpPriorityCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/BumpUpPriorityCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/BumpUpPriorityCommandTest.java
new file mode 100644
index 0000000..f5f5985
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/BumpUpPriorityCommandTest.java
@@ -0,0 +1,83 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.BumpUpPriorityCommand;
+import com.cloud.agent.api.routing.NetworkElementCommand;
+
+public class BumpUpPriorityCommandTest {
+
+ BumpUpPriorityCommand bupc = new BumpUpPriorityCommand();
+
+ // test super class
+ @Test
+ public void testSuperGetAccessDetail() {
+ String value;
+ bupc.setAccessDetail(NetworkElementCommand.ACCOUNT_ID, "accountID");
+ value = bupc.getAccessDetail(NetworkElementCommand.ACCOUNT_ID);
+ assertTrue(value.equals("accountID"));
+
+ bupc.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR,
+ "GuestNetworkCIDR");
+ value = bupc.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR);
+ assertTrue(value.equals("GuestNetworkCIDR"));
+
+ bupc.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY,
+ "GuestNetworkGateway");
+ value = bupc
+ .getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
+ assertTrue(value.equals("GuestNetworkGateway"));
+
+ bupc.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG,
+ "GuestVlanTag");
+ value = bupc.getAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG);
+ assertTrue(value.equals("GuestVlanTag"));
+
+ bupc.setAccessDetail(NetworkElementCommand.ROUTER_NAME, "RouterName");
+ value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+ assertTrue(value.equals("RouterName"));
+
+ bupc.setAccessDetail(NetworkElementCommand.ROUTER_IP, "RouterIP");
+ value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+ assertTrue(value.equals("RouterIP"));
+
+ bupc.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP,
+ "RouterGuestIP");
+ value = bupc.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
+ assertTrue(value.equals("RouterGuestIP"));
+
+ bupc.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE,
+ "ZoneNetworkType");
+ value = bupc.getAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE);
+ assertTrue(value.equals("ZoneNetworkType"));
+
+ bupc.setAccessDetail(NetworkElementCommand.GUEST_BRIDGE, "GuestBridge");
+ value = bupc.getAccessDetail(NetworkElementCommand.GUEST_BRIDGE);
+ assertTrue(value.equals("GuestBridge"));
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = bupc.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/CancelCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/CancelCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/CancelCommandTest.java
new file mode 100644
index 0000000..19827fd
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/CancelCommandTest.java
@@ -0,0 +1,46 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.CancelCommand;
+
+public class CancelCommandTest {
+ CancelCommand cc = new CancelCommand(123456789L, "goodreason");
+
+ @Test
+ public void testGetSequence() {
+ Long s = cc.getSequence();
+ assertTrue(123456789L == s);
+ }
+
+ @Test
+ public void testGetReason() {
+ String r = cc.getReason();
+ assertTrue(r.equals("goodreason"));
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = cc.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentAnswerTest.java
new file mode 100644
index 0000000..8933e6e
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentAnswerTest.java
@@ -0,0 +1,44 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.ChangeAgentAnswer;
+import com.cloud.agent.api.ChangeAgentCommand;
+import com.cloud.host.Status.Event;
+
+public class ChangeAgentAnswerTest {
+ ChangeAgentCommand cac = new ChangeAgentCommand(123456789L,
+ Event.AgentConnected);
+ ChangeAgentAnswer caa = new ChangeAgentAnswer(cac, true);
+
+ @Test
+ public void testGetResult() {
+ boolean b = caa.getResult();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = caa.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentCommandTest.java
new file mode 100644
index 0000000..d0c2bf8
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/ChangeAgentCommandTest.java
@@ -0,0 +1,50 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.ChangeAgentCommand;
+import com.cloud.host.Status.Event;
+
+public class ChangeAgentCommandTest {
+
+ ChangeAgentCommand cac = new ChangeAgentCommand(123456789L,
+ Event.AgentConnected);
+
+ @Test
+ public void testGetAgentId() {
+ Long aid = cac.getAgentId();
+ assertTrue(123456789L == aid);
+ }
+
+ @Test
+ public void testGetEvent() {
+ Event e = cac.getEvent();
+ assertEquals(Event.AgentConnected, e);
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = cac.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/CheckHealthAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckHealthAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckHealthAnswerTest.java
new file mode 100644
index 0000000..6fa94f9
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/CheckHealthAnswerTest.java
@@ -0,0 +1,49 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.CheckHealthAnswer;
+import com.cloud.agent.api.CheckHealthCommand;
+
+public class CheckHealthAnswerTest {
+ CheckHealthCommand chc = new CheckHealthCommand();
+ CheckHealthAnswer cha = new CheckHealthAnswer(chc, true);
+
+ @Test
+ public void testGetResult() {
+ boolean r = cha.getResult();
+ assertTrue(r);
+ }
+
+ @Test
+ public void testGetDetails() {
+ String d = cha.getDetails();
+ boolean r = cha.getResult();
+ assertTrue(d.equals("resource is " + (r ? "alive" : "not alive")));
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = cha.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java
new file mode 100644
index 0000000..1b565a5
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/CheckHealthCommandTest.java
@@ -0,0 +1,40 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.cloud.agent.api.CheckHealthCommand;
+
+public class CheckHealthCommandTest {
+ CheckHealthCommand chc = new CheckHealthCommand();
+
+ @Test
+ public void testGetWait() {
+ int wait = chc.getWait();
+ assertTrue(wait == 50);
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = chc.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
new file mode 100644
index 0000000..1853d39
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java
@@ -0,0 +1,62 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.cloud.agent.api.CheckNetworkAnswer;
+import com.cloud.agent.api.CheckNetworkCommand;
+
+public class CheckNetworkAnswerTest {
+ CheckNetworkCommand cnc;
+ CheckNetworkAnswer cna;
+
+ @Before
+ public void setUp() {
+ cnc = Mockito.mock(CheckNetworkCommand.class);
+ cna = new CheckNetworkAnswer(cnc, true, "details", true);
+ }
+
+ @Test
+ public void testGetResult() {
+ boolean b = cna.getResult();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testGetDetails() {
+ String d = cna.getDetails();
+ assertTrue(d.equals("details"));
+ }
+
+ @Test
+ public void testNeedReconnect() {
+ boolean b = cna.needReconnect();
+ assertTrue(b);
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = cna.executeInSequence();
+ assertFalse(b);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkCommandTest.java
----------------------------------------------------------------------
diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkCommandTest.java
new file mode 100644
index 0000000..0b87b58
--- /dev/null
+++ b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkCommandTest.java
@@ -0,0 +1,53 @@
+// 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 org.apache.cloudstack.api.agent.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.cloud.agent.api.CheckNetworkCommand;
+import com.cloud.network.PhysicalNetworkSetupInfo;
+
+public class CheckNetworkCommandTest {
+ CheckNetworkCommand cnc;
+
+ @Before
+ public void setUp() {
+ @SuppressWarnings("unchecked")
+ List<PhysicalNetworkSetupInfo> net = Mockito.mock(List.class);
+ cnc = new CheckNetworkCommand(net);
+ }
+
+ @Test
+ public void testGetPhysicalNetworkInfoList() {
+ List<PhysicalNetworkSetupInfo> networkInfoList = cnc
+ .getPhysicalNetworkInfoList();
+ assertEquals(0, networkInfoList.size());
+ }
+
+ @Test
+ public void testExecuteInSequence() {
+ boolean b = cnc.executeInSequence();
+ assertTrue(b);
+ }
+}