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.

AnnotationAccessFlagTest.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 java.io.File;
  14. import org.aspectj.apache.bcel.classfile.ConstantPool;
  15. import org.aspectj.apache.bcel.classfile.JavaClass;
  16. import org.aspectj.apache.bcel.util.ClassPath;
  17. import org.aspectj.apache.bcel.util.SyntheticRepository;
  18. import junit.framework.TestCase;
  19. public class AnnotationAccessFlagTest extends TestCase {
  20. private boolean verbose = false;
  21. protected void setUp() throws Exception {
  22. super.setUp();
  23. }
  24. /**
  25. * If you write an annotation and compile it, the class file generated should be
  26. * marked as an annotation type - which is detectable through BCEL.
  27. */
  28. public void testAnnotationClassSaysItIs() throws ClassNotFoundException {
  29. ClassPath cp =
  30. new ClassPath("testdata"+File.separator+"testcode.jar"+File.pathSeparator+System.getProperty("java.class.path"));
  31. SyntheticRepository repos = SyntheticRepository.getInstance(cp);
  32. JavaClass clazz = repos.loadClass("SimpleAnnotation");
  33. ConstantPool pool = clazz.getConstantPool();
  34. assertTrue("Expected SimpleAnnotation class to say it was an annotation - but it didn't !",
  35. clazz.isAnnotation());
  36. clazz = repos.loadClass("SimpleClass");
  37. assertTrue("Expected SimpleClass class to say it was not an annotation - but it didn't !",
  38. !clazz.isAnnotation());
  39. }
  40. protected void tearDown() throws Exception {
  41. super.tearDown();
  42. }
  43. }