org.puremvc.java.core
Class ViewTest

java.lang.Object
  extended by org.puremvc.java.core.ViewTest
All Implemented Interfaces:
org.puremvc.java.interfaces.IFunction

public class ViewTest
extends java.lang.Object
implements org.puremvc.java.interfaces.IFunction

Test the PureMVC View class.


Field Summary
 int counter
           
 java.lang.String lastNotification
           
static java.lang.String NOTE1
           
static java.lang.String NOTE2
           
static java.lang.String NOTE3
           
static java.lang.String NOTE4
           
static java.lang.String NOTE5
           
static java.lang.String NOTE6
           
 boolean onRegisterCalled
           
 boolean onRemoveCalled
           
 
Constructor Summary
ViewTest()
           
 
Method Summary
 void onNotification(org.puremvc.java.interfaces.INotification note)
          A utility method to test the notification of Observers by the view
 void testGetInstance()
          Tests the View Singleton Factory Method
 void testHasMediator()
          Tests the hasMediator Method
 void testMediatorReregistration()
          Tests registering the same mediator twice.
 void testModifyObserverListDuringNotification()
          Tests the ability for the observer list to be modified during the process of notification, and all observers be properly notified.
 void testOnRegisterAndOnRemove()
          Tests that the View callse the onRegister and onRemove methods
 void testRegisterAndNotifyObserver()
          Tests registration and notification of Observers.
 void testRegisterAndRemoveMediator()
          Tests registering and removing a mediator
 void testRegisterAndRetrieveMediator()
          Tests registering and retrieving a mediator with the View.
 void testRemoveMediatorAndSubsequentNotify()
          Tests registering a Mediator for 2 different notifications, removing the Mediator from the View, and seeing that neither notification causes the Mediator to be notified.
 void testRemoveOneOfTwoMediatorsAndSubsequentNotify()
          Tests registering one of two registered Mediators and seeing that the remaining one still responds.
 void testSuccessiveRegisterAndRemoveMediator()
          Tests successive regster and remove of same mediator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastNotification

public java.lang.String lastNotification

onRegisterCalled

public boolean onRegisterCalled

onRemoveCalled

public boolean onRemoveCalled

counter

public int counter

NOTE1

public static final java.lang.String NOTE1
See Also:
Constant Field Values

NOTE2

public static final java.lang.String NOTE2
See Also:
Constant Field Values

NOTE3

public static final java.lang.String NOTE3
See Also:
Constant Field Values

NOTE4

public static final java.lang.String NOTE4
See Also:
Constant Field Values

NOTE5

public static final java.lang.String NOTE5
See Also:
Constant Field Values

NOTE6

public static final java.lang.String NOTE6
See Also:
Constant Field Values
Constructor Detail

ViewTest

public ViewTest()
Method Detail

testGetInstance

public void testGetInstance()
Tests the View Singleton Factory Method


testRegisterAndNotifyObserver

public void testRegisterAndNotifyObserver()
Tests registration and notification of Observers.

An Observer is created to callback the viewTestMethod of this ViewTest instance. This Observer is registered with the View to be notified of 'ViewTestEvent' events. Such an event is created, and a value set on its payload. Then the View is told to notify interested observers of this Event.

The View calls the Observer's notifyObserver method which calls the viewTestMethod on this instance of the ViewTest class. The viewTestMethod method will set an instance variable to the value passed in on the Event payload. We evaluate the instance variable to be sure it is the same as that passed out as the payload of the original 'ViewTestEvent'.


onNotification

public void onNotification(org.puremvc.java.interfaces.INotification note)
A utility method to test the notification of Observers by the view

Specified by:
onNotification in interface org.puremvc.java.interfaces.IFunction

testRegisterAndRetrieveMediator

public void testRegisterAndRetrieveMediator()
Tests registering and retrieving a mediator with the View.


testHasMediator

public void testHasMediator()
Tests the hasMediator Method


testRegisterAndRemoveMediator

public void testRegisterAndRemoveMediator()
Tests registering and removing a mediator


testOnRegisterAndOnRemove

public void testOnRegisterAndOnRemove()
Tests that the View callse the onRegister and onRemove methods


testSuccessiveRegisterAndRemoveMediator

public void testSuccessiveRegisterAndRemoveMediator()
Tests successive regster and remove of same mediator.


testRemoveMediatorAndSubsequentNotify

public void testRemoveMediatorAndSubsequentNotify()
Tests registering a Mediator for 2 different notifications, removing the Mediator from the View, and seeing that neither notification causes the Mediator to be notified. Added for the fix deployed in version 1.7


testRemoveOneOfTwoMediatorsAndSubsequentNotify

public void testRemoveOneOfTwoMediatorsAndSubsequentNotify()
Tests registering one of two registered Mediators and seeing that the remaining one still responds. Added for the fix deployed in version 1.7.1


testMediatorReregistration

public void testMediatorReregistration()
Tests registering the same mediator twice. A subsequent notification should only illicit one response. Also, since reregistration was causing 2 observers to be created, ensure that after removal of the mediator there will be no further response. Added for the fix deployed in version 2.0.4


testModifyObserverListDuringNotification

public void testModifyObserverListDuringNotification()
Tests the ability for the observer list to be modified during the process of notification, and all observers be properly notified. This happens most often when multiple Mediators respond to the same notification by removing themselves. Added for the fix deployed in version 2.0.4