01: package test.tmp;
02:
03: import java.lang.reflect.Method;
04: import java.util.Calendar;
05:
06: import org.testng.annotations.Test;
07:
08: public class TimeBombTest {
09:
10: @IgnoreUntil(time="1022")
11: @Test
12: public void timeBomb() throws SecurityException,
13: NoSuchMethodException {
14: Method m = TimeBombTest.class.getMethod("timeBomb",
15: new Class[0]);
16: IgnoreUntil t = m.getAnnotation(IgnoreUntil.class);
17: long now = Calendar.getInstance().getTimeInMillis();
18: long l = parseTime(t.time());
19: ppp("IGNORE:" + (now < l));
20: }
21:
22: private long parseTime(String string) {
23: int hour = Integer.parseInt(string.substring(0, 2));
24: int minute = Integer.parseInt(string.substring(2));
25: Calendar result = Calendar.getInstance();
26: result.set(Calendar.HOUR_OF_DAY, hour);
27: result.set(Calendar.MINUTE, minute);
28:
29: return result.getTimeInMillis();
30: }
31:
32: private void ppp(String string) {
33: System.out.println("[TimeBombTest] " + string);
34: }
35:
36: }
|