JET

edu.utep.cs.et.gui.tester
Class DefaultTester

java.lang.Object
  extended by edu.utep.cs.et.gui.tester.DefaultTester
All Implemented Interfaces:
Constants, Tester
Direct Known Subclasses:
ExperimentTester

public class DefaultTester
extends Object
implements Constants, Tester

The default tester class responsible for generating test cases dynamically and displaying them. This class implements both the view and the controller, and the view can be obtained by calling the getView() method. The test cases are generated by calling an external test case generation tool.

Version:
$Revision: 1.80 $
Author:
Yoonsik Cheon

Nested Class Summary
private static class DefaultTester.StatisticsDialog
          A dialog window to display test case generation statistics.
private static class DefaultTester.TestCaseCellRenderer
          A cell renderer to render test cases displayed in the testcase subpane.
private static class DefaultTester.TestCaseList
          A special JList to contain test cases.
private  class DefaultTester.TesterView
          Tester pane with multiple subpanes that can be dynamically configured on-the-fly.
 
Field Summary
private  List<ClassFileChangeListener> classFileChangeListeners
          Registered class file change listeners.
private  Class clazz
          Currently loaded class.
private static int DIVIDER_SIZE
          Divider size.
private  File file
          The file from which the current class was loaded.
private  MethodTree methodTree
          The tree model for the method pane to displays all the methods and constructors of the class under test.
private  JTextArea spec
          The pane to display the specification of the currently selected method or constructor.
private  Statistics stat
          The test statistics manager.
private  DefaultTester.StatisticsDialog statDialog
          Dialog window showing test statistics.
private  JTextPane testcaseDescription
          The pane to display the description of the currently selected test case.
private  OutputTextArea testcaseFailure
          The pane to display the failure message, if exists, of the currently selected test case.
private  DefaultListModel testcases
          The list of test cases of the currently selected method or constructor.
private  DefaultTester.TestCaseList testcasesList
          The view to show the testcases.
private  DefaultTester.TesterView theView
          The view of this test wizard.
private  List<JLabel> titleBars
          The title bars of all subpanes.
 
Fields inherited from interface edu.utep.cs.et.gui.Constants
CLASS_EXTENSION, COLOR_EXPLORER, COLOR_OUTPUT, COPYRIGHT, DEBUG, EDIT_MENU_NAME, EXPLORER_DIR, EXPLORER_ROOT, FILE_MENU_NAME, HELP_MENU_NAME, ICON_ABOUT, ICON_ABSTRACT_CLASS, ICON_BROWSER, ICON_CLASS, ICON_CLASS_DISABLED, ICON_DELETE, ICON_ERROR, ICON_FILE, ICON_FOLDER, ICON_GEN_APP, ICON_HOME, ICON_INFORM, ICON_INTERFACE, ICON_JAVA_FILE, ICON_JML_LOGO, ICON_METHOD, ICON_METHOD_GREEN, ICON_METHOD_ORANGE, ICON_METHOD_RED, ICON_MINER, ICON_NEW, ICON_NEWTESTSUITE, ICON_NOTE, ICON_OPEN, ICON_OUTPUT, ICON_PREFERENCES, ICON_QUESTION, ICON_REDO, ICON_SAVE_AS, ICON_TEST_FILE, ICON_UNDO, ICON_UNKOWN, ICON_WARN, JAVA, JAVA_EXTENSION, JAVAC, JUNIT_SWINGGUI_TESTRUNNER, NEWLINE, OPTION_MENU_NAME, TEST_MENU_NAME, TITLE, TOOL_MENU_NAME, VERSION, WEB_PAGE_LOCATION, WEB_PAGE_NAME, WINDOW_HEIGHT, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH, WINDOW_WIDTH
 
Constructor Summary
DefaultTester()
          Creates a new instance.
 
Method Summary
 void addClassFileChangeListener(ClassFileChangeListener l)
          Registers the given class file change listener.
private  void autoEnableAction(AbstractAction act)
          Automatically enables and disables the given action based on the method selections.
(package private)  void classBeingOpened(EtClass clazz)
          Called to refresh the view, as the given class is being loaded by the the method list pane.
private  JSplitPane createDescriptionPane()
          Creates a description pane that displays a description of the currently selected test case.
private  JPanel createMethodPane()
          Creates a method pane that displays all the methods and constructors of the class under test.
private  JPopupMenu createMethodPanePopupMenu()
          Creates a popup menu for the method list pane.
private  JPanel createSpecPane()
          Creates a specification pane that displays the specification of the currently selected method.
protected  TestCaseGenerationListener createTestCaseGenerationListener(EtMethod emeth)
          Creates a test case generation listener for testing the given method.
private  JPanel createTestCasePane()
          Creates a test case pane that lists all the test cases of the currently selected method.
private  JPopupMenu createTestCasesPanePopupMenu()
          Creates a popup menu for the test cases pane.
private  JLabel createTitleBar(String title)
          Creates a title bar of the given title string.
private  void doJUnitExport(Collection<EtMethod> methods)
          Exports test cases of the methods correcponding to the given rows of the method tree pane.
private  void doJUnitExport(EtTestCase[] testcases)
          Exports the given test cases.
protected  void doTest(Collection meths)
          Tests all the methods contained in the given collecton.
protected  void doTest(EtMethod emeth)
          Tests the given method.
protected  boolean enableStatDialog()
          Returns true if the test statistics dialog has to be enabled.
 ExplorerComponent getExplorerView()
          Returns the view to be added to the explorer pane.
 OptionPanel getOptionPanel()
          Returns the option panel of this tester.
private  AbstractAction getPopExport()
          Creates an action to export all the test cases of the currently selected methods and consturctors as a JUnit test.
private  AbstractAction getPopExportAll()
          Creates an action to export all the test cases as a JUnit test.
private  AbstractAction getPopOpen()
          Creates an action to load a class file for testing.
protected  AbstractAction getPopTest()
          Creates an action to generate test cases for the currently selected method or constructor.
protected  AbstractAction getPopTestAll()
          Creates an action to generate test cases for all the methods and constructors.
protected  AbstractAction getPopTestDeclared()
          Creates an action to generate test cases for the declared methods.
protected  AbstractAction getPopTestInherited()
          Creates an action to generate test cases for the inherited methods.
private  AbstractAction getTCPopExport()
          Creates an action to export all currently selected test cases displayed in the test cases pane.
private  AbstractAction getTCPopExportAll()
          Creates an action to export all the test cases displayed in the test cases pane.
private  AbstractAction getTCPopExportFailed()
          Creates an action to export all the failed test cases displayed in the test cases pane.
private  AbstractAction getTCPopExportSuccessful()
          Creates an action to export all the successful test cases displayed in the test cases pane.
 JComponent getView()
          Returns the view of this tester.
 boolean loadFile(File file)
          Loads the given class file for testing and returns true if the file was loaded successfuly.
private static JScrollPane makeScrollable(JComponent comp)
          Adds horizontal and vertical scroll bars to the given component.
(package private)  void methodSelected(EtMethod meth)
          Called to refresh the view, as the given method has been selected from the method list pane.
private  void notifyFileLoaded(File file)
          Notifies to the registered class file change listeners that the given class file was successfully loaded by this tester.
 void setCloseViewAction(AbstractAction action)
          Given the action that closes this editor's view, provides an appropriate user interface for it, such as a popup menu.
 void setDropTarget(DropTarget dropTarget)
          Associates a drop target with this tester so that its method names subpane accepts drops of class files.
 void setSourceCodeViewer(SourceCodeViewer viewer)
          Sets the the source code viewer to locate and highlight the source code lines corresponding to the error messages obtained from the test case generation tool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clazz

private Class clazz
Currently loaded class.


file

private File file
The file from which the current class was loaded.


methodTree

private MethodTree methodTree
The tree model for the method pane to displays all the methods and constructors of the class under test.


theView

private DefaultTester.TesterView theView
The view of this test wizard.


stat

private Statistics stat
The test statistics manager.


titleBars

private List<JLabel> titleBars
The title bars of all subpanes.


testcaseDescription

private final JTextPane testcaseDescription
The pane to display the description of the currently selected test case.


testcaseFailure

private final OutputTextArea testcaseFailure
The pane to display the failure message, if exists, of the currently selected test case.


spec

private final JTextArea spec
The pane to display the specification of the currently selected method or constructor.


testcases

private final DefaultListModel testcases
The list of test cases of the currently selected method or constructor.


testcasesList

private DefaultTester.TestCaseList testcasesList
The view to show the testcases.


classFileChangeListeners

private final List<ClassFileChangeListener> classFileChangeListeners
Registered class file change listeners.


statDialog

private final DefaultTester.StatisticsDialog statDialog
Dialog window showing test statistics.


DIVIDER_SIZE

private static final int DIVIDER_SIZE
Divider size.

See Also:
Constant Field Values
Constructor Detail

DefaultTester

public DefaultTester()
Creates a new instance.

Method Detail

getView

public JComponent getView()
Returns the view of this tester. The returned view may be added to other containder widgets, such as JPanel.

Specified by:
getView in interface Tester

getExplorerView

public ExplorerComponent getExplorerView()
Returns the view to be added to the explorer pane. Null is returned if no such view is provided by this tester.

Specified by:
getExplorerView in interface Tester

getOptionPanel

public OptionPanel getOptionPanel()
Returns the option panel of this tester.

Specified by:
getOptionPanel in interface Tester

loadFile

public boolean loadFile(File file)
Loads the given class file for testing and returns true if the file was loaded successfuly. All the public methods and constructors will be read and displayed for testing.

Specified by:
loadFile in interface Tester

addClassFileChangeListener

public void addClassFileChangeListener(ClassFileChangeListener l)
Registers the given class file change listener. The listener will be notified when a new class file is loaded by the tester.

Specified by:
addClassFileChangeListener in interface Tester

setSourceCodeViewer

public void setSourceCodeViewer(SourceCodeViewer viewer)
Sets the the source code viewer to locate and highlight the source code lines corresponding to the error messages obtained from the test case generation tool.

Specified by:
setSourceCodeViewer in interface Tester

setDropTarget

public void setDropTarget(DropTarget dropTarget)
Associates a drop target with this tester so that its method names subpane accepts drops of class files.

Specified by:
setDropTarget in interface Tester

setCloseViewAction

public void setCloseViewAction(AbstractAction action)
Given the action that closes this editor's view, provides an appropriate user interface for it, such as a popup menu.

Specified by:
setCloseViewAction in interface Tester

createTestCaseGenerationListener

protected TestCaseGenerationListener createTestCaseGenerationListener(EtMethod emeth)
Creates a test case generation listener for testing the given method. This is a hook method that can be overridden by subclass. For example, a subclass can override this method to collect experimental test statistics.


methodSelected

void methodSelected(EtMethod meth)
Called to refresh the view, as the given method has been selected from the method list pane.


classBeingOpened

void classBeingOpened(EtClass clazz)
Called to refresh the view, as the given class is being loaded by the the method list pane.


notifyFileLoaded

private void notifyFileLoaded(File file)
Notifies to the registered class file change listeners that the given class file was successfully loaded by this tester.


createMethodPane

private JPanel createMethodPane()
Creates a method pane that displays all the methods and constructors of the class under test.


createTitleBar

private JLabel createTitleBar(String title)
Creates a title bar of the given title string. The returned title bar will be stored in the field titleBars.


createTestCasePane

private JPanel createTestCasePane()
Creates a test case pane that lists all the test cases of the currently selected method.


createDescriptionPane

private JSplitPane createDescriptionPane()
Creates a description pane that displays a description of the currently selected test case.


createSpecPane

private JPanel createSpecPane()
Creates a specification pane that displays the specification of the currently selected method.


makeScrollable

private static JScrollPane makeScrollable(JComponent comp)
Adds horizontal and vertical scroll bars to the given component.


createMethodPanePopupMenu

private JPopupMenu createMethodPanePopupMenu()
Creates a popup menu for the method list pane.


createTestCasesPanePopupMenu

private JPopupMenu createTestCasesPanePopupMenu()
Creates a popup menu for the test cases pane.


getPopExport

private AbstractAction getPopExport()
Creates an action to export all the test cases of the currently selected methods and consturctors as a JUnit test.


getPopExportAll

private AbstractAction getPopExportAll()
Creates an action to export all the test cases as a JUnit test.


getTCPopExport

private AbstractAction getTCPopExport()
Creates an action to export all currently selected test cases displayed in the test cases pane.


getTCPopExportFailed

private AbstractAction getTCPopExportFailed()
Creates an action to export all the failed test cases displayed in the test cases pane.


getTCPopExportSuccessful

private AbstractAction getTCPopExportSuccessful()
Creates an action to export all the successful test cases displayed in the test cases pane.


getTCPopExportAll

private AbstractAction getTCPopExportAll()
Creates an action to export all the test cases displayed in the test cases pane.


getPopOpen

private AbstractAction getPopOpen()
Creates an action to load a class file for testing.


getPopTest

protected AbstractAction getPopTest()
Creates an action to generate test cases for the currently selected method or constructor.


getPopTestInherited

protected AbstractAction getPopTestInherited()
Creates an action to generate test cases for the inherited methods.


getPopTestDeclared

protected AbstractAction getPopTestDeclared()
Creates an action to generate test cases for the declared methods.


getPopTestAll

protected AbstractAction getPopTestAll()
Creates an action to generate test cases for all the methods and constructors.


doTest

protected void doTest(Collection meths)
Tests all the methods contained in the given collecton. All the tests are executed in a new thread.


doTest

protected void doTest(EtMethod emeth)
Tests the given method.


enableStatDialog

protected boolean enableStatDialog()
Returns true if the test statistics dialog has to be enabled.


doJUnitExport

private void doJUnitExport(Collection<EtMethod> methods)
Exports test cases of the methods correcponding to the given rows of the method tree pane.


doJUnitExport

private void doJUnitExport(EtTestCase[] testcases)
Exports the given test cases.


autoEnableAction

private void autoEnableAction(AbstractAction act)
Automatically enables and disables the given action based on the method selections. That is, the action is enabled if and only if there is a method selected in the method list pane.


JET

JET is Copyright (C) 2005-2007 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.