summaryrefslogtreecommitdiffstats
path: root/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/EnumAccessFlagTest.java
blob: a91947549d0d30dd227f9e489026394cbe29e6a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* *******************************************************************
 * Copyright (c) 2004 IBM
 * All rights reserved. 
 * This program and the accompanying materials are made available 
 * under the terms of the Eclipse Public License v1.0 
 * which accompanies this distribution and is available at 
 * http://www.eclipse.org/legal/epl-v10.html 
 *  
 * Contributors: 
 *     Andy Clement -     initial implementation 
 * ******************************************************************/

package org.aspectj.apache.bcel.classfile.tests;

import java.io.File;

import junit.framework.TestCase;

import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.SyntheticRepository;

public class EnumAccessFlagTest extends TestCase {
	
	private boolean verbose = false;

	protected void setUp() throws Exception {
		super.setUp();
	}
	
	/**
	 * An enumerated type, once compiled, should result in a class file that
	 * is marked such that we can determine from the access flags (through BCEL) that
	 * it was originally an enum type declaration.
	 */
	public void testEnumClassSaysItIs() throws ClassNotFoundException {
		ClassPath cp = 
			new ClassPath("testdata"+File.separator+"testcode.jar"+File.pathSeparator+System.getProperty("java.class.path"));
		SyntheticRepository repos = SyntheticRepository.getInstance(cp);
		JavaClass clazz = repos.loadClass("SimpleEnum");
		ConstantPool pool = clazz.getConstantPool();
		assertTrue("Expected SimpleEnum class to say it was an enum - but it didn't !",
				clazz.isEnum());
		clazz = repos.loadClass("SimpleClass");
		assertTrue("Expected SimpleClass class to say it was not an enum - but it didn't !",
				!clazz.isEnum());
	}
	

	protected void tearDown() throws Exception {
		super.tearDown();
	}
	

}