1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html#License
3/**
4 *******************************************************************************
5 * Copyright (C) 2003-2011, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
8 */
9package com.ibm.icu.dev.test;
10
11import java.util.Calendar;
12import java.util.Date;
13import java.util.GregorianCalendar;
14
15import org.junit.Assert;
16
17import com.ibm.icu.util.VersionInfo;
18
19public abstract class AbstractTestLog implements TestLog {
20    /**
21     * Returns true if ICU_Version < major.minor.
22     */
23    static public boolean isICUVersionBefore(int major, int minor) {
24        return isICUVersionBefore(major, minor, 0);
25    }
26
27    /**
28     * Returns true if ICU_Version < major.minor.milli.
29     */
30    static public boolean isICUVersionBefore(int major, int minor, int milli) {
31        return VersionInfo.ICU_VERSION.compareTo(VersionInfo.getInstance(major, minor, milli)) < 0;
32    }
33
34    /**
35     * Returns true if ICU_Version >= major.minor.
36     */
37    static public boolean isICUVersionAtLeast(int major, int minor) {
38        return isICUVersionAtLeast(major, minor, 0);
39    }
40
41    /**
42     * Returns true if ICU_Version >= major.minor.milli.
43     */
44    static public boolean isICUVersionAtLeast(int major, int minor, int milli) {
45        return !isICUVersionBefore(major, minor, milli);
46    }
47
48    /**
49     * Add a message.
50     */
51    public static final void log(String message) {
52        // TODO(stuartg): turned off - causing OOM running under ant
53        // Probably temporary - must decide what to do with these
54        //System.out.print(message);
55        //msg(message, LOG, true, false);
56    }
57
58    /**
59     * Add a message and newline.
60     */
61    public static final void logln(String message) {
62        // TODO(stuartg): turned off - causing OOM running under ant
63        // Probably temporary - must decide what to do with these
64        //System.out.println(message);
65        //msg(message, LOG, true, true);
66    }
67
68    /**
69     * Report an error.
70     */
71    public static final void err(String message) {
72        Assert.fail(message);
73        //msg(message, ERR, true, false);
74    }
75
76    /**
77     * Report an error and newline.
78     */
79    public static final void errln(String message) {
80        Assert.fail(message);
81        //msg(message, ERR, true, true);
82    }
83
84    /**
85     * Report a warning (generally missing tests or data).
86     */
87    public static final void warn(String message) {
88        Assert.fail(message);
89        // TODO(stuartg): turned off - causing OOM running under ant
90        //System.out.print(message);
91        //msg(message, WARN, true, false);
92    }
93
94    /**
95     * Report a warning (generally missing tests or data) and newline.
96     */
97    public static final void warnln(String message) {
98        Assert.fail(message);
99        // TODO(stuartg): turned off - causing OOM running under ant
100        //System.out.println(message);
101        //msg(message, WARN, true, true);
102    }
103
104    /**
105     * Vector for logging.  Callers can force the logging system to
106     * not increment the error or warning level by passing false for incCount.
107     *
108     * @param message the message to output.
109     * @param level the message level, either LOG, WARN, or ERR.
110     * @param incCount if true, increments the warning or error count
111     * @param newln if true, forces a newline after the message
112     */
113    //public abstract void msg(String message, int level, boolean incCount, boolean newln);
114
115    public boolean isDateAtLeast(int year, int month, int day){
116        Date now = new Date();
117        Calendar c = new GregorianCalendar(year, month, day);
118        Date dt = c.getTime();
119        if(now.compareTo(dt)>=0){
120            return true;
121        }
122        return false;
123    }
124}
125