DRCL J-Sim API

drcl.comp.tool
Class ComponentTester

java.lang.Object
  extended bydrcl.DrclObj
      extended bydrcl.comp.Component
          extended bydrcl.comp.WrapperComponent
              extended bydrcl.comp.tool.ComponentTester
All Implemented Interfaces:
ActiveComponent, java.lang.Cloneable, ObjectCloneable, ObjectDuplicable, java.io.Serializable, Wrapper
Direct Known Subclasses:
ComponentDebugger

public class ComponentTester
extends WrapperComponent
implements ActiveComponent

This tester component is designed for testing a component. Testing of a component using this tester component is similar to testing of an IC chip where the IC chip is put in a testing circuitry. One can program the testing circuitry to generate certain signals and then monitor if the tested chip responds with correct signals.

To test a component, one must "program" this tester by setting up a sequence of events. Two types of events are essential in testing a component:

Two more types of events are derived from the above two, specifically for handling "sendReceive" events initiated by the tested component: The reason why the above two types of events are distinguished from the sending and receiving events is because the thread of sending a "sendReceive" request carries across component boundary and expects to get the reply within the same thread context, while the threads for processing the sending and receiving events are different and independent. As a result, a "rr-reply" event must be set up as a pair with a "rr-request" event.

To set up an event, use one of the addEvent() or the insertEvent() methods. To remove an event, use the removeEvent(int) method. Run this tester component (as well as the tested component if necessary) to start the test as the tester component is an ActiveComponent.

Author:
Hung-ying Tyan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class drcl.comp.Component
Component.Locks
 
Field Summary
 
Fields inherited from class drcl.comp.Component
FLAG_COMPONENT_NOTIFICATION, FLAG_DEBUG_ENABLED, FLAG_DIRECT_OUTPUT_ENABLED, FLAG_ENABLED, FLAG_ERROR_ENABLED, FLAG_EVENT_ENABLED, FLAG_GARBAGE_DISPLAY_ENABLED, FLAG_GARBAGE_ENABLED, FLAG_PORT_NOTIFICATION, FLAG_STARTED, FLAG_STOPPED, FLAG_TRACE_ENABLED, FLAG_UNDEFINED_START, id, infoPort, locks, name, parent, PortGroup_DEFAULT_GROUP, PortGroup_EVENT, PortGroup_SERVICE, Root, Trace_DATA, Trace_SEND
 
Constructor Summary
ComponentTester()
           
ComponentTester(java.lang.String id_)
           
 
Method Summary
 java.lang.Object addEvent(java.lang.String msg_)
          Adds a message event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_)
          Adds a finish event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_, java.lang.Object toSend_)
          Adds a "rr-reply" event, corresponding to last event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_, java.lang.Object toSend_, Port p_)
          Adds a "sending"/"rr-reply" event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_, java.lang.Object toRcv_, java.lang.String portDescription_)
          Adds a "receiving" event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_, java.lang.Object toRcv_, java.lang.String classExpected_, Port p_)
          Adds a "receiving"/"rr-request" event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_, java.lang.Object toRcv_, java.lang.String classExpected_, java.lang.String portDescription_)
          Adds a "receiving" event.
 java.lang.Object addEvent(java.lang.String evtType_, double time_, java.lang.String msg_)
          Adds a message event.
 void clearBatch()
           
 void clearStorage()
          Clears all the data buffered in the tester.
 void duplicate(java.lang.Object source_)
          Duplicates the content of source_, including ID, name, child components and connections among them, to this component.
 java.lang.Object getData(java.lang.Object port_, double time_)
          Returns the first data in the queue, coming in from the port at the time specified.
 java.lang.Object getData(Port port_)
          Returns the first data in the queue, coming in from the port specified.
 EventTester getEventTester()
          Returns the underlying testing engine.
 java.lang.String info()
          Returns information regarding this component.
 java.lang.Object insertEvent(int index_, java.lang.String evtType_, double time_)
          Inserts a finish event.
 java.lang.Object insertEvent(int index_, java.lang.String evtType_, double time_, java.lang.Object toSend_, Port p_)
          Inserts a "sending" event Use viewBatch() to view the list of events in the batch.
 java.lang.Object insertEvent(int index_, java.lang.String evtType_, double time_, java.lang.Object toRcv_, java.lang.String classExpected_, Port p_)
          Inserts a "receiving" event Use viewBatch() to view the list of events in the batch.
 java.lang.Object insertEvent(int index_, java.lang.String evtType_, double time_, java.lang.Object toRcv_, java.lang.String classExpected_, java.lang.String portDescription_)
          Inserts a "receiving" event.
 java.lang.Object insertEvent(int index_, java.lang.String evtType_, double time_, java.lang.String msg_)
          Inserts a message event.
 boolean isRcvEnabled()
          Returns true if printing received data is enabled.
 boolean isStorageEnabled()
           
 ComponentMonitor monitor(Component comp_)
           
 void post(java.lang.String msg_)
           
 java.lang.Object removeEvent(int index_)
          Removes the index'th event.
 void reset()
          Resets the tester component.
 void resetBatch()
           
 void setRcvEnabled(boolean v_)
          Enables/disables printing received data.
 void setStorageEnabled(boolean v_)
           
 java.lang.String viewBatch()
           
 java.lang.String viewStorage()
          View the list of data that are buffered in the tester.
 
Methods inherited from class drcl.comp.WrapperComponent
getHandler, getObject, setHandler, setObject
 
Methods inherited from class drcl.comp.Component
addComponent, addComponent, addEventPort, addEventPort, addForkPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addServerPort, addServerPort, cancelFork, connect, containsComponent, containsComponent, containsPort, debug, disconnectAll, disconnectAllPeers, disconnectAllPorts, drop, drop, error, error, expose, exposeEventPorts, exposePort, exposePort, exposePort, exposePort, exposePort, findAvailable, findAvailable, findAvailable, fork, forkAt, getAllComponents, getAllPorts, getAllPorts, getAllWiresInside, getAllWiresInsideOut, getAllWiresOut, getComponent, getComponentFlag, getComponentFlag, getContract, getContractHT, getContractHT, getDebugFlagsInBinary, getDebugLevelNames, getID, getName, getParent, getPort, getPort, getRoot, getTime, iduplicate, isAncestorOf, isContainer, isDebugEnabled, isDebugEnabledAt, isDirectlyRelatedTo, isDirectOutputEnabled, isEnabled, isErrorNoticeEnabled, isEventExportEnabled, isGarbageDisplayEnabled, isGarbageEnabled, isPortRemovable, isStarted, isStopped, isTraceEnabled, lock, notify, notifyAll, operate, reboot, removeAll, removeAllComponents, removeAllPorts, removeAllPorts, removeComponent, removeComponent, removePort, removePort, removePort, resume, run, sduplicate, send, sendAt, setComponentFlag, setComponentFlag, setDebugEnabled, setDebugEnabled, setDebugEnabledAt, setDebugEnabledAt, setDebugEnabledAt, setDirectOutputEnabled, setDirectOutputEnabled, setEnabled, setErrorNoticeEnabled, setErrorNoticeEnabled, setEventExportEnabled, setEventExportEnabled, setExecutionBoundary, setGarbageDisplayEnabled, setGarbageDisplayEnabled, setGarbageEnabled, setGarbageEnabled, setID, setID, setName, setPort, setPort, setTraceEnabled, setTraceEnabled, sleepFor, sleepUntil, stop, toString, unexpose, unlock, useLocalForkManager, useLocalForkManager, wait
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComponentTester

public ComponentTester()

ComponentTester

public ComponentTester(java.lang.String id_)
Method Detail

setRcvEnabled

public void setRcvEnabled(boolean v_)
Enables/disables printing received data.


isRcvEnabled

public boolean isRcvEnabled()
Returns true if printing received data is enabled.


getEventTester

public EventTester getEventTester()
Returns the underlying testing engine.


reset

public void reset()
Resets the tester component. The events are not removed.

Overrides:
reset in class Component

addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_,
                                 java.lang.Object toSend_,
                                 Port p_)
Adds a "sending"/"rr-reply" event. Must specify time, object to send and the port on which the object is to send. The time is relative to the time when the test starts.


addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_,
                                 java.lang.Object toSend_)
Adds a "rr-reply" event, corresponding to last event.


addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_,
                                 java.lang.Object toRcv_,
                                 java.lang.String portDescription_)
Adds a "receiving" event.

See Also:
addEvent(String, double, Object, String, String)

addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_,
                                 java.lang.Object toRcv_,
                                 java.lang.String classExpected_,
                                 Port p_)
Adds a "receiving"/"rr-request" event. When a data is received, time, data itself, class of data and port are matched with the event. In the event, if time is less than 0, time always matches. Similarly, data always matches if null is specified. Class always matches if null is specified. The time is relative to the time when the test starts.


addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_,
                                 java.lang.Object toRcv_,
                                 java.lang.String classExpected_,
                                 java.lang.String portDescription_)
Adds a "receiving" event. Exactly the same as the other add-recv-event method except that port is specified in group id and port id. Group id always matches if null is specified. Port id always matches if null is specified.


addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_)
Adds a finish event. The event is to finish the test no matter whether there are still events behind.


addEvent

public java.lang.Object addEvent(java.lang.String evtType_,
                                 double time_,
                                 java.lang.String msg_)
Adds a message event. Executing the event results in the message being printed to the out channels.


addEvent

public java.lang.Object addEvent(java.lang.String msg_)
Adds a message event. Executing the event results in the message being printed to the out channels.


removeEvent

public java.lang.Object removeEvent(int index_)
Removes the index'th event. Use viewBatch() to view the list of events in the batch.


insertEvent

public java.lang.Object insertEvent(int index_,
                                    java.lang.String evtType_,
                                    double time_,
                                    java.lang.Object toSend_,
                                    Port p_)
Inserts a "sending" event Use viewBatch() to view the list of events in the batch.

See Also:
addEvent(String, double, Object, Port)

insertEvent

public java.lang.Object insertEvent(int index_,
                                    java.lang.String evtType_,
                                    double time_,
                                    java.lang.Object toRcv_,
                                    java.lang.String classExpected_,
                                    Port p_)
Inserts a "receiving" event Use viewBatch() to view the list of events in the batch.

See Also:
addEvent(String, double, Object, String, Port)

insertEvent

public java.lang.Object insertEvent(int index_,
                                    java.lang.String evtType_,
                                    double time_,
                                    java.lang.Object toRcv_,
                                    java.lang.String classExpected_,
                                    java.lang.String portDescription_)
Inserts a "receiving" event. Use viewBatch() to view the list of events in the batch.

See Also:
addEvent(String, double, Object, String, String)

insertEvent

public java.lang.Object insertEvent(int index_,
                                    java.lang.String evtType_,
                                    double time_)
Inserts a finish event. Use viewBatch() to view the list of events in the batch.

See Also:
addEvent(String, double)

insertEvent

public java.lang.Object insertEvent(int index_,
                                    java.lang.String evtType_,
                                    double time_,
                                    java.lang.String msg_)
Inserts a message event. Use viewBatch() to view the list of events in the batch.

See Also:
addEvent(String, double, String)

viewBatch

public java.lang.String viewBatch()

clearBatch

public void clearBatch()

resetBatch

public void resetBatch()

setStorageEnabled

public void setStorageEnabled(boolean v_)

isStorageEnabled

public boolean isStorageEnabled()

viewStorage

public java.lang.String viewStorage()
View the list of data that are buffered in the tester. Use getData(Port) to retrieve them.


getData

public java.lang.Object getData(Port port_)
Returns the first data in the queue, coming in from the port specified.


getData

public java.lang.Object getData(java.lang.Object port_,
                                double time_)
Returns the first data in the queue, coming in from the port at the time specified.


clearStorage

public void clearStorage()
Clears all the data buffered in the tester.


monitor

public ComponentMonitor monitor(Component comp_)

post

public void post(java.lang.String msg_)

info

public java.lang.String info()
Description copied from class: Component
Returns information regarding this component. Subclasses should override this method to provide useful information at run time.

Overrides:
info in class WrapperComponent

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: Component
Duplicates the content of source_, including ID, name, child components and connections among them, to this component. Subclasses need to override this method to copy its own variables.

Specified by:
duplicate in interface ObjectDuplicable
Overrides:
duplicate in class WrapperComponent

DRCL J-Sim API

Copyright © 1998-2003 Distributed Real-time Computing Lab (DRCL). All Rights Reserved.     ~ To J-Sim Home ~