1 package net.firstpartners.nounit.reader.bytecode.test; 2 3 26 import java.io.File ; 27 28 import junit.framework.Test; 29 import junit.framework.TestCase; 30 import junit.framework.TestSuite; 31 import net.firstpartners.nounit.reader.ISnippetFactory; 32 import net.firstpartners.nounit.reader.bytecode.AbstractByteCodeSnippetFactory; 33 import net.firstpartners.nounit.reader.bytecode.ByteCodeClassSnippetFactory; 34 import net.firstpartners.nounit.snippet.Snippets; 35 import net.firstpartners.nounit.test.TestData; 36 37 40 public class TestByteCodeClassSnippetFactory extends TestCase { 41 42 46 public TestByteCodeClassSnippetFactory(String name) { 47 super(name); 48 } 49 50 54 public static void main(String [] args) { 55 junit.textui.TestRunner.run (suite()); 56 } 57 58 62 public static Test suite() { 63 return new TestSuite(TestByteCodeClassSnippetFactory.class); 64 } 65 66 public void testGetClassInfo() throws Exception { 67 68 File sourceFile= new File ( TestData.SAMPLE_CLASS_PROXY ); 70 71 ISnippetFactory myFactory = 73 new ByteCodeClassSnippetFactory( sourceFile ); 74 Snippets javaInformation = myFactory.getSnippets(); 75 String info = javaInformation.toString(); 76 77 assertTrue(info.indexOf("public eip.ProxyBean")>-1); 78 assertTrue(info.indexOf("handleGenericRequest(")>-1); 79 assertTrue(info.indexOf("main(")>-1); 80 assertTrue(info.indexOf("handleCommandLineRequest(")>-1); 81 assertTrue(info.indexOf("<init>(")>-1); 82 assertTrue(info.indexOf("clearError(")>-1); 83 assertTrue(info.indexOf("extends java.lang.Object")>-1); 84 assertTrue(info.indexOf("public")>-1); 85 assertTrue(info.indexOf("protected")>-1); 86 } 87 88 91 public void testParameterStringConversion() throws Exception { 92 93 AbstractByteCodeSnippetFactory myFactory 94 = new ByteCodeClassSnippetFactory(TestData.getSampleFile()); 95 String testString=".somepackage/someClass"; 96 String results=myFactory.cleanValues(testString); 97 98 assertTrue(results.equals("somepackage.someClass")); 99 } 100 101 } 102 | Popular Tags |