1 package csdl.jblanket.modifier; 2 3 import csdl.jblanket.methodset.MethodSet; 4 import csdl.jblanket.methodset.MethodSetManager; 5 import csdl.jblanket.util.MethodCategories; 6 7 import java.io.File ; 8 9 import junit.framework.TestCase; 10 11 import org.apache.tools.ant.util.FileUtils; 12 13 19 public class TestClassModifier extends TestCase { 20 21 22 private File inFile; 23 24 25 private MethodCounter counter; 26 27 28 private ClassModifier modifier; 29 30 35 public TestClassModifier(String name) { 36 super(name); 37 } 38 39 44 public void setUp() throws Exception { 45 final String slash = File.separator; 47 48 File dir = new File (System.getProperty("jblanket.data.dir")); 50 File originalDir = new File (dir, "unjar" + slash + "edu" + slash + "hawaii" + slash + "stack"); 51 File originalFile = new File (originalDir, "Stack.class"); 52 53 File inDir = new File (System.getProperty("jblanket.testdir"), "testclassmodifier"); 55 this.inFile = new File (inDir, "Stack.class"); 56 57 FileUtils fileUtils = FileUtils.newFileUtils(); 59 fileUtils.copyFile(originalFile, this.inFile); 60 61 this.counter = new MethodCounter(); 62 this.modifier = new ClassModifier(false, "Test*.class", true, true, false, 63 this.counter, this.inFile); 64 } 65 66 69 public void testModifyMethods() { 70 71 assertEquals("Checking if class already modified", false, this.modifier.isModified()); 72 73 try { 74 this.modifier.modifyMethods(); 75 } 76 catch (Exception e) { 77 fail("Unable to store modified methods"); 78 } 79 80 assertEquals("Checking if class already modified", true, this.modifier.isModified()); 81 } 82 83 87 public void testExcludeMethods() { 88 89 try { 90 this.modifier = new ClassModifier(false, this.counter, this.inFile); 91 } 92 catch (Exception e) { 93 fail("Unable to construct new object"); 94 } 95 96 this.modifier.excludeMethods(); 97 98 String fileName = MethodCategories.getInstance().getFileName("excludedFile"); 99 MethodSet methodSet = MethodSetManager.getInstance().getMethodSet(fileName); 100 assertEquals("Checking size of exclude MethodSet", 8, methodSet.size()); 101 } 102 } | Popular Tags |