ICU-13703 Fixed TestHoliday/TestEaster test execution issue.

X-SVN-Rev: 41416
This commit is contained in:
Yoshito Umaoka 2018-05-20 18:47:57 +00:00
parent 8265a37aa4
commit 19eadbf90d
3 changed files with 33 additions and 16 deletions

View File

@ -154,8 +154,7 @@ class EasterRule implements DateRule {
public EasterRule(int daysAfterEaster, boolean isOrthodox) {
this.daysAfterEaster = daysAfterEaster;
if (isOrthodox) {
orthodox.setGregorianChange(new Date(Long.MAX_VALUE));
calendar = orthodox;
calendar.setGregorianChange(new Date(Long.MAX_VALUE));
}
}
@ -288,9 +287,6 @@ class EasterRule implements DateRule {
}
}
private static GregorianCalendar gregorian = new GregorianCalendar(/* new SimpleTimeZone(0, "UTC") */);
private static GregorianCalendar orthodox = new GregorianCalendar(/* new SimpleTimeZone(0, "UTC") */);
private int daysAfterEaster;
private GregorianCalendar calendar = gregorian;
private GregorianCalendar calendar = new GregorianCalendar();
}

View File

@ -11,7 +11,6 @@ package com.ibm.icu.dev.test.calendar;
import java.util.Date;
import java.util.Locale;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -33,13 +32,14 @@ import com.ibm.icu.util.ULocale;
*/
@RunWith(JUnit4.class)
public class HolidayTest extends TestFmwk {
@Before
public void init() throws Exception {
if(cal==null){
cal = new GregorianCalendar(1, 0, 1);
longTimeAgo = cal.getTime();
now = new Date();
}
// Do not use Before annotation, because TestFmwk's Before
// method must be executed first to initialize default time zone
@Override
protected void localTestInitialize() {
cal = new GregorianCalendar(1, 0, 1);
longTimeAgo = cal.getTime();
now = new Date();
}
private Calendar cal;

View File

@ -75,17 +75,38 @@ abstract public class TestFmwk extends AbstractTestLog {
}
@Before
public void testInitialize() {
public final void testInitialize() {
Locale.setDefault(defaultLocale);
TimeZone.setDefault(defaultTimeZone);
if (getParams().testSecurityManager != null) {
System.setSecurityManager(getParams().testSecurityManager);
}
localTestInitialize();
}
/**
* This method is called at the end of {@link #testInitialize()}.
* Because JUnit does not guarantee the order of multiple Before
* methods, TestFmwk implementation class should override this
* method, instead of annotating Before.
*/
protected void localTestInitialize() {
}
/**
* This method is called at the beginning of {@link #testTeardown()}.
* TestFmwk implementation class hould override this method, instead
* of annotating After.
*/
protected void localTestTeardown() {
}
@After
public void testTeardown() {
public final void testTeardown() {
localTestTeardown();
if (getParams().testSecurityManager != null) {
System.setSecurityManager(getParams().originalSecurityManager);
}