org.jwalk.tool
Class JWalkTester

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.jwalk.tool.JWalkTester
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Thread.UncaughtExceptionHandler, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class JWalkTester
extends javax.swing.JFrame
implements java.lang.Thread.UncaughtExceptionHandler

JWalkTester is a simple GUI for conducting JWalk tests. It consists of an input panel, allowing the user to specify the location and name of the test class, and to specify the test strategy, test modality and maximum test path depth. The "JWalker" animated button is then clicked to start a test cycle with the current settings. The output is displayed in a series of tabs in the output panel, which may be clicked to review the results of different test cycles and summary reports. Custom test settings may be set by invoking further custom dialogs using buttons at the bottom of the input panel.

JWalkTester uses the JWalker test engine to perform lazy systematic unit testing. It uses the Settings and Channels APIs in order to communicate with the JWalker. In particular, the various sub-panels of the input panel upload settings to the Settings API. This JWalkTester registers two listeners with the Channels API: QuestionMaster, to handle interactive questions; and ReportPublisher, to publish test reports. This JWalkTester handles the exceptions: LoaderException, raised if a test class or generator class could not be loaded; PermissionException, raised if the test class refuses permission to be executed; SettingsException, raised if the GUI supplied badly formatted test settings; GeneratorException, raised if the JWalker could not synthesise a test input for a particular type; and ExecutionException, if any constructor or method of the test class could not be executed for any reason.

Version:
1.1
Author:
Anthony J H Simons, Mihai Gabriel Glont, Erik Tittel
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JWalkTester()
          Creates a JWalkTester.
 
Method Summary
 void addOutput(java.lang.String title, java.lang.String content)
          Adds the next set of test results to the output panel.
 void clearOutput()
          Clears the output panel of existing output.
 void executeTests()
          Executes the next test series, according to the current test settings.
 void finishedTests()
          Reports asynchronously to this JWalkTester when testing has finished.
 Settings getSettings()
          Returns the current test settings for the JWalker test engine.
 void handleException(JWalkException ex)
          The main exception handler for this JWalkTester.
 void interruptTests()
          Interrupts the currently executing test series.
static void main(java.lang.String[] args)
          Main program to create and open a JWalkTester.
 void uncaughtException(java.lang.Thread thread, java.lang.Throwable thrown)
          Special method for handling uncaught exceptions in any GUI thread.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

JWalkTester

public JWalkTester()
Creates a JWalkTester. This constructs a main frame with an input panel and an output panel. The dimensions of the main frame are set by default to MAIN_VIEWER_WIDTH, MAIN_VIEWER_HEIGHT. The main frame will appear centrally on the screen. If this JWalkTester application is minimised to an icon, a "JWalker" graphic may appear in the icon form. Creating this JWalkTester will also create the JWalker test engine to be used; and will register a QuestionMaster and ReportPublisher with the JWalker's Channels API.

Method Detail

main

public static void main(java.lang.String[] args)
Main program to create and open a JWalkTester. This creates a single instance of JWalkTester and makes it visible. The program terminates when the user closes the JWalkTester. Before opening the JWalkTester, the program seeks to install the system look-and-feel of the current operating system, whether Windows, Unix or Linux. If this fails, opens a JWalk Warning dialog to inform the user, and then defaults to the standard Java look-and-feel.


getSettings

public Settings getSettings()
Returns the current test settings for the JWalker test engine. This access method is provided to allow sub-panels of this JWalkTester to access the JWalker's test settings directly (following the "Law of Demeter", by which JWalkTester must explicitly provide access to the nested Settings API).

Returns:
the current Settings.

clearOutput

public void clearOutput()
Clears the output panel of existing output. This method is invoked at the start of any new test run; and also if the test class is altered, so that the displayed output always relates to the current test class.


addOutput

public void addOutput(java.lang.String title,
                      java.lang.String content)
Adds the next set of test results to the output panel. This creates a new tab, which is added to the tabbed pane displaying the current output. Tabs initially stack along the top of the output panel, but wrap to a subsequent row if necessary. The tabs are individually scrollable, and whether scroll-bars appear is determined by the default row width and column height set in the


executeTests

public void executeTests()
Executes the next test series, according to the current test settings. This method is invoked when the user clicks on the execute button with the "Jimbo" icon. Clicking immediately disables the button until testing is over. First, the current output is cleared; then, the current test settings displayed in the input panel are uploaded to the JWalker test engine. Finally, the test series is executed according to the uploaded settings. The JWalker engine is executed asynchronously in a separate thread. This process may cause a dialog between the tool and the user, to confirm certain key test results (in validation modality), in which case an oracle file is created and saved. Also, any of the following exceptions may be handled: LoaderException, PermissionException, GeneratorException or ExecutionException, whose content is communicated to the user via dialogs.


finishedTests

public void finishedTests()
Reports asynchronously to this JWalkTester when testing has finished. Since the JWalker engine executes in the background, the JWalkTester must wait for a notification that testing has ended, before enabling the execute button again.


interruptTests

public void interruptTests()
Interrupts the currently executing test series. This allows the user interface to set the user abort condition in the asynchronous worker thread executing the JWalker engine in the background.


handleException

public void handleException(JWalkException ex)
The main exception handler for this JWalkTester. Handles every kind of JWalkException expected by this JWalkTester, while executing a test series. Exceptions may be thrown and caught locally within the GUI or passed inside events notified by the JWalker engine, which executes in a background thread. Listeners unpack the events and invoke this method to handle the exceptions.

Parameters:
ex - the JWalkException to be unpacked.

uncaughtException

public void uncaughtException(java.lang.Thread thread,
                              java.lang.Throwable thrown)
Special method for handling uncaught exceptions in any GUI thread. Because of the asynchronous execution of the GUI and the JWalker, it is possible for OutOfMemoryError to be raised by one of several GUI threads (the AWT main event queue, the image animator, the system timer queue). This handler releases some safety memory, then notifies the JWalker worker thread to abort. If the image animator was broken, restarts the image animation thread.

Specified by:
uncaughtException in interface java.lang.Thread.UncaughtExceptionHandler
Parameters:
thread - the thread in which the exception was thrown.
thrown - the exception or error was thrown.