ack = dialog.createAck(cseq.getSequenceNumberLong());
ack = dialog.createAck(cseq.getSeqNumber());
	private void doTestSendAck( boolean sameBranch ) {		try {			//We will now send an OK response			//start listening for the response			try {				eventCollector.collectResponseEvent(tiSipProvider);			} catch (TooManyListenersException e) {				throw new TckInternalError(					"Failed to register a SipListener with the RI.",					e);			}			Response ok = null;			try {				ok = riMessageFactory.createResponse(Response.OK, riInvite);				ok.addHeader(					createRiInviteRequest(null, null, null).getHeader(						ContactHeader.NAME));				ToHeader okToHeader = (ToHeader)ok.getHeader(ToHeader.NAME);				okToHeader.setTag( riToTag );	// needs same tag as 180 ringing!				// riSipProvider.sendResponse(ok);								// Need to explicitly create the dialog on RI side				ServerTransaction riST = riSipProvider.getNewServerTransaction( riInvite );				riST.getDialog();				riST.sendResponse( ok );			} catch (Exception e) {				throw new TckInternalError(					"Failed to create and send an OK response",					e);			}			waitForMessage();			ResponseEvent okRespEvt =				eventCollector.extractCollectedResponseEvent();			if (okRespEvt == null || okRespEvt.getResponse() == null)				throw new TiUnexpectedError("The TI did not dispatch an OK response.");						// After 2xx, dialog should be in CONFIRMED state. Needed to send ACK			assertEquals( DialogState.CONFIRMED, dialog.getState() );						//Send the ack			//Setup the ack listener			try {				eventCollector.collectRequestEvent(riSipProvider);			} catch (TooManyListenersException ex) {				throw new TckInternalError(					"Failed to register a SipListener with the RI",					ex);			}			Request ack = null;			try {				CSeqHeader cseq = (CSeqHeader) okRespEvt.getResponse().getHeader(CSeqHeader.NAME);				ack = dialog.createAck(cseq.getSequenceNumberLong());				//System.out.println( "Created ACK:" + ack );				//System.out.println( "original INVITE:" + riInvite );				// This is wrong according to RFC3261, but some clients do this...				if (sameBranch) {					ViaHeader via = (ViaHeader) ack.getHeader("Via");					via.setBranch( ((ViaHeader)riInvite.getHeader("Via")).getBranch() );				}							} catch (SipException ex) {				throw new TiUnexpectedError(					"Failed to create an ACK request.",					ex);			}			try {				dialog.sendAck(ack);			} catch (Throwable ex) {				ex.printStackTrace();				fail("SipException; Failed to send an ACK request using Dialog.sendAck()");			}			waitForMessage();			// Did the RI get the ACK? If the dialog is not found, the ACK is filtered!			RequestEvent ackEvt = eventCollector.extractCollectedRequestEvent();			assertNotNull(				"No requestEvent sent by Dialog.sendAck() was received by the RI",				ackEvt);			assertNotNull(				"The request sent by Dialog.sendAck() was not received by the RI",				ackEvt.getRequest());		} catch (Throwable exc) {			exc.printStackTrace();			fail(exc.getClass().getName() + ": " + exc.getMessage());		}		assertTrue(new Exception().getStackTrace()[0].toString(), true);	}