Copyright © 1999 Sita Ramakrishnan, Monash University All rights reserved

Light Views

HomeCase StudiesOO TheoryHelp

TicTacToe Game

Event Based Testing of TicTacToe JavaBean

Test case scenario:

Show how beans use events (delegation) to veto property changes.
Expected Result: show the constrained property of bean at work.

Animating message sequence diagram and activity diagram for tictactoe bean's constrained property, setMove()

Demonstration: Activity Diagram and Message Sequence Diagram

  • The tictactoe board bean sends a signal of vetoable change to its constrained subscriber, Human Player by communicating the request for change using this constrained property, setMove().
  • The bean invokes the fireVetoableChange method of Human Player object and passes it the name of the property as well as its old and new values.
  • If the method returns without throwing an exception, the source bean board, can apply the change.
  • The Human Player object constructs an instance of property change event with the "new move".
  • It invokes the vetoable change method on its registered subscriber, the TicTacToe Game, with property change event as the parameter.
  • Note that the constrained property fires property change events before they have changed, and gives the vetoable change listeners the option to veto the change.
  • The Human Player object receives the vetoable change signal (see the activity diagram) and throws a propertyVetoException if it is not a valid move.
  • Returns at this point as its is through after property Change event has occurred. The other threads take their time as you see when the message sequence proceeds as shown in the animation and the text that accompanies (follows) it
  • The Human Player object invokes setYourTurn and calls setMove with newMove parameter to the tictactoe game object.
  • The Human Player passes an asynchronous event to the TicTacToe Game
  • The Game invokes yourMove() and so on as is shown in the animation

Funded by Committee of University Teaching And Staff Development (CUTSD) through DEETYA, 1998