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.

EnumAccessFlagTest.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 EnumAccessFlagTest extends TestCase {
  20. private boolean verbose = false;
  21. protected void setUp() throws Exception {
  22. super.setUp();
  23. }
  24. /**
  25. * An enumerated type, once compiled, should result in a class file that
  26. * is marked such that we can determine from the access flags (through BCEL) that
  27. * it was originally an enum type declaration.
  28. */
  29. public void testEnumClassSaysItIs() throws ClassNotFoundException {
  30. ClassPath cp =
  31. new ClassPath("testdata"+File.separator+"testcode.jar"+File.pathSeparator+System.getProperty("java.class.path"));
  32. SyntheticRepository repos = SyntheticRepository.getInstance(cp);
  33. JavaClass clazz = repos.loadClass("SimpleEnum");
  34. ConstantPool pool = clazz.getConstantPool();
  35. assertTrue("Expected SimpleEnum class to say it was an enum - but it didn't !",
  36. clazz.isEnum());
  37. clazz = repos.loadClass("SimpleClass");
  38. assertTrue("Expected SimpleClass class to say it was not an enum - but it didn't !",
  39. !clazz.isEnum());
  40. }
  41. protected void tearDown() throws Exception {
  42. super.tearDown();
  43. }
  44. }