org.apache.james.test.functional
Class ProtocolSession

java.lang.Object
  extended by org.apache.james.test.functional.ProtocolSession

public class ProtocolSession
extends java.lang.Object

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: 709874 $
Author:
Darrell DeBoer

Nested Class Summary
 class ProtocolSession.InvalidServerResponseException
          An exception which is thrown when the actual response from a server is different from that expected.
 
Field Summary
protected  java.util.List 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(HostSystem.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 serverLines, java.lang.String location, java.lang.String lastClientMessage)
          adds a new Server Unordered Block to the test elements.
 void SUB(java.util.List serverLines, java.lang.String location)
          adds a new Server Unordered Block to the test elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testElements

protected java.util.List 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(HostSystem.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:
out - The client requests are written to here.
in - The server responses are read from here.
Throws:
java.lang.Exception

doContinue

public void doContinue()

CL

public void CL(java.lang.String clientLine)
adds a new Client request line to the test elements


SL

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


SUB

public void SUB(java.util.List serverLines,
                java.lang.String location)
adds a new Server Unordered Block to the test elements.


CL

public void CL(int sessionNumber,
               java.lang.String clientLine)
adds a new Client request line to the test elements


CONT

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

Throws:
java.lang.Exception

SL

public 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.


SUB

public void SUB(int sessionNumber,
                java.util.List serverLines,
                java.lang.String location,
                java.lang.String lastClientMessage)
adds a new Server Unordered Block to the test elements.



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