Adding new unit tests Signed-off-by: Chip Childers <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/8c4c445a Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8c4c445a Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8c4c445a Branch: refs/heads/junit-tests Commit: 8c4c445afa1a26119b3271599076792360ae4670 Parents: a2a4a0b Author: Yichi Lu <[email protected]> Authored: Mon Oct 22 13:26:09 2012 -0400 Committer: Chip Childers <[email protected]> Committed: Mon Oct 22 13:26:09 2012 -0400 ---------------------------------------------------------------------- .../cloud/agent/api/BumpUpPriorityCommandTest.java | 73 +++ .../com/cloud/agent/api/CancelCommandTest.java | 43 ++ .../com/cloud/agent/api/ChangeAgentAnswerTest.java | 39 ++ .../cloud/agent/api/ChangeAgentCommandTest.java | 44 ++ .../com/cloud/agent/api/CheckHealthAnswerTest.java | 45 ++ .../cloud/agent/api/CheckHealthCommandTest.java | 37 ++ .../cloud/agent/api/CheckNetworkAnswerTest.java | 51 ++ .../cloud/agent/api/CheckNetworkCommandTest.java | 39 ++ .../cloud/agent/api/CheckOnHostCommandTest.java | 366 +++++++++++++++ 9 files changed, 737 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/BumpUpPriorityCommandTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/BumpUpPriorityCommandTest.java b/api/src/test/java/com/cloud/agent/api/BumpUpPriorityCommandTest.java new file mode 100644 index 0000000..f111ced --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/BumpUpPriorityCommandTest.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 com.cloud.agent.api; + +import com.cloud.agent.api.*; +import com.cloud.agent.api.routing.*; +import static org.junit.Assert.*; +import org.junit.Test; + +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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/CancelCommandTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/CancelCommandTest.java b/api/src/test/java/com/cloud/agent/api/CancelCommandTest.java new file mode 100644 index 0000000..9ea8452 --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/CancelCommandTest.java @@ -0,0 +1,43 @@ +// 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.agent.api; + +import com.cloud.agent.api.*; +import static org.junit.Assert.*; +import org.junit.Test; + +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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/ChangeAgentAnswerTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/ChangeAgentAnswerTest.java b/api/src/test/java/com/cloud/agent/api/ChangeAgentAnswerTest.java new file mode 100644 index 0000000..f915e19 --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/ChangeAgentAnswerTest.java @@ -0,0 +1,39 @@ +// 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.agent.api; + +import com.cloud.agent.api.*; +import com.cloud.host.Status.Event; +import static org.junit.Assert.*; +import org.junit.Test; + +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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/ChangeAgentCommandTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/ChangeAgentCommandTest.java b/api/src/test/java/com/cloud/agent/api/ChangeAgentCommandTest.java new file mode 100644 index 0000000..43b68b1 --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/ChangeAgentCommandTest.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 com.cloud.agent.api; + +import com.cloud.agent.api.*; +import com.cloud.host.Status.Event; +import static org.junit.Assert.*; +import org.junit.Test; + +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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/CheckHealthAnswerTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/CheckHealthAnswerTest.java b/api/src/test/java/com/cloud/agent/api/CheckHealthAnswerTest.java new file mode 100644 index 0000000..30f817b --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/CheckHealthAnswerTest.java @@ -0,0 +1,45 @@ +// 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.agent.api; + +import com.cloud.agent.api.*; +import static org.junit.Assert.*; +import org.junit.Test; + +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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/CheckHealthCommandTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/CheckHealthCommandTest.java b/api/src/test/java/com/cloud/agent/api/CheckHealthCommandTest.java new file mode 100644 index 0000000..428ec92 --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/CheckHealthCommandTest.java @@ -0,0 +1,37 @@ +// 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.agent.api; + +import com.cloud.agent.api.*; +import static org.junit.Assert.*; +import org.junit.Test; + +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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/CheckNetworkAnswerTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/CheckNetworkAnswerTest.java b/api/src/test/java/com/cloud/agent/api/CheckNetworkAnswerTest.java new file mode 100644 index 0000000..6484214 --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/CheckNetworkAnswerTest.java @@ -0,0 +1,51 @@ +// 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.agent.api; + +import com.cloud.agent.api.*; +import com.cloud.host.Status.Event; +import static org.junit.Assert.*; +import org.junit.Test; + +public class CheckNetworkAnswerTest { + CheckNetworkCommand cnc = new CheckNetworkCommand(); + CheckNetworkAnswer 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/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/CheckNetworkCommandTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/CheckNetworkCommandTest.java b/api/src/test/java/com/cloud/agent/api/CheckNetworkCommandTest.java new file mode 100644 index 0000000..f25874c --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/CheckNetworkCommandTest.java @@ -0,0 +1,39 @@ +// 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.agent.api; + +import java.util.List; +import com.cloud.agent.api.*; +import com.cloud.network.PhysicalNetworkSetupInfo; +import static org.junit.Assert.*; +import org.junit.Test; + +public class CheckNetworkCommandTest { + CheckNetworkCommand cnc = new CheckNetworkCommand(); + + @Test + public void testGetPhysicalNetworkInfoList() { + List<PhysicalNetworkSetupInfo> networkInfoList = cnc.getPhysicalNetworkInfoList(); + assertNull(networkInfoList); + } + + @Test + public void testExecuteInSequence() { + boolean b = cnc.executeInSequence(); + assertTrue(b); + } +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8c4c445a/api/src/test/java/com/cloud/agent/api/CheckOnHostCommandTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/com/cloud/agent/api/CheckOnHostCommandTest.java b/api/src/test/java/com/cloud/agent/api/CheckOnHostCommandTest.java new file mode 100644 index 0000000..1fae802 --- /dev/null +++ b/api/src/test/java/com/cloud/agent/api/CheckOnHostCommandTest.java @@ -0,0 +1,366 @@ +// 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.agent.api; + +import java.util.List; +import java.util.Date; +import java.text.SimpleDateFormat; +import java.text.ParseException; +import com.cloud.agent.api.*; +import com.cloud.agent.api.to.HostTO; +import com.cloud.host.Host; +import com.cloud.host.Status; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.resource.ResourceState; +import static org.junit.Assert.*; +import org.junit.Test; + +public class CheckOnHostCommandTest { + public Host host = new Host() { + public Status getState() {return Status.Up;}; + public long getId() {return 101L;}; + public String getName() {return "hostName";}; + public Type getType() {return Host.Type.Storage;}; + 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; + } + public Status getStatus() {return Status.Up;}; + public String getPrivateIpAddress() {return "10.1.1.1";}; + public String getStorageIpAddress() {return "10.1.1.2";}; + public String getGuid() {return "bed9f83e-cac3-11e1-ac8a-0050568b007e";}; + public Long getTotalMemory() {return 100000000000L;}; + public Integer getCpus() {return 16;}; + public Long getSpeed() {return 2000000000L;}; + public Integer getProxyPort() {return 22;}; + public Long getPodId() {return 16L;}; + public long getDataCenterId() {return 17L;}; + public String getParent() {return "parent";}; + public String getStorageIpAddressDeux() {return "10.1.1.3";}; + public HypervisorType getHypervisorType() {return HypervisorType.XenServer;}; + public Date getDisconnectedOn() { + Date date = null; + try{ + date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/2012 12:12:12"); + } + catch (ParseException e) { + e.printStackTrace(); + } + return date; + } + public String getVersion() {return "4.0.1";}; + public long getTotalSize() {return 100000000000L;}; + public String getCapabilities() {return "capabilities";}; + public long getLastPinged() {return 1L;}; + public Long getManagementServerId() {return 2L;}; + public Date getRemoved() { + Date date = null; + try{ + date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("02/01/2012 12:12:12"); + } + catch (ParseException e) { + e.printStackTrace(); + } + return date; + }; + public Long getClusterId() {return 3L;}; + public String getPublicIpAddress() {return "10.1.1.4";}; + public String getPublicNetmask() {return "255.255.255.8";}; + public String getPrivateNetmask() {return "255.255.255.16";}; + public String getStorageNetmask() {return "255.255.255.24";}; + public String getStorageMacAddress() {return "01:f4:17:38:0e:26";}; + public String getPublicMacAddress() {return "02:f4:17:38:0e:26";}; + public String getPrivateMacAddress() {return "03:f4:17:38:0e:26";}; + public String getStorageNetmaskDeux() {return "255.255.255.25";}; + public String getStorageMacAddressDeux() {return "01:f4:17:38:0e:27";}; + public String getHypervisorVersion() {return "1.2.3.0";}; + public boolean isInMaintenanceStates() {return false;}; + public ResourceState getResourceState() {return ResourceState.Enabled;}; + }; + + CheckOnHostCommand cohc = new CheckOnHostCommand(host); + + @Test + public void testGetHost() { + HostTO h = cohc.getHost(); + assertNotNull(h); + } + + @Test + public void testGetState() { + Status s = host.getState(); + assertTrue(s == Status.Up); + } + + @Test + public void testGetId() { + Long id = host.getId(); + assertTrue(101L == id); + } + + @Test + public void testGetName() { + String name = host.getName(); + assertTrue(name.equals("hostName")); + } + + @Test + public void testGetType() { + Host.Type t = host.getType(); + assertTrue(t == Host.Type.Storage); + } + + @Test + public void testGetCreated() { + try{ + Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 12:12:12"); + Date d = host.getCreated(); + assertTrue(d.compareTo(date) == 0); + } + catch (ParseException e) { + e.printStackTrace(); + } + } + + @Test + public void testGetStatus() { + Status s = host.getStatus(); + assertTrue(s == Status.Up); + } + + @Test + public void testGetPrivateIpAddress() { + String addr = host.getPrivateIpAddress(); + assertTrue(addr.equals("10.1.1.1")); + } + + @Test + public void testGetStorageIpAddress() { + String addr = host.getStorageIpAddress(); + assertTrue(addr.equals("10.1.1.2")); + } + + @Test + public void testGetGuid() { + String guid = host.getGuid(); + assertTrue(guid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e")); + } + + @Test + public void testGetTotalMemory() { + Long m = host.getTotalMemory(); + assertTrue(m == 100000000000L); + } + + @Test + public void testGetCpus() { + int cpus = host.getCpus(); + assertTrue(cpus == 16); + } + + @Test + public void testGetSpeed() { + Long spped = host.getSpeed(); + assertTrue(spped == 2000000000L); + } + + @Test + public void testGetProxyPort() { + Integer port = host.getProxyPort(); + assertTrue(port == 22); + } + + @Test + public void testGetPodId() { + Long pID = host.getPodId(); + assertTrue(pID == 16L); + } + + @Test + public void testGetDataCenterId() { + long dcID = host.getDataCenterId(); + assertTrue(dcID == 17L); + } + + @Test + public void testGetParent() { + String p = host.getParent(); + assertTrue(p.equals("parent")); + } + + @Test + public void testGetStorageIpAddressDeux() { + String addr = host.getStorageIpAddressDeux(); + assertTrue(addr.equals("10.1.1.3")); + } + + @Test + public void testGetHypervisorType() { + HypervisorType type = host.getHypervisorType(); + assertTrue(type == HypervisorType.XenServer); + } + + @Test + public void testGetDisconnectedOn() { + try{ + Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/2012 12:12:12"); + Date d = host.getDisconnectedOn(); + assertTrue(d.compareTo(date) == 0); + } + catch (ParseException e) { + e.printStackTrace(); + } + } + + @Test + public void testGetVersion() { + String v = host.getVersion(); + assertTrue(v.equals("4.0.1")); + } + + @Test + public void testGetTotalSize() { + long size = host.getTotalSize(); + assertTrue(size == 100000000000L); + } + + @Test + public void testGetCapabilities() { + String c = host.getCapabilities(); + assertTrue(c.equals("capabilities")); + } + + @Test + public void testGetLastPinged() { + long lp = host.getLastPinged(); + assertTrue(lp == 1L); + } + + @Test + public void testGetManagementServerId() { + Long msID = host.getManagementServerId(); + assertTrue(msID == 2L); + } + + @Test + public void testGetRemoved() { + try{ + Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("02/01/2012 12:12:12"); + Date d = host.getRemoved(); + assertTrue(d.compareTo(date) == 0); + } + catch (ParseException e) { + e.printStackTrace(); + } + } + + @Test + public void testGetClusterId() { + Long cID = host.getClusterId(); + assertTrue(cID == 3L); + } + + @Test + public void testGetPublicIpAddress() { + String pipAddr = host.getPublicIpAddress(); + assertTrue(pipAddr.equals("10.1.1.4")); + } + + @Test + public void testGetPublicNetmask() { + String pMask = host.getPublicNetmask(); + assertTrue(pMask.equals("255.255.255.8")); + } + + @Test + public void testGetPrivateNetmask() { + String pMask = host.getPrivateNetmask(); + assertTrue(pMask.equals("255.255.255.16")); + } + + @Test + public void testGetStorageNetmask() { + String sMask = host.getStorageNetmask(); + assertTrue(sMask.equals("255.255.255.24")); + } + + @Test + public void testGetStorageMacAddress() { + String sMac = host.getStorageMacAddress(); + assertTrue(sMac.equals("01:f4:17:38:0e:26")); + } + + @Test + public void testGetPublicMacAddress() { + String pMac = host.getPublicMacAddress(); + assertTrue(pMac.equals("02:f4:17:38:0e:26")); + } + + @Test + public void testGetPrivateMacAddress() { + String pMac = host.getPrivateMacAddress(); + assertTrue(pMac.equals("03:f4:17:38:0e:26")); + } + + @Test + public void testGetStorageNetmaskDeux() { + String sMask = host.getStorageNetmaskDeux(); + assertTrue(sMask.equals("255.255.255.25")); + } + + @Test + public void testGetStorageMacAddressDeux() { + String sMac = host.getStorageMacAddressDeux(); + assertTrue(sMac.equals("01:f4:17:38:0e:27")); + } + + @Test + public void testGetHypervisorVersion() { + String v = host.getHypervisorVersion(); + assertTrue(v.equals("1.2.3.0")); + } + + @Test + public void testIsInMaintenanceStates() { + boolean b = host.isInMaintenanceStates(); + assertFalse(b); + } + + @Test + public void testGetResourceState() { + ResourceState r = host.getResourceState(); + assertTrue(r == ResourceState.Enabled); + } + + @Test + public void testGetWait() { + int wait = cohc.getWait(); + assertTrue(20 == wait); + } + + @Test + public void testExecuteInSequence() { + boolean b = cohc.executeInSequence(); + assertFalse(b); + } +}
