org.apache.bcel
Class GeneratingAnnotatedClassesTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.bcel.AbstractTestCase
              extended by org.apache.bcel.GeneratingAnnotatedClassesTestCase
All Implemented Interfaces:
junit.framework.Test

public class GeneratingAnnotatedClassesTestCase
extends AbstractTestCase

The program that some of the tests generate looks like this:

 public class HelloWorld
 {
        public static void main(String[] argv)
        {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String name = null;
 
                try
                {
                        name = "Andy";
                }
                catch (IOException e)
                {
                        return;
                }
                System.out.println("Hello, " + name);
        }
 }
 


Constructor Summary
GeneratingAnnotatedClassesTestCase()
           
 
Method Summary
 AnnotationEntryGen createCombinedAnnotation(ConstantPoolGen cp)
           
 AnnotationEntryGen createFruitAnnotation(ConstantPoolGen cp, String aFruit)
           
 AnnotationEntryGen createSimpleInvisibleAnnotation(ConstantPoolGen cp)
           
 AnnotationEntryGen createSimpleVisibleAnnotation(ConstantPoolGen cp)
           
 void testGenerateClassLevelAnnotations()
          Steps in the test: Programmatically construct the HelloWorld program Add two simple annotations at the class level Save the class to disk Reload the class using the 'static' variant of the BCEL classes Check the attributes are OK
 void testGenerateMethodLevelAnnotations1()
          Just check that we can dump a class that has a method annotation on it and it is still there when we read it back in
 void testGenerateMethodLevelAnnotations2()
          Going further than the last test - when we reload the method back in, let's change it (adding a new annotation) and then store that, read it back in and verify both annotations are there !
 void testModifyingClasses1()
          Load a class in and modify it with a new attribute - A SimpleAnnotation annotation
 void testModifyingClasses2()
          Load a class in and modify it with a new attribute - A ComplexAnnotation annotation
 void testTransformClassToClassGen_ArrayAndAnnotationTypes()
          Transform simple class from an immutable to a mutable object.
 void testTransformClassToClassGen_EnumType()
          Transform simple class from an immutable to a mutable object.
 void testTransformClassToClassGen_SimpleTypes()
          Transform simple class from an immutable to a mutable object.
 void testTransformComplexClassToClassGen()
          Transform complex class from an immutable to a mutable object.
 
Methods inherited from class org.apache.bcel.AbstractTestCase
createFruitAnnotationEntry, createRepos, createTestdataFile, dumpAnnotationEntries, dumpAnnotationEntries, dumpAttributes, findAttribute, findAttribute, getMethod, getTestClass, wipe, wipe
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneratingAnnotatedClassesTestCase

public GeneratingAnnotatedClassesTestCase()
Method Detail

testGenerateClassLevelAnnotations

public void testGenerateClassLevelAnnotations()
                                       throws ClassNotFoundException
Steps in the test:
  1. Programmatically construct the HelloWorld program
  2. Add two simple annotations at the class level
  3. Save the class to disk
  4. Reload the class using the 'static' variant of the BCEL classes
  5. Check the attributes are OK

Throws:
ClassNotFoundException

testGenerateMethodLevelAnnotations1

public void testGenerateMethodLevelAnnotations1()
                                         throws ClassNotFoundException
Just check that we can dump a class that has a method annotation on it and it is still there when we read it back in

Throws:
ClassNotFoundException

testGenerateMethodLevelAnnotations2

public void testGenerateMethodLevelAnnotations2()
                                         throws ClassNotFoundException
Going further than the last test - when we reload the method back in, let's change it (adding a new annotation) and then store that, read it back in and verify both annotations are there !

Throws:
ClassNotFoundException

testTransformClassToClassGen_SimpleTypes

public void testTransformClassToClassGen_SimpleTypes()
                                              throws ClassNotFoundException
Transform simple class from an immutable to a mutable object.

Throws:
ClassNotFoundException

testTransformClassToClassGen_EnumType

public void testTransformClassToClassGen_EnumType()
                                           throws ClassNotFoundException
Transform simple class from an immutable to a mutable object. The class is annotated with an annotation that uses an enum.

Throws:
ClassNotFoundException

testTransformClassToClassGen_ArrayAndAnnotationTypes

public void testTransformClassToClassGen_ArrayAndAnnotationTypes()
                                                          throws ClassNotFoundException
Transform simple class from an immutable to a mutable object. The class is annotated with an annotation that uses an array of SimpleAnnotations.

Throws:
ClassNotFoundException

testTransformComplexClassToClassGen

public void testTransformComplexClassToClassGen()
                                         throws ClassNotFoundException
Transform complex class from an immutable to a mutable object.

Throws:
ClassNotFoundException

testModifyingClasses1

public void testModifyingClasses1()
                           throws ClassNotFoundException
Load a class in and modify it with a new attribute - A SimpleAnnotation annotation

Throws:
ClassNotFoundException

testModifyingClasses2

public void testModifyingClasses2()
                           throws ClassNotFoundException
Load a class in and modify it with a new attribute - A ComplexAnnotation annotation

Throws:
ClassNotFoundException

createSimpleVisibleAnnotation

public AnnotationEntryGen createSimpleVisibleAnnotation(ConstantPoolGen cp)

createFruitAnnotation

public AnnotationEntryGen createFruitAnnotation(ConstantPoolGen cp,
                                                String aFruit)

createCombinedAnnotation

public AnnotationEntryGen createCombinedAnnotation(ConstantPoolGen cp)

createSimpleInvisibleAnnotation

public AnnotationEntryGen createSimpleInvisibleAnnotation(ConstantPoolGen cp)


Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.