From 5f2c732a2c3ff90c5d21c53477576b754d934305 Mon Sep 17 00:00:00 2001 From: borisroman Date: Wed, 9 Sep 2015 11:16:14 +0200 Subject: [PATCH 1/2] Removal of test/debug code. Removed main() method from LocalTemplateDownloader.java --- .../storage/template/LocalTemplateDownloader.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/src/com/cloud/storage/template/LocalTemplateDownloader.java b/core/src/com/cloud/storage/template/LocalTemplateDownloader.java index d55a4a2ecfe..3d33a214276 100644 --- a/core/src/com/cloud/storage/template/LocalTemplateDownloader.java +++ b/core/src/com/cloud/storage/template/LocalTemplateDownloader.java @@ -159,16 +159,4 @@ public class LocalTemplateDownloader extends TemplateDownloaderBase implements T } } } - - public static void main(String[] args) { - String url = "file:///home/ahuang/Download/E3921_P5N7A-VM_manual.zip"; - TemplateDownloader td = new LocalTemplateDownloader(null, url, "/tmp/mysql", TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null); - long bytes = td.download(true, null); - if (bytes > 0) { - System.out.println("Downloaded (" + bytes + " bytes)" + " in " + td.getDownloadTime() / 1000 + " secs"); - } else { - System.out.println("Failed download"); - } - - } } From c3f2ea6ae0aa5cf1f54d82aab5d9873b8753d541 Mon Sep 17 00:00:00 2001 From: Boris Schrijver Date: Thu, 10 Sep 2015 01:26:23 +0200 Subject: [PATCH 2/2] Added Unit Test for LocalTemplateDownloader. --- .../template/LocalTemplateDownloaderTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 core/test/com/cloud/storage/template/LocalTemplateDownloaderTest.java diff --git a/core/test/com/cloud/storage/template/LocalTemplateDownloaderTest.java b/core/test/com/cloud/storage/template/LocalTemplateDownloaderTest.java new file mode 100644 index 00000000000..74d1adc3c58 --- /dev/null +++ b/core/test/com/cloud/storage/template/LocalTemplateDownloaderTest.java @@ -0,0 +1,41 @@ +// +// 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.storage.template; + +import static org.junit.Assert.fail; + +import java.io.File; + +import org.junit.Test; + + +public class LocalTemplateDownloaderTest { + + @Test + public void localTemplateDownloaderTest() { + String url = "file://" + new File("pom.xml").getAbsolutePath(); + TemplateDownloader td = new LocalTemplateDownloader(null, url, "/tmp", TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES, null); + long bytes = td.download(true, null); + if (!(bytes > 0)) { + fail("Failed download"); + } + } + +}