1 package net.firstpartners.nounit.reader.bytecode.test; 2 3 26 import java.util.HashMap ; 27 import java.util.Iterator ; 28 29 import junit.framework.Test; 30 import junit.framework.TestCase; 31 import junit.framework.TestSuite; 32 import net.firstpartners.nounit.reader.ISnippetFactory; 33 import net.firstpartners.nounit.reader.bytecode.ByteCodeMethodSnippetFactory; 34 import net.firstpartners.nounit.snippet.Snippets; 35 import net.firstpartners.nounit.test.TestData; 36 import org.apache.log4j.Logger; 37 41 public class TestByteCodeMethodSnippetFactory extends TestCase { 42 43 static Logger log = Logger.getLogger(TestByteCodeCallsSnippetFactory.class); 45 46 50 public TestByteCodeMethodSnippetFactory(String name) { 51 super(name); 52 } 53 54 57 public void setUp(){ 58 59 } 60 61 64 protected void tearDown() 65 { 66 67 } 68 69 73 public static void main(String [] args) { 74 junit.textui.TestRunner.run (suite()); 75 } 76 77 81 public static Test suite() { 82 return new TestSuite(TestByteCodeMethodSnippetFactory.class); 83 } 84 85 88 public void testParameterStringConversion() throws Exception { 89 90 String tmpString; 91 String testString="<(Ljava/lang/String;Ljava/lang/String;Lorg/jdom/Namespace;)Lorg/jdom/Attirbute;>"; 92 ByteCodeMethodSnippetFactory myFactory = 93 new ByteCodeMethodSnippetFactory(TestData.getSampleClassFile()); 94 95 HashMap results= myFactory.splitTagVerboseIntoHashMap(testString); 96 Iterator loop = results.keySet().iterator(); 97 98 99 assertTrue(results.get("0").equals("java.lang.String")); 100 assertTrue(results.get("1").equals("java.lang.String")); 101 assertTrue(results.get("2").equals("org.jdom.Namespace")); 102 assertTrue(results.get("3").equals("org.jdom.Attirbute")); 103 104 } 105 106 public void testConvertMethodsAsSnippets() throws Exception { 107 108 Snippets javaInformation; 109 Iterator informationList; 110 ISnippetFactory myFactory = 111 new ByteCodeMethodSnippetFactory(TestData.getSampleClassFile()); 112 113 javaInformation = myFactory.getSnippets(); 115 informationList = javaInformation.getIterator(); 116 117 while (informationList.hasNext()) { 118 log.debug(informationList.next().getClass()); 120 } 121 122 } 123 124 125 } | Popular Tags |