01: /*
02: * Copyright 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.cg.service.impl;
17:
18: import java.io.IOException;
19:
20: import org.kuali.kfs.context.KualiTestBase;
21: import org.kuali.kfs.context.SpringContext;
22: import org.kuali.module.cg.service.CfdaService;
23: import org.kuali.module.cg.service.CfdaUpdateResults;
24: import org.kuali.test.ConfigureContext;
25:
26: @ConfigureContext
27: public class CfdaServiceTest extends KualiTestBase {
28:
29: public void testPatternExtraction() {
30:
31: String[] table = {
32: "<TD ALIGN=\"Center\" NOWRAP valign=\"TOP\" WIDTH=\"0\"><A HREF=\"CATALOG.PROGRAM_TEXT_RPT.SHOW?p_arg_names=prog_nbr&p_arg_values=10.001\"><FONT STYLE = \"font-family:Arial; color:#00008B; font-size:10pt; \"><B><U>10.001</U></B></FONT></A></TD>\n",
33: "<TD ALIGN=\"Left\" NOWRAP valign=\"TOP\" WIDTH=\"0\"><FONT STYLE = \"font-family:Arial; font-size:10pt; \">USDA</FONT></TD>\n",
34: "<TD ALIGN=\"Left\" NOWRAP valign=\"TOP\" WIDTH=\"666\"><FONT STYLE = \"font-family:Arial; font-size:10pt; \">Agricultural Research_Basic and Applied Research</FONT></TD>" };
35:
36: String n = ((CfdaServiceImpl) SpringContext
37: .getBean(CfdaService.class))
38: .extractCfdaNumberFrom(table[0]);
39: String a = ((CfdaServiceImpl) SpringContext
40: .getBean(CfdaService.class))
41: .extractCfdaAgencyFrom(table[1]);
42: String t = ((CfdaServiceImpl) SpringContext
43: .getBean(CfdaService.class))
44: .extractCfdaTitleFrom(table[2]);
45:
46: assertEquals("Number extraction failed", "10.001", n);
47: assertEquals("Agency extraction failed", "USDA", a);
48: assertEquals("Title extraction failed",
49: "Agricultural Research_Basic and Applied Research", t);
50: }
51:
52: public void testUpdate() throws IOException {
53: CfdaUpdateResults results = SpringContext.getBean(
54: CfdaService.class).update();
55: }
56:
57: }
|