1 package csdl.jblanket.util; 2 3 import csdl.jblanket.modifier.MethodCollector; 4 5 import java.io.File ; 6 7 import junit.framework.TestCase; 8 import junit.framework.TestSuite; 9 import junit.textui.TestRunner; 10 11 22 public class TestMethodCategories extends TestCase { 23 24 25 private MethodCategories categories; 26 27 28 private static String jblanketDir; 29 30 31 private final String slash = File.separator; 32 33 38 public TestMethodCategories(String name) { 39 super(name); 40 41 jblanketDir = MethodCollector.getJBlanketDir(); 42 } 43 44 47 public void setUp() { 48 this.categories = MethodCategories.getInstance(); 49 } 50 51 54 public void testValidCategories() { 55 56 assertEquals("checking totalFile category in empty categories", 59 jblanketDir + slash + "totalMethods.xml", categories.getFileName("totalFile")); 60 61 int oldCategoriesSize = categories.getCategories().size(); 62 63 categories.addCategory("totalFile", "myTotalMethods.xml"); 65 assertEquals("checking totalFile category in non-empty categories", 66 jblanketDir + slash + "myTotalMethods.xml", categories.getFileName("totalFile")); 67 68 assertEquals("checking number of categories", oldCategoriesSize, 70 categories.getCategories().size()); 71 } 72 73 76 public void testInvalidCategories() { 77 78 assertEquals("checking junkFile category in empty categories", 80 null, categories.getFileName("junkFile")); 81 82 categories.addCategory("junkFile"); 84 assertEquals("checking junkFile category in non-empty categories", 85 null, categories.getFileName("junkFile")); 86 87 categories.addCategory("junkFile", "myJunkMethods.xml"); 88 assertEquals("checking junkFile category and file name in non-empty categories", 89 jblanketDir + slash + "myJunkMethods.xml", categories.getFileName("junkFile")); 90 91 } 92 93 98 public static void main(String [] args) { 99 100 System.out.println("JUnit testing MethodCategories."); 101 TestRunner.run(new TestSuite(TestMethodCategories.class)); 103 } 104 } | Popular Tags |