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

package org.netbeans.test.refactoring.encapsulatefields;

import java.lang.reflect.Modifier;
import junit.textui.TestRunner;
import org.netbeans.junit.NbTestSuite;




/**
 * Encapsulate fields refactoring simple tests
 * @author  Emanuel Hucka
 */
public class SimpleTest extends EncapsulateTestCase {
    
    private static final String CLASS_NAME_1 = "org.netbeans.tests.examples.packa.Bean";
    private static final String CLASS_NAME_2 = "org.netbeans.tests.examples.packb.BeansD";
    private static final String CLASS_NAME_3 = "org.netbeans.tests.examples.packb.BeanA";
    private static final String CLASS_NAME_4 = "org.netbeans.tests.examples.packc.AbstractBean";
    private static final String CLASS_NAME_5 = "org.netbeans.tests.examples.packc.AFrame";
    
    private static final String IFACE_NAME_1 = "org.netbeans.tests.examples.packc.Makable";
    
    /** Creates a new instance of Signature1Test */
    public SimpleTest(String name) {
        super(name);
    }
    
    public static NbTestSuite suite() {
        NbTestSuite suite = new NbTestSuite();
        //undo
        suite.addTest(new SimpleTest("testUndoEncapsulateClassField1"));
        suite.addTest(new SimpleTest("testUndoEncapsulateClassField2"));
        suite.addTest(new SimpleTest("testUndoEncapsulateClassField3"));
        suite.addTest(new SimpleTest("testUndoEncapsulateClassField4"));
        suite.addTest(new SimpleTest("testUndoEncapsulateClassField5"));
        suite.addTest(new SimpleTest("testUndoEncapsulateInterfaceField1"));
        
        suite.addTest(new SimpleTest("testClassField1"));
        suite.addTest(new SimpleTest("testClassField2"));
        suite.addTest(new SimpleTest("testClassField3"));
        suite.addTest(new SimpleTest("testClassField4"));
        suite.addTest(new SimpleTest("testClassField5"));
        suite.addTest(new SimpleTest("testClassField6"));
        suite.addTest(new SimpleTest("testClassField7"));
        suite.addTest(new SimpleTest("testInterfaceField1"));
        return suite;
    }
    
    public void testUndoEncapsulateClassField1() {
        encapsulateField(CLASS_NAME_1, "refID", "setRefId", null, Modifier.PUBLIC, Modifier.PRIVATE, true);
    }
    
    public void testUndoEncapsulateClassField2() {
        encapsulateField(CLASS_NAME_2, "bb", "setBeanA", "getBeanA", Modifier.PUBLIC, Modifier.PROTECTED, true);
    }
    
    public void testUndoEncapsulateClassField3() {
        log("field of abstract class");
        encapsulateField(CLASS_NAME_4, "rootField", null, null, Modifier.PUBLIC, Modifier.PROTECTED, true);
    }
    
    public void testUndoEncapsulateClassField4() {
        log("field of a form");
        encapsulateField(CLASS_NAME_5, "counter", null, null, Modifier.PUBLIC, Modifier.PRIVATE, true);
    }
    
    public void testUndoEncapsulateClassField5() {
        log("guarded field");
        encapsulateField(CLASS_NAME_5, "button", null, null, Modifier.PUBLIC, Modifier.PROTECTED, true);
    }
    
    public void testUndoEncapsulateInterfaceField1() {
        log("interface field");
        encapsulateField(IFACE_NAME_1, "CODE", "setCode", "getCode", Modifier.PUBLIC, Modifier.PRIVATE, true);
    }
    
    public void testClassField1() {
        encapsulateField(CLASS_NAME_1, "refID", "setRefId", null, Modifier.PUBLIC, Modifier.PRIVATE, false);
    }
    
    public void testClassField2() {
        encapsulateField(CLASS_NAME_2, "bb", "setBeanA", "getBeanA", Modifier.PUBLIC, Modifier.PROTECTED, false);
    }
    
    public void testClassField3() {
        log("existing accessors");
        encapsulateField(CLASS_NAME_3, "protectedProperty", null, null, Modifier.PUBLIC, Modifier.PROTECTED, false);
    }
    
    public void testClassField4() {
        log("same access as new accessors");
        encapsulateField(CLASS_NAME_3, "publicProperty", null, null, Modifier.PUBLIC, Modifier.PUBLIC, false);
    }
    
    public void testClassField5() {
        log("field of abstract class");
        encapsulateField(CLASS_NAME_4, "rootField", null, null, Modifier.PUBLIC, Modifier.PROTECTED, false);
    }
    
    public void testClassField6() {
        log("field of a form");
        encapsulateField(CLASS_NAME_5, "counter", null, null, Modifier.PUBLIC, Modifier.PRIVATE, false);
    }
    
    public void testClassField7() {
        log("guarded field");
        encapsulateField(CLASS_NAME_5, "button", null, null, Modifier.PUBLIC, Modifier.PROTECTED, false);
    }
    
    public void testInterfaceField1() {
        log("interface field");
        encapsulateField(IFACE_NAME_1, "CODE", "setCode", "getCode", Modifier.PUBLIC, Modifier.PRIVATE, false);
    }
    
    /**
     * Used for running test from inside the IDE by internal execution.
     *
     * @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

 

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.