KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > file > TestDottedStringTools


1 /**
2  * Copyright (C) 2002
3  */

4
5 package org.objectweb.util.monolog.file;
6
7 import junit.framework.TestCase;
8 import junit.framework.TestSuite;
9 import junit.textui.TestRunner;
10
11 /**
12  *
13  * @author Sebastien Chassande-Barrioz
14  */

15 public class TestDottedStringTools extends TestCase {
16
17     public TestDottedStringTools(String JavaDoc name) {
18         super(name);
19     }
20
21     /**
22      * For running the TestLevelConf suite standalone. A particular TestSuite is
23      * used to initialized the class instance by setter methods.
24      * Two parameters are required:
25      * <ul>
26      * <li>a LoggerFactory class name</li>
27      * <li>a MonologConfFactory class name</li>
28      * </ul>
29      */

30     public static void main(String JavaDoc args[]) {
31         try {
32             TestSuite suite = new TestSuite(TestDottedStringTools.class);
33             TestRunner.run(suite);
34         }
35         catch (Exception JavaDoc e) {
36             e.printStackTrace();
37         }
38     }
39
40     /**
41      * it tests the getFirst method.
42      */

43     public void testGetFirst() {
44         assertEquals("1", "org",
45             DottedStringTools.getFirst("org.objectweb.toto"));
46         assertEquals("2", "org", DottedStringTools.getFirst("org"));
47         assertEquals("3", "", DottedStringTools.getFirst(""));
48         assertEquals("4", "org", DottedStringTools.getFirst("org."));
49         assertEquals("5", "", DottedStringTools.getFirst(".org"));
50         assertNull("6", DottedStringTools.getFirst(null));
51     }
52
53     /**
54      * it tests the getLast method.
55      */

56     public void testGetLast() {
57         assertEquals("1", "toto", DottedStringTools.getLast("org.objectweb.toto"));
58         assertEquals("2", "org", DottedStringTools.getLast("org"));
59         assertEquals("3", "", DottedStringTools.getLast(""));
60         assertEquals("4", "", DottedStringTools.getLast("org."));
61         assertEquals("5", "org", DottedStringTools.getLast(".org"));
62         assertNull("6", DottedStringTools.getLast(null));
63     }
64
65     /**
66      * it tests the getEnd method.
67      */

68     public void testGetEnd() {
69         assertEquals("1", "objectweb.toto",
70             DottedStringTools.getEnd("org.objectweb.toto"));
71         assertEquals("2", "org", DottedStringTools.getEnd("org"));
72         assertEquals("3", "", DottedStringTools.getEnd(""));
73         assertEquals("", DottedStringTools.getEnd("org."));
74         assertEquals("5", "org", DottedStringTools.getEnd(".org"));
75         assertNull("6", DottedStringTools.getEnd(null));
76     }
77
78     /**
79      * It tests the getBegin method.
80      */

81     public void testGetBegin() {
82         assertEquals("1", "org.objectweb",
83             DottedStringTools.getBegin("org.objectweb.toto"));
84         assertEquals("2", "org", DottedStringTools.getBegin("org"));
85         assertEquals("3", "", DottedStringTools.getBegin(""));
86         assertEquals("4", "org", DottedStringTools.getBegin("org."));
87         assertEquals("5", "", DottedStringTools.getBegin(".org"));
88         assertNull("6", DottedStringTools.getBegin(null));
89     }
90 }
91
Popular Tags