01: /*
02: * CSVFormatterConfigParserTest.java
03: *
04: * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net)
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19: *
20: * Version: $Revision: 1.2 $
21: */
22: package net.sf.anupam.csv.formatters;
23:
24: import junit.framework.TestCase;
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27:
28: import java.util.Map;
29:
30: /**
31: * CSVFormatterConfigParserTest.
32: *
33: * @author Anupam Sengupta
34: * @version $Revision: 1.2 $
35: */
36: public class CSVFormatterConfigParserTest extends TestCase {
37:
38: /**
39: * The logger to use.
40: */
41: private static final Log LOG = LogFactory
42: .getLog(CSVFormatterConfigParserTest.class);
43:
44: /**
45: * Constructor for CSVFormatterConfigParserTest.
46: *
47: * @param name name of the test
48: */
49: public CSVFormatterConfigParserTest(final String name) {
50: super (name);
51: }
52:
53: /**
54: * Main method to run the test.
55: *
56: * @param args program arguments
57: */
58: public static void main(final String[] args) {
59: junit.textui.TestRunner.run(CSVFormatterConfigParserTest.class);
60: }
61:
62: /**
63: * Test method for
64: * 'net.sf.anupam.csv.formatters.CSVFormatterConfigParser.getFormatMappings(String,
65: * boolean)'.
66: */
67: public void testGetFormatMappings() {
68: final CSVFormatterConfigParser parser = CSVFormatterConfigParser
69: .getConfigParser();
70: assertNotNull(parser);
71:
72: final Map<String, FormatterConfiguration> formatterMap = parser
73: .getFormatMappings(
74: "net/sf/anupam/csv/formatters/csv-formatter-config.xml",
75: true);
76: assertNotNull("Formatter Map Should not be Null", formatterMap);
77: assertFalse("Formatter Map should not be Empty", formatterMap
78: .isEmpty());
79:
80: for (String formatterName : formatterMap.keySet()) {
81: final FormatterConfiguration formatterConfig = formatterMap
82: .get(formatterName);
83: assertNotNull(formatterConfig);
84: LOG.info(formatterConfig);
85: }
86:
87: }
88:
89: }
|