01: /**
02: * Copyright (C) 2002
03: */package org.objectweb.util.monolog.file;
04:
05: import junit.framework.TestCase;
06: import junit.framework.TestSuite;
07: import junit.textui.TestRunner;
08:
09: /**
10: *
11: * @author Sebastien Chassande-Barrioz
12: */
13: public class TestDottedStringTools extends TestCase {
14:
15: public TestDottedStringTools(String name) {
16: super (name);
17: }
18:
19: /**
20: * For running the TestLevelConf suite standalone. A particular TestSuite is
21: * used to initialized the class instance by setter methods.
22: * Two parameters are required:
23: * <ul>
24: * <li>a LoggerFactory class name</li>
25: * <li>a MonologConfFactory class name</li>
26: * </ul>
27: */
28: public static void main(String args[]) {
29: try {
30: TestSuite suite = new TestSuite(TestDottedStringTools.class);
31: TestRunner.run(suite);
32: } catch (Exception e) {
33: e.printStackTrace();
34: }
35: }
36:
37: /**
38: * it tests the getFirst method.
39: */
40: public void testGetFirst() {
41: assertEquals("1", "org", DottedStringTools
42: .getFirst("org.objectweb.toto"));
43: assertEquals("2", "org", DottedStringTools.getFirst("org"));
44: assertEquals("3", "", DottedStringTools.getFirst(""));
45: assertEquals("4", "org", DottedStringTools.getFirst("org."));
46: assertEquals("5", "", DottedStringTools.getFirst(".org"));
47: assertNull("6", DottedStringTools.getFirst(null));
48: }
49:
50: /**
51: * it tests the getLast method.
52: */
53: public void testGetLast() {
54: assertEquals("1", "toto", DottedStringTools
55: .getLast("org.objectweb.toto"));
56: assertEquals("2", "org", DottedStringTools.getLast("org"));
57: assertEquals("3", "", DottedStringTools.getLast(""));
58: assertEquals("4", "", DottedStringTools.getLast("org."));
59: assertEquals("5", "org", DottedStringTools.getLast(".org"));
60: assertNull("6", DottedStringTools.getLast(null));
61: }
62:
63: /**
64: * it tests the getEnd method.
65: */
66: public void testGetEnd() {
67: assertEquals("1", "objectweb.toto", DottedStringTools
68: .getEnd("org.objectweb.toto"));
69: assertEquals("2", "org", DottedStringTools.getEnd("org"));
70: assertEquals("3", "", DottedStringTools.getEnd(""));
71: assertEquals("", DottedStringTools.getEnd("org."));
72: assertEquals("5", "org", DottedStringTools.getEnd(".org"));
73: assertNull("6", DottedStringTools.getEnd(null));
74: }
75:
76: /**
77: * It tests the getBegin method.
78: */
79: public void testGetBegin() {
80: assertEquals("1", "org.objectweb", DottedStringTools
81: .getBegin("org.objectweb.toto"));
82: assertEquals("2", "org", DottedStringTools.getBegin("org"));
83: assertEquals("3", "", DottedStringTools.getBegin(""));
84: assertEquals("4", "org", DottedStringTools.getBegin("org."));
85: assertEquals("5", "", DottedStringTools.getBegin(".org"));
86: assertNull("6", DottedStringTools.getBegin(null));
87: }
88: }
|