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.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.ClassFormatException;
  14. import org.aspectj.apache.bcel.classfile.Utility;
  15. import org.aspectj.apache.bcel.generic.Type;
  16. import junit.framework.TestCase;
  17. public class UtilTests extends TestCase {
  18. protected void setUp() throws Exception {
  19. super.setUp();
  20. }
  21. public void testUtilityClassSignatureManipulation1() {
  22. String[] ss = UtilTests.methodSignatureArgumentTypes("(Ljava/lang/String;I[Ljava/lang/Integer;)");
  23. assertTrue("should be 3 not "+ss.length,ss.length==3);
  24. assertTrue("first should be 'String', not "+ss[0],ss[0].equals("String"));
  25. assertTrue("second should be 'int', not "+ss[1],ss[1].equals("int"));
  26. assertTrue("third should be 'Integer[]', not "+ss[2],ss[2].equals("Integer[]"));
  27. }
  28. public void testUtilityClassSignatureManipulation2() {
  29. String s = Utility.methodSignatureToString("(Ljava/lang/String;[Z[[Ljava/lang/Integer;II)Z","hello","public");
  30. String expected = "public boolean hello(String arg1, boolean[] arg2, Integer[][] arg3, int arg4, int arg5)";
  31. assertTrue("Expected '"+expected+"' but got "+s,s.equals(expected));
  32. }
  33. public void testTypeUtilMethods1() {
  34. String s = Utility.toMethodSignature(Type.DOUBLE,new Type[]{Type.INT,Type.STRING,Type.SHORT});
  35. System.err.println(s);
  36. }
  37. public void testTypeUtilMethods2() {
  38. Type s = Type.getType("Ljava/lang/String;");
  39. System.err.println(s);
  40. s = Type.getType("Z");
  41. System.err.println(s);
  42. }
  43. protected void tearDown() throws Exception {
  44. super.tearDown();
  45. }
  46. /**
  47. * @param signature Method signature
  48. * @return Array of argument types
  49. * @throws ClassFormatException
  50. */
  51. public static final String[] methodSignatureArgumentTypes(String signature) throws ClassFormatException {
  52. return GenericSignatureParsingTest.methodSignatureArgumentTypes(signature, true);
  53. }
  54. }