0001: /* ===========================================================
0002: * JFreeChart : a free chart library for the Java(tm) platform
0003: * ===========================================================
0004: *
0005: * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
0006: *
0007: * Project Info: http://www.jfree.org/jfreechart/index.html
0008: *
0009: * This library is free software; you can redistribute it and/or modify it
0010: * under the terms of the GNU Lesser General Public License as published by
0011: * the Free Software Foundation; either version 2.1 of the License, or
0012: * (at your option) any later version.
0013: *
0014: * This library is distributed in the hope that it will be useful, but
0015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
0017: * License for more details.
0018: *
0019: * You should have received a copy of the GNU Lesser General Public
0020: * License along with this library; if not, write to the Free Software
0021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
0022: * USA.
0023: *
0024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
0025: * in the United States and other countries.]
0026: *
0027: * ------------------
0028: * DateAxisTests.java
0029: * ------------------
0030: * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors.
0031: *
0032: * Original Author: David Gilbert (for Object Refinery Limited);
0033: * Contributor(s): -;
0034: *
0035: * $Id: DateAxisTests.java,v 1.1.2.3 2007/05/03 14:27:11 mungady Exp $
0036: *
0037: * Changes
0038: * -------
0039: * 22-Apr-2003 : Version 1 (DG);
0040: * 07-Jan-2005 : Added test for hashCode() method (DG);
0041: * 25-Sep-2005 : New tests for bug 1564977 (DG);
0042: * 19-Apr-2007 : Added further checks for setMinimumDate() and
0043: * setMaximumDate() (DG);
0044: * 03-May-2007 : Replaced the tests for the previousStandardDate() method with
0045: * new tests that check that the previousStandardDate and the
0046: * next standard date do in fact span the reference date (DG);
0047: *
0048: */
0049:
0050: package org.jfree.chart.axis.junit;
0051:
0052: import java.awt.geom.Rectangle2D;
0053: import java.io.ByteArrayInputStream;
0054: import java.io.ByteArrayOutputStream;
0055: import java.io.ObjectInput;
0056: import java.io.ObjectInputStream;
0057: import java.io.ObjectOutput;
0058: import java.io.ObjectOutputStream;
0059: import java.text.SimpleDateFormat;
0060: import java.util.Calendar;
0061: import java.util.Date;
0062:
0063: import junit.framework.Test;
0064: import junit.framework.TestCase;
0065: import junit.framework.TestSuite;
0066:
0067: import org.jfree.chart.axis.DateAxis;
0068: import org.jfree.chart.axis.DateTickMarkPosition;
0069: import org.jfree.chart.axis.DateTickUnit;
0070: import org.jfree.chart.axis.SegmentedTimeline;
0071: import org.jfree.data.time.DateRange;
0072: import org.jfree.data.time.Day;
0073: import org.jfree.data.time.Hour;
0074: import org.jfree.data.time.Millisecond;
0075: import org.jfree.data.time.Month;
0076: import org.jfree.data.time.Second;
0077: import org.jfree.data.time.Year;
0078: import org.jfree.ui.RectangleEdge;
0079:
0080: /**
0081: * Tests for the {@link DateAxis} class.
0082: */
0083: public class DateAxisTests extends TestCase {
0084:
0085: static class MyDateAxis extends DateAxis {
0086:
0087: /**
0088: * Creates a new instance.
0089: *
0090: * @param label the label.
0091: */
0092: public MyDateAxis(String label) {
0093: super (label);
0094: }
0095:
0096: public Date previousStandardDate(Date d, DateTickUnit unit) {
0097: return super .previousStandardDate(d, unit);
0098: }
0099: }
0100:
0101: /**
0102: * Returns the tests as a test suite.
0103: *
0104: * @return The test suite.
0105: */
0106: public static Test suite() {
0107: return new TestSuite(DateAxisTests.class);
0108: }
0109:
0110: /**
0111: * Constructs a new set of tests.
0112: *
0113: * @param name the name of the tests.
0114: */
0115: public DateAxisTests(String name) {
0116: super (name);
0117: }
0118:
0119: /**
0120: * Confirm that the equals method can distinguish all the required fields.
0121: */
0122: public void testEquals() {
0123:
0124: DateAxis a1 = new DateAxis("Test");
0125: DateAxis a2 = new DateAxis("Test");
0126: assertTrue(a1.equals(a2));
0127: assertFalse(a1.equals(null));
0128: assertFalse(a1.equals("Some non-DateAxis object"));
0129:
0130: // tickUnit
0131: a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
0132: assertFalse(a1.equals(a2));
0133: a2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7));
0134: assertTrue(a1.equals(a2));
0135:
0136: // dateFormatOverride
0137: a1.setDateFormatOverride(new SimpleDateFormat("yyyy"));
0138: assertFalse(a1.equals(a2));
0139: a2.setDateFormatOverride(new SimpleDateFormat("yyyy"));
0140: assertTrue(a1.equals(a2));
0141:
0142: // tickMarkPosition
0143: a1.setTickMarkPosition(DateTickMarkPosition.END);
0144: assertFalse(a1.equals(a2));
0145: a2.setTickMarkPosition(DateTickMarkPosition.END);
0146: assertTrue(a1.equals(a2));
0147:
0148: // timeline
0149: a1.setTimeline(SegmentedTimeline
0150: .newMondayThroughFridayTimeline());
0151: assertFalse(a1.equals(a2));
0152: a2.setTimeline(SegmentedTimeline
0153: .newMondayThroughFridayTimeline());
0154: assertTrue(a1.equals(a2));
0155:
0156: }
0157:
0158: /**
0159: * A test for bug report 1472942. The DateFormat.equals() method is not
0160: * checking the range attribute.
0161: */
0162: public void test1472942() {
0163: DateAxis a1 = new DateAxis("Test");
0164: DateAxis a2 = new DateAxis("Test");
0165: assertTrue(a1.equals(a2));
0166:
0167: // range
0168: a1.setRange(new Date(1L), new Date(2L));
0169: assertFalse(a1.equals(a2));
0170: a2.setRange(new Date(1L), new Date(2L));
0171: assertTrue(a1.equals(a2));
0172: }
0173:
0174: /**
0175: * Two objects that are equal are required to return the same hashCode.
0176: */
0177: public void testHashCode() {
0178: DateAxis a1 = new DateAxis("Test");
0179: DateAxis a2 = new DateAxis("Test");
0180: assertTrue(a1.equals(a2));
0181: int h1 = a1.hashCode();
0182: int h2 = a2.hashCode();
0183: assertEquals(h1, h2);
0184: }
0185:
0186: /**
0187: * Confirm that cloning works.
0188: */
0189: public void testCloning() {
0190: DateAxis a1 = new DateAxis("Test");
0191: DateAxis a2 = null;
0192: try {
0193: a2 = (DateAxis) a1.clone();
0194: } catch (CloneNotSupportedException e) {
0195: e.printStackTrace();
0196: }
0197: assertTrue(a1 != a2);
0198: assertTrue(a1.getClass() == a2.getClass());
0199: assertTrue(a1.equals(a2));
0200: }
0201:
0202: /**
0203: * Test that the setRange() method works.
0204: */
0205: public void testSetRange() {
0206:
0207: DateAxis axis = new DateAxis("Test Axis");
0208: Calendar calendar = Calendar.getInstance();
0209: calendar.set(1999, Calendar.JANUARY, 3);
0210: Date d1 = calendar.getTime();
0211: calendar.set(1999, Calendar.JANUARY, 31);
0212: Date d2 = calendar.getTime();
0213: axis.setRange(d1, d2);
0214:
0215: DateRange range = (DateRange) axis.getRange();
0216: assertEquals(d1, range.getLowerDate());
0217: assertEquals(d2, range.getUpperDate());
0218:
0219: }
0220:
0221: /**
0222: * Test that the setMaximumDate() method works.
0223: */
0224: public void testSetMaximumDate() {
0225: DateAxis axis = new DateAxis("Test Axis");
0226: Date date = new Date();
0227: axis.setMaximumDate(date);
0228: assertEquals(date, axis.getMaximumDate());
0229:
0230: // check that setting the max date to something on or before the
0231: // current min date works...
0232: Date d1 = new Date();
0233: Date d2 = new Date(d1.getTime() + 1);
0234: Date d0 = new Date(d1.getTime() - 1);
0235: axis.setMaximumDate(d2);
0236: axis.setMinimumDate(d1);
0237: axis.setMaximumDate(d1);
0238: assertEquals(d0, axis.getMinimumDate());
0239: }
0240:
0241: /**
0242: * Test that the setMinimumDate() method works.
0243: */
0244: public void testSetMinimumDate() {
0245: DateAxis axis = new DateAxis("Test Axis");
0246: Date d1 = new Date();
0247: Date d2 = new Date(d1.getTime() + 1);
0248: axis.setMaximumDate(d2);
0249: axis.setMinimumDate(d1);
0250: assertEquals(d1, axis.getMinimumDate());
0251:
0252: // check that setting the min date to something on or after the
0253: // current min date works...
0254: Date d3 = new Date(d2.getTime() + 1);
0255: axis.setMinimumDate(d2);
0256: assertEquals(d3, axis.getMaximumDate());
0257: }
0258:
0259: /**
0260: * Tests two doubles for 'near enough' equality.
0261: *
0262: * @param d1 number 1.
0263: * @param d2 number 2.
0264: * @param tolerance maximum tolerance.
0265: *
0266: * @return A boolean.
0267: */
0268: private boolean same(double d1, double d2, double tolerance) {
0269: return (Math.abs(d1 - d2) < tolerance);
0270: }
0271:
0272: /**
0273: * Test the translation of Java2D values to data values.
0274: */
0275: public void testJava2DToValue() {
0276: DateAxis axis = new DateAxis();
0277: axis.setRange(50.0, 100.0);
0278: Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0,
0279: 400.0, 300.0);
0280: double y1 = axis.java2DToValue(75.0, dataArea,
0281: RectangleEdge.LEFT);
0282: assertTrue(same(y1, 95.8333333, 1.0));
0283: double y2 = axis.java2DToValue(75.0, dataArea,
0284: RectangleEdge.RIGHT);
0285: assertTrue(same(y2, 95.8333333, 1.0));
0286: double x1 = axis.java2DToValue(75.0, dataArea,
0287: RectangleEdge.TOP);
0288: assertTrue(same(x1, 58.125, 1.0));
0289: double x2 = axis.java2DToValue(75.0, dataArea,
0290: RectangleEdge.BOTTOM);
0291: assertTrue(same(x2, 58.125, 1.0));
0292: axis.setInverted(true);
0293: double y3 = axis.java2DToValue(75.0, dataArea,
0294: RectangleEdge.LEFT);
0295: assertTrue(same(y3, 54.1666667, 1.0));
0296: double y4 = axis.java2DToValue(75.0, dataArea,
0297: RectangleEdge.RIGHT);
0298: assertTrue(same(y4, 54.1666667, 1.0));
0299: double x3 = axis.java2DToValue(75.0, dataArea,
0300: RectangleEdge.TOP);
0301: assertTrue(same(x3, 91.875, 1.0));
0302: double x4 = axis.java2DToValue(75.0, dataArea,
0303: RectangleEdge.BOTTOM);
0304: assertTrue(same(x4, 91.875, 1.0));
0305: }
0306:
0307: /**
0308: * Serialize an instance, restore it, and check for equality.
0309: */
0310: public void testSerialization() {
0311:
0312: DateAxis a1 = new DateAxis("Test Axis");
0313: DateAxis a2 = null;
0314:
0315: try {
0316: ByteArrayOutputStream buffer = new ByteArrayOutputStream();
0317: ObjectOutput out = new ObjectOutputStream(buffer);
0318: out.writeObject(a1);
0319: out.close();
0320:
0321: ObjectInput in = new ObjectInputStream(
0322: new ByteArrayInputStream(buffer.toByteArray()));
0323: a2 = (DateAxis) in.readObject();
0324: in.close();
0325: } catch (Exception e) {
0326: e.printStackTrace();
0327: }
0328: boolean b = a1.equals(a2);
0329: assertTrue(b);
0330:
0331: }
0332:
0333: /**
0334: * A basic check for the testPreviousStandardDate() method when the
0335: * tick unit is 1 year.
0336: */
0337: public void testPreviousStandardDateYearA() {
0338: MyDateAxis axis = new MyDateAxis("Year");
0339: Year y2006 = new Year(2006);
0340: Year y2007 = new Year(2007);
0341:
0342: // five dates to check...
0343: Date d0 = new Date(y2006.getFirstMillisecond());
0344: Date d1 = new Date(y2006.getFirstMillisecond() + 500L);
0345: Date d2 = new Date(y2006.getMiddleMillisecond());
0346: Date d3 = new Date(y2006.getMiddleMillisecond() + 500L);
0347: Date d4 = new Date(y2006.getLastMillisecond());
0348:
0349: Date end = new Date(y2007.getLastMillisecond());
0350:
0351: DateTickUnit unit = new DateTickUnit(DateTickUnit.YEAR, 1);
0352: axis.setTickUnit(unit);
0353:
0354: // START: check d0 and d1
0355: axis.setTickMarkPosition(DateTickMarkPosition.START);
0356:
0357: axis.setRange(d0, end);
0358: Date psd = axis.previousStandardDate(d0, unit);
0359: Date nsd = unit.addToDate(psd);
0360: assertTrue(psd.getTime() < d0.getTime());
0361: assertTrue(nsd.getTime() >= d0.getTime());
0362:
0363: axis.setRange(d1, end);
0364: psd = axis.previousStandardDate(d1, unit);
0365: nsd = unit.addToDate(psd);
0366: assertTrue(psd.getTime() < d1.getTime());
0367: assertTrue(nsd.getTime() >= d1.getTime());
0368:
0369: // MIDDLE: check d1, d2 and d3
0370: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0371:
0372: axis.setRange(d1, end);
0373: psd = axis.previousStandardDate(d1, unit);
0374: nsd = unit.addToDate(psd);
0375: assertTrue(psd.getTime() < d1.getTime());
0376: assertTrue(nsd.getTime() >= d1.getTime());
0377:
0378: axis.setRange(d2, end);
0379: psd = axis.previousStandardDate(d2, unit);
0380: nsd = unit.addToDate(psd);
0381: assertTrue(psd.getTime() < d2.getTime());
0382: assertTrue(nsd.getTime() >= d2.getTime());
0383:
0384: axis.setRange(d3, end);
0385: psd = axis.previousStandardDate(d3, unit);
0386: nsd = unit.addToDate(psd);
0387: assertTrue(psd.getTime() < d3.getTime());
0388: assertTrue(nsd.getTime() >= d3.getTime());
0389:
0390: // END: check d3 and d4
0391: axis.setTickMarkPosition(DateTickMarkPosition.END);
0392:
0393: axis.setRange(d3, end);
0394: psd = axis.previousStandardDate(d3, unit);
0395: nsd = unit.addToDate(psd);
0396: assertTrue(psd.getTime() < d3.getTime());
0397: assertTrue(nsd.getTime() >= d3.getTime());
0398:
0399: axis.setRange(d4, end);
0400: psd = axis.previousStandardDate(d4, unit);
0401: nsd = unit.addToDate(psd);
0402: assertTrue(psd.getTime() < d4.getTime());
0403: assertTrue(nsd.getTime() >= d4.getTime());
0404: }
0405:
0406: /**
0407: * A basic check for the testPreviousStandardDate() method when the
0408: * tick unit is 10 years (just for the sake of having a multiple).
0409: */
0410: public void testPreviousStandardDateYearB() {
0411: MyDateAxis axis = new MyDateAxis("Year");
0412: Year y2006 = new Year(2006);
0413: Year y2007 = new Year(2007);
0414:
0415: // five dates to check...
0416: Date d0 = new Date(y2006.getFirstMillisecond());
0417: Date d1 = new Date(y2006.getFirstMillisecond() + 500L);
0418: Date d2 = new Date(y2006.getMiddleMillisecond());
0419: Date d3 = new Date(y2006.getMiddleMillisecond() + 500L);
0420: Date d4 = new Date(y2006.getLastMillisecond());
0421:
0422: Date end = new Date(y2007.getLastMillisecond());
0423:
0424: DateTickUnit unit = new DateTickUnit(DateTickUnit.YEAR, 10);
0425: axis.setTickUnit(unit);
0426:
0427: // START: check d0 and d1
0428: axis.setTickMarkPosition(DateTickMarkPosition.START);
0429:
0430: axis.setRange(d0, end);
0431: Date psd = axis.previousStandardDate(d0, unit);
0432: Date nsd = unit.addToDate(psd);
0433: assertTrue(psd.getTime() < d0.getTime());
0434: assertTrue(nsd.getTime() >= d0.getTime());
0435:
0436: axis.setRange(d1, end);
0437: psd = axis.previousStandardDate(d1, unit);
0438: nsd = unit.addToDate(psd);
0439: assertTrue(psd.getTime() < d1.getTime());
0440: assertTrue(nsd.getTime() >= d1.getTime());
0441:
0442: // MIDDLE: check d1, d2 and d3
0443: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0444:
0445: axis.setRange(d1, end);
0446: psd = axis.previousStandardDate(d1, unit);
0447: nsd = unit.addToDate(psd);
0448: assertTrue(psd.getTime() < d1.getTime());
0449: assertTrue(nsd.getTime() >= d1.getTime());
0450:
0451: axis.setRange(d2, end);
0452: psd = axis.previousStandardDate(d2, unit);
0453: nsd = unit.addToDate(psd);
0454: assertTrue(psd.getTime() < d2.getTime());
0455: assertTrue(nsd.getTime() >= d2.getTime());
0456:
0457: axis.setRange(d3, end);
0458: psd = axis.previousStandardDate(d3, unit);
0459: nsd = unit.addToDate(psd);
0460: assertTrue(psd.getTime() < d3.getTime());
0461: assertTrue(nsd.getTime() >= d3.getTime());
0462:
0463: // END: check d3 and d4
0464: axis.setTickMarkPosition(DateTickMarkPosition.END);
0465:
0466: axis.setRange(d3, end);
0467: psd = axis.previousStandardDate(d3, unit);
0468: nsd = unit.addToDate(psd);
0469: assertTrue(psd.getTime() < d3.getTime());
0470: assertTrue(nsd.getTime() >= d3.getTime());
0471:
0472: axis.setRange(d4, end);
0473: psd = axis.previousStandardDate(d4, unit);
0474: nsd = unit.addToDate(psd);
0475: assertTrue(psd.getTime() < d4.getTime());
0476: assertTrue(nsd.getTime() >= d4.getTime());
0477: }
0478:
0479: /**
0480: * A basic check for the testPreviousStandardDate() method when the
0481: * tick unit is 1 month.
0482: */
0483: public void testPreviousStandardDateMonthA() {
0484: MyDateAxis axis = new MyDateAxis("Month");
0485: Month nov2006 = new Month(11, 2006);
0486: Month dec2006 = new Month(12, 2006);
0487:
0488: // five dates to check...
0489: Date d0 = new Date(nov2006.getFirstMillisecond());
0490: Date d1 = new Date(nov2006.getFirstMillisecond() + 500L);
0491: Date d2 = new Date(nov2006.getMiddleMillisecond());
0492: Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L);
0493: Date d4 = new Date(nov2006.getLastMillisecond());
0494:
0495: Date end = new Date(dec2006.getLastMillisecond());
0496:
0497: DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 1);
0498: axis.setTickUnit(unit);
0499:
0500: // START: check d0 and d1
0501: axis.setTickMarkPosition(DateTickMarkPosition.START);
0502:
0503: axis.setRange(d0, end);
0504: Date psd = axis.previousStandardDate(d0, unit);
0505: Date nsd = unit.addToDate(psd);
0506: assertTrue(psd.getTime() < d0.getTime());
0507: assertTrue(nsd.getTime() >= d0.getTime());
0508:
0509: axis.setRange(d1, end);
0510: psd = axis.previousStandardDate(d1, unit);
0511: nsd = unit.addToDate(psd);
0512: assertTrue(psd.getTime() < d1.getTime());
0513: assertTrue(nsd.getTime() >= d1.getTime());
0514:
0515: // MIDDLE: check d1, d2 and d3
0516: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0517:
0518: axis.setRange(d1, end);
0519: psd = axis.previousStandardDate(d1, unit);
0520: nsd = unit.addToDate(psd);
0521: assertTrue(psd.getTime() < d1.getTime());
0522: assertTrue(nsd.getTime() >= d1.getTime());
0523:
0524: axis.setRange(d2, end);
0525: psd = axis.previousStandardDate(d2, unit);
0526: nsd = unit.addToDate(psd);
0527: assertTrue(psd.getTime() < d2.getTime());
0528: assertTrue(nsd.getTime() >= d2.getTime());
0529:
0530: axis.setRange(d3, end);
0531: psd = axis.previousStandardDate(d3, unit);
0532: nsd = unit.addToDate(psd);
0533: assertTrue(psd.getTime() < d3.getTime());
0534: assertTrue(nsd.getTime() >= d3.getTime());
0535:
0536: // END: check d3 and d4
0537: axis.setTickMarkPosition(DateTickMarkPosition.END);
0538:
0539: axis.setRange(d3, end);
0540: psd = axis.previousStandardDate(d3, unit);
0541: nsd = unit.addToDate(psd);
0542: assertTrue(psd.getTime() < d3.getTime());
0543: assertTrue(nsd.getTime() >= d3.getTime());
0544:
0545: axis.setRange(d4, end);
0546: psd = axis.previousStandardDate(d4, unit);
0547: nsd = unit.addToDate(psd);
0548: assertTrue(psd.getTime() < d4.getTime());
0549: assertTrue(nsd.getTime() >= d4.getTime());
0550: }
0551:
0552: /**
0553: * A basic check for the testPreviousStandardDate() method when the
0554: * tick unit is 3 months (just for the sake of having a multiple).
0555: */
0556: public void testPreviousStandardDateMonthB() {
0557: MyDateAxis axis = new MyDateAxis("Month");
0558: Month nov2006 = new Month(11, 2006);
0559: Month dec2006 = new Month(12, 2006);
0560:
0561: // five dates to check...
0562: Date d0 = new Date(nov2006.getFirstMillisecond());
0563: Date d1 = new Date(nov2006.getFirstMillisecond() + 500L);
0564: Date d2 = new Date(nov2006.getMiddleMillisecond());
0565: Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L);
0566: Date d4 = new Date(nov2006.getLastMillisecond());
0567:
0568: Date end = new Date(dec2006.getLastMillisecond());
0569:
0570: DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 3);
0571: axis.setTickUnit(unit);
0572:
0573: // START: check d0 and d1
0574: axis.setTickMarkPosition(DateTickMarkPosition.START);
0575:
0576: axis.setRange(d0, end);
0577: Date psd = axis.previousStandardDate(d0, unit);
0578: Date nsd = unit.addToDate(psd);
0579: assertTrue(psd.getTime() < d0.getTime());
0580: assertTrue(nsd.getTime() >= d0.getTime());
0581:
0582: axis.setRange(d1, end);
0583: psd = axis.previousStandardDate(d1, unit);
0584: nsd = unit.addToDate(psd);
0585: assertTrue(psd.getTime() < d1.getTime());
0586: assertTrue(nsd.getTime() >= d1.getTime());
0587:
0588: // MIDDLE: check d1, d2 and d3
0589: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0590:
0591: axis.setRange(d1, end);
0592: psd = axis.previousStandardDate(d1, unit);
0593: nsd = unit.addToDate(psd);
0594: assertTrue(psd.getTime() < d1.getTime());
0595: assertTrue(nsd.getTime() >= d1.getTime());
0596:
0597: axis.setRange(d2, end);
0598: psd = axis.previousStandardDate(d2, unit);
0599: nsd = unit.addToDate(psd);
0600: assertTrue(psd.getTime() < d2.getTime());
0601: assertTrue(nsd.getTime() >= d2.getTime());
0602:
0603: axis.setRange(d3, end);
0604: psd = axis.previousStandardDate(d3, unit);
0605: nsd = unit.addToDate(psd);
0606: assertTrue(psd.getTime() < d3.getTime());
0607: assertTrue(nsd.getTime() >= d3.getTime());
0608:
0609: // END: check d3 and d4
0610: axis.setTickMarkPosition(DateTickMarkPosition.END);
0611:
0612: axis.setRange(d3, end);
0613: psd = axis.previousStandardDate(d3, unit);
0614: nsd = unit.addToDate(psd);
0615: assertTrue(psd.getTime() < d3.getTime());
0616: assertTrue(nsd.getTime() >= d3.getTime());
0617:
0618: axis.setRange(d4, end);
0619: psd = axis.previousStandardDate(d4, unit);
0620: nsd = unit.addToDate(psd);
0621: assertTrue(psd.getTime() < d4.getTime());
0622: assertTrue(nsd.getTime() >= d4.getTime());
0623: }
0624:
0625: /**
0626: * A basic check for the testPreviousStandardDate() method when the
0627: * tick unit is 1 day.
0628: */
0629: public void testPreviousStandardDateDayA() {
0630: MyDateAxis axis = new MyDateAxis("Day");
0631: Day apr12007 = new Day(1, 4, 2007);
0632: Day apr22007 = new Day(2, 4, 2007);
0633:
0634: // five dates to check...
0635: Date d0 = new Date(apr12007.getFirstMillisecond());
0636: Date d1 = new Date(apr12007.getFirstMillisecond() + 500L);
0637: Date d2 = new Date(apr12007.getMiddleMillisecond());
0638: Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L);
0639: Date d4 = new Date(apr12007.getLastMillisecond());
0640:
0641: Date end = new Date(apr22007.getLastMillisecond());
0642:
0643: DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1);
0644: axis.setTickUnit(unit);
0645:
0646: // START: check d0 and d1
0647: axis.setTickMarkPosition(DateTickMarkPosition.START);
0648:
0649: axis.setRange(d0, end);
0650: Date psd = axis.previousStandardDate(d0, unit);
0651: Date nsd = unit.addToDate(psd);
0652: assertTrue(psd.getTime() < d0.getTime());
0653: assertTrue(nsd.getTime() >= d0.getTime());
0654:
0655: axis.setRange(d1, end);
0656: psd = axis.previousStandardDate(d1, unit);
0657: nsd = unit.addToDate(psd);
0658: assertTrue(psd.getTime() < d1.getTime());
0659: assertTrue(nsd.getTime() >= d1.getTime());
0660:
0661: // MIDDLE: check d1, d2 and d3
0662: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0663:
0664: axis.setRange(d1, end);
0665: psd = axis.previousStandardDate(d1, unit);
0666: nsd = unit.addToDate(psd);
0667: assertTrue(psd.getTime() < d1.getTime());
0668: assertTrue(nsd.getTime() >= d1.getTime());
0669:
0670: axis.setRange(d2, end);
0671: psd = axis.previousStandardDate(d2, unit);
0672: nsd = unit.addToDate(psd);
0673: assertTrue(psd.getTime() < d2.getTime());
0674: assertTrue(nsd.getTime() >= d2.getTime());
0675:
0676: axis.setRange(d3, end);
0677: psd = axis.previousStandardDate(d3, unit);
0678: nsd = unit.addToDate(psd);
0679: assertTrue(psd.getTime() < d3.getTime());
0680: assertTrue(nsd.getTime() >= d3.getTime());
0681:
0682: // END: check d3 and d4
0683: axis.setTickMarkPosition(DateTickMarkPosition.END);
0684:
0685: axis.setRange(d3, end);
0686: psd = axis.previousStandardDate(d3, unit);
0687: nsd = unit.addToDate(psd);
0688: assertTrue(psd.getTime() < d3.getTime());
0689: assertTrue(nsd.getTime() >= d3.getTime());
0690:
0691: axis.setRange(d4, end);
0692: psd = axis.previousStandardDate(d4, unit);
0693: nsd = unit.addToDate(psd);
0694: assertTrue(psd.getTime() < d4.getTime());
0695: assertTrue(nsd.getTime() >= d4.getTime());
0696: }
0697:
0698: /**
0699: * A basic check for the testPreviousStandardDate() method when the
0700: * tick unit is 7 days (just for the sake of having a multiple).
0701: */
0702: public void testPreviousStandardDateDayB() {
0703: MyDateAxis axis = new MyDateAxis("Day");
0704: Day apr12007 = new Day(1, 4, 2007);
0705: Day apr22007 = new Day(2, 4, 2007);
0706:
0707: // five dates to check...
0708: Date d0 = new Date(apr12007.getFirstMillisecond());
0709: Date d1 = new Date(apr12007.getFirstMillisecond() + 500L);
0710: Date d2 = new Date(apr12007.getMiddleMillisecond());
0711: Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L);
0712: Date d4 = new Date(apr12007.getLastMillisecond());
0713:
0714: Date end = new Date(apr22007.getLastMillisecond());
0715:
0716: DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7);
0717: axis.setTickUnit(unit);
0718:
0719: // START: check d0 and d1
0720: axis.setTickMarkPosition(DateTickMarkPosition.START);
0721:
0722: axis.setRange(d0, end);
0723: Date psd = axis.previousStandardDate(d0, unit);
0724: Date nsd = unit.addToDate(psd);
0725: assertTrue(psd.getTime() < d0.getTime());
0726: assertTrue(nsd.getTime() >= d0.getTime());
0727:
0728: axis.setRange(d1, end);
0729: psd = axis.previousStandardDate(d1, unit);
0730: nsd = unit.addToDate(psd);
0731: assertTrue(psd.getTime() < d1.getTime());
0732: assertTrue(nsd.getTime() >= d1.getTime());
0733:
0734: // MIDDLE: check d1, d2 and d3
0735: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0736:
0737: axis.setRange(d1, end);
0738: psd = axis.previousStandardDate(d1, unit);
0739: nsd = unit.addToDate(psd);
0740: assertTrue(psd.getTime() < d1.getTime());
0741: assertTrue(nsd.getTime() >= d1.getTime());
0742:
0743: axis.setRange(d2, end);
0744: psd = axis.previousStandardDate(d2, unit);
0745: nsd = unit.addToDate(psd);
0746: assertTrue(psd.getTime() < d2.getTime());
0747: assertTrue(nsd.getTime() >= d2.getTime());
0748:
0749: axis.setRange(d3, end);
0750: psd = axis.previousStandardDate(d3, unit);
0751: nsd = unit.addToDate(psd);
0752: assertTrue(psd.getTime() < d3.getTime());
0753: assertTrue(nsd.getTime() >= d3.getTime());
0754:
0755: // END: check d3 and d4
0756: axis.setTickMarkPosition(DateTickMarkPosition.END);
0757:
0758: axis.setRange(d3, end);
0759: psd = axis.previousStandardDate(d3, unit);
0760: nsd = unit.addToDate(psd);
0761: assertTrue(psd.getTime() < d3.getTime());
0762: assertTrue(nsd.getTime() >= d3.getTime());
0763:
0764: axis.setRange(d4, end);
0765: psd = axis.previousStandardDate(d4, unit);
0766: nsd = unit.addToDate(psd);
0767: assertTrue(psd.getTime() < d4.getTime());
0768: assertTrue(nsd.getTime() >= d4.getTime());
0769: }
0770:
0771: /**
0772: * A basic check for the testPreviousStandardDate() method when the
0773: * tick unit is 1 hour.
0774: */
0775: public void testPreviousStandardDateHourA() {
0776: MyDateAxis axis = new MyDateAxis("Hour");
0777: Hour h0 = new Hour(12, 1, 4, 2007);
0778: Hour h1 = new Hour(13, 1, 4, 2007);
0779:
0780: // five dates to check...
0781: Date d0 = new Date(h0.getFirstMillisecond());
0782: Date d1 = new Date(h0.getFirstMillisecond() + 500L);
0783: Date d2 = new Date(h0.getMiddleMillisecond());
0784: Date d3 = new Date(h0.getMiddleMillisecond() + 500L);
0785: Date d4 = new Date(h0.getLastMillisecond());
0786:
0787: Date end = new Date(h1.getLastMillisecond());
0788:
0789: DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1);
0790: axis.setTickUnit(unit);
0791:
0792: // START: check d0 and d1
0793: axis.setTickMarkPosition(DateTickMarkPosition.START);
0794:
0795: axis.setRange(d0, end);
0796: Date psd = axis.previousStandardDate(d0, unit);
0797: Date nsd = unit.addToDate(psd);
0798: assertTrue(psd.getTime() < d0.getTime());
0799: assertTrue(nsd.getTime() >= d0.getTime());
0800:
0801: axis.setRange(d1, end);
0802: psd = axis.previousStandardDate(d1, unit);
0803: nsd = unit.addToDate(psd);
0804: assertTrue(psd.getTime() < d1.getTime());
0805: assertTrue(nsd.getTime() >= d1.getTime());
0806:
0807: // MIDDLE: check d1, d2 and d3
0808: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0809:
0810: axis.setRange(d1, end);
0811: psd = axis.previousStandardDate(d1, unit);
0812: nsd = unit.addToDate(psd);
0813: assertTrue(psd.getTime() < d1.getTime());
0814: assertTrue(nsd.getTime() >= d1.getTime());
0815:
0816: axis.setRange(d2, end);
0817: psd = axis.previousStandardDate(d2, unit);
0818: nsd = unit.addToDate(psd);
0819: assertTrue(psd.getTime() < d2.getTime());
0820: assertTrue(nsd.getTime() >= d2.getTime());
0821:
0822: axis.setRange(d3, end);
0823: psd = axis.previousStandardDate(d3, unit);
0824: nsd = unit.addToDate(psd);
0825: assertTrue(psd.getTime() < d3.getTime());
0826: assertTrue(nsd.getTime() >= d3.getTime());
0827:
0828: // END: check d3 and d4
0829: axis.setTickMarkPosition(DateTickMarkPosition.END);
0830:
0831: axis.setRange(d3, end);
0832: psd = axis.previousStandardDate(d3, unit);
0833: nsd = unit.addToDate(psd);
0834: assertTrue(psd.getTime() < d3.getTime());
0835: assertTrue(nsd.getTime() >= d3.getTime());
0836:
0837: axis.setRange(d4, end);
0838: psd = axis.previousStandardDate(d4, unit);
0839: nsd = unit.addToDate(psd);
0840: assertTrue(psd.getTime() < d4.getTime());
0841: assertTrue(nsd.getTime() >= d4.getTime());
0842: }
0843:
0844: /**
0845: * A basic check for the testPreviousStandardDate() method when the
0846: * tick unit is 6 hours (just for the sake of having a multiple).
0847: */
0848: public void testPreviousStandardDateHourB() {
0849: MyDateAxis axis = new MyDateAxis("Hour");
0850: Hour h0 = new Hour(12, 1, 4, 2007);
0851: Hour h1 = new Hour(13, 1, 4, 2007);
0852:
0853: // five dates to check...
0854: Date d0 = new Date(h0.getFirstMillisecond());
0855: Date d1 = new Date(h0.getFirstMillisecond() + 500L);
0856: Date d2 = new Date(h0.getMiddleMillisecond());
0857: Date d3 = new Date(h0.getMiddleMillisecond() + 500L);
0858: Date d4 = new Date(h0.getLastMillisecond());
0859:
0860: Date end = new Date(h1.getLastMillisecond());
0861:
0862: DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 6);
0863: axis.setTickUnit(unit);
0864:
0865: // START: check d0 and d1
0866: axis.setTickMarkPosition(DateTickMarkPosition.START);
0867:
0868: axis.setRange(d0, end);
0869: Date psd = axis.previousStandardDate(d0, unit);
0870: Date nsd = unit.addToDate(psd);
0871: assertTrue(psd.getTime() < d0.getTime());
0872: assertTrue(nsd.getTime() >= d0.getTime());
0873:
0874: axis.setRange(d1, end);
0875: psd = axis.previousStandardDate(d1, unit);
0876: nsd = unit.addToDate(psd);
0877: assertTrue(psd.getTime() < d1.getTime());
0878: assertTrue(nsd.getTime() >= d1.getTime());
0879:
0880: // MIDDLE: check d1, d2 and d3
0881: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0882:
0883: axis.setRange(d1, end);
0884: psd = axis.previousStandardDate(d1, unit);
0885: nsd = unit.addToDate(psd);
0886: assertTrue(psd.getTime() < d1.getTime());
0887: assertTrue(nsd.getTime() >= d1.getTime());
0888:
0889: axis.setRange(d2, end);
0890: psd = axis.previousStandardDate(d2, unit);
0891: nsd = unit.addToDate(psd);
0892: assertTrue(psd.getTime() < d2.getTime());
0893: assertTrue(nsd.getTime() >= d2.getTime());
0894:
0895: axis.setRange(d3, end);
0896: psd = axis.previousStandardDate(d3, unit);
0897: nsd = unit.addToDate(psd);
0898: assertTrue(psd.getTime() < d3.getTime());
0899: assertTrue(nsd.getTime() >= d3.getTime());
0900:
0901: // END: check d3 and d4
0902: axis.setTickMarkPosition(DateTickMarkPosition.END);
0903:
0904: axis.setRange(d3, end);
0905: psd = axis.previousStandardDate(d3, unit);
0906: nsd = unit.addToDate(psd);
0907: assertTrue(psd.getTime() < d3.getTime());
0908: assertTrue(nsd.getTime() >= d3.getTime());
0909:
0910: axis.setRange(d4, end);
0911: psd = axis.previousStandardDate(d4, unit);
0912: nsd = unit.addToDate(psd);
0913: assertTrue(psd.getTime() < d4.getTime());
0914: assertTrue(nsd.getTime() >= d4.getTime());
0915: }
0916:
0917: /**
0918: * A basic check for the testPreviousStandardDate() method when the
0919: * tick unit is 1 second.
0920: */
0921: public void testPreviousStandardDateSecondA() {
0922: MyDateAxis axis = new MyDateAxis("Second");
0923: Second s0 = new Second(58, 31, 12, 1, 4, 2007);
0924: Second s1 = new Second(59, 31, 12, 1, 4, 2007);
0925:
0926: // five dates to check...
0927: Date d0 = new Date(s0.getFirstMillisecond());
0928: Date d1 = new Date(s0.getFirstMillisecond() + 50L);
0929: Date d2 = new Date(s0.getMiddleMillisecond());
0930: Date d3 = new Date(s0.getMiddleMillisecond() + 50L);
0931: Date d4 = new Date(s0.getLastMillisecond());
0932:
0933: Date end = new Date(s1.getLastMillisecond());
0934:
0935: DateTickUnit unit = new DateTickUnit(DateTickUnit.SECOND, 1);
0936: axis.setTickUnit(unit);
0937:
0938: // START: check d0 and d1
0939: axis.setTickMarkPosition(DateTickMarkPosition.START);
0940:
0941: axis.setRange(d0, end);
0942: Date psd = axis.previousStandardDate(d0, unit);
0943: Date nsd = unit.addToDate(psd);
0944: assertTrue(psd.getTime() < d0.getTime());
0945: assertTrue(nsd.getTime() >= d0.getTime());
0946:
0947: axis.setRange(d1, end);
0948: psd = axis.previousStandardDate(d1, unit);
0949: nsd = unit.addToDate(psd);
0950: assertTrue(psd.getTime() < d1.getTime());
0951: assertTrue(nsd.getTime() >= d1.getTime());
0952:
0953: // MIDDLE: check d1, d2 and d3
0954: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
0955:
0956: axis.setRange(d1, end);
0957: psd = axis.previousStandardDate(d1, unit);
0958: nsd = unit.addToDate(psd);
0959: assertTrue(psd.getTime() < d1.getTime());
0960: assertTrue(nsd.getTime() >= d1.getTime());
0961:
0962: axis.setRange(d2, end);
0963: psd = axis.previousStandardDate(d2, unit);
0964: nsd = unit.addToDate(psd);
0965: assertTrue(psd.getTime() < d2.getTime());
0966: assertTrue(nsd.getTime() >= d2.getTime());
0967:
0968: axis.setRange(d3, end);
0969: psd = axis.previousStandardDate(d3, unit);
0970: nsd = unit.addToDate(psd);
0971: assertTrue(psd.getTime() < d3.getTime());
0972: assertTrue(nsd.getTime() >= d3.getTime());
0973:
0974: // END: check d3 and d4
0975: axis.setTickMarkPosition(DateTickMarkPosition.END);
0976:
0977: axis.setRange(d3, end);
0978: psd = axis.previousStandardDate(d3, unit);
0979: nsd = unit.addToDate(psd);
0980: assertTrue(psd.getTime() < d3.getTime());
0981: assertTrue(nsd.getTime() >= d3.getTime());
0982:
0983: axis.setRange(d4, end);
0984: psd = axis.previousStandardDate(d4, unit);
0985: nsd = unit.addToDate(psd);
0986: assertTrue(psd.getTime() < d4.getTime());
0987: assertTrue(nsd.getTime() >= d4.getTime());
0988: }
0989:
0990: /**
0991: * A basic check for the testPreviousStandardDate() method when the
0992: * tick unit is 5 seconds (just for the sake of having a multiple).
0993: */
0994: public void testPreviousStandardDateSecondB() {
0995: MyDateAxis axis = new MyDateAxis("Second");
0996: Second s0 = new Second(58, 31, 12, 1, 4, 2007);
0997: Second s1 = new Second(59, 31, 12, 1, 4, 2007);
0998:
0999: // five dates to check...
1000: Date d0 = new Date(s0.getFirstMillisecond());
1001: Date d1 = new Date(s0.getFirstMillisecond() + 50L);
1002: Date d2 = new Date(s0.getMiddleMillisecond());
1003: Date d3 = new Date(s0.getMiddleMillisecond() + 50L);
1004: Date d4 = new Date(s0.getLastMillisecond());
1005:
1006: Date end = new Date(s1.getLastMillisecond());
1007:
1008: DateTickUnit unit = new DateTickUnit(DateTickUnit.SECOND, 5);
1009: axis.setTickUnit(unit);
1010:
1011: // START: check d0 and d1
1012: axis.setTickMarkPosition(DateTickMarkPosition.START);
1013:
1014: axis.setRange(d0, end);
1015: Date psd = axis.previousStandardDate(d0, unit);
1016: Date nsd = unit.addToDate(psd);
1017: assertTrue(psd.getTime() < d0.getTime());
1018: assertTrue(nsd.getTime() >= d0.getTime());
1019:
1020: axis.setRange(d1, end);
1021: psd = axis.previousStandardDate(d1, unit);
1022: nsd = unit.addToDate(psd);
1023: assertTrue(psd.getTime() < d1.getTime());
1024: assertTrue(nsd.getTime() >= d1.getTime());
1025:
1026: // MIDDLE: check d1, d2 and d3
1027: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1028:
1029: axis.setRange(d1, end);
1030: psd = axis.previousStandardDate(d1, unit);
1031: nsd = unit.addToDate(psd);
1032: assertTrue(psd.getTime() < d1.getTime());
1033: assertTrue(nsd.getTime() >= d1.getTime());
1034:
1035: axis.setRange(d2, end);
1036: psd = axis.previousStandardDate(d2, unit);
1037: nsd = unit.addToDate(psd);
1038: assertTrue(psd.getTime() < d2.getTime());
1039: assertTrue(nsd.getTime() >= d2.getTime());
1040:
1041: axis.setRange(d3, end);
1042: psd = axis.previousStandardDate(d3, unit);
1043: nsd = unit.addToDate(psd);
1044: assertTrue(psd.getTime() < d3.getTime());
1045: assertTrue(nsd.getTime() >= d3.getTime());
1046:
1047: // END: check d3 and d4
1048: axis.setTickMarkPosition(DateTickMarkPosition.END);
1049:
1050: axis.setRange(d3, end);
1051: psd = axis.previousStandardDate(d3, unit);
1052: nsd = unit.addToDate(psd);
1053: assertTrue(psd.getTime() < d3.getTime());
1054: assertTrue(nsd.getTime() >= d3.getTime());
1055:
1056: axis.setRange(d4, end);
1057: psd = axis.previousStandardDate(d4, unit);
1058: nsd = unit.addToDate(psd);
1059: assertTrue(psd.getTime() < d4.getTime());
1060: assertTrue(nsd.getTime() >= d4.getTime());
1061: }
1062:
1063: /**
1064: * A basic check for the testPreviousStandardDate() method when the
1065: * tick unit is 1 millisecond.
1066: */
1067: public void testPreviousStandardDateMillisecondA() {
1068: MyDateAxis axis = new MyDateAxis("Millisecond");
1069: Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007);
1070: Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007);
1071:
1072: Date d0 = new Date(m0.getFirstMillisecond());
1073: Date end = new Date(m1.getLastMillisecond());
1074:
1075: DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND,
1076: 1);
1077: axis.setTickUnit(unit);
1078:
1079: // START: check d0
1080: axis.setTickMarkPosition(DateTickMarkPosition.START);
1081:
1082: axis.setRange(d0, end);
1083: Date psd = axis.previousStandardDate(d0, unit);
1084: Date nsd = unit.addToDate(psd);
1085: assertTrue(psd.getTime() < d0.getTime());
1086: assertTrue(nsd.getTime() >= d0.getTime());
1087:
1088: // MIDDLE: check d0
1089: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1090:
1091: axis.setRange(d0, end);
1092: psd = axis.previousStandardDate(d0, unit);
1093: nsd = unit.addToDate(psd);
1094: assertTrue(psd.getTime() < d0.getTime());
1095: assertTrue(nsd.getTime() >= d0.getTime());
1096:
1097: // END: check d0
1098: axis.setTickMarkPosition(DateTickMarkPosition.END);
1099:
1100: axis.setRange(d0, end);
1101: psd = axis.previousStandardDate(d0, unit);
1102: nsd = unit.addToDate(psd);
1103: assertTrue(psd.getTime() < d0.getTime());
1104: assertTrue(nsd.getTime() >= d0.getTime());
1105: }
1106:
1107: /**
1108: * A basic check for the testPreviousStandardDate() method when the
1109: * tick unit is 10 milliseconds (just for the sake of having a multiple).
1110: */
1111: public void testPreviousStandardDateMillisecondB() {
1112: MyDateAxis axis = new MyDateAxis("Millisecond");
1113: Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007);
1114: Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007);
1115:
1116: Date d0 = new Date(m0.getFirstMillisecond());
1117: Date end = new Date(m1.getLastMillisecond());
1118:
1119: DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND,
1120: 10);
1121: axis.setTickUnit(unit);
1122:
1123: // START: check d0
1124: axis.setTickMarkPosition(DateTickMarkPosition.START);
1125:
1126: axis.setRange(d0, end);
1127: Date psd = axis.previousStandardDate(d0, unit);
1128: Date nsd = unit.addToDate(psd);
1129: assertTrue(psd.getTime() < d0.getTime());
1130: assertTrue(nsd.getTime() >= d0.getTime());
1131:
1132: // MIDDLE: check d0
1133: axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1134:
1135: axis.setRange(d0, end);
1136: psd = axis.previousStandardDate(d0, unit);
1137: nsd = unit.addToDate(psd);
1138: assertTrue(psd.getTime() < d0.getTime());
1139: assertTrue(nsd.getTime() >= d0.getTime());
1140:
1141: // END: check d0
1142: axis.setTickMarkPosition(DateTickMarkPosition.END);
1143:
1144: axis.setRange(d0, end);
1145: psd = axis.previousStandardDate(d0, unit);
1146: nsd = unit.addToDate(psd);
1147: assertTrue(psd.getTime() < d0.getTime());
1148: assertTrue(nsd.getTime() >= d0.getTime());
1149: }
1150:
1151: }
|