| 1 28 29 package com.idaremedia.antx.tests; 30 31 import java.util.Collections ; 32 import java.util.List ; 33 import java.util.Map ; 34 35 import junit.framework.TestSuite; 36 37 import org.apache.tools.ant.Project; 38 39 import com.idaremedia.antx.ut.HTC; 40 import com.idaremedia.antx.ut.HTCUtils; 41 42 import com.idaremedia.antx.AntX; 43 import com.idaremedia.antx.AntXFixture; 44 import com.idaremedia.antx.helpers.Tk; 45 46 55 56 public final class UtilitiesTest extends HTC 57 { 58 59 public static final String TEST_CATEGORY="CLASS"; 60 61 62 65 public UtilitiesTest(String methodName) 66 { 67 super("Utilities::",methodName); 68 } 69 70 71 74 public static TestSuite suite() 75 { 76 return new TestSuite(UtilitiesTest.class); 77 } 78 79 80 83 public static TestSuite baseline() 84 { 85 return suite(); 86 } 87 88 89 92 public static void main(String [] argv) 93 { 94 HTCUtils.quickCheck(suite()); 95 } 96 97 101 protected void setUp() throws Exception  102 { 103 configureProjectFromResource("empty.xml"); 104 Project P = getProject(); 105 assertNotNil(P,"test's project"); 106 } 107 108 112 public void checkBaseline() 113 { 114 } 116 117 118 public void testBaseline() 119 { 120 checkBaseline(); 121 } 122 123 124 127 public void testAntXStringsAccessible_AntX04() 128 { 129 String s1 = AntX.uistrs().get("antx_.debug.helloworld"); 130 assertNotWhitespace(s1,"AntX debug UIString"); 131 assertTrue(s1.indexOf("DO NOT REMOVE")>=0,"Expected AntX debug string"); 132 133 assertNotWhitespace(AntX.uistrs().get(AntX.CLONE_BROKEN_MSGID)); 135 assertNotWhitespace(AntX.uistrs().get("cv.require")); 136 assertNotWhitespace(AntX.uistrs().get("task.warn.property.exists")); 137 assertNotWhitespace(AntX.uistrs().get("task.cant.flip.unknown")); 138 } 139 140 141 144 public void testReadonlyMapWrapperUtil_AntX04() 145 { 146 Map mp; 147 Map mutableMap = AntXFixture.newMap(); 148 149 assertNil(Tk.readonlyFrom(null,false)); 150 mp = Tk.readonlyFrom(null,true); 151 assertNotNil(mp); 152 assertIdent(mp,Tk.readonlyFrom(mp,false)); 153 154 mp= Collections.EMPTY_MAP; 155 assertIdent(mp,Tk.readonlyFrom(mp,false)); 156 157 mp= Collections.unmodifiableMap(mutableMap); 158 assertIdent(mp,Tk.readonlyFrom(mp,false)); 159 assertNotIdent(mp,Tk.readonlyFrom(mutableMap,false)); 160 } 161 162 163 166 public void testResolveStringOverheadUtil_AntX04() 167 { 168 Project P= getProject(); 169 170 assertNil(Tk.resolveString(P,null)); 171 172 String s = "no variables here"; 173 assertIdent(s,Tk.resolveString(P,s),"no variables in string"); 174 175 assertNotNil(P.getProperty("p.true"),"p.true definition"); 176 s = "This is a test: ${p.true}"; 177 assertNotEqual(s,Tk.resolveString(P,s),"variables in string"); 178 } 179 180 181 182 186 public void testResolveLocalVariables_AntX04() 187 { 188 Project P= getProject(); 189 190 assertNil(Tk.resolveString(P,null)); 191 192 String s = "no variables here"; 193 assertIdent(s,Tk.resolveString(P,s,true),"no variables in string"); 194 195 assertNotNil(P.getProperty("p.true"),"p.true definition"); 196 197 s = "This is a test: @{p.true}. Happy ? @{p.false}"; 198 String xpected = "This is a test: true. Happy ? false"; 199 String out = Tk.resolveString(P,s,true); 200 201 assertEqual(out,xpected,"local variables in string(a)"); 202 203 s = "This is a test: ${p.true}. Happy ? @{p.false}"; 204 out = Tk.resolveString(P,s,true); 205 assertEqual(out,xpected,"local variables in string(b)"); 206 } 207 208 209 214 public void testResolveValueURIFriendlyRefs_AntX05() 215 { 216 Project P= getProject(); 217 String s; 218 219 s = "This is a test: @(p.true). Happy ? @(p.false)"; 220 String xpected = "This is a test: true. Happy ? false"; 221 String out = Tk.resolveString(P,s,true); 222 223 assertEqual(out,xpected,"local variables in string(a)"); 224 225 s = "This is a test: ${p.true}. Happy ? @(p.false)"; 226 out = Tk.resolveString(P,s,true); 227 assertEqual(out,xpected,"local variables in string(b)"); 228 } 229 230 231 236 public void testSplitListEmptyStringIsZeroLengthList_AntX05() 237 { 238 List l = Tk.splitList(""); 239 assertNotNil(l,"empty string's list"); 240 assertEqual(0,l.size(),"list's size"); 241 } 242 } 243 244 245 | Popular Tags |