From: aclement Date: Thu, 10 Mar 2005 12:15:38 +0000 (+0000) Subject: Declare annotation: tests changed due to constant pool copying change for annotation... X-Git-Tag: V1_5_0M2~89 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fcd5db07a048c9526b90d8b8b52f7c15644ac1c5;p=aspectj.git Declare annotation: tests changed due to constant pool copying change for annotation support. also tests removal of the static state from Utility/Type --- diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java index c2a087166..cba6096cf 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java @@ -49,6 +49,7 @@ public class AllTests { suite.addTestSuite(ParameterAnnotationsTest.class); suite.addTestSuite(GeneratingAnnotatedClassesTest.class); suite.addTestSuite(TypeAnnotationsTest.class); + suite.addTestSuite(UtilTests.class); //$JUnit-END$ return suite; } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java index 884270c9f..e1c9f382c 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java @@ -161,8 +161,8 @@ public class ElementValueGenTest extends BcelTestCase { EnumElementValueGen evg = new EnumElementValueGen(enumType,"Red",cp); // Creation of an element like that should leave a new entry in the cpool assertTrue("The new ElementValue value index should match the contents of the constantpool but "+ - evg.getValueIndex()+"!="+cp.lookupString("Red"), - evg.getValueIndex()==cp.lookupString("Red")); + evg.getValueIndex()+"!="+cp.lookupUtf8("Red"), + evg.getValueIndex()==cp.lookupUtf8("Red")); //BCELBUG: Should the class signature or class name be in the constant pool? (see note in ConstantPool) // assertTrue("The new ElementValue type index should match the contents of the constantpool but "+ // evg.getTypeIndex()+"!="+cp.lookupClass(enumType.getSignature()), diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java index 494bc1239..d87dc22cd 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java @@ -235,7 +235,8 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { Annotation[] anns = clazz.getAnnotations(); ClassGen cg = new ClassGen(clazz); // Checks we can copy class values in an annotation - new AnnotationGen(anns[0],cg.getConstantPool()); + new AnnotationGen(anns[0],cg.getConstantPool(),true); + new AnnotationGen(anns[0],cg.getConstantPool(),false); } public void testAnnotationClassElementReadWrite() throws ClassNotFoundException,IOException { diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java new file mode 100644 index 000000000..fd4e75e81 --- /dev/null +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java @@ -0,0 +1,58 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement - initial implementation + * ******************************************************************/ + +package org.aspectj.apache.bcel.classfile.tests; + +import org.aspectj.apache.bcel.classfile.Utility; +import org.aspectj.apache.bcel.generic.Type; + +import junit.framework.TestCase; + +public class UtilTests extends TestCase { + + protected void setUp() throws Exception { + super.setUp(); + } + + public void testUtilityClassSignatureManipulation1() { + String[] ss = Utility.methodSignatureArgumentTypes("(Ljava/lang/String;I[Ljava/lang/Integer;)"); + assertTrue("should be 3 not "+ss.length,ss.length==3); + + assertTrue("first should be 'String', not "+ss[0],ss[0].equals("String")); + assertTrue("second should be 'int', not "+ss[1],ss[1].equals("int")); + assertTrue("third should be 'Integer[]', not "+ss[2],ss[2].equals("Integer[]")); + } + + public void testUtilityClassSignatureManipulation2() { + String s = Utility.methodSignatureToString("(Ljava/lang/String;[Z[[Ljava/lang/Integer;II)Z","hello","public"); + String expected = "public boolean hello(String arg1, boolean[] arg2, Integer[][] arg3, int arg4, int arg5)"; + assertTrue("Expected '"+expected+"' but got "+s,s.equals(expected)); + } + + public void testTypeUtilMethods1() { + String s = Type.getMethodSignature(Type.DOUBLE,new Type[]{Type.INT,Type.STRING,Type.SHORT}); + System.err.println(s); + } + + public void testTypeUtilMethods2() { + Type s = Type.getType("Ljava/lang/String;"); + System.err.println(s); + s = Type.getType("Z"); + System.err.println(s); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + +}