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/a2a4a0bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a2a4a0bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a2a4a0bb

Branch: refs/heads/junit-tests
Commit: a2a4a0bb0771f6729f4a8dd32a39799991073b2f
Parents: 8ec5749
Author: Yichi Lu <[email protected]>
Authored: Mon Oct 22 13:24:25 2012 -0400
Committer: Chip Childers <[email protected]>
Committed: Mon Oct 22 13:24:25 2012 -0400

----------------------------------------------------------------------
 api/src/test/.gitignore                            |    1 +
 api/src/test/java/com/cloud/agent/api/.gitignore   |   15 +
 .../cloud/agent/api/AgentControlAnswerTest.java    |   32 ++
 .../cloud/agent/api/AgentControlCommandTest.java   |   31 ++
 .../test/java/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 +++++++++++++++
 10 files changed, 674 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2a4a0bb/api/src/test/.gitignore
----------------------------------------------------------------------
diff --git a/api/src/test/.gitignore b/api/src/test/.gitignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/api/src/test/.gitignore
@@ -0,0 +1 @@
+target

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2a4a0bb/api/src/test/java/com/cloud/agent/api/.gitignore
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/.gitignore 
b/api/src/test/java/com/cloud/agent/api/.gitignore
new file mode 100644
index 0000000..991a3b6
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/.gitignore
@@ -0,0 +1,15 @@
+*.class
+*.jar
+*.pom
+*.properties
+*.repositories
+*.sha1
+*.xml
+META-INF/
+baremetal/
+check/
+com/
+proxy/
+routing/
+storage/
+to/

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a2a4a0bb/api/src/test/java/com/cloud/agent/api/AgentControlAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/AgentControlAnswerTest.java 
b/api/src/test/java/com/cloud/agent/api/AgentControlAnswerTest.java
new file mode 100644
index 0000000..7bfd776
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/AgentControlAnswerTest.java
@@ -0,0 +1,32 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/AgentControlCommandTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/AgentControlCommandTest.java 
b/api/src/test/java/com/cloud/agent/api/AgentControlCommandTest.java
new file mode 100644
index 0000000..12ea0d6
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/AgentControlCommandTest.java
@@ -0,0 +1,31 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/AnswerTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/AnswerTest.java 
b/api/src/test/java/com/cloud/agent/api/AnswerTest.java
new file mode 100644
index 0000000..c53c84a
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/AnswerTest.java
@@ -0,0 +1,67 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/AttachIsoCommandTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/AttachIsoCommandTest.java 
b/api/src/test/java/com/cloud/agent/api/AttachIsoCommandTest.java
new file mode 100644
index 0000000..42df9db
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/AttachIsoCommandTest.java
@@ -0,0 +1,77 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/AttachVolumeAnswerTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/AttachVolumeAnswerTest.java 
b/api/src/test/java/com/cloud/agent/api/AttachVolumeAnswerTest.java
new file mode 100644
index 0000000..886995e
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/AttachVolumeAnswerTest.java
@@ -0,0 +1,59 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/AttachVolumeCommandTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/cloud/agent/api/AttachVolumeCommandTest.java 
b/api/src/test/java/com/cloud/agent/api/AttachVolumeCommandTest.java
new file mode 100644
index 0000000..24e1a51
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/AttachVolumeCommandTest.java
@@ -0,0 +1,116 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/BackupSnapshotAnswerTest.java
----------------------------------------------------------------------
diff --git 
a/api/src/test/java/com/cloud/agent/api/BackupSnapshotAnswerTest.java 
b/api/src/test/java/com/cloud/agent/api/BackupSnapshotAnswerTest.java
new file mode 100644
index 0000000..6c6929f
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/BackupSnapshotAnswerTest.java
@@ -0,0 +1,56 @@
+// 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/a2a4a0bb/api/src/test/java/com/cloud/agent/api/BackupSnapshotCommandTest.java
----------------------------------------------------------------------
diff --git 
a/api/src/test/java/com/cloud/agent/api/BackupSnapshotCommandTest.java 
b/api/src/test/java/com/cloud/agent/api/BackupSnapshotCommandTest.java
new file mode 100644
index 0000000..28e8c0a
--- /dev/null
+++ b/api/src/test/java/com/cloud/agent/api/BackupSnapshotCommandTest.java
@@ -0,0 +1,220 @@
+// 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);
+       }
+
+}

Reply via email to