KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > anupam > csv > formatters > FirstWordFormatterTest


1 /*
2  * FirstWordFormatterTest.java
3  *
4  * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * 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.1 $
21  */

22 package net.sf.anupam.csv.formatters;
23
24 import junit.framework.TestCase;
25
26 /**
27  * FirstWordFormatterTest.
28  *
29  * @author Anupam Sengupta
30  * @version $Revision: 1.1 $
31  */

32 public class FirstWordFormatterTest
33         extends TestCase {
34
35     /**
36      * Constructor for FirstWordFormatterTest.
37      *
38      * @param name
39      * name of the test
40      */

41     public FirstWordFormatterTest(final String JavaDoc name) {
42         super(name);
43     }
44
45     /**
46      * Main method to perform the tests.
47      *
48      * @param args
49      * Program arguments
50      */

51     public static void main(final String JavaDoc [] args) {
52         junit.textui.TestRunner.run(FirstWordFormatterTest.class);
53     }
54
55     /**
56      * Test method for
57      * 'com.tcs.mis.csv.utilities.FirstWordFormatter.format(String)'.
58      */

59     public void testFormat() {
60         final String JavaDoc name = "Anupam B Sengupta";
61         final CSVFieldFormatter formatter = new FirstWordFormatter();
62         assertNotNull(formatter);
63         final String JavaDoc result = formatter.format(name);
64         assertEquals("Anupam", result);
65     }
66
67     /**
68      * Test method for
69      * 'com.tcs.mis.csv.utilities.FirstWordFormatter.format(String)'.
70      */

71     public void testFormatWhenNull() {
72         final CSVFieldFormatter formatter = new FirstWordFormatter();
73         assertNotNull(formatter);
74
75         final String JavaDoc nullResult = formatter.format(null);
76         assertNull(nullResult);
77
78     }
79
80     /**
81      * Test method for
82      * 'com.tcs.mis.csv.utilities.FirstWordFormatter.format(String)'.
83      */

84     public void testFormatWhenEmpty() {
85         final CSVFieldFormatter formatter = new FirstWordFormatter();
86         assertNotNull(formatter);
87
88         final String JavaDoc emptyResult = formatter.format("");
89         assertEquals("", emptyResult);
90
91     }
92 }
93
Popular Tags