|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SIPAgent
SIPAgent serves as the user interface for SIP endpoints in a KitCAT
test case. An instance of SIPAgent is created using createAgent
factory
method in CATTestCase
. Once an agent is created, the test writer can perform
operations on an agent using the API below. Example operations on
an agent are - make a call to another endpoint, answer a call from
another endpoint, send DTMF key sequence, etc. The internal
implementation of this interface in KitCAT uses a state machine to
drive the SIP interaction. Assertions can be performed on agents
using the assertThat
JUnit primitive that takes in
as argument a KitCAT matcher object (see CATMatchers
). A SIPAgent is not
thread-safe. Only one thread (the main test case runner thread)
should access the SIPAgent methods.
Field Summary | |
---|---|
static java.lang.String |
rcsid
|
Method Summary | |
---|---|
void |
addMessageModifier(MessageModifier modifier)
Adds a message modifier. |
CommandId |
answer()
Send a 200 OK response to the peer endpoint |
CommandId |
call(SIPAgent callee)
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee |
CommandId |
call(SIPAgent callee,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee and with the
additional headers specified |
CommandId |
call(SIPAgent callee,
java.lang.String fromUri)
Sends an INVITE with the request URI containing the SipURI of the agent specified in callee and From header
containing the value specified in fromUri . |
CommandId |
call(java.lang.String calleeUri)
Sends an INVITE with the request URI containing the value specified in calleeUri |
CommandId |
call(java.lang.String sipuri,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap)
Sends an INVITE with the request URI containing the value specified in sipuri and with the additional
headers specified |
CommandId |
call(java.lang.String calleeUri,
java.lang.String fromUri)
Sends an INVITE with the request URI containing the value specified in calleeUri and From header containing
the value specified in fromUri . |
CommandId |
callNoSdp(SIPAgent callee)
Variant of call method where no SDP is sent |
CommandId |
callNoSdp(SIPAgent callee,
java.lang.String fromUri)
Variant of call method where no SDP is sent |
CommandId |
callNoSdp(java.lang.String calleeUri)
Variant of call method where no SDP is sent |
CommandId |
callNoSdp(java.lang.String calleeUri,
java.lang.String fromUri)
Variant of call method where no SDP is sent |
CommandId |
cancel()
Send a CANCEL to the peer endpoint |
void |
clearMediaBuffer()
This primitive clears the internal data structures within a agent used to keep track of the received RTP packets. |
void |
enableAutoAnswer()
Sends a 200 OK response to an incoming INVITE without any explicit answer() command from the test case. |
CommandId |
end()
Send a BYE to the peer endpoint |
CommandId |
execUserCommand(UserCommand command)
Execute user command. |
BaseState |
getCurrentState()
Get the current state of the agent state machine |
java.lang.String |
getDTMFReceived()
Gets the DTMF digits that were received earlier as part of the RTP stream and then stored in a buffer. |
java.lang.String |
getLastRecvdSDPAsString()
Get the last received SDP in string format |
java.lang.String |
getName()
Get the name of the agent |
java.lang.String |
getProxy()
Get the SIP address of the proxy server this agent points to. |
java.util.List<Response> |
getResponses(CommandId cmdId,
int respCode)
Returns the list of responses for the request indicated by cmdId and with response code respCode . |
java.lang.String |
getRTPCaptureFileName()
Returns the name of the file in which the RTP packets are captured. |
java.lang.String |
getRTPIP()
Gets the IP address being used for listening in RTP sessions |
int |
getRTPPort()
Gets port number being used for listening in RTP sessions |
SipURI |
getSipURI()
Get the SIP URI of this agent as a SipURI so that it can be used in methods like call , answer . |
java.lang.String |
getSipURIAsString()
Get the SIP URI of this agent as a string so that it can be used in methods like call , answer . |
CommandId |
info(java.lang.String contentType,
java.lang.String contentSubType,
java.lang.String content)
Send a INFO message to the peer endpoint with the specified content type, content subtype and content. |
void |
markSDP()
Saves the latest SDP received from the peer agent as a result of session negotiation. |
void |
playAudio(java.io.InputStream stream)
Play raw audio from the specified input stream. |
void |
playAudio(java.lang.String fileName)
Play raw audio from the file name specified. |
void |
printMessageHistory()
Print the history of SIP messages received/sent by this agent |
void |
pushRoute(java.lang.String route)
Specify route header(s) that needs to be included as part of an initial INVITE message that may be sent later. |
void |
pushSelfRoute()
Specify a self route header that needs to be sent as part of an initial INVITE message that may be sent later. |
void |
recycle()
Resets the agent and makes it ready for use again even after an end |
CommandId |
redirect(int redirectCode,
Address address)
Send a 302 redirect response to the peer endpoint with the specified contact address in the response |
CommandId |
redirect(int redirectCode,
SipURI sipuri)
Send a 302 redirect response to the peer endpoint with the specified contact URI in the response |
CommandId |
redirect(int redirectCode,
java.lang.String address)
Send a 302 redirect response to the peer endpoint with the specified contact address in the response |
CommandId |
register(java.lang.String domain,
java.lang.String userid,
java.lang.String passwd)
Sends a REGISTER message. |
CommandId |
register(java.lang.String domain,
java.lang.String userid,
java.lang.String passwd,
int expires)
Sends a REGISTER message. |
CommandId |
reinvite()
Send a re-INVITE to the peer endpoint with no change in SDPs. |
CommandId |
reinvite(SDPModifier sdpModifier)
Send a re-INVITE to the peer endpoint with changes in SDP, the changes specified using the SDPModifier. |
CommandId |
reinviteHold()
Send a re-INVITE to the peer endpoint with a hold SDP (a=sendonly media attribute). |
CommandId |
reinviteNoSdp()
Send a re-INVITE with no SDP to solicit an offer from the peer endpoint. |
CommandId |
reinviteResume()
Send a re-INVITE to the peer endpoint with a normal SDP (a=sendrecv media attribute). |
void |
removeAllMessageModifiers()
Removes all previously added message modifiers. |
void |
removeMessageModifier(MessageModifier modifier)
Removes a previously added message modifier. |
CommandId |
sendDTMF(java.lang.String keys)
Sends DTMF keys to the remote SIP agent with which this agent has already established a SIP dialog and started an RTP session. |
CommandId |
sendResponse(int responseCode)
Send a response to the peer end point with the response code specified as parameter |
void |
setProxy(java.lang.String proxy)
Sets the proxy for this agent. |
void |
setStepMode(boolean b)
Turns on/off user agent step execution mode. |
void |
step()
Takes default action for the most recently received message. |
int |
waitForRtpAbsence(int silenceDuration,
int maxWait)
EXPERIMENTAL. |
int |
waitForRtpPresence(int maxWait)
EXPERIMENTAL. |
Field Detail |
---|
static final java.lang.String rcsid
Method Detail |
---|
java.lang.String getName()
java.lang.String getProxy()
java.lang.String getSipURIAsString() throws CATException
call
, answer
.
CATException
- If an exception occuredSipURI getSipURI() throws CATException
call
, answer
.
CATException
- If an exception occuredvoid setProxy(java.lang.String proxy) throws CATException
CATException
CommandId sendDTMF(java.lang.String keys) throws CATException
CATException
CommandId register(java.lang.String domain, java.lang.String userid, java.lang.String passwd) throws CATException
sip:domain
, From header contains
sip:agentName@domain
, To header contains
sip:agentName@domain
. The userid and passwd
parameters are used only for MD5 digest authentication after
the agent receives a challenge response. If no authentication
is needed, these fields can be empty. The registration expiry
time is internally set to 3600. The expiry time is sent in the
REGISTER message using an Expiry header although this may be
subject to change in the future.
domain
- domain for registrationuserid
- userid for registrationpasswd
- password for registration
CATException
CommandId register(java.lang.String domain, java.lang.String userid, java.lang.String passwd, int expires) throws CATException
sip:domain
, From header contains
sip:agentName@domain
, To header contains
sip:agentName@domain
. The userid and passwd
parameters are used only for MD5 digest authentication after
the agent receives a challenge response. If no authentication
is needed, these fields can be empty. The specified expiry
time is sent in the REGISTER message using an Expiry header
although this may be subject to change in the future.
domain
- domain for registrationuserid
- userid for registrationpasswd
- password for registrationexpires
- registration expiry
CATException
CommandId execUserCommand(UserCommand command) throws CATException
CATException
void pushRoute(java.lang.String route) throws CATException
agent1.pushRoute("sip:R1.abc.com;lr");
agent1.pushRoute("sip:R2.xyz.com;lr");
agent1.pushSelfRoute();
The above example will result in the following route headers in
the initial INVITE message
Route: <sip:thisagent@this.host;lr>,
<sip:R2.xyz.com;lr>,
<sip:R1.abc.com;lr>
Note that using the setProxy
method adds another
route header to the specified proxy at the very top. In the
above example, the addition of the following statement
agent.setProxy("proxy.lmn.com");
results in the addition of a route header to the proxy as the
very first route header irrespective of the relative ordering
of the setProxy
and the pushRoute
calls. The resulting route headers will be as follows:
Route: <sip:proxy.lmn.com;lr>,
<sip:thisagent@this.host;lr>,
<sip:R2.xyz.com;lr>,
<sip:R1.abc.com;lr>
CATException
void pushSelfRoute() throws CATException
CATException
CommandId call(java.lang.String calleeUri) throws CATException
calleeUri
CATException
CommandId call(java.lang.String calleeUri, java.lang.String fromUri) throws CATException
calleeUri
and From header containing
the value specified in fromUri
.
CATException
CommandId call(SIPAgent callee) throws CATException
callee
CATException
CommandId call(SIPAgent callee, java.lang.String fromUri) throws CATException
callee
and From header
containing the value specified in fromUri
.
CATException
CommandId call(SIPAgent callee, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap) throws CATException
callee
and with the
additional headers specified
CATException
CommandId call(java.lang.String sipuri, java.util.Map<java.lang.String,java.util.List<java.lang.String>> headerMap) throws CATException
sipuri
and with the additional
headers specified
CATException
CommandId callNoSdp(java.lang.String calleeUri) throws CATException
call
method where no SDP is sent
CATException
CommandId callNoSdp(java.lang.String calleeUri, java.lang.String fromUri) throws CATException
call
method where no SDP is sent
CATException
CommandId callNoSdp(SIPAgent callee) throws CATException
call
method where no SDP is sent
CATException
CommandId callNoSdp(SIPAgent callee, java.lang.String fromUri) throws CATException
call
method where no SDP is sent
CATException
CommandId reinvite() throws CATException
CATException
CommandId reinviteHold() throws CATException
CATException
CommandId reinviteResume() throws CATException
CATException
CommandId reinvite(SDPModifier sdpModifier) throws CATException
CATException
CommandId reinviteNoSdp() throws CATException
CATException
CommandId sendResponse(int responseCode) throws CATException
CATException
CommandId cancel() throws CATException
CATException
CommandId answer() throws CATException
CATException
CommandId redirect(int redirectCode, java.lang.String address) throws CATException
CATException
CommandId redirect(int redirectCode, SipURI sipuri) throws CATException
CATException
CommandId redirect(int redirectCode, Address address) throws CATException
CATException
CommandId end() throws CATException
CATException
void recycle() throws CATException
CATException
CommandId info(java.lang.String contentType, java.lang.String contentSubType, java.lang.String content) throws CATException
CATException
BaseState getCurrentState()
void clearMediaBuffer()
//assume agent1 and agent2 are in a call
agent1.clearMediaBuffer();
agent2.playAudio("hello.raw");
processSIP(3000);
assertThat(agent1, has (incomingMedia()));
agent1
first and send audio packets to
agent1
. Then we assert whether any RTP packets
were received by agent1
.
Irrespective of calls to this primitive, all the RTP packets
received by an agent over its lifetime are stored in an
agent-specific disk file.
void playAudio(java.lang.String fileName) throws CATException
CATException
void playAudio(java.io.InputStream stream) throws CATException
CATException
void addMessageModifier(MessageModifier modifier) throws CATException
HeaderAddHelper
) of this
method is to add user-defined headers to ALL messages that are
sent out by an agent to which this modifier is added. For each
message that is sent out, this modifier gets invoked and this
modifier adds the specified headers to the message. To specify
additional headers only during call establishment, use the
call
method with
header map argument.
CATException
void removeMessageModifier(MessageModifier modifier) throws CATException
CATException
void removeAllMessageModifiers() throws CATException
CATException
void printMessageHistory()
java.lang.String getLastRecvdSDPAsString()
void markSDP()
CATMatchers.recvdNewSDP()
.
java.lang.String getRTPIP()
int getRTPPort()
void setStepMode(boolean b) throws java.lang.Exception
SIPAgent caller = createAgent("caller");
SIPAgent callee = createAgent("callee");
CommandId inv = caller.call(callee);
processSIP(1000);
assertThat(callee, invited());
callee.answer();
processSIP(1000);
assertThat(callee, connectedTo(caller));
//from this point on, turn on step execution mode
//for callee
callee.setStepMode(true);
CommandId cmd = caller.end();
processSIP(1000);
assertThat(callee, recvdRequest("BYE"));
//send a error response to the BYE.
caller.sendResponse(500);
processSIP(1000);
assertThat(caller, recvdResponse(cmd, 500));
//from this point on, turn on step execution mode
//for callee
callee.setStepMode(true);
CommandId cmd = caller.end();
processSIP(1000);
assertThat(callee, recvdRequest("BYE"));
//resume default execution. this causes callee to
//send a default 200 OK response to the BYE.
callee.setStepMode(false);
processSIP(1000);
assertThat(caller, recvdResponse(cmd, 200));
java.lang.Exception
void step() throws java.lang.Exception
setStepMode(boolean)
(true)). Invoking
this method causes an agent to proceed with default execution
until the next "breakpoint".
......caller connected to callee at this point.......
//from this point on, turn on step execution mode
//for callee
callee.setStepMode(true);
CommandId cmd = caller.end();
processSIP(1000);
assertThat(callee, recvdRequest("BYE"));
//perform default execution which sends a 200
//OK response to BYE
caller.step();
processSIP(1000);
assertThat(caller, recvdResponse(cmd, 200));
//resume default execution for callee
callee.setStepMode(false);
java.lang.Exception
java.lang.String getRTPCaptureFileName()
java.util.List<Response> getResponses(CommandId cmdId, int respCode)
cmdId
and with response code respCode
.
void enableAutoAnswer()
java.lang.String getDTMFReceived()
int waitForRtpAbsence(int silenceDuration, int maxWait) throws CATException
Wait for absence of incoming RTP
packets for a minimum duration specified by
silenceDuration
. On reaching the
maxWait
duration, returns -1, else returns 0.
CATException
int waitForRtpPresence(int maxWait) throws CATException
Wait for presence of incoming RTP
packets. On reaching the maxWait
duration, returns
-1, else returns 0.
CATException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |