View Javadoc
1 package attrib4j.tests; 2 3 import java.util.Arrays; 4 5 import junit.framework.TestCase; 6 import attrib4j.bcel.DescriptorUtil; 7 8 /*** 9 * Test the conversion of method signatures used in Javadoc and Java 10 * to those used in the JVM spec. 11 * 12 * @author <a href="mailto:mpollack@speakeasy.org">Mark Pollack</a> 13 */ 14 15 public class DescriptorTest extends TestCase { 16 17 /*** 18 * Creates a new <code>DescriptorTest</code> instance. 19 * 20 * @param name The name of the test. 21 */ 22 public DescriptorTest(String name) { 23 super(name); 24 } 25 26 /*** 27 * Test the conversion of method signatures from Java/Javadoc format 28 * to JVM format. 29 * 30 */ 31 public void testJavaToJVM() { 32 String javadocSig = "(int, long)"; 33 String javadocReturnType = "void"; 34 String converted = 35 DescriptorUtil.convert(javadocSig, javadocReturnType); 36 System.out.println("******* converted = " + converted); 37 assertEquals("not equal", "(IJ)V", converted); 38 39 } 40 41 /*** 42 * Test the conversion of JVM like signatures to signatures provided 43 * by the reflection package. 44 */ 45 public void testJVMtoJava() { 46 String[] methodParamTypes = new String[2]; 47 methodParamTypes[0] = "java.lang.Object"; 48 methodParamTypes[1] = "java.lang.Object"; 49 String jvmSignature = "(Ljava/lang/Object;Ljava/lang/Object;)V"; 50 String[] convertedParamTypes = 51 DescriptorUtil.convertToJavaFormat(jvmSignature); 52 assertTrue( 53 "method signature arrays for object,object not equal", 54 Arrays.equals(methodParamTypes, convertedParamTypes)); 55 methodParamTypes[0] = "int"; 56 methodParamTypes[1] = "long"; 57 jvmSignature = "(IJ)V"; 58 convertedParamTypes = DescriptorUtil.convertToJavaFormat(jvmSignature); 59 assertTrue( 60 "method signature arrays for int long not equal", 61 Arrays.equals(methodParamTypes, convertedParamTypes)); 62 63 } 64 65 } // DescriptorTest

This page was automatically generated by Maven