org.apache.james.mpt
Class ProtocolSession

java.lang.Object
  extended by org.apache.james.mpt.ProtocolSession
All Implemented Interfaces:
ProtocolInteractor

public class ProtocolSession
extends java.lang.Object
implements ProtocolInteractor

A protocol session which can be run against a reader and writer, which checks the server response against the expected values. TODO make ProtocolSession itself be a permissible ProtocolElement, so that we can nest and reuse sessions.

Version:
$Revision: 776401 $
Author:
Darrell DeBoer

Field Summary
protected  java.util.List<org.apache.james.mpt.ProtocolSession.ProtocolElement> testElements
           
 
Constructor Summary
ProtocolSession()
           
 
Method Summary
 void CL(int sessionNumber, java.lang.String clientLine)
          adds a new Client request line to the test elements
 void CL(java.lang.String clientLine)
          adds a new Client request line to the test elements
 void CONT(int sessionNumber)
          Adds a continuation.
 void doContinue()
           
 int getSessionCount()
          Returns the number of sessions required to run this ProtocolSession.
 boolean isContinueAfterFailure()
           
 void runSessions(Session[] sessions)
          Executes the ProtocolSession in real time against the readers and writers supplied, writing client requests and reading server responses in the order that they appear in the test elements.
 void setContinueAfterFailure(boolean continueAfterFailure)
           
 void SL(int sessionNumber, java.lang.String serverLine, java.lang.String location, java.lang.String lastClientMessage)
          adds a new Server Response line to the test elements, with the specified location.
 void SL(java.lang.String serverLine, java.lang.String location)
          adds a new Server Response line to the test elements, with the specified location.
 void SUB(int sessionNumber, java.util.List<java.lang.String> serverLines, java.lang.String location, java.lang.String lastClientMessage)
          adds a new Server Unordered Block to the test elements.
 void SUB(java.util.List<java.lang.String> serverLines, java.lang.String location)
          adds a new Server Unordered Block to the test elements.
 java.lang.String toString()
          Constructs a String with all attributes in name = value format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

testElements

protected java.util.List<org.apache.james.mpt.ProtocolSession.ProtocolElement> testElements
Constructor Detail

ProtocolSession

public ProtocolSession()
Method Detail

isContinueAfterFailure

public final boolean isContinueAfterFailure()

setContinueAfterFailure

public final void setContinueAfterFailure(boolean continueAfterFailure)

getSessionCount

public int getSessionCount()
Returns the number of sessions required to run this ProtocolSession. If the number of readers and writers provided is less than this number, an exception will occur when running the tests.


runSessions

public void runSessions(Session[] sessions)
                 throws java.lang.Exception
Executes the ProtocolSession in real time against the readers and writers supplied, writing client requests and reading server responses in the order that they appear in the test elements. The index of a reader/writer in the array corresponds to the number of the session. If an exception occurs, no more test elements are executed.

Parameters:
sessions - not null
Throws:
java.lang.Exception

doContinue

public void doContinue()

CL

public void CL(java.lang.String clientLine)
Description copied from interface: ProtocolInteractor
adds a new Client request line to the test elements

Specified by:
CL in interface ProtocolInteractor
See Also:
ProtocolInteractor.CL(java.lang.String)

SL

public void SL(java.lang.String serverLine,
               java.lang.String location)
Description copied from interface: ProtocolInteractor
adds a new Server Response line to the test elements, with the specified location.

Specified by:
SL in interface ProtocolInteractor
See Also:
ProtocolInteractor.SL(java.lang.String, java.lang.String)

SUB

public void SUB(java.util.List<java.lang.String> serverLines,
                java.lang.String location)
Description copied from interface: ProtocolInteractor
adds a new Server Unordered Block to the test elements.

Specified by:
SUB in interface ProtocolInteractor
See Also:
ProtocolInteractor.SUB(java.util.List, java.lang.String)

CL

public void CL(int sessionNumber,
               java.lang.String clientLine)
Description copied from interface: ProtocolInteractor
adds a new Client request line to the test elements

Specified by:
CL in interface ProtocolInteractor
See Also:
ProtocolInteractor.CL(int, java.lang.String)

CONT

public void CONT(int sessionNumber)
          throws java.lang.Exception
Description copied from interface: ProtocolInteractor
Adds a continuation. To allow one thread to be used for testing.

Specified by:
CONT in interface ProtocolInteractor
Throws:
java.lang.Exception
See Also:
ProtocolInteractor.CONT(int)

SL

public void SL(int sessionNumber,
               java.lang.String serverLine,
               java.lang.String location,
               java.lang.String lastClientMessage)
Description copied from interface: ProtocolInteractor
adds a new Server Response line to the test elements, with the specified location.

Specified by:
SL in interface ProtocolInteractor
See Also:
ProtocolInteractor.SL(int, java.lang.String, java.lang.String, java.lang.String)

SUB

public void SUB(int sessionNumber,
                java.util.List<java.lang.String> serverLines,
                java.lang.String location,
                java.lang.String lastClientMessage)
Description copied from interface: ProtocolInteractor
adds a new Server Unordered Block to the test elements.

Specified by:
SUB in interface ProtocolInteractor
See Also:
ProtocolInteractor.SUB(int, java.util.List, java.lang.String, java.lang.String)

toString

public java.lang.String toString()
Constructs a String with all attributes in name = value format.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this object.


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.