1 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 15 public class TestDottedStringTools extends TestCase { 16 17 public TestDottedStringTools(String name) { 18 super(name); 19 } 20 21 30 public static void main(String args[]) { 31 try { 32 TestSuite suite = new TestSuite(TestDottedStringTools.class); 33 TestRunner.run(suite); 34 } 35 catch (Exception e) { 36 e.printStackTrace(); 37 } 38 } 39 40 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 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 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 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 |