01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.gl.dao.ojb;
17:
18: import java.text.SimpleDateFormat;
19: import java.util.Date;
20:
21: import org.kuali.kfs.context.KualiTestBase;
22: import org.kuali.kfs.context.SpringContext;
23: import org.kuali.module.gl.bo.UniversityDate;
24: import org.kuali.module.gl.dao.UniversityDateDao;
25: import org.kuali.test.ConfigureContext;
26:
27: @ConfigureContext
28: public class TestUniversityDateDao extends KualiTestBase {
29:
30: private SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
31:
32: public void testGetByPrimaryKey() throws Exception {
33: UniversityDateDao dao = SpringContext
34: .getBean(UniversityDateDao.class);
35: assertNotNull("Dao shouldn't be null", dao);
36:
37: Date missing = sdf.parse("01/01/1901");
38: UniversityDate notexist = dao
39: .getByPrimaryKey(new java.sql.Date(missing.getTime()));
40: assertNull("01/01/1901 shouldn't exist in table", notexist);
41:
42: Date notMissing = sdf.parse("08/14/1993");
43: UniversityDate exist = dao.getByPrimaryKey(new java.sql.Date(
44: notMissing.getTime()));
45: assertNotNull("08/14/1993 should exist in table", exist);
46: }
47:
48: public void testGetFirstLastFiscalYearDates() throws Exception {
49: UniversityDateDao dao = SpringContext
50: .getBean(UniversityDateDao.class);
51: assertNotNull("Dao shouldn't be null", dao);
52:
53: UniversityDate firstFiscalYearDate = dao
54: .getFirstFiscalYearDate(new Integer(2007));
55: assertEquals("07/01/2006", sdf.format(firstFiscalYearDate
56: .getUniversityDate()));
57:
58: UniversityDate lastFiscalYearDate = dao
59: .getLastFiscalYearDate(new Integer(2007));
60: assertEquals("06/30/2007", sdf.format(lastFiscalYearDate
61: .getUniversityDate()));
62: }
63: }
|