You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UtilTests.java 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* *******************************************************************
  2. * Copyright (c) 2004 IBM
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement - initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.apache.bcel.classfile.tests;
  13. import org.aspectj.apache.bcel.classfile.Utility;
  14. import org.aspectj.apache.bcel.generic.Type;
  15. import junit.framework.TestCase;
  16. public class UtilTests extends TestCase {
  17. protected void setUp() throws Exception {
  18. super.setUp();
  19. }
  20. public void testUtilityClassSignatureManipulation1() {
  21. String[] ss = Utility.methodSignatureArgumentTypes("(Ljava/lang/String;I[Ljava/lang/Integer;)");
  22. assertTrue("should be 3 not "+ss.length,ss.length==3);
  23. assertTrue("first should be 'String', not "+ss[0],ss[0].equals("String"));
  24. assertTrue("second should be 'int', not "+ss[1],ss[1].equals("int"));
  25. assertTrue("third should be 'Integer[]', not "+ss[2],ss[2].equals("Integer[]"));
  26. }
  27. public void testUtilityClassSignatureManipulation2() {
  28. String s = Utility.methodSignatureToString("(Ljava/lang/String;[Z[[Ljava/lang/Integer;II)Z","hello","public");
  29. String expected = "public boolean hello(String arg1, boolean[] arg2, Integer[][] arg3, int arg4, int arg5)";
  30. assertTrue("Expected '"+expected+"' but got "+s,s.equals(expected));
  31. }
  32. public void testTypeUtilMethods1() {
  33. String s = Type.getMethodSignature(Type.DOUBLE,new Type[]{Type.INT,Type.STRING,Type.SHORT});
  34. System.err.println(s);
  35. }
  36. public void testTypeUtilMethods2() {
  37. Type s = Type.getType("Ljava/lang/String;");
  38. System.err.println(s);
  39. s = Type.getType("Z");
  40. System.err.println(s);
  41. }
  42. protected void tearDown() throws Exception {
  43. super.tearDown();
  44. }
  45. }