You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ch...@apache.org on 2012/11/21 15:57:47 UTC
[3/5] git commit: Moving api tests into a similar package structure
as other tests
Moving api tests into a similar package structure as other tests
Signed-off-by: Chip Childers <ch...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/e953b774
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/e953b774
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/e953b774
Branch: refs/heads/master
Commit: e953b77492f27ab4a2cabbcdeb52702c0fcea335
Parents: 3e8655b
Author: Chip Childers <ch...@gmail.com>
Authored: Tue Nov 20 16:42:27 2012 -0500
Committer: Chip Childers <ch...@gmail.com>
Committed: Wed Nov 21 09:17:47 2012 -0500
----------------------------------------------------------------------
.../cloud/agent/api/AgentControlAnswerTest.java | 32 --
.../cloud/agent/api/AgentControlCommandTest.java | 31 --
api/test/com/cloud/agent/api/AnswerTest.java | 67 ---
.../com/cloud/agent/api/AttachIsoCommandTest.java | 77 ---
.../cloud/agent/api/AttachVolumeAnswerTest.java | 59 ---
.../cloud/agent/api/AttachVolumeCommandTest.java | 116 -----
.../cloud/agent/api/BackupSnapshotAnswerTest.java | 56 ---
.../cloud/agent/api/BackupSnapshotCommandTest.java | 220 ---------
.../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 ---------------
.../com/cloud/agent/api/SnapshotCommandTest.java | 98 ----
.../cloud/api/commands/ActivateProjectCmdTest.java | 86 ----
.../api/commands/AddAccountToProjectCmdTest.java | 175 -------
.../com/cloud/api/commands/AddClusterCmdTest.java | 123 -----
.../com/cloud/api/commands/AddHostCmdTest.java | 169 -------
.../commands/AddNetworkServiceProviderCmdTest.java | 118 -----
.../api/commands/AddSecondaryStorageCmdTest.java | 120 -----
.../com/cloud/api/commands/AddSwiftCmdTest.java | 92 ----
.../com/cloud/api/commands/AddVpnUserCmdTest.java | 143 ------
.../agent/api/test/AgentControlAnswerTest.java | 32 ++
.../agent/api/test/AgentControlCommandTest.java | 31 ++
.../src/com/cloud/agent/api/test/AnswerTest.java | 67 +++
.../cloud/agent/api/test/AttachIsoCommandTest.java | 77 +++
.../agent/api/test/AttachVolumeAnswerTest.java | 59 +++
.../agent/api/test/AttachVolumeCommandTest.java | 116 +++++
.../agent/api/test/BackupSnapshotAnswerTest.java | 56 +++
.../agent/api/test/BackupSnapshotCommandTest.java | 220 +++++++++
.../agent/api/test/BumpUpPriorityCommandTest.java | 73 +++
.../cloud/agent/api/test/CancelCommandTest.java | 43 ++
.../agent/api/test/ChangeAgentAnswerTest.java | 39 ++
.../agent/api/test/ChangeAgentCommandTest.java | 44 ++
.../agent/api/test/CheckHealthAnswerTest.java | 45 ++
.../agent/api/test/CheckHealthCommandTest.java | 37 ++
.../agent/api/test/CheckNetworkAnswerTest.java | 51 ++
.../agent/api/test/CheckNetworkCommandTest.java | 39 ++
.../agent/api/test/CheckOnHostCommandTest.java | 366 +++++++++++++++
.../cloud/agent/api/test/SnapshotCommandTest.java | 98 ++++
.../api/commands/test/ActivateProjectCmdTest.java | 86 ++++
.../commands/test/AddAccountToProjectCmdTest.java | 175 +++++++
.../cloud/api/commands/test/AddClusterCmdTest.java | 123 +++++
.../cloud/api/commands/test/AddHostCmdTest.java | 169 +++++++
.../test/AddNetworkServiceProviderCmdTest.java | 118 +++++
.../commands/test/AddSecondaryStorageCmdTest.java | 120 +++++
.../cloud/api/commands/test/AddSwiftCmdTest.java | 92 ++++
.../cloud/api/commands/test/AddVpnUserCmdTest.java | 143 ++++++
52 files changed, 2519 insertions(+), 2519 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/AgentControlAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/AgentControlAnswerTest.java b/api/test/com/cloud/agent/api/AgentControlAnswerTest.java
deleted file mode 100644
index 7bfd776..0000000
--- a/api/test/com/cloud/agent/api/AgentControlAnswerTest.java
+++ /dev/null
@@ -1,32 +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.agent.api;
-
-import com.cloud.agent.api.*;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/AgentControlCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/AgentControlCommandTest.java b/api/test/com/cloud/agent/api/AgentControlCommandTest.java
deleted file mode 100644
index 12ea0d6..0000000
--- a/api/test/com/cloud/agent/api/AgentControlCommandTest.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.agent.api;
-
-import com.cloud.agent.api.*;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/AnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/AnswerTest.java b/api/test/com/cloud/agent/api/AnswerTest.java
deleted file mode 100644
index c53c84a..0000000
--- a/api/test/com/cloud/agent/api/AnswerTest.java
+++ /dev/null
@@ -1,67 +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.agent.api;
-
-import com.cloud.agent.api.*;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/AttachIsoCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/AttachIsoCommandTest.java b/api/test/com/cloud/agent/api/AttachIsoCommandTest.java
deleted file mode 100644
index 42df9db..0000000
--- a/api/test/com/cloud/agent/api/AttachIsoCommandTest.java
+++ /dev/null
@@ -1,77 +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.agent.api;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-import com.cloud.agent.api.*;
-
-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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/AttachVolumeAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/AttachVolumeAnswerTest.java b/api/test/com/cloud/agent/api/AttachVolumeAnswerTest.java
deleted file mode 100644
index 886995e..0000000
--- a/api/test/com/cloud/agent/api/AttachVolumeAnswerTest.java
+++ /dev/null
@@ -1,59 +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.agent.api;
-
-import com.cloud.agent.api.*;
-import com.cloud.storage.Storage.StoragePoolType;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/AttachVolumeCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/AttachVolumeCommandTest.java b/api/test/com/cloud/agent/api/AttachVolumeCommandTest.java
deleted file mode 100644
index 24e1a51..0000000
--- a/api/test/com/cloud/agent/api/AttachVolumeCommandTest.java
+++ /dev/null
@@ -1,116 +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.agent.api;
-
-import com.cloud.storage.Storage.StoragePoolType;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-import com.cloud.agent.api.*;
-
-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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/BackupSnapshotAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/BackupSnapshotAnswerTest.java b/api/test/com/cloud/agent/api/BackupSnapshotAnswerTest.java
deleted file mode 100644
index 6c6929f..0000000
--- a/api/test/com/cloud/agent/api/BackupSnapshotAnswerTest.java
+++ /dev/null
@@ -1,56 +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.agent.api;
-
-import com.cloud.agent.api.*;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-public class BackupSnapshotAnswerTest {
- BackupSnapshotCommand bsc = new BackupSnapshotCommand();
- BackupSnapshotAnswer 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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/BackupSnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/BackupSnapshotCommandTest.java b/api/test/com/cloud/agent/api/BackupSnapshotCommandTest.java
deleted file mode 100644
index 28e8c0a..0000000
--- a/api/test/com/cloud/agent/api/BackupSnapshotCommandTest.java
+++ /dev/null
@@ -1,220 +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.agent.api;
-
-import com.cloud.agent.api.*;
-import static org.junit.Assert.*;
-import org.junit.Test;
-import com.cloud.agent.api.to.StorageFilerTO;
-import com.cloud.agent.api.to.SwiftTO;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.storage.StoragePoolStatus;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import java.text.ParseException;
-
-public class BackupSnapshotCommandTest {
- public StoragePool pool = new StoragePool() {
- public long getId() {return 1L;};
- public String getName() {return "name";};
- public String getUuid() {return "bed9f83e-cac3-11e1-ac8a-0050568b007e";};
- public StoragePoolType getPoolType() {return StoragePoolType.Filesystem;};
- 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 Date getUpdateTime() {return new Date();};
- public long getDataCenterId() {return 0L;};
- public long getCapacityBytes() {return 0L;};
- public long getAvailableBytes() {return 0L;};
- public Long getClusterId() {return 0L;};
- public String getHostAddress() {return "hostAddress";};
- public String getPath() {return "path";};
- public String getUserInfo() {return "userInfo";};
- public boolean isShared() {return false;};
- public boolean isLocal() {return false;};
- public StoragePoolStatus getStatus() {return StoragePoolStatus.Up;};
- public int getPort() {return 25;};
- public Long getPodId() {return 0L;};
- };
-
- BackupSnapshotCommand bsc = new BackupSnapshotCommand(
- "primaryStoragePoolNameLabel",
- "http://secondary.Storage.Url",
- 101L,
- 102L,
- 103L,
- 104L,
- "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();
-
- @Test
- public void testGetPrimaryStoragePoolNameLabel() {
- String label = bsc.getPrimaryStoragePoolNameLabel();
- assertTrue(label.equals("primaryStoragePoolNameLabel"));
- }
-
- @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/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/BumpUpPriorityCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/BumpUpPriorityCommandTest.java b/api/test/com/cloud/agent/api/BumpUpPriorityCommandTest.java
deleted file mode 100644
index f111ced..0000000
--- a/api/test/com/cloud/agent/api/BumpUpPriorityCommandTest.java
+++ /dev/null
@@ -1,73 +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.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/e953b774/api/test/com/cloud/agent/api/CancelCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/CancelCommandTest.java b/api/test/com/cloud/agent/api/CancelCommandTest.java
deleted file mode 100644
index 9ea8452..0000000
--- a/api/test/com/cloud/agent/api/CancelCommandTest.java
+++ /dev/null
@@ -1,43 +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.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/e953b774/api/test/com/cloud/agent/api/ChangeAgentAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/ChangeAgentAnswerTest.java b/api/test/com/cloud/agent/api/ChangeAgentAnswerTest.java
deleted file mode 100644
index f915e19..0000000
--- a/api/test/com/cloud/agent/api/ChangeAgentAnswerTest.java
+++ /dev/null
@@ -1,39 +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.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/e953b774/api/test/com/cloud/agent/api/ChangeAgentCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/ChangeAgentCommandTest.java b/api/test/com/cloud/agent/api/ChangeAgentCommandTest.java
deleted file mode 100644
index 43b68b1..0000000
--- a/api/test/com/cloud/agent/api/ChangeAgentCommandTest.java
+++ /dev/null
@@ -1,44 +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.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/e953b774/api/test/com/cloud/agent/api/CheckHealthAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/CheckHealthAnswerTest.java b/api/test/com/cloud/agent/api/CheckHealthAnswerTest.java
deleted file mode 100644
index 30f817b..0000000
--- a/api/test/com/cloud/agent/api/CheckHealthAnswerTest.java
+++ /dev/null
@@ -1,45 +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.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/e953b774/api/test/com/cloud/agent/api/CheckHealthCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/CheckHealthCommandTest.java b/api/test/com/cloud/agent/api/CheckHealthCommandTest.java
deleted file mode 100644
index 428ec92..0000000
--- a/api/test/com/cloud/agent/api/CheckHealthCommandTest.java
+++ /dev/null
@@ -1,37 +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.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/e953b774/api/test/com/cloud/agent/api/CheckNetworkAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/CheckNetworkAnswerTest.java b/api/test/com/cloud/agent/api/CheckNetworkAnswerTest.java
deleted file mode 100644
index 6484214..0000000
--- a/api/test/com/cloud/agent/api/CheckNetworkAnswerTest.java
+++ /dev/null
@@ -1,51 +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.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/e953b774/api/test/com/cloud/agent/api/CheckNetworkCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/CheckNetworkCommandTest.java b/api/test/com/cloud/agent/api/CheckNetworkCommandTest.java
deleted file mode 100644
index f25874c..0000000
--- a/api/test/com/cloud/agent/api/CheckNetworkCommandTest.java
+++ /dev/null
@@ -1,39 +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.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/e953b774/api/test/com/cloud/agent/api/CheckOnHostCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/CheckOnHostCommandTest.java b/api/test/com/cloud/agent/api/CheckOnHostCommandTest.java
deleted file mode 100644
index 1fae802..0000000
--- a/api/test/com/cloud/agent/api/CheckOnHostCommandTest.java
+++ /dev/null
@@ -1,366 +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.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);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/agent/api/SnapshotCommandTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/agent/api/SnapshotCommandTest.java b/api/test/com/cloud/agent/api/SnapshotCommandTest.java
deleted file mode 100644
index 5bb412e..0000000
--- a/api/test/com/cloud/agent/api/SnapshotCommandTest.java
+++ /dev/null
@@ -1,98 +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.agent.api;
-
-import com.cloud.agent.api.*;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-public class SnapshotCommandTest {
- SnapshotCommand ssc = new SnapshotCommand("primaryStoragePoolNameLabel",
- "http://secondary.Storage.Url",
- "420fa39c-4ef1-a83c-fd93-46dc1ff515ae",
- "snapshotName",
- 101L,
- 102L,
- 103L);
-
- SnapshotCommand ssc1 = new SnapshotCommand();
-
- @Test
- public void testGetPrimaryStoragePoolNameLabel() {
- String label = ssc.getPrimaryStoragePoolNameLabel();
- assertTrue(label.equals("primaryStoragePoolNameLabel"));
- }
-
- @Test
- public void testGetSecondaryStorageUrl() {
- String url = ssc.getSecondaryStorageUrl();
- assertTrue(url.equals("http://secondary.Storage.Url"));
- }
-
- @Test
- public void testGetSnapshotUuid() {
- String uuid = ssc.getSnapshotUuid();
- assertTrue(uuid.equals("420fa39c-4ef1-a83c-fd93-46dc1ff515ae"));
- }
-
- @Test
- public void testGetSnapshotName() {
- String name = ssc.getSnapshotName();
- assertTrue(name.equals("snapshotName"));
- }
-
- @Test
- public void testGetVolumePath() {
- ssc.setVolumePath("vPath");
- String path = ssc.getVolumePath();
- assertTrue(path.equals("vPath"));
-
- ssc1.setVolumePath("vPath1");
- path = ssc1.getVolumePath();
- assertTrue(path.equals("vPath1"));
- }
-
- @Test
- public void testExecuteInSequence() {
- boolean b = ssc.executeInSequence();
- assertFalse(b);
-
- b = ssc1.executeInSequence();
- assertFalse(b);
- }
-
- @Test
- public void testGetDataCenterId() {
- Long dcId = ssc.getDataCenterId();
- Long expected = 101L;
- assertEquals(expected, dcId);
- }
-
- @Test
- public void testGetAccountId() {
- Long aId = ssc.getAccountId();
- Long expected = 102L;
- assertEquals(expected, aId);
- }
-
- @Test
- public void testGetVolumeId() {
- Long vId = ssc.getVolumeId();
- Long expected = 103L;
- assertEquals(expected, vId);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/ActivateProjectCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/ActivateProjectCmdTest.java b/api/test/com/cloud/api/commands/ActivateProjectCmdTest.java
deleted file mode 100644
index 9957851..0000000
--- a/api/test/com/cloud/api/commands/ActivateProjectCmdTest.java
+++ /dev/null
@@ -1,86 +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.api.commands;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.api.ResponseGenerator;
-import com.cloud.api.response.ProjectResponse;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.projects.Project;
-import com.cloud.projects.ProjectService;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-public class ActivateProjectCmdTest extends TestCase {
-
- private ActivateProjectCmd activateProjectCmd;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
-
- activateProjectCmd = new ActivateProjectCmd(){
-
- @Override
- public Long getId() {
- return 2L;
- }
-
- };
- }
-
-
- @Test
- public void testGetEntityOwnerIdForNullProject() {
- ProjectService projectService = Mockito.mock(ProjectService.class);
- Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(null);
- activateProjectCmd._projectService = projectService;
-
- try {
- activateProjectCmd.getEntityOwnerId();
- } catch(InvalidParameterValueException exception) {
- Assert.assertEquals("Unable to find project by id 2", exception.getLocalizedMessage());
- }
- }
-
- @Test
- public void testGetEntityOwnerIdForProject() {
- Project project = Mockito.mock(Project.class);
- Mockito.when(project.getId()).thenReturn(2L);
- ProjectService projectService = Mockito.mock(ProjectService.class);
- Account account = Mockito.mock(Account.class);
- Mockito.when(account.getId()).thenReturn(2L);
- Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(project);
-
- Mockito.when(projectService.getProjectOwner(Mockito.anyLong())).thenReturn(account);
- activateProjectCmd._projectService = projectService;
-
- Assert.assertEquals(2L, activateProjectCmd.getEntityOwnerId());
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/AddAccountToProjectCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/AddAccountToProjectCmdTest.java b/api/test/com/cloud/api/commands/AddAccountToProjectCmdTest.java
deleted file mode 100644
index 152a089..0000000
--- a/api/test/com/cloud/api/commands/AddAccountToProjectCmdTest.java
+++ /dev/null
@@ -1,175 +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.api.commands;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.projects.Project;
-import com.cloud.projects.ProjectService;
-import com.cloud.user.Account;
-
-public class AddAccountToProjectCmdTest extends TestCase {
-
-
- private AddAccountToProjectCmd addAccountToProjectCmd;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
- addAccountToProjectCmd = new AddAccountToProjectCmd(){
-
- @Override
- public Long getProjectId() {
- return 2L;
- }
-
- @Override
- public String getAccountName() {
-
- // to run the test testGetEventDescriptionForAccount set the accountName
-// return "accountName";
- // to run the test the testGetEventDescriptionForNullAccount return accountname as null
- return null;
- }
-
- @Override
- public String getEmail() {
-// return "customer@abc.com";
- return null;
- }
-
- };
- }
-
-
- /****
- * Condition not handled in the code
- *
- *****/
-
- /*@Test
- public void testGetEntityOwnerIdForNullProject() {
-
- ProjectService projectService = Mockito.mock(ProjectService.class);
- Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(null);
- addAccountToProjectCmd._projectService = projectService;
-
- try {
- addAccountToProjectCmd.getEntityOwnerId();
- } catch(InvalidParameterValueException exception) {
- Assert.assertEquals("Unable to find project by id 2", exception.getLocalizedMessage());
- }
-
- }*/
-
-
- @Test
- public void testGetEntityOwnerIdForProject() {
-
- Project project = Mockito.mock(Project.class);
- Mockito.when(project.getId()).thenReturn(2L);
-
- ProjectService projectService = Mockito.mock(ProjectService.class);
- Account account = Mockito.mock(Account.class);
-
- Mockito.when(account.getId()).thenReturn(2L);
- Mockito.when(projectService.getProject(Mockito.anyLong())).thenReturn(
- project);
-
- Mockito.when(projectService.getProjectOwner(Mockito.anyLong()))
- .thenReturn(account);
- addAccountToProjectCmd._projectService = projectService;
-
- Assert.assertEquals(2L, addAccountToProjectCmd.getEntityOwnerId());
-
- }
-
- /**
- * To run the test uncomment the return statement for getAccountName() in setup() and return null
- *
- * **/
-
-
- /*@Test
- public void testGetEventDescriptionForNullAccount() {
-
- String result = addAccountToProjectCmd.getEventDescription();
- String expected = "Sending invitation to email null to join project: 2";
- Assert.assertEquals(expected, result);
-
- }*/
-
- /***
- *
- *
- *
- * ***/
-
-
-
- /*@Test
- public void testGetEventDescriptionForAccount() {
-
- String result = addAccountToProjectCmd.getEventDescription();
- String expected = "Adding account accountName to project: 2";
- Assert.assertEquals(expected, result);
-
- }*/
-
- @Test
- public void testExecuteForNullAccountNameEmail() {
-
- try {
- addAccountToProjectCmd.execute();
- } catch(InvalidParameterValueException exception) {
- Assert.assertEquals("Either accountName or email is required", exception.getLocalizedMessage());
- }
-
- }
-
-
- /*@Test
- public void testExecuteForAccountNameEmail() {
-
- try {
-
- ComponentLocator c = Mockito.mock(ComponentLocator.class);
- UserContext userContext = Mockito.mock(UserContext.class);
-
-// Mockito.when(userContext.current()).thenReturn(userContext);
-
-
- addAccountToProjectCmd.execute();
- } catch(InvalidParameterValueException exception) {
- Assert.assertEquals("Either accountName or email is required", exception.getLocalizedMessage());
- }
-
- }*/
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/AddClusterCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/AddClusterCmdTest.java b/api/test/com/cloud/api/commands/AddClusterCmdTest.java
deleted file mode 100644
index bba1b3a..0000000
--- a/api/test/com/cloud/api/commands/AddClusterCmdTest.java
+++ /dev/null
@@ -1,123 +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.api.commands;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.api.ResponseGenerator;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.ClusterResponse;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.ResourceInUseException;
-import com.cloud.org.Cluster;
-import com.cloud.resource.ResourceService;
-
-import edu.emory.mathcs.backport.java.util.Arrays;
-
-public class AddClusterCmdTest extends TestCase {
-
- private AddClusterCmd addClusterCmd;
- private ResourceService resourceService;
- private ResponseGenerator responseGenerator;
-
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
-/* resourceService = Mockito.mock(ResourceService.class);
- responseGenerator = Mockito.mock(ResponseGenerator.class);
-*/ addClusterCmd = new AddClusterCmd(){
- };
- }
-
-
-
- @Test
- public void testExecuteForNullResult() {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
-
- try {
- Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(null);
- } catch (ResourceInUseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (DiscoveryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- addClusterCmd._resourceService = resourceService;
-
- try {
- addClusterCmd.execute();
- } catch (ServerApiException exception) {
- Assert.assertEquals("Failed to add cluster", exception.getDescription());
- }
-
- }
-
-
- @Test
- public void testExecuteForEmptyResult() {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addClusterCmd._resourceService = resourceService;
-
- try {
- addClusterCmd.execute();
- } catch (ServerApiException exception) {
- Assert.assertEquals("Failed to add cluster", exception.getDescription());
- }
-
- }
-
-
- @Test
- public void testExecuteForResult() throws Exception {
-
- resourceService = Mockito.mock(ResourceService.class);
- responseGenerator = Mockito.mock(ResponseGenerator.class);
-
- addClusterCmd._resourceService = resourceService;
- addClusterCmd._responseGenerator = responseGenerator;
-
- Cluster cluster = Mockito.mock(Cluster.class);
- Cluster[] clusterArray = new Cluster[]{cluster};
-
- Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(Arrays.asList(clusterArray));
-
- addClusterCmd.execute();
-
-
- }
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/AddHostCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/AddHostCmdTest.java b/api/test/com/cloud/api/commands/AddHostCmdTest.java
deleted file mode 100644
index 85cac0c..0000000
--- a/api/test/com/cloud/api/commands/AddHostCmdTest.java
+++ /dev/null
@@ -1,169 +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.api.commands;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.api.ResponseGenerator;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.HostResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.host.Status;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.resource.ResourceService;
-import com.cloud.resource.ResourceState;
-
-import edu.emory.mathcs.backport.java.util.Arrays;
-
-public class AddHostCmdTest extends TestCase {
-
- private AddHostCmd addHostCmd;
- private ResourceService resourceService;
- private ResponseGenerator responseGenerator;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
- resourceService = Mockito.mock(ResourceService.class);
- responseGenerator = Mockito.mock(ResponseGenerator.class);
- addHostCmd = new AddHostCmd(){
- };
- }
-
- @Test
- public void testExecuteForEmptyResult() {
- addHostCmd._resourceService = resourceService;
-
- try {
- addHostCmd.execute();
- } catch(ServerApiException exception) {
- Assert.assertEquals("Failed to add host", exception.getDescription());
- }
-
- }
-
-
- @Test
- public void testExecuteForNullResult() {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addHostCmd._resourceService = resourceService;
-
- try {
- Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(null);
- } catch (InvalidParameterValueException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (DiscoveryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- try {
- addHostCmd.execute();
- } catch(ServerApiException exception) {
- Assert.assertEquals("Failed to add host", exception.getDescription());
- }
-
- }
-
-
-/* @Test
- public void testExecuteForResult() throws Exception {
-
- addHostCmd._resourceService = resourceService;
- addHostCmd._responseGenerator = responseGenerator;
- MockHost mockInstance = new MockHost();
- MockHost[] mockArray = new MockHost[]{mockInstance};
- HostResponse responseHost = new HostResponse();
- responseHost.setName("Test");
- Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(Arrays.asList(mockArray));
- Mockito.when(responseGenerator.createHostResponse(mockInstance)).thenReturn(responseHost);
- addHostCmd.execute();
- Mockito.verify(responseGenerator).createHostResponse(mockInstance);
- ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>)addHostCmd.getResponseObject());
- Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
- Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
- }
-*/
- @Test
- public void testExecuteForResult() throws Exception {
-
- addHostCmd._resourceService = resourceService;
- addHostCmd._responseGenerator = responseGenerator;
- Host host = Mockito.mock(Host.class);
- Host[] mockArray = new Host[]{host};
-
- HostResponse responseHost = new HostResponse();
- responseHost.setName("Test");
- Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(Arrays.asList(mockArray));
- Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(responseHost);
- addHostCmd.execute();
- Mockito.verify(responseGenerator).createHostResponse(host);
- ListResponse<HostResponse> actualResponse = ((ListResponse<HostResponse>)addHostCmd.getResponseObject());
- Assert.assertEquals(responseHost, actualResponse.getResponses().get(0));
- Assert.assertEquals("addhostresponse", actualResponse.getResponseName());
-
- }
-
-
- @Test
- public void testExecuteForDiscoveryException() {
-
- addHostCmd._resourceService = resourceService;
-
- try {
- Mockito.when(resourceService.discoverHosts(addHostCmd)).thenThrow(DiscoveryException.class);
- } catch (InvalidParameterValueException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (DiscoveryException e) {
- e.printStackTrace();
- }
-
- try {
- addHostCmd.execute();
- } catch(ServerApiException exception) {
- Assert.assertNull(exception.getDescription());
- }
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/AddNetworkServiceProviderCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/AddNetworkServiceProviderCmdTest.java b/api/test/com/cloud/api/commands/AddNetworkServiceProviderCmdTest.java
deleted file mode 100644
index 387680d..0000000
--- a/api/test/com/cloud/api/commands/AddNetworkServiceProviderCmdTest.java
+++ /dev/null
@@ -1,118 +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.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.api.ServerApiException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.network.NetworkService;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-
-public class AddNetworkServiceProviderCmdTest extends TestCase {
-
- private AddNetworkServiceProviderCmd addNetworkServiceProviderCmd;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
- addNetworkServiceProviderCmd = new AddNetworkServiceProviderCmd() {
-
- @Override
- public Long getPhysicalNetworkId() {
- return 2L;
- }
-
- @Override
- public String getProviderName() {
- return "ProviderName";
- }
-
- @Override
- public Long getDestinationPhysicalNetworkId() {
- return 2L;
- }
-
- @Override
- public List<String> getEnabledServices() {
- List<String> lOfEnabledServices = new ArrayList<String>();
- lOfEnabledServices.add("Enabled Services");
- return lOfEnabledServices;
- }
-
- public Long getEntityId() {
- return 2L;
- }
-
- };
-
- }
-
- @Test
- public void testCreateProviderToPhysicalNetworkSuccess() {
-
- NetworkService networkService = Mockito.mock(NetworkService.class);
- addNetworkServiceProviderCmd._networkService = networkService;
-
- PhysicalNetworkServiceProvider physicalNetworkServiceProvider = Mockito.mock(PhysicalNetworkServiceProvider.class);
- Mockito.when(networkService.addProviderToPhysicalNetwork(Mockito.anyLong(),
- Mockito.anyString(), Mockito.anyLong(),
- Mockito.anyList())).thenReturn(
- physicalNetworkServiceProvider);
-
- try {
- addNetworkServiceProviderCmd.create();
- } catch (ResourceAllocationException e) {
- e.printStackTrace();
- }
-
- }
-
-
- @Test
- public void testCreateProviderToPhysicalNetworkFailure() throws ResourceAllocationException {
-
- NetworkService networkService = Mockito.mock(NetworkService.class);
- addNetworkServiceProviderCmd._networkService = networkService;
-
- Mockito.when(networkService.addProviderToPhysicalNetwork(Mockito.anyLong(),
- Mockito.anyString(), Mockito.anyLong(),
- Mockito.anyList())).thenReturn(null);
-
- try {
- addNetworkServiceProviderCmd.create();
- } catch (ServerApiException exception) {
- Assert.assertEquals("Failed to add service provider entity to physical network", exception.getDescription());
- }
-
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/AddSecondaryStorageCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/AddSecondaryStorageCmdTest.java b/api/test/com/cloud/api/commands/AddSecondaryStorageCmdTest.java
deleted file mode 100644
index c20415c..0000000
--- a/api/test/com/cloud/api/commands/AddSecondaryStorageCmdTest.java
+++ /dev/null
@@ -1,120 +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.api.commands;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.api.ResponseGenerator;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.HostResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.resource.ResourceService;
-
-import edu.emory.mathcs.backport.java.util.Arrays;
-
-public class AddSecondaryStorageCmdTest extends TestCase {
-
- private AddSecondaryStorageCmd addSecondaryStorageCmd;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
- addSecondaryStorageCmd = new AddSecondaryStorageCmd() {
- };
-
- }
-
-
- @Test
- public void testExecuteForResult() throws Exception {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addSecondaryStorageCmd._resourceService = resourceService;
-
- Host host = Mockito.mock(Host.class);
- Host[] mockHosts = new Host[] {host};
-
- Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd)).thenReturn(Arrays.asList(mockHosts));
-
- ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
- addSecondaryStorageCmd._responseGenerator = responseGenerator;
-
- HostResponse responseHost = new HostResponse();
- responseHost.setName("Test");
-
- Mockito.when(responseGenerator.createHostResponse(host)).thenReturn(responseHost);
-
- addSecondaryStorageCmd.execute();
-
- Mockito.verify(responseGenerator).createHostResponse(host);
-
- HostResponse actualResponse = (HostResponse)addSecondaryStorageCmd.getResponseObject();
-
- Assert.assertEquals(responseHost, actualResponse);
- Assert.assertEquals("addsecondarystorageresponse", actualResponse.getResponseName());
-
-
- }
-
- @Test
- public void testExecuteForEmptyResult() throws Exception {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addSecondaryStorageCmd._resourceService = resourceService;
-
- Host[] mockHosts = new Host[] {};
-
- Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd)).thenReturn(Arrays.asList(mockHosts));
-
- try {
- addSecondaryStorageCmd.execute();
- } catch(ServerApiException exception) {
- Assert.assertEquals("Failed to add secondary storage", exception.getDescription());
- }
-
- }
-
- @Test
- public void testExecuteForNullResult() throws Exception {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addSecondaryStorageCmd._resourceService = resourceService;
-
- Mockito.when(resourceService.discoverHosts(addSecondaryStorageCmd)).thenReturn(null);
-
- try {
- addSecondaryStorageCmd.execute();
- } catch(ServerApiException exception) {
- Assert.assertEquals("Failed to add secondary storage", exception.getDescription());
- }
-
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e953b774/api/test/com/cloud/api/commands/AddSwiftCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/com/cloud/api/commands/AddSwiftCmdTest.java b/api/test/com/cloud/api/commands/AddSwiftCmdTest.java
deleted file mode 100644
index 0402135..0000000
--- a/api/test/com/cloud/api/commands/AddSwiftCmdTest.java
+++ /dev/null
@@ -1,92 +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.api.commands;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Mockito;
-
-import com.cloud.api.ResponseGenerator;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SwiftResponse;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.resource.ResourceService;
-import com.cloud.storage.Swift;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-public class AddSwiftCmdTest extends TestCase {
-
- private AddSwiftCmd addSwiftCmd;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setUp() {
- addSwiftCmd = new AddSwiftCmd();
- }
-
- @Test
- public void testExecuteSuccess() {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addSwiftCmd._resourceService = resourceService;
-
- Swift swift = Mockito.mock(Swift.class);
-
- try {
- Mockito.when(resourceService.discoverSwift(addSwiftCmd)).thenReturn(swift);
- } catch (DiscoveryException e) {
- e.printStackTrace();
- }
-
- ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
- addSwiftCmd._responseGenerator = responseGenerator;
-
- SwiftResponse swiftResponse = Mockito.mock(SwiftResponse.class);
-
- Mockito.when(responseGenerator.createSwiftResponse(swift)).thenReturn(swiftResponse);
-
- addSwiftCmd.execute();
-
- }
-
-
- @Test
- public void testExecuteFailure() {
-
- ResourceService resourceService = Mockito.mock(ResourceService.class);
- addSwiftCmd._resourceService = resourceService;
- try {
- Mockito.when(resourceService.discoverSwift(addSwiftCmd)).thenReturn(null);
- } catch (DiscoveryException e) {
- e.printStackTrace();
- }
-
- try {
- addSwiftCmd.execute();
- } catch(ServerApiException exception) {
- Assert.assertEquals("Failed to add Swift", exception.getDescription());
- }
-
- }
-
-}