コード例 #1
0
 /** Test whether new ClientTransactions are properly created. */
 public void testGetNewClientTransaction() {
   try {
     Request invite = createTiInviteRequest(null, null, null);
     ClientTransaction tran = null;
     try {
       tran = tiSipProvider.getNewClientTransaction(invite);
     } catch (TransactionUnavailableException exc) {
       exc.printStackTrace();
       fail(
           "A TransactionUnavailableException was thrown while trying to "
               + "create a new client transaction");
     }
     assertNotNull(
         "A null ClientTransaction was returned by SipProvider." + "getNewClientTransaction().",
         tran);
     String tranBranch = tran.getBranchId();
     String reqBranch = ((ViaHeader) invite.getHeader(ViaHeader.NAME)).getBranch();
     assertEquals(
         "The newly created transaction did not have the same "
             + "branch id as the request that created it",
         tranBranch,
         reqBranch);
     assertNotNull(
         "The newly created transaction returned a null Dialog. "
             + "Please check the docs on Transaction.getDialog()",
         tran.getDialog());
     assertNotNull(
         "The transaction's getRequest() method returned a null Request ", tran.getRequest());
     assertEquals(
         "The transaction's getRequest() method returned a Request "
             + "that did not match the one that we used to create it!",
         tran.getRequest(),
         invite);
   } catch (Throwable exc) {
     exc.printStackTrace();
     fail(exc.getClass().getName() + ": " + exc.getMessage());
   }
   assertTrue(new Exception().getStackTrace()[0].toString(), true);
 }
コード例 #2
0
 /**
  * Sends a request from the RI and tests whether the tested implementation properly creates a
  * ServerTransaction.
  */
 public void testGetNewServerTransaction() {
   try {
     Request invite = createRiInviteRequest(null, null, null);
     ServerTransaction tran = null;
     RequestEvent receivedRequestEvent = null;
     try {
       // Send using RI and collect using TI
       eventCollector.collectRequestEvent(tiSipProvider);
       riSipProvider.sendRequest(invite);
       waitForMessage();
       receivedRequestEvent = eventCollector.extractCollectedRequestEvent();
       if (receivedRequestEvent == null || receivedRequestEvent.getRequest() == null)
         throw new TiUnexpectedError("The sent request was not received by the RI!");
     } catch (TooManyListenersException ex) {
       throw new TiUnexpectedError(
           "A TooManyListenersException was thrown while trying to add "
               + "a SipListener to a TI SipProvider.",
           ex);
     } catch (SipException ex) {
       throw new TckInternalError("The RI failed to send the request!", ex);
     }
     try {
       tran = tiSipProvider.getNewServerTransaction(invite);
     } catch (TransactionUnavailableException exc) {
       exc.printStackTrace();
       fail(
           "A TransactionUnavailableException was thrown while trying to "
               + "create a new client transaction");
     } catch (TransactionAlreadyExistsException exc) {
       exc.printStackTrace();
       fail(
           "A TransactionAlreadyExistsException was thrown while trying to "
               + "create a new server transaction");
     }
     assertNotNull(
         "A null ServerTransaction was returned by SipProvider." + "getNewServerTransaction().",
         tran);
     String tranBranch = tran.getBranchId();
     String reqBranch = ((ViaHeader) invite.getHeader(ViaHeader.NAME)).getBranch();
     assertEquals(
         "The newly created transaction did not have the same "
             + "branch id as the request that created it!",
         tranBranch,
         reqBranch);
     assertNotNull(
         "The newly created transaction returned a null Dialog. "
             + "Please check the docs on Transaction.getDialog()",
         tran.getDialog());
     assertNotNull(
         "The transaction's getRequest() method returned a null Request ", tran.getRequest());
     assertEquals(
         "The transaction's getRequest() method returned a Request "
             + "that did not match the one that we used to create it!",
         tran.getRequest(),
         invite);
   } catch (Throwable exc) {
     exc.printStackTrace();
     fail(exc.getClass().getName() + ": " + exc.getMessage());
   }
   assertTrue(new Exception().getStackTrace()[0].toString(), true);
 }