1 package net.firstpartners.nounit.reader.bytecode.test; 2 3 26 27 import junit.framework.Test; 28 import junit.framework.TestCase; 29 import junit.framework.TestSuite; 30 31 import org.apache.log4j.Logger; 32 33 import org.gjt.jclasslib.structures.AttributeInfo; 34 import org.gjt.jclasslib.structures.ClassFile; 35 import org.gjt.jclasslib.structures.MethodInfo; 36 import org.gjt.jclasslib.structures.attributes.CodeAttribute; 37 38 import net.firstpartners.nounit.reader.bytecode.ByteCodeCallsSnippetFactory; 39 import net.firstpartners.nounit.test.TestData; 40 41 45 public class TestByteCodeCallsSnippetFactory extends TestCase { 46 47 static Logger log = Logger.getLogger(TestByteCodeCallsSnippetFactory.class); 49 50 54 public TestByteCodeCallsSnippetFactory(String name) { 55 super(name); 56 } 57 58 61 public void setUp(){ 62 63 } 64 65 68 protected void tearDown() { 69 70 } 71 72 76 public static void main(String [] args) { 77 junit.textui.TestRunner.run(suite()); 78 } 79 80 84 public static Test suite() { 85 return new TestSuite(TestByteCodeCallsSnippetFactory.class); 86 } 87 88 91 public void testParameterStringConversion() throws Exception { 92 93 ByteCodeCallsSnippetFactory testByteCode; 95 AttributeInfo[] myAttributes; 96 CodeAttribute tmpCodeAttribute; 97 98 ClassFile classSource = TestData.getSampleClassFile(); 100 101 MethodInfo[] myMethods = classSource.getMethods(); 103 104 StringBuffer output = new StringBuffer (); 106 107 108 for (int a=0;a<myMethods.length; a++) { 110 111 myAttributes = myMethods[a].getAttributes(); 112 113 for (int b=0; b<myAttributes.length;b++) { 114 115 if (myAttributes[b] instanceof CodeAttribute){ 117 118 tmpCodeAttribute = (CodeAttribute)myAttributes[b]; 119 testByteCode = new ByteCodeCallsSnippetFactory(tmpCodeAttribute,classSource); 120 121 output.append(testByteCode.getSnippets().toXml()); 124 125 126 } 128 } 130 } 132 log.debug(output); 133 134 String info = output.toString(); 135 136 assertTrue(info.indexOf("<CALLS class=")>-1); 137 assertTrue(info.indexOf("method=")>-1); 138 139 } 140 141 } 142 | Popular Tags |