private void assertTopMostVia(
     final SipMessage msg, final String host, final int port, final String transport)
     throws Exception {
   final ViaHeader via =
       this.headerFactory.createViaHeader(Buffers.wrap(host), port, Buffers.wrap(transport), null);
   msg.addHeaderFirst(via);
   final ViaHeader topMostVia = msg.getViaHeader();
   assertThat(topMostVia.getBranch(), not((Buffer) null));
   assertThat(topMostVia.getHost().toString(), is(host));
   assertThat(topMostVia.getPort(), is(port));
   assertThat(topMostVia.getTransport().toString(), is(transport));
 }
Exemple #2
0
  /**
   * {@inheritDoc}
   *
   * <p>Very basic way of framing a sip message. It makes a lot of assumption but in the framing
   * phase we are, well, just framing.
   */
  @Override
  public SipPacket frame(final TransportPacket parent, final Buffer buffer) throws IOException {

    if (parent == null) {
      throw new IllegalArgumentException("The parent frame cannot be null");
    }

    final SipMessage sip = SipParser.frame(buffer);
    if (sip.isRequest()) {
      return new SipRequestPacketImpl(parent, sip.toRequest());
    }

    return new SipResponsePacketImpl(parent, sip.toResponse());
  }
 /**
  * Helper method for ensuring that all the via headers exists in the SipMessage.
  *
  * @param msg
  * @param formatedVias note that these Via's have been formated already
  */
 private void assertViasInMessageDump(final SipMessage msg, final String[] formatedVias) {
   final String msgDump = msg.toString();
   for (final String formatedVia : formatedVias) {
     assertThat(msgDump.contains(formatedVia), is(true));
   }
 }