/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Quarter q = new Quarter(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623347200000L, q.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { q.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Quarter q = new Quarter(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); assertEquals(978307200000L, q.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { q.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Quarter q = new Quarter(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-615488400001L, q.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { q.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Quarter q = new Quarter(3, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); assertEquals(1001890799999L, q.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { q.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L). Use this * to check the quarter constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Calendar c = new GregorianCalendar(zone); Quarter q1 = new Quarter(new Date(1017619199999L), zone, Locale.getDefault()); Quarter q2 = new Quarter(new Date(1017619200000L), zone, Locale.getDefault()); assertEquals(1, q1.getQuarter()); assertEquals(1017619199999L, q1.getLastMillisecond(c)); assertEquals(2, q2.getQuarter()); assertEquals(1017619200000L, q2.getFirstMillisecond(c)); }
/** * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L). Use * this to check the quarter constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul"); Calendar c = new GregorianCalendar(zone); Quarter q1 = new Quarter(new Date(1017608399999L), zone, Locale.getDefault()); Quarter q2 = new Quarter(new Date(1017608400000L), zone, Locale.getDefault()); assertEquals(1, q1.getQuarter()); assertEquals(1017608399999L, q1.getLastMillisecond(c)); assertEquals(2, q2.getQuarter()); assertEquals(1017608400000L, q2.getFirstMillisecond(c)); }
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Quarter q = new Quarter(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-623347200000L, q.getFirstMillisecond(c)); // try null calendar boolean pass = false; try { q.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Quarter q = new Quarter(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, q.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { q.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Quarter q = new Quarter(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-615488400001L, q.getLastMillisecond(c)); // try null calendar boolean pass = false; try { q.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Quarter q = new Quarter(3, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1001894399999L, q.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { q.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = new PeriodAxis("Test"); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); a1.setFirst(new Year(2000)); assertFalse(a1.equals(a2)); a2.setFirst(new Year(2000)); assertTrue(a1.equals(a2)); a1.setLast(new Year(2004)); assertFalse(a1.equals(a2)); a2.setLast(new Year(2004)); assertTrue(a1.equals(a2)); a1.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); assertFalse(a1.equals(a2)); a2.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); assertTrue(a1.equals(a2)); a1.setAutoRangeTimePeriodClass(Quarter.class); assertFalse(a1.equals(a2)); a2.setAutoRangeTimePeriodClass(Quarter.class); assertTrue(a1.equals(a2)); PeriodAxisLabelInfo info[] = new PeriodAxisLabelInfo[1]; info[0] = new PeriodAxisLabelInfo(Month.class, "MMM"); a1.setLabelInfo(info); assertFalse(a1.equals(a2)); a2.setLabelInfo(info); assertTrue(a1.equals(a2)); }
/** * Common test setup. */ protected void setUp() { this.q1Y1900 = new Quarter(1, 1900); this.q2Y1900 = new Quarter(2, 1900); this.q3Y9999 = new Quarter(3, 9999); this.q4Y9999 = new Quarter(4, 9999); }
/** * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L). Use this to check the * quarter constructor. */ public void testDateConstructor1() { final TimeZone zone = TimeZone.getTimeZone("GMT"); final Quarter q1 = new Quarter(new Date(1017619199999L), zone); final Quarter q2 = new Quarter(new Date(1017619200000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017619199999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017619200000L, q2.getFirstMillisecond(zone)); }
/** * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L). Use this to check the * quarter constructor. */ public void testDateConstructor2() { final TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul"); final Quarter q1 = new Quarter(new Date(1017608399999L), zone); final Quarter q2 = new Quarter(new Date(1017608400000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017608399999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017608400000L, q2.getFirstMillisecond(zone)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { final Quarter q1 = new Quarter(2, 2003); final Quarter q2 = new Quarter(2, 2003); assertTrue(q1.equals(q2)); final int h1 = q1.hashCode(); final int h2 = q2.hashCode(); assertEquals(h1, h2); }
/** * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L). Use this * to check the quarter constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Quarter q1 = new Quarter(new Date(1017619199999L), zone); Quarter q2 = new Quarter(new Date(1017619200000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017619199999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017619200000L, q2.getFirstMillisecond(zone)); }
/** * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L). Use * this to check the quarter constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul"); Quarter q1 = new Quarter(new Date(1017608399999L), zone); Quarter q2 = new Quarter(new Date(1017608400000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017608399999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017608400000L, q2.getFirstMillisecond(zone)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Quarter q1 = new Quarter(2, 2003); Quarter q2 = new Quarter(2, 2003); assertTrue(q1.equals(q2)); int h1 = q1.hashCode(); int h2 = q2.hashCode(); assertEquals(h1, h2); }
/** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); Quarter q = new Quarter(3, 1970); assertEquals(15634800000L, q.getFirstMillisecond()); Locale.setDefault(saved); }
/** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); Quarter q = new Quarter(3, 1970); assertEquals(23583599999L, q.getLastMillisecond()); Locale.setDefault(saved); }
/** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JULY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Quarter q = new Quarter(3, 2006); assertEquals(cal.getTime(), q.getStart()); Locale.setDefault(saved); }
/** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.MARCH, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Quarter q = new Quarter(1, 2006); assertEquals(cal.getTime(), q.getEnd()); Locale.setDefault(saved); }
/** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Quarter q = new Quarter(3, 1970); assertEquals(15634800000L, q.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
/** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Quarter q = new Quarter(3, 1970); assertEquals(23583599999L, q.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }