alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

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-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

/*
 * ConstructorChanged.java
 *
 * Created on June 26, 2000, 9:29 AM
 */

package org.netbeans.test.java.sourceexception.ConstructorChanged;

import org.openide.src.Identifier;
import org.openide.src.SourceException;
import org.netbeans.test.java.Common;
import org.openide.loaders.DataObject;

/**
 * @author Jan Becicka 
 */

public class ConstructorChanged extends org.netbeans.test.java.XRunner {
    
    public static void main(java.lang.String[] args) {
        junit.textui.TestRunner.run(suite());
    }
    
    public ConstructorChanged() {
        super("");
    }
    
    public ConstructorChanged(java.lang.String testName) {
        super(testName);
    }
    
    public static org.netbeans.junit.NbTest suite() {
        return new org.netbeans.junit.NbTestSuite(ConstructorChanged.class);
    }
    
    /** "body" of this TestCase
     * @param o SourceElement - target for generating
     * @param log log is used for logging StackTraces
     * @throws Exception
     * @return true if test passed
     * false if failed
     */    
    public boolean go(Object o, java.io.PrintWriter log) throws Exception {
        
        org.openide.src.ClassElement clazz = ((org.openide.src.SourceElement) o).getClasses()[0];
        System.setProperty(org.netbeans.test.java.eventfiring.MyListener.RESULT_KEY,"");
        boolean passed = true;
        
        org.openide.src.ConstructorElement ce = Common.createConstructor(null,Common.PARS1);
        clazz.addConstructor(ce);
        ce = clazz.getConstructor(Common.TPARS1);
        clazz.removeConstructor(ce);
        
        try {
            ce.setBody("//blah\n");
        } catch (SourceException e){
            ref("setBody succesfully throws "+e);
        }
        
        try {
            ce.setExceptions(new Identifier[]{Identifier.create("java.lang.Exception","Exception")});
        } catch (SourceException e){
            ref("setExceptions succesfully throws "+e);
        }
        
        try {
            ce.setModifiers(java.lang.reflect.Modifier.PROTECTED);
        } catch (SourceException e){
            ref("setModifiers succesfully throws "+e);
        }
        
        try {
            ce.setParameters(Common.PARS2);
        } catch (SourceException e){
            ref("setParameters succesfully throws "+e);
        }
        
        try {
            ce.setName(Identifier.create("ranamedConstructor"));
        } catch (SourceException e){
            ref("setName succesfully throws "+e);
        }
        
        return passed;
    }
    
    protected boolean writeResult(DataObject DO) {
        return true;
    }
    
    /**
     */    
    protected void setUp() {
        super.setUp();
        name = "JavaTestSourceExceptionThrowingConstructorsChanged";
        packageName = "org.netbeans.test.java.testsources";
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.