Criado um novo pacote
[JavaDecompiler.git] / src / test / java / br / org / javadecompiler / decoder / DecoderTest.java
blob4fa261b9d919aa262370148cdd5c02d9dba5caa1
1 package br.org.javadecompiler.decoder;
3 import java.io.InputStream;
5 import br.org.javadecompiler.classfile.JavaClass;
6 import br.org.javadecompiler.reader.ClassReader;
7 import br.org.javadecompiler.reader.DefaultClassReader;
9 import junit.framework.TestCase;
11 public class DecoderTest extends TestCase {
12 public DecoderTest(String testName) {
13 super(testName);
16 private ClassReader readClass(Class clazz) throws Exception {
17 String fileName = "/" + clazz.getName().replace('.', '/') + ".class";
18 InputStream is = clazz.getResourceAsStream(fileName);
19 return DefaultClassReader.getFromInputStream(is);
22 private void decodeClass(Class clazz) throws Exception {
23 JavaClass result = Decoder.decodeClass(readClass(clazz));
24 assertNotNull(result);
25 //System.out.println(result);
28 public void testDecodeThis() throws Exception {
29 decodeClass(this.getClass());
32 public void testDecodeJavaLangObject() throws Exception {
33 decodeClass(java.lang.Object.class);
36 public void testDecodeJavaLangClass() throws Exception {
37 decodeClass(java.lang.Class.class);
40 public void testDecodeInnerClasses() throws Exception {
41 decodeClass(br.org.javadecompiler.classfile.attribute.LineNumberTableAttribute.LineNumber.class);
44 public void testDecodeAnonymousInnerClasses() throws Exception {
45 Object object = new br.org.javadecompiler.classfile.attribute.AttributeOwner() {
46 public br.org.javadecompiler.classfile.attribute.Attribute[] getAttributes() {
47 return null;
50 decodeClass(object.getClass());