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.

GenericSignatureParserTest.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * ******************************************************************/
  11. package org.aspectj.weaver;
  12. import org.aspectj.apache.bcel.classfile.JavaClass;
  13. import org.aspectj.apache.bcel.classfile.Method;
  14. import org.aspectj.apache.bcel.util.SyntheticRepository;
  15. import org.aspectj.util.GenericSignatureParser;
  16. import junit.framework.TestCase;
  17. /**
  18. * @author Adrian Colyer
  19. * @author Andy Clement
  20. */
  21. public class GenericSignatureParserTest extends TestCase {
  22. GenericSignatureParser parser;
  23. protected void setUp() throws Exception {
  24. super.setUp();
  25. parser = new GenericSignatureParser();
  26. }
  27. public void testClassSignatureParsingInJDK() throws Exception {
  28. SyntheticRepository repository = SyntheticRepository.getInstance();
  29. String[] testClasses = new String[] { "java.lang.Comparable", "java.lang.Iterable", "java.lang.Class", "java.lang.Enum",
  30. "java.lang.InheritableThreadLocal", "java.lang.ThreadLocal", "java.util.Collection", "java.util.Comparator",
  31. "java.util.Enumeration", "java.util.Iterator", "java.util.List", "java.util.ListIterator", "java.util.Map",
  32. "java.util.Map$Entry", "java.util.Queue", "java.util.Set", "java.util.SortedMap", "java.util.SortedSet" };
  33. for (int i = 0; i < testClasses.length; i++) {
  34. JavaClass jc = repository.loadClass(testClasses[i]);
  35. String sig = jc.getGenericSignature();
  36. parser.parseAsClassSignature(sig);
  37. }
  38. }
  39. public void testMethodSignatureParsingInJDK() throws Exception {
  40. SyntheticRepository repository = SyntheticRepository.getInstance();
  41. String[] testClasses = new String[] { "java.lang.Comparable", "java.lang.Iterable", "java.lang.Class", "java.lang.Enum",
  42. "java.lang.InheritableThreadLocal", "java.lang.ThreadLocal", "java.util.Collection", "java.util.Comparator",
  43. "java.util.Enumeration", "java.util.Iterator", "java.util.List", "java.util.ListIterator", "java.util.Map",
  44. "java.util.Map$Entry", "java.util.Queue", "java.util.Set", "java.util.SortedMap", "java.util.SortedSet" };
  45. for (int i = 0; i < testClasses.length; i++) {
  46. JavaClass jc = repository.loadClass(testClasses[i]);
  47. Method[] methods = jc.getMethods();
  48. for (int j = 0; j < methods.length; j++) {
  49. String sig = methods[j].getGenericSignature();
  50. if (sig != null)
  51. parser.parseAsMethodSignature(sig);
  52. }
  53. }
  54. }
  55. }