1 package test.crispy.util; 2 3 import java.util.HashMap; 4 import java.util.Map; 5 6 import test.crispy.example.model.ProblemNode; 7 import net.sf.crispy.util.ClassPropertiesCache; 8 import junit.framework.TestCase; 9 10 public class ClassPropertiesCacheTest extends TestCase { 11 12 public void testAllClassPropertiesMap() throws Exception { 13 ClassPropertiesCache lvCache = new ClassPropertiesCache(); 14 lvCache.addClassPropertiesMap(ProblemNode.class, new HashMap()); 15 assertEquals(1, lvCache.size()); 16 } 17 18 public void testAllNotValidClassPropertiesMap() throws Exception { 19 ClassPropertiesCache lvCache = new ClassPropertiesCache(); 20 Map lvMap = new HashMap(); 21 boolean lvAdded = lvCache.addClassPropertiesMap(lvMap); 22 assertFalse(lvAdded); 23 assertEquals(0, lvCache.size()); 24 25 lvMap.put("class", "NotValidClass"); 26 lvAdded = lvCache.addClassPropertiesMap(lvMap); 27 assertFalse(lvAdded); 28 assertEquals(0, lvCache.size()); 29 30 lvMap.put("class", ProblemNode.class.getName()); 31 lvAdded = lvCache.addClassPropertiesMap(lvMap); 32 assertTrue(lvAdded); 33 assertEquals(1, lvCache.size()); 34 } 35 36 public void testGetClassPropertiesMapByClass() throws Exception { 37 ClassPropertiesCache lvCache = new ClassPropertiesCache(); 38 lvCache.addClassPropertiesMap(ProblemNode.class, new HashMap()); 39 assertEquals(1, lvCache.size()); 40 41 Map lvMap = lvCache.getClassPropertiesMapByClass(ProblemNode.class); 42 assertNotNull(lvMap); 43 assertEquals(0, lvMap.size()); 44 } 45 46 }