org.echarts.test.sip
Class CATTestCase

java.lang.Object
  extended by org.echarts.test.sip.CATTestCase

public abstract class CATTestCase
extends java.lang.Object

A KitCAT testcase must extend this class. It acts as the factory for creating instances of SIPAgent and is responsible for managing these agents. It is also responsible for synchronous processing of SIP messages that arrive in the background. A number of assertions can be performed in KitCAT using the assertThat primitive in JUnit and the matchers that are provided as part of KitCAT (CATMatchers).


Method Summary
 SIPAgent createAgent(java.lang.String userName)
          Create an instance of SIPAgent.
 java.lang.String getCallId(Response resp)
          Utility method to get the call id from a response
static Address getContactAddress(Response resp)
          Utility method to get the contact address from a response
 org.apache.log4j.Logger getLogger()
          Returns a log4j logger with name KitCAT.Tester.
 void init(CATConfig config)
           
 void init(int listenPort)
          Initialize the SIP subsystem.
 void init(java.lang.String testName, java.lang.String outputDir, int listenPort)
          Deprecated. 
 void init(java.lang.String testName, java.lang.String outputDir, java.lang.String listenIP, int listenPort)
          Deprecated. 
 void processSIP(long timeout)
          Process all received SIP messages until timeout expiry.
 void release()
          Releases all resources including agents.
 void releaseAgent(SIPAgent agent)
          Releases resources associated with an agent.
static void setSingletonStack()
          EXPERIMENTAL.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public void init(int listenPort)
          throws CATException
Initialize the SIP subsystem. The name of the test case is inferred to be the calling method as determined from the call stack. The default output directory is "out". The init method must be invoked at the start of each test case.

Parameters:
listenPort - SIP listen port
Throws:
CATException

init

@Deprecated
public void init(java.lang.String testName,
                            java.lang.String outputDir,
                            int listenPort)
          throws CATException
Deprecated. 

Use init(CATConfig) instead.

Throws:
CATException

init

@Deprecated
public void init(java.lang.String testName,
                            java.lang.String outputDir,
                            java.lang.String listenIP,
                            int listenPort)
          throws CATException
Deprecated. 

Use init(CATConfig) instead

Parameters:
testName - Name of the test case
outputDir - Name of output directory for output files generated by this test case
listenIP - SIP listen IP address
listenPort - SIP listen port
Throws:
CATException

init

public void init(CATConfig config)
          throws CATException
Throws:
CATException

setSingletonStack

public static void setSingletonStack()
EXPERIMENTAL.


getLogger

public org.apache.log4j.Logger getLogger()
Returns a log4j logger with name KitCAT.Tester.


processSIP

public void processSIP(long timeout)
                throws CATException
Process all received SIP messages until timeout expiry. Calling this method causes all SIP agents to process SIP messages received by them. There are no call-back functions to handle the asynchronously arriving SIP messages. Instead, the KitCAT runtime framework handles these asynchronous SIP messages in background threads and buffers them in internal KitCAT buffers. It then provides a synchronous (blocking) interface for the test case to process these messages using the this API. This primitive causes all buffered messages for all agents to be processed by the agents until a specified time expiry occurs. If all messages are processed by all agents, then this primitive causes the test case execution to block until either a newly arrived message is buffered for processing or a timeout occurs whichever is earlier. Processing of messages involve execution of the agent state machines causing their states to possibly change. Sometimes, this could cause agents to send further SIP messages in response to the processed message. For example, by default an agent sends an ACK in response to a 200 OK to an INVITE. Whenever there is a need to introduce a delay in the test case, it is highly recommended to use this primitive instead of Thread.sleep(). This ensures that SIP messages are still being processed during the delay. processSIP is the only primitive where arriving SIP messages are processed by test agents.

Parameters:
timeout - timeout in milliseconds
Throws:
CATException

release

public void release()
             throws java.lang.Exception
Releases all resources including agents.

Throws:
java.lang.Exception

releaseAgent

public void releaseAgent(SIPAgent agent)
                  throws CATException
Releases resources associated with an agent.

Throws:
CATException

createAgent

public SIPAgent createAgent(java.lang.String userName)
                     throws CATException
Create an instance of SIPAgent.

Throws:
CATException

getContactAddress

public static Address getContactAddress(Response resp)
Utility method to get the contact address from a response


getCallId

public java.lang.String getCallId(Response resp)
Utility method to get the call id from a response