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.

AnonymousClassTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) 2005 Contributors
  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. * Adrian Colyer - initial implementation
  11. */
  12. package org.aspectj.apache.bcel.classfile.tests;
  13. import java.io.File;
  14. import org.aspectj.apache.bcel.classfile.JavaClass;
  15. import org.aspectj.apache.bcel.util.ClassPath;
  16. import org.aspectj.apache.bcel.util.SyntheticRepository;
  17. import junit.framework.TestCase;
  18. /**
  19. * @author adrian colyer
  20. *
  21. */
  22. public class AnonymousClassTest extends TestCase {
  23. private SyntheticRepository repos;
  24. public void testRegularClassIsNotAnonymous() throws ClassNotFoundException {
  25. JavaClass clazz = repos.loadClass("AnonymousClassTest");
  26. assertFalse("regular outer classes are not anonymous",clazz.isAnonymous());
  27. assertFalse("regular outer classes are not nested",clazz.isNested());
  28. }
  29. public void testNamedInnerClassIsNotAnonymous() throws ClassNotFoundException {
  30. JavaClass clazz = repos.loadClass("AnonymousClassTest$X");
  31. assertFalse("regular inner classes are not anonymous",clazz.isAnonymous());
  32. assertTrue("regular inner classes are nested",clazz.isNested());
  33. }
  34. public void testStaticInnerClassIsNotAnonymous() throws ClassNotFoundException {
  35. JavaClass clazz = repos.loadClass("AnonymousClassTest$Y");
  36. assertFalse("regular static inner classes are not anonymous",clazz.isAnonymous());
  37. assertTrue("regular static inner classes are nested",clazz.isNested());
  38. }
  39. public void testAnonymousInnerClassIsAnonymous() throws ClassNotFoundException {
  40. JavaClass clazz = repos.loadClass("AnonymousClassTest$1");
  41. assertTrue("anonymous inner classes are anonymous",clazz.isAnonymous());
  42. assertTrue("anonymous inner classes are anonymous",clazz.isNested());
  43. }
  44. protected void setUp() throws Exception {
  45. ClassPath cp =
  46. new ClassPath("testdata"+File.separator+"testcode.jar"+File.pathSeparator+System.getProperty("java.class.path"));
  47. repos = SyntheticRepository.getInstance(cp);
  48. }
  49. }