1 15 package org.apache.hivemind.util; 16 17 import org.apache.hivemind.test.HiveMindTestCase; 18 import org.apache.hivemind.util.StringUtils; 19 20 25 public class TestStringUtils extends HiveMindTestCase 26 { 27 public void testCapitalize() 28 { 29 assertEquals("Fred", StringUtils.capitalize("fred")); 30 assertSame("Barney", StringUtils.capitalize("Barney")); 31 } 32 33 public void testCapitalizeEmpty() 34 { 35 assertSame("", StringUtils.capitalize("")); 36 } 37 38 public void testCapitalizeNull() 39 { 40 try 41 { 42 StringUtils.capitalize(null); 43 unreachable(); 44 } 45 catch (NullPointerException ex) 46 { 47 assertTrue(true); 48 } 49 } 50 51 public void testSplit() 52 { 53 assertListsEqual(new String [] { "alpha", "beta" }, StringUtils.split("alpha,beta")); 54 } 55 56 public void testSplitSingle() 57 { 58 assertListsEqual(new String [] { "alpha" }, StringUtils.split("alpha")); 59 } 60 61 public void testSplitNull() 62 { 63 assertListsEqual(new String [0], StringUtils.split(null)); 64 } 65 66 public void testSplitEmpty() 67 { 68 assertListsEqual(new String [0], StringUtils.split(null)); 69 } 70 71 public void testSplitTrailingComma() 72 { 73 assertListsEqual( 74 new String [] { "fred", "barney", "wilma" }, 75 StringUtils.split("fred,barney,wilma,")); 76 } 77 78 public void testJoin() 79 { 80 assertEquals("alpha:beta", StringUtils.join(new String [] { "alpha", "beta" }, ':')); 81 } 82 83 public void testJoinNull() 84 { 85 assertEquals(null, StringUtils.join(null, ',')); 86 } 87 88 public void testJoinEmpty() 89 { 90 assertEquals(null, StringUtils.join(new String [0], ',')); 91 } 92 } | Popular Tags |