incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [1/2] git commit: refs/heads/qemu-img - Add a more advanced test for the image convert
Date Wed, 20 Feb 2013 21:52:58 GMT
Add a more advanced test for the image convert


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

Branch: refs/heads/qemu-img
Commit: af50747b0770f6397dce96608838f4d9e995747d
Parents: 5e6ff4b
Author: Wido den Hollander <wido@42on.com>
Authored: Wed Feb 20 22:09:43 2013 +0100
Committer: Wido den Hollander <wido@42on.com>
Committed: Wed Feb 20 22:09:43 2013 +0100

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


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af50747b/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
index 17687eb..b2464b9 100644
--- a/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
+++ b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
@@ -79,4 +79,35 @@ public class QemuImgTest {
         df.delete();
 
     }
+
+    @Test
+    public void testConvertAdvanced() {
+        long srcSize = 4019200;
+        String srcFileName = "/tmp/test-src-image.qcow2";
+        String destFileName = "/tmp/test-dest-image.qcow2";
+        PhysicalDiskFormat srcFormat = PhysicalDiskFormat.RAW;
+        PhysicalDiskFormat destFormat = PhysicalDiskFormat.QCOW2;
+
+        QemuImgFile srcFile = new QemuImgFile(srcFileName, srcSize, srcFormat);
+        QemuImgFile destFile = new QemuImgFile(destFileName, destFormat);
+
+        QemuImg qemu = new QemuImg();
+        qemu.create(srcFile);
+        qemu.convert(srcFile, destFile);
+
+        Map<String, String> info = qemu.info(destFile);
+
+        PhysicalDiskFormat infoFormat = PhysicalDiskFormat.valueOf(info.get(new String("file_format")).toUpperCase());
+        assertEquals(destFormat, infoFormat);
+
+        Long infoSize = Long.parseLong(info.get(new String("virtual_size")));
+        assertEquals(Long.valueOf(srcSize), Long.valueOf(infoSize));
+
+        File sf = new File(srcFileName);
+        sf.delete();
+
+        File df = new File(destFileName);
+        df.delete();
+
+    }
 }
\ No newline at end of file


Mime
View raw message