CLOUDSTACK-8656: move cli test tool to separate file

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

Branch: refs/heads/master
Commit: 3229d9601523110aa4de672a3ef2990d5fbc99c0
Parents: f203acc
Author: Daan Hoogland <[email protected]>
Authored: Fri Aug 14 13:15:11 2015 +0200
Committer: Daan Hoogland <[email protected]>
Committed: Fri Aug 14 13:15:11 2015 +0200

----------------------------------------------------------------------
 utils/src/com/cloud/utils/DateUtil.java      | 26 ----------
 utils/test/com/cloud/utils/DateUtilTest.java | 60 +++++++++++++++++++++++
 2 files changed, 60 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3229d960/utils/src/com/cloud/utils/DateUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/DateUtil.java 
b/utils/src/com/cloud/utils/DateUtil.java
index be18fa2..7787e1b 100644
--- a/utils/src/com/cloud/utils/DateUtil.java
+++ b/utils/src/com/cloud/utils/DateUtil.java
@@ -271,30 +271,4 @@ public class DateUtil {
         return (dateCalendar1.getTimeInMillis() - 
dateCalendar2.getTimeInMillis() )/1000;
 
     }
-
-    // test only
-    public static void main(String[] args) {
-        TimeZone localTimezone = Calendar.getInstance().getTimeZone();
-        TimeZone gmtTimezone = TimeZone.getTimeZone("GMT");
-        TimeZone estTimezone = TimeZone.getTimeZone("EST");
-
-        Date time = new Date();
-        System.out.println("local time :" + 
getDateDisplayString(localTimezone, time));
-        System.out.println("GMT time   :" + getDateDisplayString(gmtTimezone, 
time));
-        System.out.println("EST time   :" + getDateDisplayString(estTimezone, 
time));
-        //Test next run time. Expects interval and schedule as arguments
-        if (args.length == 2) {
-            System.out.println("Next run time: " + 
getNextRunTime(IntervalType.getIntervalType(args[0]), args[1], "GMT", 
time).toString());
-        }
-
-        time = new Date();
-        DateFormat dfDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'Z");
-        String str = dfDate.format(time);
-        System.out.println("Formated TZ time string : " + str);
-        try {
-            Date dtParsed = DateUtil.parseTZDateString(str);
-            System.out.println("Parsed TZ time string : " + 
dtParsed.toString());
-        } catch (ParseException e) {
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3229d960/utils/test/com/cloud/utils/DateUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/DateUtilTest.java 
b/utils/test/com/cloud/utils/DateUtilTest.java
new file mode 100644
index 0000000..ba88505
--- /dev/null
+++ b/utils/test/com/cloud/utils/DateUtilTest.java
@@ -0,0 +1,60 @@
+//
+// 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.utils;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import com.cloud.utils.DateUtil.IntervalType;
+
+
+public class DateUtilTest {
+
+    // command line test tool
+    public static void main(String[] args) {
+        TimeZone localTimezone = Calendar.getInstance().getTimeZone();
+        TimeZone gmtTimezone = TimeZone.getTimeZone("GMT");
+        TimeZone estTimezone = TimeZone.getTimeZone("EST");
+
+        Date time = new Date();
+        System.out.println("local time :" + 
DateUtil.getDateDisplayString(localTimezone, time));
+        System.out.println("GMT time   :" + 
DateUtil.getDateDisplayString(gmtTimezone, time));
+        System.out.println("EST time   :" + 
DateUtil.getDateDisplayString(estTimezone, time));
+        //Test next run time. Expects interval and schedule as arguments
+        if (args.length == 2) {
+            System.out.println("Next run time: " + 
DateUtil.getNextRunTime(IntervalType.getIntervalType(args[0]), args[1], "GMT", 
time).toString());
+        }
+
+        time = new Date();
+        DateFormat dfDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'Z");
+        String str = dfDate.format(time);
+        System.out.println("Formated TZ time string : " + str);
+        try {
+            Date dtParsed = DateUtil.parseTZDateString(str);
+            System.out.println("Parsed TZ time string : " + 
dtParsed.toString());
+        } catch (ParseException e) {
+            System.err.println("Parsing failed\n string : " + str + 
"\nexception :" + e.getLocalizedMessage());
+        }
+    }
+
+}

Reply via email to