Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
  * Conditions Of Use
  *
  * This software was developed by employees of the National Institute of
  * Standards and Technology (NIST), and others.
  * This software is has been contributed to the public domain.
  * As a result, a formal license is not needed to use the software.
  *
  * This software is provided "AS IS."
 * NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
 * AND DATA ACCURACY.  NIST does not warrant or make any representations
 * regarding the use of the software or the results thereof, including but
 * not limited to the correctness, accuracy, reliability or usefulness of
 * the software.
 *
 *
 */
 package test.tck.msgflow;
 
 
 
 
Timeout test for invite client transactions -- test to see if an timeout event is delivered to the listener if the RI refuses to send OK to the INVITE Client Tx.

Author(s):
M. Ranganathan
 
 
     private static Logger logger = Logger
             .getLogger(InviteClientTransactionsStateMachineTest.class);
 
     public TransactionTimeoutEventTest(String name) {
         super(namefalse); // disable auto-dialog for the RI, else ACKs get
                             // filtered out
     }
 
     // ==================== tests ==============================
 
    
Test if the tx timeout is delivered.
 
     public void testClientTransactionTimeout() {
         try {
             Request invite = createTiInviteRequest(nullnullnull);
             ClientTransaction tran = null;
             try {
                 .collectRequestEvent();
 
                 tran = .getNewClientTransaction(invite);
                 tran.sendRequest();
             } catch (SipException ex) {
                 throw new TiUnexpectedError(
                         "A SipExceptionOccurred while trying to send request!",
                         ex);
             } catch (TooManyListenersException ex) {
                 throw new TckInternalError(
                         "Failed to regiest a SipListener with an RI SipProvider",
                         ex);
             }
             waitForMessage();
             RequestEvent inviteReceivedEvent = 
                     .extractCollectedRequestEvent();
             assertNotNull("RequestEvent"inviteReceivedEvent);
             try {
                 .collectTimeoutEvent();
             } catch (TooManyListenersException ex) {
                 throw new TiUnexpectedError(
                         "Failed to register a SipListener with TI"ex);
             }
             waitForTimeout();
             TimeoutEvent timeoutEvent = 
                     .extractCollectedTimeoutEvent();
             assertNotNull("Timeout event"timeoutEvent);
             assertTrue("Timeout event type "timeoutEvent.getTimeout().equals(
                     .));
         } catch (Exception ex) {
             .error("unexpected exception "ex);
             ex.printStackTrace();
             fail("unexpected exception");
        }
    }
    public void testServerTransactionForTimeout() {
        try {
            Request invite = createRiInviteRequest(nullnullnull);
            ClientTransaction tran = null;
            try {
                .collectRequestEvent();
                tran = .getNewClientTransaction(invite);
                tran.sendRequest();
            } catch (SipException ex) {
                throw new TiUnexpectedError(
                        "A SipExceptionOccurred while trying to send request!",
                        ex);
            } catch (TooManyListenersException ex) {
                throw new TckInternalError(
                        "Failed to regiest a SipListener with an RI SipProvider",
                        ex);
            }
            waitForMessage();
            RequestEvent inviteReceivedEvent = 
                    .extractCollectedRequestEvent();
            assertNotNull("RequestEvent not seen at TI"inviteReceivedEvent);
            assertTrue("Server Transaction MUST be null"inviteReceivedEvent
                    .getServerTransaction() == null);
            ServerTransaction st = 
                    .getNewServerTransaction(inviteReceivedEvent.getRequest());
            Response response = .createResponse(.,
                    inviteReceivedEvent.getRequest());
            ToHeader toHeader = (ToHeaderresponse.getHeader(.);
            toHeader.setTag("123456");
            ContactHeader contact = super.createTiContact();
            response.setHeader(contact);
            st.sendResponse(response);
            waitForTimeout();
            TimeoutEvent timeoutEvent = 
                    .extractCollectedTimeoutEvent();
            assertNull("Timeout event"timeoutEvent);
            //assertNotNull("Timeout event", timeoutEvent);
            //assertTrue("Timeout event type must be TRANSACTION ", timeoutEvent
                //.getTimeout().equals(Timeout.TRANSACTION));
        } catch (Exception ex) {
            .error("unexpected exception "ex);
            ex.printStackTrace();
            fail("unexpected exception");
        }
    }
        try {
            Request invite = createRiInviteRequest(nullnullnull);
            ClientTransaction tran = null;
            .setAutomaticDialogSupportEnabled(false);
            try {
                .collectRequestEvent();
                tran = .getNewClientTransaction(invite);
                tran.sendRequest();
            } catch (SipException ex) {
                throw new TiUnexpectedError(
                        "A SipExceptionOccurred while trying to send request!",
                        ex);
            } catch (TooManyListenersException ex) {
                throw new TckInternalError(
                        "Failed to regiest a SipListener with an RI SipProvider",
                        ex);
            }
            waitForMessage();
            RequestEvent inviteReceivedEvent = 
                    .extractCollectedRequestEvent();
            assertNotNull("RequestEvent not seen at TI"inviteReceivedEvent);
            assertTrue("Server Transaction MUST be null"inviteReceivedEvent
                    .getServerTransaction() == null);
            ServerTransaction st = 
                    .getNewServerTransaction(inviteReceivedEvent.getRequest());
            Response response = .createResponse(.,
                    inviteReceivedEvent.getRequest());
            ToHeader toHeader = (ToHeaderresponse.getHeader(.);
            toHeader.setTag("1234567");
            ContactHeader contact = super.createTiContact();
            response.setHeader(contact);
            st.enableRetransmissionAlerts();
            st.sendResponse(response);
            waitForTimeout();
            TimeoutEvent timeoutEvent = 
                    .extractCollectedTimeoutEvent();
            assertNotNull("Timeout event not found "timeoutEvent);
            assertTrue("Timeout event type must be retransmit "timeoutEvent
                    .getTimeout().equals(.));
        } catch (Exception ex) {
            .error("unexpected exception "ex);
            ex.printStackTrace();
            fail("unexpected exception");
        }
    }
New to GrepCode? Check out our FAQ X