示例#1
0
 public void testDifferent() throws Exception {
   for (int i = 0; i < different.length; i++) {
     SipURI uri1 = sipUri(different[i][0]);
     SipURI uri2 = sipUri(different[i][1]);
     assertFalse(uri1 + " is the same as " + uri2, uri1.equals(uri2));
     assertFalse(uri2 + " is the same as " + uri1, uri2.equals(uri1));
   }
 }
示例#2
0
 public void testEqual() throws Exception {
   for (int i = 0; i < equal.length; i++) {
     SipURI uri1 = sipUri(equal[i][0]);
     SipURI uri2 = sipUri(equal[i][1]);
     assertTrue(uri1 + " is different as " + uri2, uri1.equals(uri2));
     assertTrue(uri2 + " is different as " + uri1, uri2.equals(uri1));
   }
 }
示例#3
0
 public void testNullUser() throws Exception {
   SipURI uri1 = sipUri("sip:atlanta.com;transport=TCP?Subject=SIP%20Servlets");
   assertNotNull(uri1);
   assertNull(uri1.getUser());
   assertNotNull(uri1.getHost());
   assertEquals("TCP", uri1.getTransportParam());
   assertTrue(
       uri1.getHeader("Subject") + " is different as SIP Servlets",
       uri1.getHeader("Subject").equals("SIP Servlets"));
 }
示例#4
0
  private SipURI newProxyURI(SipConnector connector, boolean applicationId) {
    SipURI rrUri = (SipURI) connector.getSipUri().clone();
    rrUri.setParameter("lr", "");

    if (applicationId) {
      AppSession appSession = _tx.getRequest().appSession();
      rrUri.setParameter(ID.APP_SESSION_ID_PARAMETER, appSession.getAppId());
    }

    return rrUri;
  }
示例#5
0
 public void customizeRequest(SipRequest request, SipConnection connection) {
   SipConnector connector = _tx.getRequest().getConnection().getConnector();
   if (getRecordRoute() && connection.getConnector() != connector) {
     SipURI rrUri = newProxyURI(connection.getConnector(), true);
     rrUri.setParameter(SipParams.DRR, "2");
     _branchRRUri.setParameter(SipParams.DRR, "");
     if (connector.getTransportOrdinal() == SipConnectors.TCP_ORDINAL)
       _branchRRUri.setTransportParam("tcp");
     if (connection.getConnector().getTransportOrdinal() == SipConnectors.TCP_ORDINAL)
       rrUri.setTransportParam("tcp");
     request.addRecordRoute(new NameAddr(rrUri));
   }
 }
示例#6
0
  protected Branch addTarget(URI uri) {
    URI target = uri.clone();
    if (target.isSipURI()) {
      SipURI sipUri = (SipURI) target;
      sipUri.removeParameter("method");
      Iterator<String> it = sipUri.getHeaderNames();
      while (it.hasNext()) {
        it.remove();
      }
    }
    if (isInTargetSet(target)) {
      if (LOG.isDebugEnabled()) LOG.debug("target {} is already in target set", target);
      return null;
    } else {
      if (LOG.isDebugEnabled()) LOG.debug("adding target {} to target set", target);

      Branch branch = new Branch(target);
      _targets = LazyList.add(_targets, branch);
      return branch;
    }
  }
示例#7
0
 public void testEscaping() throws Exception {
   SipURI uri1 = sipUri("sip:%[email protected];transport=TCP");
   assertTrue(uri1.getUser() + " is different as alice", uri1.getUser().equals("alice"));
   assertTrue(
       uri1.toString() + " is different as sip:[email protected];transport=TCP",
       uri1.toString().equals("sip:[email protected];transport=TCP"));
   uri1 = sipUri("sip:[email protected];transport=tcp?Subject=SIP%20Servlets");
   assertTrue(
       uri1.getHeader("Subject") + " is different as SIP Servlets",
       uri1.getHeader("Subject").equals("SIP Servlets"));
   assertTrue(
       uri1.toString()
           + " is different as sip:[email protected];transport=tcp?Subject=SIP Servlets",
       uri1.toString().equals("sip:[email protected];transport=tcp?Subject=SIP Servlets"));
   //		uri1 =
   // sipUri("sip:[email protected];play=file://fs.example.net//clips/my-intro.dvi;content-type=video/mpeg%3bencode%3d314M-25/625-50");
   //		SipURI uri2 =
   // sipUri("sip:[email protected];play=file://fs.example.net//clips/my-intro.dvi;content-type=video/mpeg;encode=314M-25/625-50");
   //		assertTrue(uri1.getParameter("content-type") + " is different as
   // video/mpeg;encode=314M-25/625-50" ,
   // uri1.getParameter("content-type").equals("video/mpeg;encode=314M-25/625-50"));
   //		assertTrue(uri1.toString() + " is different as
   // sip:[email protected];play=file://fs.example.net//clips/my-intro.dvi;content-type=video/mpeg%3bencode%3d314M-25/625-50" , uri1.equals(uri2));
 }