|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.jmi.javamodel.getters; import java.io.PrintStream; import junit.textui.TestRunner; import org.netbeans.jmi.javamodel.codegen.Utility; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; import org.netbeans.jmi.javamodel.*; /** * Test getters of Attribute model element. * * @author Pavel Flaska */ public class AnnTypeAttrTest extends NbTestCase { private static String[] correctIdentifiers = { "id", "synopsis", "engineer", "date" }; private static String[] correctDefValuesText = { null, "\"MaM likes M&M's.\"", null, null }; private static String[] correctTypeNames = { "int", "String", "String", "String" }; private static String[] correctTypes = { "int", "java.lang.String", "java.lang.String", "java.lang.String" }; AnnotationType clazz; JavaModelPackage pkg; Attribute[] attribute; /** Creates a new instance of AnnTypeAttrTest */ public AnnTypeAttrTest() { super("AnnTypeAttrTest"); attribute = new Attribute[4]; } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(AnnTypeAttrTest.class); return suite; } protected void setUp() { clazz = (AnnotationType) Utility.findClass("org.netbeans.test.getters.AnnotationType"); pkg = (JavaModelPackage) clazz.refImmediatePackage(); for (int i = 0; i < 4; i++) { attribute[i] = (Attribute) clazz.getContents().get(i); } } public void testAttributeIdentifier() { PrintStream log = getLog(); log.println("Found identifiers:"); for (int i = 0; i < 4; i++) { String name = attribute[i].getName(); log.println("\t" + name); assertEquals("Identifier differs!", name, correctIdentifiers[i]); } } public void testAttributeDefaultValue() { /* PrintStream log = getLog(); log.println("Found default value texts:"); for (int i = 0; i < 4; i++) { String defaultValue = ((InitialValueImpl) attribute[i].getDefaultValue()).getSourceText(); log.print("\t" + defaultValue); assertEquals("Default values differ!", defaultValue, correctDefValuesText[i]); } */ } public void testAttributeDefaultValueText() { PrintStream log = getLog(); log.println("Found default value texts:"); for (int i = 0; i < 4; i++) { String defaultValueText = attribute[i].getDefaultValueText(); log.println("\t" + defaultValueText); assertEquals("Default Values differ!", defaultValueText, correctDefValuesText[i]); } } public void testAttributeType() { PrintStream log = getLog(); log.println("Found types:"); for (int i = 0; i < 4; i++) { String type = attribute[i].getType().getName(); log.println("\t" + type + "; " + correctTypes[i]); assertEquals("Attribute types differ!", type, correctTypes[i]); } } public void testAttributeTypeName() { PrintStream log = getLog(); log.println("Found type names:"); for (int i = 0; i < 4; i++) { String typeName = attribute[i].getTypeName().getName(); log.println("\t" + typeName + "; " + correctTypeNames[i]); assertEquals("Attribute type names differ!", typeName, correctTypeNames[i]); } } public void testAttributeGetType() { boolean fail = true; Utility.beginTrans(true); try { Attribute attr = pkg.getAttribute().createAttribute("newA", null, 0, null, null, null, null, null); Type type = attr.getType(); getLog().println("Type is '" + type + "'."); fail = false; } finally { Utility.endTrans(fail); } } /** * @param args the command line arguments */ public static void main(String[] args) { TestRunner.run(suite()); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.