Examples of TckInternalError


Examples of test.tck.TckInternalError

            Address address = riAddressFactory.createAddress(srcSipURI);
            address.setDisplayName("RI Contact");
            contact.setAddress(address);
            return contact;
        } catch (Exception ex) {
            throw new TckInternalError(ex.getMessage());
        }
    }
View Full Code Here

Examples of test.tck.TckInternalError

      } 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 = eventCollector
          .extractCollectedRequestEvent();
      if (inviteReceivedEvent == null
          || inviteReceivedEvent.getRequest() == null)
        throw new TiUnexpectedError(
            "The invite request was not received by the RI!");
      // At this point the ClientTransaction should be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Check Request retransmission
      try {
        eventCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      // Wait for the retransmission timer to fire if it had not already
      // done so.
      if (tran.getRetransmitTimer() > MESSAGES_ARRIVE_FOR)
        sleep((long) tran.getRetransmitTimer() - MESSAGES_ARRIVE_FOR); // subtract
                                        // the
                                        // time
                                        // we
                                        // waited
                                        // for
                                        // the
                                        // invite
      // Wait for the retransmitted request to arrive
      waitForMessage();
      inviteReceivedEvent = eventCollector.extractCollectedRequestEvent();
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent);
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent.getRequest());
      assertEquals(Request.INVITE, inviteReceivedEvent.getRequest()
          .getMethod());
      // At this point the ClientTransaction should STILL be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Send a TRYING response
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      try {
        Response resp = riMessageFactory.createResponse(
            Response.TRYING, inviteReceivedEvent.getRequest());
        addStatus(inviteReceivedEvent.getRequest(), resp);
        riSipProvider.sendResponse(resp);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a trying response back to the TI",
            ex);
      }

      waitForMessage();
      // Analyze the TRYING response and Tran state back at the TI
      ResponseEvent responseEvent = eventCollector
          .extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 1xx response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 1xx response to the TU!",
          responseEvent.getResponse());
      assertTrue(
          "A response different from TYING was passed to the TU!",
          responseEvent.getResponse().getStatusCode() == Response.TRYING);
      assertSame(
          "The TRYING response was not associated with the right transaction.",
          tran, responseEvent.getClientTransaction());
      // verify the the tran state is now PROCEEDING
      assertEquals(
          "The ClientTransaction did not pass in the PROCEEDING state after "
              + "receiving 1xx provisional response", tran
              .getState(), TransactionState.PROCEEDING);
      // Send a 486 BUSY HERE (final) response from the RI
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // The BUSY_HERE response should trigger some ACKs so let's register
      // a listener with the RI
      SipEventCollector ackCollector = new SipEventCollector();
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      Response busyHere = null;
      try {
        busyHere = riMessageFactory.createResponse(Response.BUSY_HERE,
            inviteReceivedEvent.getRequest());
        addStatus(inviteReceivedEvent.getRequest(), busyHere);

        // JvB: set to-tag too, mandatory and tests that ACK is properly
        // formatted
        ((ToHeader) busyHere.getHeader("to")).setTag("busy-here");

        riSipProvider.sendResponse(busyHere);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a BUSY HERE response back to the TI",
            ex);
      }
      waitForMessage();

      // Analyze the BUSY_HERE response and Tran state back at the TI
      responseEvent = eventCollector.extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 300-699 response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 300-699 response to the TU!",
          responseEvent.getResponse());
      assertSame(
          "The BUSY_HERE response was not associated with the right transaction",
          tran, responseEvent.getClientTransaction());
      assertEquals(
          "A response different from BUSY_HERE was passed to the TU",
          Response.BUSY_HERE, responseEvent.getResponse()
              .getStatusCode());
      assertEquals(
          "The ClientTransaction did not pass in the COMPLETED state after "
              + "receiving 300-699 final response", tran
              .getState(), TransactionState.COMPLETED);
      // check whether the ackCollector has caught any fish
      RequestEvent ackReceivedEvent = ackCollector
          .extractCollectedRequestEvent();

      // JvB: With auto-dialog-support enabled, the ACK should be filtered
      // by the RI
      assertNotNull("The TI did not send an ACK request",
          ackReceivedEvent);
      assertNotNull("The TI did not send an ACK request",
          ackReceivedEvent.getRequest());
      assertEquals(Request.ACK, ackReceivedEvent.getRequest().getMethod());

      // Try to kill remaining ACK retransmissions
      // TODO this may not always work .. should give it a specific
      // timeout value
      waitForMessage();
      // Now let's retransmit the final response. This time it shouldn't
      // be
      // passed to the TU but an ACK should still be sent
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // go fish the ack
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      try {
        riSipProvider.sendResponse((Response) busyHere.clone());
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a BUSY HERE response back to the TI",
            ex);
      }
      waitForMessage();
      // The TU shouldn't see the retransmitted BUSY_HERE response
View Full Code Here

Examples of test.tck.TckInternalError

      } 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 = eventCollector
          .extractCollectedRequestEvent();

      if (inviteReceivedEvent == null
          || inviteReceivedEvent.getRequest() == null)
        throw new TiUnexpectedError(
            "The invite request was not received by the RI!");

      // At this point the ClientTransaction should be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());

      // Send a TRYING response
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      try {
        Response resp = riMessageFactory.createResponse(
            Response.TRYING, inviteReceivedEvent.getRequest());
        addStatus(inviteReceivedEvent.getRequest(), resp);
        riSipProvider.sendResponse(resp);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a trying response back to the TI",
            ex);
      }

      waitForMessage();
      // Analyze the TRYING response and Tran state back at the TI
      ResponseEvent responseEvent = eventCollector
          .extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 1xx response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 1xx response to the TU!",
          responseEvent.getResponse());
      assertTrue(
          "A response different from TYING was passed to the TU!",
          responseEvent.getResponse().getStatusCode() == Response.TRYING);
      assertSame(
          "The TRYING response was not associated with the right transaction.",
          tran, responseEvent.getClientTransaction());
      // verify the the tran state is now PROCEEDING
      assertEquals(
          "The ClientTransaction did not pass in the PROCEEDING state after "
              + "receiving 1xx provisional response", tran
              .getState(), TransactionState.PROCEEDING);

      // Send a CANCEL from the TI
      Request tiCancel = tran.createCancel();

      /*
       * this works, but since we cannot patch the INVITE the test fails
       * if (!rfc3261Compliant) { ((ViaHeader)
       * tiCancel.getHeader("Via")).setBranch( "xxx" ); // Not allowed by
       * RI // ((FromHeader) tiCancel.getHeader("From")).setTag( "" ); }
       */

      ClientTransaction tiCancelTrans;
      try {
        eventCollector.collectRequestEvent(riSipProvider);
        tiCancelTrans = tiSipProvider.getNewClientTransaction(tiCancel);
        tiCancelTrans.sendRequest();
      } catch (SipException ex) {
        throw new TiUnexpectedError(
            "A SipExceptionOccurred while trying to send CANCEL!",
            ex);
      }
      waitForMessage();
      RequestEvent cancelReceivedEvent = eventCollector
          .extractCollectedRequestEvent();
      if (cancelReceivedEvent == null
          || cancelReceivedEvent.getRequest() == null)
        throw new TiUnexpectedError(
            "The CANCEL request was not received by the RI!");

      // Send 200 OK to the CANCEL
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      Response riCancelOk = null;
      try {
        riCancelOk = riMessageFactory.createResponse(Response.OK,
            cancelReceivedEvent.getRequest());
        addStatus(cancelReceivedEvent.getRequest(), riCancelOk);
        riSipProvider.sendResponse(riCancelOk);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a CANCEL OK response back to the TI",
            ex);
      }
      waitForMessage();

      // Analyze the OK response and Tran state back at the TI
      responseEvent = eventCollector.extractCollectedResponseEvent();
      if (responseEvent == null || responseEvent.getResponse() == null) {
        throw new TiUnexpectedError(
            "The CANCEL OK response was not received by the TI!");
      }

      // Send 487 to the INVITE, expect ACK
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      SipEventCollector ackCollector = new SipEventCollector();
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }

      Response riInviteTerminated = null;
      try {
        riInviteTerminated = riMessageFactory.createResponse(
            Response.REQUEST_TERMINATED, inviteReceivedEvent
                .getRequest());
        addStatus(inviteReceivedEvent.getRequest(), riInviteTerminated);
        riSipProvider.sendResponse(riInviteTerminated);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a INVITE 487 response back to the TI",
            ex);
      }
      waitForMessage();

View Full Code Here

Examples of test.tck.TckInternalError

      } 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 = eventCollector
          .extractCollectedRequestEvent();
      if (inviteReceivedEvent == null
          || inviteReceivedEvent.getRequest() == null)
        throw new TiUnexpectedError(
            "The invite request was not received by the RI!");
      // At this point the ClientTransaction should be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Check Request retransmission
      try {
        eventCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      // Wait for the retransmission timer to fire if it had not already
      // done so.
      if (tran.getRetransmitTimer() > MESSAGES_ARRIVE_FOR)
        sleep((long) tran.getRetransmitTimer() - MESSAGES_ARRIVE_FOR); // subtract
                                        // the
                                        // time
                                        // we
                                        // waited
                                        // for
                                        // the
                                        // invite
      // Wait for the retransmitted request to arrive
      waitForMessage();
      inviteReceivedEvent = eventCollector.extractCollectedRequestEvent();
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent);
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent.getRequest());
      assertEquals(Request.INVITE, inviteReceivedEvent.getRequest()
          .getMethod());
      // At this point the ClientTransaction should STILL be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Send a 486 BUSY HERE (final) response from the RI
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // The BUSY_HERE response should trigger some ACKs so let's register
      // a listener with the RI
      SipEventCollector ackCollector = new SipEventCollector();
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      Response busyHere = null;
      try {
        busyHere = riMessageFactory.createResponse(Response.BUSY_HERE,
            inviteReceivedEvent.getRequest());
        addStatus(inviteReceivedEvent.getRequest(), busyHere);

        // JvB: set to-tag, check it against the ACK generated
        ((ToHeader) busyHere.getHeader("to")).setTag("ack-to-test");

        riSipProvider.sendResponse((Response) busyHere.clone());
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a BUSY HERE response back to the TI",
            ex);
      }
      waitForMessage();
      // Analyze the BUSY_HERE response and Tran state back at the TI
      ResponseEvent responseEvent = eventCollector
          .extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 300-699 response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 300-699 response to the TU!",
          responseEvent.getResponse());
      assertSame(
          "The BUSY_HERE response was not associated with the right transaction",
          tran, responseEvent.getClientTransaction());
      assertSame(
          "A response different from BUSY_HERE was passed to the TU",
          tran, responseEvent.getClientTransaction());
      assertEquals(
          "The ClientTransaction did not pass in the COMPLETED state after "
              + "receiving 300-699 final response", tran
              .getState(), TransactionState.COMPLETED);
      // check whether the ackCollector has caught any fish
      RequestEvent ackReceivedEvent = ackCollector
          .extractCollectedRequestEvent();
      assertNotNull("The TI did not send an ACK request",
          ackReceivedEvent);
      assertNotNull("The TI did not send an ACK request",
          ackReceivedEvent.getRequest());
      assertEquals(Request.ACK, ackReceivedEvent.getRequest().getMethod());
      // Try to kill remaining ACK retransmissions
      // TODO this may not always work .. should give it a specific
      // timeout value
      waitForMessage();
      // Now let's retransmit the final response. This time it shouldn't
      // be
      // passed to the TU but an ACK should still be sent
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // go fish the ack
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      try {
        riSipProvider.sendResponse((Response) busyHere.clone());
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a BUSY HERE response back to the TI",
            ex);
      }
      waitForMessage();
      // The TU shouldn't see the retransmitted BUSY_HERE response
View Full Code Here

Examples of test.tck.TckInternalError

      } 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 = eventCollector
          .extractCollectedRequestEvent();
      if (inviteReceivedEvent == null
          || inviteReceivedEvent.getRequest() == null)
        throw new TiUnexpectedError(
            "The invite request was not received by the RI!");
      // At this point the ClientTransaction should be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Check Request retransmission
      try {
        eventCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      // Wait for the retransmission timer to fire if it had not already
      // done so.
      if (tran.getRetransmitTimer() > MESSAGES_ARRIVE_FOR)
        sleep((long) tran.getRetransmitTimer() - MESSAGES_ARRIVE_FOR); // subtract
                                        // the
                                        // time
                                        // we
                                        // waited
                                        // for
                                        // the
                                        // invite
      // Wait for the retransmitted request to arrive
      waitForMessage();
      inviteReceivedEvent = eventCollector.extractCollectedRequestEvent();
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent);
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent.getRequest());
      assertEquals(Request.INVITE, inviteReceivedEvent.getRequest()
          .getMethod());
      // At this point the ClientTransaction should STILL be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Send a TRYING response
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      try {
        Response resp = riMessageFactory.createResponse(
            Response.TRYING, inviteReceivedEvent.getRequest());
        addStatus(inviteReceivedEvent.getRequest(), resp);
        riSipProvider.sendResponse(resp);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send a trying response back to the TI",
            ex);
      }
      waitForMessage();
      // Analyze the TRYING response and Tran state back at the TI
      ResponseEvent responseEvent = eventCollector
          .extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 1xx response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 1xx response to the TU!",
          responseEvent.getResponse());
      assertTrue(
          "A response different from TYING was passed to the TU!",
          responseEvent.getResponse().getStatusCode() == Response.TRYING);
      assertSame(
          "The TRYING response was not associated with the right transaction",
          tran, responseEvent.getClientTransaction());
      // verify the the tran state is now PROCEEDING
      assertEquals(
          "The ClientTransaction did not pass in the PROCEEDING state after "
              + "receiving 1xx provisional response", tran
              .getState(), TransactionState.PROCEEDING);
      // Send a 200 OK (final) response from the RI
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // The OK response shouldn't trigger any ACKs so let's register
      // a listener with the RI to verify whether that is the case
      SipEventCollector ackCollector = new SipEventCollector();
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      Response ok = null;
      try {
        ok = riMessageFactory.createResponse(Response.OK,
            inviteReceivedEvent.getRequest());

        // JvB: MUST add Contact too!
        ContactHeader contact = riHeaderFactory
            .createContactHeader(((ToHeader) ok.getHeader("To"))
                .getAddress());
        ok.addHeader(contact);
        // end JvB

        addStatus(inviteReceivedEvent.getRequest(), ok);
        riSipProvider.sendResponse((Response) ok.clone());
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send an OK response back to the TI",
            ex);
      }
      waitForMessage();
      // Analyze the OK response and Tran state back at the TI
      responseEvent = eventCollector.extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 200 OK response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 200 OK response to the TU!",
          responseEvent.getResponse());
      assertSame(
          "The OK response was not associated with the right transaction",
          tran, responseEvent.getClientTransaction());
      assertSame("A response different from OK was passed to the TU",
          tran, responseEvent.getClientTransaction());
      assertEquals(
          "The ClientTransaction did not pass in the TERMINATED state after "
              + "receiving 200 final response", tran.getState(),
          TransactionState.TERMINATED);
      // check whether the ackCollector has caught any fish
      RequestEvent ackReceivedEvent = ackCollector
          .extractCollectedRequestEvent();
      if (ackReceivedEvent != null)
        logger.error("Shouldn't have received that="
            + ackReceivedEvent.getRequest());
      assertNull("The TI sent an ACK to an OK (this is TU's job)!",
          ackReceivedEvent);
      // Now let's retransmit the final response and see it is
      // passed to the TU (again no ACKs)
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // go fish the ack
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      try {
        riSipProvider.sendResponse((Response) ok.clone());
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send an OK response back to the TI",
            ex);
      }
      waitForMessage();
      // Did we get the 2nd OK?
View Full Code Here

Examples of test.tck.TckInternalError

      } 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 = eventCollector
          .extractCollectedRequestEvent();
      if (inviteReceivedEvent == null
          || inviteReceivedEvent.getRequest() == null)
        throw new TiUnexpectedError(
            "The invite request was not received by the RI!");
      // At this point the ClientTransaction should be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Check Request retransmission
      try {
        eventCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      // Wait for the retransmission timer to fire if it had not already
      // done so.
      if (tran.getRetransmitTimer() > MESSAGES_ARRIVE_FOR)
        sleep((long) tran.getRetransmitTimer() - MESSAGES_ARRIVE_FOR); // subtract
                                        // the
                                        // time
                                        // we
                                        // waited
                                        // for
                                        // the
                                        // invite
      // Wait for the retransmitted request to arrive
      waitForMessage();
      inviteReceivedEvent = eventCollector.extractCollectedRequestEvent();
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent);
      assertNotNull("The invite request was not retransmitted!",
          inviteReceivedEvent.getRequest());
      assertEquals(Request.INVITE, inviteReceivedEvent.getRequest()
          .getMethod());
      // At this point the ClientTransaction should STILL be CALLING!
      assertEquals(TransactionState.CALLING, tran.getState());
      // Send a 200 OK (final) response from the RI
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // The OK response shouldn't trigger any ACKs so let's register
      // a listener with the RI to verify whether that is the case
      SipEventCollector ackCollector = new SipEventCollector();
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      Response ok = null;
      try {
        ok = riMessageFactory.createResponse(Response.OK,
            inviteReceivedEvent.getRequest());
        addStatus(inviteReceivedEvent.getRequest(), ok);

        // JvB: MUST add Contact too!
        ContactHeader contact = riHeaderFactory
            .createContactHeader(((ToHeader) ok.getHeader("To"))
                .getAddress());
        ok.addHeader(contact);
        // end JvB

        riSipProvider.sendResponse(ok);
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send an OK response back to the TI",
            ex);
      }
      waitForMessage();
      // Analyze the OK response and Tran state back at the TI
      ResponseEvent responseEvent = eventCollector
          .extractCollectedResponseEvent();
      assertNotNull(
          "The Tested Implementation did not pass a 200 OK response to the TU!",
          responseEvent);
      assertNotNull(
          "The Tested Implementation did not pass a 200 OK response to the TU!",
          responseEvent.getResponse());
      assertSame(
          "The OK response was not associated with the right transaction",
          tran, responseEvent.getClientTransaction());
      assertSame("A response different from OK was passed to the TU",
          tran, responseEvent.getClientTransaction());
      assertEquals(
          "The ClientTransaction did not pass in the TERMINATED state after "
              + "receiving 200 final response", tran.getState(),
          TransactionState.TERMINATED);
      // check whether the ackCollector has caught any fish
      RequestEvent ackReceivedEvent = ackCollector
          .extractCollectedRequestEvent();
      assertNull("The TI sent an ACK to an OK (this is TU's job)!",
          ackReceivedEvent);
      // Now let's retransmit the final response and see that it is
      // passed to the TU (again no ACKs should be sent by the TI)
      try {
        eventCollector.collectResponseEvent(tiSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TiUnexpectedError(
            "Failed to register a SipListener with TI", ex);
      }
      // go fish the ack
      try {
        ackCollector.collectRequestEvent(riSipProvider);
      } catch (TooManyListenersException ex) {
        throw new TckInternalError(
            "Failed to regiest a SipListener with an RI SipProvider",
            ex);
      }
      try {
        riSipProvider.sendResponse((Response) ok.clone());
      } catch (Throwable ex) {
        throw new TckInternalError(
            "The TCK could not send an OK response back to the TI",
            ex);
      }
      waitForMessage();
      // Did we get the 2nd OK?
View Full Code Here

Examples of test.tck.TckInternalError

                break;
        }
        if (j == implementedInterfaces.length) {
            System.out.println("Hmm... could not find it" +
            refRequest.getClass());
      throw new TckInternalError("Request not implemented");
        }
       
        String jainClassName = implementedInterfaces[j].getName();
       
        // Make sure that all the methods of the interface are implemented
        checkImplementsInterface(requestToTest.getClass(),
        Request.class);
       
    // Test the get methods of the interface.
    Method methods[] = implementedInterfaces[j].getDeclaredMethods();
    for (int i = 0; i < methods.length;  i++) {
      String methodName = methods[i].getName();
      if  (! methodName.startsWith("get") ) continue;
      // Testing only null argument gets
      if ( methods[i].getParameterTypes().length != 0) continue;
      Class returnType = methods[i].getReturnType();
      Object refType = null;
      try {
        refType = methods[i].invoke(refRequest,(Object[])null);
      } catch (Exception ex) {
        throw new TckInternalError("Invocation failure " + methodName);
      }
      String ftype = returnType.toString();
      if (returnType.isPrimitive()) {
        Object testValue = methods[i].invoke( requestToTest, (Object[])null);
        assertEquals( refType, testValue );
      } else {
        // Non primitive.
        Object testValue = methods[i].invoke( requestToTest,(Object[])null);
        if (refType != null) {
          assertTrue(testValue != null);
          // Find the jain type implemented by the interface.
          Class fclass = refType.getClass();
          Class[] fInterfaces = fclass.getInterfaces();
          // Find what JAIN interface this is implementing.
          int k = 0;
          for ( k = 0; k < fInterfaces.length; k++) {
            if ( javax.sip.header.Header.class.isAssignableFrom(fInterfaces[k]))
              break;
          }
          // If this implements a header interface
          // check that the same header is returned in both
          // ti and ri
          if ( k < fInterfaces.length) {
            // Make sure that the return type matches.
            assertTrue(fInterfaces[k].isAssignableFrom(testValue.getClass()));
            String refhdrString = refType.toString();
            String testhdrString = testValue.toString();
            // Use the factory to test for equivalence
            Header riHeader = createRiHeaderFromString(refhdrString);
            if (riHeader == null)
              throw new TckInternalError( "could not parse "  + refhdrString );

            // Create a RI header from the string to test
            // for equivalence. Note that we cannot compare
            // ti header to RI header otherwise.
            Header tiHeader = createRiHeaderFromString(testhdrString);
View Full Code Here

Examples of test.tck.TckInternalError

     
      tiFactory.resetFactory();
      tiFactory.setPathName( getImplementationPath() );
      tiSipStack = tiFactory.createSipStack(getTiProperties());
      if (riSipStack == tiSipStack) {
        throw new TckInternalError("riSipStack should not the same as tiSipStack");
      }
    } catch (TckInternalError ex)  {
      throw ex;
    } catch (Exception ex) {
      fail("initialization failed");
View Full Code Here

Examples of test.tck.TckInternalError

        continue;
      }
      break;
    }
    if (tries >= RETRY_OBJECT_DELETES)
      throw new TckInternalError("Failed to delete riSipProvider!");

    // Delete RI ListeningPoint
    for (tries = 0; tries < RETRY_OBJECT_DELETES; tries++) {
      try {
        riSipStack.deleteListeningPoint(riListeningPoint);
      } catch (ObjectInUseException ex) {
        // System.err.println("Retrying delete of riListeningPoint!");
        sleep(RETRY_OBJECT_DELETES_AFTER);
        continue;
      }
      break;
    }
    if (tries >= RETRY_OBJECT_DELETES)
      throw new TckInternalError("Failed to delete riListeningPoint!");

    riSipProvider = null;
    riListeningPoint = null;

    // Delete TI SipProvider
View Full Code Here

Examples of test.tck.TckInternalError

    try {
      return createRequest(Request.INVITE, riAddressFactory,
          riHeaderFactory, riMessageFactory, riSipProvider,
          tiSipProvider, contentType, contentSubType, content);
    } catch (Throwable exc) {
      throw new TckInternalError(
          "Failed to create an RI->TI invite request", exc);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.