org.echarts.test.sip
Class CATMatchers

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

public class CATMatchers
extends java.lang.Object

This class is a holder for static factory methods for instantiating matchers in KitCAT. To access these methods without qualification, a test case can import these methods statically by including the following static import statement.

import static org.echarts.test.sip.CATMatchers.*;


Method Summary
static org.hamcrest.Matcher<SIPAgent> blackHoleSDP()
          Factory method to create a matcher to check whether agent has current SDP with "black-hole" connection address (0.0.0.0)
static org.hamcrest.Matcher<SIPAgent> connected()
          Factory method to create a matcher to check whether an agent is in a SIP dialog.
static org.hamcrest.Matcher<SIPAgent> connectedTo(SIPAgent peerAgent)
          Factory method to create a matcher to check whether an agent is connected to another agent.
static org.hamcrest.Matcher<SIPAgent> disconnected()
          Factory method to create a matcher to check whether an agent has terminated its SIP dialog.
static
<T> org.hamcrest.Matcher<T>
has(org.hamcrest.Matcher<T> matcher)
          Syntactic sugar to improve readability.
static org.hamcrest.Matcher<SIPAgent> idle()
          Factory method to create a matcher to check whether the current state of an agent is idle.
static org.hamcrest.Matcher<SIPAgent> incomingMedia()
          Factory method to create a matcher to check whether agent has RTP packets in its media buffer.
static org.hamcrest.Matcher<SIPAgent> inState(BaseState expectedState)
          Factory method for matcher to check whether agent is in a specific state.
static org.hamcrest.Matcher<SIPAgent> invited()
          Factory method to create a matcher to check whether an agent is in a state where it has received an INVITE.
static
<T> org.hamcrest.Matcher<T>
no(org.hamcrest.Matcher<T> matcher)
          Syntactic sugar to improve readability.
static org.hamcrest.Matcher<SIPAgent> onHold()
          Factory method to create a matcher to check whether agent is on hold, either via "black-hole" SDP, or SDP in which all media descriptions have port 0.
static org.hamcrest.Matcher<SIPAgent> recvdErrorResponse(BaseState state)
          Factory method to create a matcher to check whether agent received an error response (response code between 400 and 699) in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdErrorResponse(CommandId cmdId)
          Factory method to create a matcher to check whether agent received a error response (response code between 400 and 699) for the specified earlier request.
static org.hamcrest.Matcher<SIPAgent> recvdFinalResponse(BaseState state)
          Factory method to create a matcher to check whether agent received a final response (response code between 200 and 699) in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdFinalResponse(CommandId cmdId)
          Factory method to create a matcher to check whether agent received a final response (response code between 200 and 699) for the specified earlier request.
static org.hamcrest.Matcher<SIPAgent> recvdMessage(BaseState state, MessageComparator comparator)
          Factory method to create a matcher to check whether agent received a message with particular properties in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdMessage(CommandId cmdId, MessageComparator comparator)
          Factory method to create a matcher to check whether agent received a response with particular properties to a request sent earlier.
static org.hamcrest.Matcher<SIPAgent> recvdMessage(MessageComparator comparator)
          Factory method to create a matcher to check whether agent ever received a message with specific properties.
static org.hamcrest.Matcher<SIPAgent> recvdNewSDP()
          Factory method to create a matcher to check whether an agent has received a different SDP since the last call to SIPAgent.markSDP() on the agent.
static org.hamcrest.Matcher<SIPAgent> recvdNewSDP(boolean temporal)
          Factory method to create a matcher to check whether an agent has received a SDP since the last call to SIPAgent.markSDP() on the agent.
static org.hamcrest.Matcher<SIPAgent> recvdProvisionalResponse(BaseState state)
          Factory method to create a matcher to check whether agent received a provisional response (response code between 100 and 199) in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdProvisionalResponse(CommandId cmdId)
          Factory method to create a matcher to check whether agent received a provisional response (response code between 100 and 199) for the specified earlier request.
static org.hamcrest.Matcher<SIPAgent> recvdRedirectResponse(BaseState state)
          Factory method to create a matcher to check whether agent received a redirect response (response code between 300 and 399) in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdRedirectResponse(CommandId cmdId)
          Factory method to create a matcher to check whether agent received a rediect response (response code between 300 and 399) for the specified earlier request.
static org.hamcrest.Matcher<SIPAgent> recvdRequest(BaseState state, java.lang.String method)
          Factory method to create a matcher to check whether agent received a request with the specified method in the specified state
static org.hamcrest.Matcher<SIPAgent> recvdRequest(java.lang.String method)
          Factory method to create a matcher to check whether agent ever received a request with the specified method
static org.hamcrest.Matcher<SIPAgent> recvdRequest(java.lang.String method, java.util.regex.Pattern messagePattern, java.util.regex.Pattern contentPattern)
          Factory method to create a matcher to check whether agent received a request with the specified method and the message satisfies the specified regex pattern and the message body sastisfies the specified regex pattern.
static org.hamcrest.Matcher<SIPAgent> recvdResponse(BaseState state, int respCode)
          Factory method to create a matcher to check whether agent received a response with the specified response code in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdResponse(BaseState state, int respCode1, int respCode2)
          Factory method to create a matcher to check whether agent received a response in the specified state and the response code is in the specified range.
static org.hamcrest.Matcher<SIPAgent> recvdResponse(CommandId cmdId, int respCode)
          Factory method to create a matcher to check whether agent received a response for a specified earlier request and with specified response code.
static org.hamcrest.Matcher<SIPAgent> recvdResponse(CommandId cmdId, int respCode1, int respCode2)
          Factory method to create a matcher to check whether agent received a response for a specified earlier request and with response code in the specified range.
static org.hamcrest.Matcher<SIPAgent> recvdResponse(CommandId cmdId, int respCode, java.util.regex.Pattern messagePattern, java.util.regex.Pattern contentPattern)
           
static org.hamcrest.Matcher<SIPAgent> recvdResponse(int respCode)
          Factory method to create a matcher to check whether agent ever received a response with the specified response code.
static org.hamcrest.Matcher<SIPAgent> recvdResponse(int respCode, java.util.regex.Pattern messagePattern, java.util.regex.Pattern contentPattern)
          Factory method to create a matcher to check whether agent received a response with the specified response code and the response satisfies the specified regex pattern and the response body sastisfies the specified regex pattern.
static org.hamcrest.Matcher<SIPAgent> recvdSuccessResponse(BaseState state)
          Factory method to create a matcher to check whether agent received a success response (response code between 200 and 299) in the specified state.
static org.hamcrest.Matcher<SIPAgent> recvdSuccessResponse(CommandId cmdId)
          Factory method to create a matcher to check whether agent received a success response (response code between 200 and 299) for the specified earlier request.
static org.hamcrest.Matcher<SIPAgent> sentMessage(BaseState state, MessageComparator comparator)
          Factory method to create a matcher to check whether agent sent a message with specific properties in the specified state.
static org.hamcrest.Matcher<SIPAgent> sentMessage(MessageComparator comparator)
          Factory method to create a matcher to check whether agent ever sent a message with specific properties.
static org.hamcrest.Matcher<SIPAgent> sentRequest(BaseState state, java.lang.String method)
          Factory method to create a matcher to check whether agent sent a request with the specified method in the specified state.
static org.hamcrest.Matcher<SIPAgent> sentRequest(java.lang.String method)
          Factory method to create a matcher to check whether agent ever sent a request with the specified method.
static org.hamcrest.Matcher<SIPAgent> sentResponse(BaseState state, int respCode)
          Factory method to create a matcher to check whether agent sent a response with the specified response code in the specified state.
static org.hamcrest.Matcher<SIPAgent> sentResponse(int respCode)
          Factory method to create a matcher to check whether agent sent a response with the specified response code.
static org.hamcrest.Matcher<SIPAgent> zeroPortSDP()
          Factory method to create a matcher to check whether agent has current SDP in which all media descriptions have port 0.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

has

public static <T> org.hamcrest.Matcher<T> has(org.hamcrest.Matcher<T> matcher)
Syntactic sugar to improve readability.


no

public static <T> org.hamcrest.Matcher<T> no(org.hamcrest.Matcher<T> matcher)
Syntactic sugar to improve readability.


recvdNewSDP

public static org.hamcrest.Matcher<SIPAgent> recvdNewSDP()
Factory method to create a matcher to check whether an agent has received a different SDP since the last call to SIPAgent.markSDP() on the agent. This is the same as recvdNewSDP(false).

agent.markSDP();
....
//i am expecting a re-INVITE here for agent with
//a different SDP from the marked SDP.
....
assertThat(agent, has (recvdNewSDP()));


recvdNewSDP

public static org.hamcrest.Matcher<SIPAgent> recvdNewSDP(boolean temporal)
Factory method to create a matcher to check whether an agent has received a SDP since the last call to SIPAgent.markSDP() on the agent. If the marked SDP (SDP saved by markSDP()) is different from the latest SDP received, then this method returns true, irrespective of the value of the argument passed. If the SDPs are the same, a true argument causes a temporal comparison between the SDPs i.e., the time stamp of the received SDPs are compared and if different, a true is returned.

agent.markSDP();
....
//i am expecting a re-INVITE here for agent with
//the same or different SDP as the marked SDP
....
assertThat(agent, has (recvdNewSDP(true)));

Parameters:
temporal - whether SDPs should be compared temporally if they are same.

idle

public static org.hamcrest.Matcher<SIPAgent> idle()
Factory method to create a matcher to check whether the current state of an agent is idle.

assertThat(agent, is (idle()) );


invited

public static org.hamcrest.Matcher<SIPAgent> invited()
Factory method to create a matcher to check whether an agent is in a state where it has received an INVITE.

agent1.call(agent2);
processSIP(3000);
assertThat(agent2, is (invited()) );


connected

public static org.hamcrest.Matcher<SIPAgent> connected()
Factory method to create a matcher to check whether an agent is in a SIP dialog.

agent1.call(agent2);
processSIP(3000);
assertThat(agent2, is (invited()) );
agent2.answer();
processSIP(2000);
assertThat(agent1, is (connected()) );


disconnected

public static org.hamcrest.Matcher<SIPAgent> disconnected()
Factory method to create a matcher to check whether an agent has terminated its SIP dialog.

//agent1 and agent2 are in a call
agent2.end();
processSIP(2000);
assertThat(agent1, is (disconnected()) );
assertThat(agent2, is (disconnected()) );


connectedTo

public static org.hamcrest.Matcher<SIPAgent> connectedTo(SIPAgent peerAgent)
Factory method to create a matcher to check whether an agent is connected to another agent. This includes checking whether the agents are in the appropriate states and the agents have correctly exchanged their SDPs. In the following example, this matcher checks whether agent1 has received agent2's media SDP and vice-versa. Note that this matcher works only in cases where the agents have each other's SDP - i.e. media flows directly between the agents.

agent1.call(agent2);
processSIP(3000);
assertThat(agent2, is (invited()) );
agent2.answer();
processSIP(2000);
assertThat(agent1, is (connectedTo(agent2)) );


incomingMedia

public static org.hamcrest.Matcher<SIPAgent> incomingMedia()
Factory method to create a matcher to check whether agent has RTP packets in its media buffer.


inState

public static org.hamcrest.Matcher<SIPAgent> inState(BaseState expectedState)
Factory method for matcher to check whether agent is in a specific state.

agent1.call(agent2);
processSIP(3000);
assertThat(agent2, is (inState(CATState.Invited)));


recvdMessage

public static org.hamcrest.Matcher<SIPAgent> recvdMessage(BaseState state,
                                                          MessageComparator comparator)
Factory method to create a matcher to check whether agent received a message with particular properties in the specified state. User must pass in an implementation of the MessageComparator interface. This implementation must check whether the message satisfies a particular property.

MessageComparator msgComparator =
new MessageComparator() {
public boolean compare(final javax.sip.message.Message msg) {
//user can check any property on the message using JAIN-SIP API.
}
}

agent1.call(agent2);
processSIP(3000);
assertThat(agent2, recvdMessage(CATState.Idle, msgComparator);

Parameters:
state - State of agent
comparator - A message comparator that implements the MessageComparator interface.

recvdMessage

public static org.hamcrest.Matcher<SIPAgent> recvdMessage(CommandId cmdId,
                                                          MessageComparator comparator)
Factory method to create a matcher to check whether agent received a response with particular properties to a request sent earlier.

MessageComparator msgComparator = new MessageComparator() { public boolean compare(final javax.sip.message.Message msg) { //user can check any property on the message using JAIN-SIP API. } } CommandId callCmd = agent1.call(agent2); processSIP(3000); assertThat(agent2, recvdMessage(callCmd, msgComparator);

Parameters:
cmdId - identifier for the earlier request
comparator - A message comparator that implements the MessageComparator interface.

sentMessage

public static org.hamcrest.Matcher<SIPAgent> sentMessage(BaseState state,
                                                         MessageComparator comparator)
Factory method to create a matcher to check whether agent sent a message with specific properties in the specified state.

Parameters:
state - Agent machine state
comparator - User specified message comparator

recvdMessage

public static org.hamcrest.Matcher<SIPAgent> recvdMessage(MessageComparator comparator)
Factory method to create a matcher to check whether agent ever received a message with specific properties.


sentMessage

public static org.hamcrest.Matcher<SIPAgent> sentMessage(MessageComparator comparator)
Factory method to create a matcher to check whether agent ever sent a message with specific properties.


recvdRequest

public static org.hamcrest.Matcher<SIPAgent> recvdRequest(java.lang.String method)
Factory method to create a matcher to check whether agent ever received a request with the specified method


recvdRequest

public static org.hamcrest.Matcher<SIPAgent> recvdRequest(BaseState state,
                                                          java.lang.String method)
Factory method to create a matcher to check whether agent received a request with the specified method in the specified state


recvdRequest

public static org.hamcrest.Matcher<SIPAgent> recvdRequest(java.lang.String method,
                                                          java.util.regex.Pattern messagePattern,
                                                          java.util.regex.Pattern contentPattern)
Factory method to create a matcher to check whether agent received a request with the specified method and the message satisfies the specified regex pattern and the message body sastisfies the specified regex pattern.

Parameters:
method - Request method
messagePattern - regex pattern to search in the request
contentPattern - regex pattern to search in the content of the request, if any.

recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(int respCode)
Factory method to create a matcher to check whether agent ever received a response with the specified response code.


recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(BaseState state,
                                                           int respCode1,
                                                           int respCode2)
Factory method to create a matcher to check whether agent received a response in the specified state and the response code is in the specified range.

Parameters:
state - agent state
respCode1 - start of range for response code
respCode2 - end of range for response code

recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(int respCode,
                                                           java.util.regex.Pattern messagePattern,
                                                           java.util.regex.Pattern contentPattern)
Factory method to create a matcher to check whether agent received a response with the specified response code and the response satisfies the specified regex pattern and the response body sastisfies the specified regex pattern.

Parameters:
respCode - response code
messagePattern - regex pattern to search in the response
contentPattern - regex pattern to search in the content of the response, if any.

recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(BaseState state,
                                                           int respCode)
Factory method to create a matcher to check whether agent received a response with the specified response code in the specified state.


recvdProvisionalResponse

public static org.hamcrest.Matcher<SIPAgent> recvdProvisionalResponse(BaseState state)
Factory method to create a matcher to check whether agent received a provisional response (response code between 100 and 199) in the specified state.


recvdFinalResponse

public static org.hamcrest.Matcher<SIPAgent> recvdFinalResponse(BaseState state)
Factory method to create a matcher to check whether agent received a final response (response code between 200 and 699) in the specified state.


recvdSuccessResponse

public static org.hamcrest.Matcher<SIPAgent> recvdSuccessResponse(BaseState state)
Factory method to create a matcher to check whether agent received a success response (response code between 200 and 299) in the specified state.


recvdRedirectResponse

public static org.hamcrest.Matcher<SIPAgent> recvdRedirectResponse(BaseState state)
Factory method to create a matcher to check whether agent received a redirect response (response code between 300 and 399) in the specified state.


recvdErrorResponse

public static org.hamcrest.Matcher<SIPAgent> recvdErrorResponse(BaseState state)
Factory method to create a matcher to check whether agent received an error response (response code between 400 and 699) in the specified state.


recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(CommandId cmdId,
                                                           int respCode1,
                                                           int respCode2)
Factory method to create a matcher to check whether agent received a response for a specified earlier request and with response code in the specified range.

Parameters:
cmdId - id of earlier request
respCode1 - start of range for response code
respCode2 - end of range for response code

recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(CommandId cmdId,
                                                           int respCode)
Factory method to create a matcher to check whether agent received a response for a specified earlier request and with specified response code.

Parameters:
cmdId - id of earlier request
respCode - response code

recvdResponse

public static org.hamcrest.Matcher<SIPAgent> recvdResponse(CommandId cmdId,
                                                           int respCode,
                                                           java.util.regex.Pattern messagePattern,
                                                           java.util.regex.Pattern contentPattern)

recvdProvisionalResponse

public static org.hamcrest.Matcher<SIPAgent> recvdProvisionalResponse(CommandId cmdId)
Factory method to create a matcher to check whether agent received a provisional response (response code between 100 and 199) for the specified earlier request.


recvdFinalResponse

public static org.hamcrest.Matcher<SIPAgent> recvdFinalResponse(CommandId cmdId)
Factory method to create a matcher to check whether agent received a final response (response code between 200 and 699) for the specified earlier request.


recvdSuccessResponse

public static org.hamcrest.Matcher<SIPAgent> recvdSuccessResponse(CommandId cmdId)
Factory method to create a matcher to check whether agent received a success response (response code between 200 and 299) for the specified earlier request.


recvdRedirectResponse

public static org.hamcrest.Matcher<SIPAgent> recvdRedirectResponse(CommandId cmdId)
Factory method to create a matcher to check whether agent received a rediect response (response code between 300 and 399) for the specified earlier request.


recvdErrorResponse

public static org.hamcrest.Matcher<SIPAgent> recvdErrorResponse(CommandId cmdId)
Factory method to create a matcher to check whether agent received a error response (response code between 400 and 699) for the specified earlier request.


sentRequest

public static org.hamcrest.Matcher<SIPAgent> sentRequest(java.lang.String method)
Factory method to create a matcher to check whether agent ever sent a request with the specified method.


sentRequest

public static org.hamcrest.Matcher<SIPAgent> sentRequest(BaseState state,
                                                         java.lang.String method)
Factory method to create a matcher to check whether agent sent a request with the specified method in the specified state.


sentResponse

public static org.hamcrest.Matcher<SIPAgent> sentResponse(int respCode)
Factory method to create a matcher to check whether agent sent a response with the specified response code.


sentResponse

public static org.hamcrest.Matcher<SIPAgent> sentResponse(BaseState state,
                                                          int respCode)
Factory method to create a matcher to check whether agent sent a response with the specified response code in the specified state.


blackHoleSDP

public static org.hamcrest.Matcher<SIPAgent> blackHoleSDP()
Factory method to create a matcher to check whether agent has current SDP with "black-hole" connection address (0.0.0.0)


zeroPortSDP

public static org.hamcrest.Matcher<SIPAgent> zeroPortSDP()
Factory method to create a matcher to check whether agent has current SDP in which all media descriptions have port 0.


onHold

public static org.hamcrest.Matcher<SIPAgent> onHold()
Factory method to create a matcher to check whether agent is on hold, either via "black-hole" SDP, or SDP in which all media descriptions have port 0.