1 9 10 package org.netbeans.jmi.javamodel.getters; 11 12 import java.io.PrintStream ; 13 import java.util.List ; 14 import org.netbeans.jmi.javamodel.Annotation; 15 import org.netbeans.jmi.javamodel.AttributeValue; 16 import org.netbeans.jmi.javamodel.BooleanLiteral; 17 import org.netbeans.jmi.javamodel.JavaClass; 18 import org.netbeans.jmi.javamodel.JavaModelPackage; 19 import org.netbeans.jmi.javamodel.PrimitiveTypeKindEnum; 20 import org.netbeans.jmi.javamodel.codegen.*; 21 import org.netbeans.junit.NbTestCase; 22 import org.netbeans.junit.NbTestSuite; 23 import org.openide.filesystems.FileStateInvalidException; 24 25 29 public class BooleanAttributeValueTest extends NbTestCase { 30 31 JavaClass clazz; 32 JavaModelPackage pkg; 33 34 35 public BooleanAttributeValueTest() { 36 super("BooleanAttributeValueTest"); 37 } 38 39 public static NbTestSuite suite() { 40 NbTestSuite suite = new NbTestSuite(BooleanAttributeValueTest.class); 41 return suite; 42 } 43 44 protected void setUp() { 45 clazz = (JavaClass) Utility.findClass("org.netbeans.test.getters.BooleanAttributeValue"); 46 pkg = (JavaModelPackage) clazz.refImmediatePackage(); 47 } 48 49 public void testGetAttrBoolValue() throws java.io.IOException , FileStateInvalidException { 50 PrintStream log = getLog(); 51 Utility.beginTrans(false); 52 boolean result = false; 53 try { 54 List l = clazz.getAnnotations(); 55 log.println("Class BooleanAttributeValue has " + l.size() + " annotations."); 56 if (l.size() > 0) { Annotation ann = (Annotation) l.get(0); 58 List attrs = ann.getAttributeValues(); 59 if (attrs.size() > 0) { AttributeValue attrVal = (AttributeValue) ann.getAttributeValues().get(0); 61 log.print("\tAttribute '" + attrVal.getDefinition().getName() + "' has the following value: '"); 62 if (attrVal.getValue() instanceof BooleanLiteral) { 63 BooleanLiteral bool = (BooleanLiteral) attrVal.getValue(); 64 result = bool.isValue(); 65 log.println(bool.isValue() + "'."); 66 } else { 67 log.println(attrVal.getValue() + "'."); 68 } 69 } 70 } 71 } finally { 72 Utility.endTrans(); 73 } 74 assertEquals(result, true); 75 } 76 77 78 } 79 | Popular Tags |