1 22 package org.objectweb.petals.tools.util; 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 27 import org.objectweb.petals.tools.jbicommon.util.StringHelper; 28 29 import junit.framework.TestCase; 30 31 37 public class StringHelperTest extends TestCase { 38 39 42 public void testIsEmpty1() { 43 assertTrue(StringHelper.isNullOrEmpty(null)); 44 } 45 46 public void testIsEmpty2() { 47 assertTrue(StringHelper.isNullOrEmpty("")); 48 } 49 50 public void testIsEmpty3() { 51 assertFalse(StringHelper.isNullOrEmpty("a")); 52 } 53 54 58 public void testEqual1() { 59 assertTrue(StringHelper.equal(null, null)); 60 } 61 62 public void testEqual2() { 63 assertTrue(StringHelper.equal("a", "a")); 64 } 65 66 public void testEqual3() { 67 assertFalse(StringHelper.equal(null, "")); 68 } 69 70 public void testEqual4() { 71 assertFalse(StringHelper.equal("", null)); 72 } 73 74 public void testEqual5() { 75 assertFalse(StringHelper.equal("a", "A")); 76 } 77 78 public void testEqual6() { 79 assertFalse(StringHelper.equal("a", "b")); 80 } 81 82 86 public void testequalIgnoreCaseIgnoreCase1() { 87 assertTrue(StringHelper.equalIgnoreCase(null, null)); 88 } 89 90 public void testequalIgnoreCaseIgnoreCase2() { 91 assertTrue(StringHelper.equalIgnoreCase("a", "a")); 92 } 93 94 public void testequalIgnoreCaseIgnoreCase5() { 95 assertTrue(StringHelper.equalIgnoreCase("a", "A")); 96 } 97 98 public void testequalIgnoreCaseIgnoreCase3() { 99 assertFalse(StringHelper.equalIgnoreCase(null, "")); 100 } 101 102 public void testequalIgnoreCaseIgnoreCase4() { 103 assertFalse(StringHelper.equalIgnoreCase("", null)); 104 } 105 106 public void testequalIgnoreCaseIgnoreCase6() { 107 assertFalse(StringHelper.equalIgnoreCase("a", "b")); 108 } 109 110 115 116 public void testextractValueForAttribute1() { 118 assertNull(StringHelper.extractValueForAttribute(null, "", "")); 119 } 120 121 public void testextractValueForAttribute2() { 122 assertNull(StringHelper.extractValueForAttribute("", null, "")); 123 } 124 125 public void testextractValueForAttribute3() { 126 assertNull(StringHelper.extractValueForAttribute("", "", null)); 127 } 128 129 public void testextractValueForAttribute4() { 131 assertEquals("value", StringHelper.extractValueForAttribute( 132 "att=value", "att", null)); 133 } 134 135 public void testextractValueForAttribute5() { 136 assertEquals("value", StringHelper.extractValueForAttribute( 137 "yo att=value", "att", null)); 138 } 139 140 public void testextractValueForAttribute6() { 141 assertEquals("value", StringHelper.extractValueForAttribute( 142 "yo att=value&yo", "att", "&")); 143 } 144 145 public void testextractValueForAttribute7() { 146 assertEquals("value etc", StringHelper.extractValueForAttribute( 147 "yo att=value etc", "att", null)); 148 } 149 150 153 public void testSplitPathElements1() { 154 assertTrue(StringHelper.splitPathElements(null).isEmpty()); 155 } 156 157 public void testSplitPathElements2() { 158 List <String > result = new ArrayList <String >(); 159 result.add("foo"); 160 result.add("bar"); 161 assertEquals(result, StringHelper.splitPathElements("/foo/bar")); 162 } 163 164 public void testSplitPathElements3() { 165 List <String > result = new ArrayList <String >(); 166 result.add("foo"); 167 result.add("bar"); 168 assertEquals(result, StringHelper.splitPathElements("foo/bar")); 169 } 170 171 public void testSplitPathElements4() { 172 List <String > result = new ArrayList <String >(); 173 result.add("foo"); 174 result.add("bar"); 175 assertEquals(result, StringHelper.splitPathElements("/foo/bar/")); 176 } 177 178 public void testSplitPathElements5() { 179 List <String > result = new ArrayList <String >(); 180 result.add("foo"); 181 result.add("bar"); 182 assertEquals(result, StringHelper.splitPathElements("//foo///bar//")); 183 } 184 185 } 186 | Popular Tags |