Updated Branches:
  refs/heads/qemu-img be90c90f6 -> 4d39ad412

Add tests for QemuImg


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/4d39ad41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/4d39ad41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/4d39ad41

Branch: refs/heads/qemu-img
Commit: 4d39ad412297eea95281450ecc02a4fffeb6d0ee
Parents: 67ecff4
Author: Wido den Hollander <[email protected]>
Authored: Sat Feb 16 16:06:57 2013 +0100
Committer: Wido den Hollander <[email protected]>
Committed: Sat Feb 16 16:06:57 2013 +0100

----------------------------------------------------------------------
 .../apache/cloudstack/utils/qemu/QemuImgTest.java  |   61 +++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4d39ad41/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
----------------------------------------------------------------------
diff --git a/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java 
b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
new file mode 100644
index 0000000..ef22390
--- /dev/null
+++ b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
@@ -0,0 +1,61 @@
+// 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
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.utils.qemu;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import org.apache.cloudstack.utils.qemu.QemuImgFile;
+import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+public class QemuImgTest {
+    @Test
+    public void testCreateAndInfo() {
+        String filename = "/tmp/test-image.qcow2";
+        long size = 10240;
+        QemuImgFile file = new QemuImgFile(filename);
+
+        QemuImg qemu = new QemuImg();
+        qemu.create(file);
+        List<Map<String, String>> info = qemu.info(file);
+        if (info == null) {
+            fail("We didn't get any information back from qemu-img");
+        }
+    }
+
+    @Test
+    public void testConvertBasic() {
+        long srcSize = 20480;
+        String srcFileName = "/tmp/test-src-image.qcow2";
+        String destFileName = "/tmp/test-dest-image.qcow2";
+
+        QemuImgFile srcFile = new QemuImgFile(srcFileName, srcSize);
+        QemuImgFile destFile = new QemuImgFile(destFileName);
+
+        QemuImg qemu = new QemuImg();
+        qemu.create(srcFile);
+        qemu.convert(srcFile, destFile);
+        List<Map<String, String>> info = qemu.info(destFile);
+        if (info == null) {
+            fail("We didn't get any information back from qemu-img");
+        }
+    }
+}
\ No newline at end of file

Reply via email to