01: package org.springunit.examples.tutorial;
02:
03: import org.springunit.examples.CompositeDate;
04: import org.springunit.framework.SpringUnitContext;
05: import org.springunit.framework.SpringUnitTest;
06:
07: public class CompositeDateTutorialExample3Test extends SpringUnitTest {
08:
09: public void testJan01() throws Exception {
10: runSetDay();
11: }
12:
13: public void testDec31() throws Exception {
14: runSetDay();
15: }
16:
17: public void testApr31() throws Exception {
18: runSetDay();
19: }
20:
21: public void testFeb29() throws Exception {
22: runSetDay();
23: }
24:
25: protected void runSetDay() throws Exception {
26: CompositeDate subject = getObject("subject");
27: Integer day = getObject("day");
28: Integer expectedDay = getObject("expectedDay");
29: Exception expectedException = getObject("expectedException");
30: try {
31: subject.setDay(day);
32: if (expectedException != null) {
33: fail("Exception not thrown");
34: }
35: assertTrue(expectedDay == subject.getDay());
36: } catch (Exception ex) {
37: if (expectedException != null
38: && !expectedException.getClass().isAssignableFrom(
39: ex.getClass())) {
40: throw ex;
41: }
42: }
43: }
44:
45: public SpringUnitContext getCompositeDateTutorialExample3Test() {
46: return this .compositeDateTutorialExample3Test;
47: }
48:
49: public void setCompositeDateTutorialExample3Test(
50: SpringUnitContext compositeDateTutorialExample3Test) {
51: this .compositeDateTutorialExample3Test = compositeDateTutorialExample3Test;
52: }
53:
54: private SpringUnitContext compositeDateTutorialExample3Test;
55:
56: }
|