001: package org.springunit.examples.constructor.junit.v1;
002:
003: import org.springunit.examples.CompositeDate;
004: import org.springunit.examples.InvalidDateException;
005:
006: import junit.framework.TestCase;
007:
008: /**
009: * Brute-force test of constructor for CompositeDate.
010: *
011: * @author Ted.Velkoff
012: *
013: */
014: public class CompositeDateConstructorTest extends TestCase {
015:
016: public void testJan01() throws Exception {
017: int day = 1;
018: int month = 1;
019: int year = 2006;
020: int expectedDay = 1;
021: int expectedMonth = 1;
022: int expectedYear = 2006;
023: CompositeDate subject = new CompositeDate(year, month, day);
024: assertTrue(expectedMonth == subject.getMonth());
025: assertTrue(expectedDay == subject.getDay());
026: assertTrue(expectedYear == subject.getYear());
027: }
028:
029: public void testDec31() throws Exception {
030: int day = 31;
031: int month = 12;
032: int year = 2006;
033: int expectedDay = 31;
034: int expectedMonth = 12;
035: int expectedYear = 2006;
036: CompositeDate subject = new CompositeDate(year, month, day);
037: assertTrue(expectedMonth == subject.getMonth());
038: assertTrue(expectedDay == subject.getDay());
039: assertTrue(expectedYear == subject.getYear());
040: }
041:
042: public void testFeb29Leap2000() throws Exception {
043: int day = 29;
044: int month = 2;
045: int year = 2000;
046: int expectedDay = 29;
047: int expectedMonth = 2;
048: int expectedYear = 2000;
049: CompositeDate subject = new CompositeDate(year, month, day);
050: assertTrue(expectedMonth == subject.getMonth());
051: assertTrue(expectedDay == subject.getDay());
052: assertTrue(expectedYear == subject.getYear());
053: }
054:
055: public void testFeb29Leap2004() throws Exception {
056: int day = 29;
057: int month = 2;
058: int year = 2004;
059: int expectedDay = 29;
060: int expectedMonth = 2;
061: int expectedYear = 2004;
062: CompositeDate subject = new CompositeDate(year, month, day);
063: assertTrue(expectedMonth == subject.getMonth());
064: assertTrue(expectedDay == subject.getDay());
065: assertTrue(expectedYear == subject.getYear());
066: }
067:
068: public void testApr31() throws Exception {
069: int day = 31;
070: int month = 4;
071: int year = 2006;
072: try {
073: new CompositeDate(year, month, day);
074: fail("Exception not thrown");
075: } catch (InvalidDateException ex) {
076: }
077: }
078:
079: public void testJun31() throws Exception {
080: int day = 31;
081: int month = 6;
082: int year = 2006;
083: try {
084: new CompositeDate(year, month, day);
085: fail("Exception not thrown");
086: } catch (InvalidDateException ex) {
087: }
088: }
089:
090: public void testSep31() throws Exception {
091: int day = 31;
092: int month = 9;
093: int year = 2006;
094: try {
095: new CompositeDate(year, month, day);
096: fail("Exception not thrown");
097: } catch (InvalidDateException ex) {
098: }
099: }
100:
101: public void testNov31() throws Exception {
102: int day = 31;
103: int month = 11;
104: int year = 2006;
105: try {
106: new CompositeDate(year, month, day);
107: fail("Exception not thrown");
108: } catch (InvalidDateException ex) {
109: }
110: }
111:
112: public void testFeb31() throws Exception {
113: int day = 31;
114: int month = 2;
115: int year = 2006;
116: try {
117: new CompositeDate(year, month, day);
118: fail("Exception not thrown");
119: } catch (InvalidDateException ex) {
120: }
121: }
122:
123: public void testFeb30() throws Exception {
124: int day = 30;
125: int month = 2;
126: int year = 2006;
127: try {
128: new CompositeDate(year, month, day);
129: fail("Exception not thrown");
130: } catch (InvalidDateException ex) {
131: }
132: }
133:
134: public void testFeb29NoLeap() throws Exception {
135: int day = 29;
136: int month = 2;
137: int year = 2003;
138: try {
139: new CompositeDate(year, month, day);
140: fail("Exception not thrown");
141: } catch (InvalidDateException ex) {
142: }
143: }
144:
145: public void testFeb29NoLeap1900() throws Exception {
146: int day = 29;
147: int month = 2;
148: int year = 1900;
149: try {
150: new CompositeDate(year, month, day);
151: fail("Exception not thrown");
152: } catch (InvalidDateException ex) {
153: }
154: }
155:
156: }
|