Package javax.servlet.sip

Examples of javax.servlet.sip.SipURI


        "1"));
  }

  protected void testRouterInfo(SipApplicationRouterInfo routerInfo) throws Exception
  {
    SipURI uri = new SipURIImpl(null, "localhost", 5060);
    RouterInfoUtil.encode(uri, routerInfo);
    //System.out.println(uri);
    assertEquals(routerInfo, RouterInfoUtil.decode(new SipURIImpl(uri.toString())));
  }
View Full Code Here


 
  protected SipURI getOwnUri()
  {
    @SuppressWarnings("unchecked")
    List<SipURI> l = (List<SipURI>) getServletContext().getAttribute(OUTBOUND_INTERFACES);
    SipURI uri = l.get(0);
    uri = (SipURI) uri.clone();
    uri.setUser("cipango-servlet-test");
    uri.setLrParam(true);
    return uri;
  }
View Full Code Here

  }

  @Test
  public void testSipUri() throws Exception
  {
    SipURI orig = new SipURIImpl("sip:foo@bar.com;transport=tcp?to=sip:bob%40biloxi.com");
    SipURI readOnly = new ReadOnlySipURI((SipURI) orig.clone());
   
    assertEquals(orig, readOnly);
    try { readOnly.setParameter("foo", "bar"); fail();} catch (IllegalStateException e) {}
    try { readOnly.removeParameter("transport"); fail();} catch (IllegalStateException e) {} 
    try { readOnly.setHeader("subject", "toto"); fail();} catch (IllegalStateException e) {}
    try { readOnly.removeHeader("to"); fail();} catch (IllegalStateException e) {}
    assertEquals(orig, readOnly);
    assertEquals(readOnly, orig);
    assertEquals(orig.toString(), readOnly.toString());
    URI clone = (URI) readOnly.clone();
    clone.setParameter("a", "b");
    testSerializable(readOnly);
  }
View Full Code Here

    Address contact = request.getAddressHeader("Contact");
    assertEquals("<sip:127.0.0.1:5060;transport=TCP>", contact.toString());
    contact.setDisplayName("Bob");
    contact.setParameter("isfocus", "");
    assertEquals("Bob", contact.getDisplayName());
    SipURI uri = (SipURI) contact.getURI();
    uri.setUser("bob");
    assertEquals("bob", uri.getUser());
    try { uri.setHost("bad"); fail(); } catch (IllegalStateException e) {}
    try { uri.setLrParam(true); fail(); } catch (IllegalStateException e) {}
    try { uri.setMAddrParam("bad"); fail(); } catch (IllegalStateException e) {}
    try { uri.setMethodParam("Bad"); fail(); } catch (IllegalStateException e) {}
    try { uri.setTTLParam(2); fail(); } catch (IllegalStateException e) {}
    try { uri.setParameter("lr", ""); fail(); } catch (IllegalStateException e) {}
    try { uri.removeParameter("Maddr"); fail(); } catch (IllegalStateException e) {}
    uri.setParameter("transport", "UDP");
    assertEquals("UDP", uri.getParameter("transport"));
    assertEquals("Bob <sip:bob@127.0.0.1:5060;transport=UDP>;isfocus", contact.toString());
   
    // Full read-only on committed
    request.setCommitted(true);
    contact = request.getAddressHeader("Contact");
    uri = (SipURI) contact.getURI();
    try { contact.setDisplayName("bad"); fail(); } catch (IllegalStateException e) {}
    try { uri.setUser("bad"); fail(); } catch (IllegalStateException e) {}
   
    // Full writable on REGISTER
    request = (SipRequest) getMessage(REGISTER);
    contact = request.getAddressHeader("Contact");
    uri = (SipURI) contact.getURI();
    contact.setDisplayName("Bob");
    uri.setHost("nexcom.fr");
    uri.setPort(5062);
    uri.removeParameter("transport");
    uri.setUser("bob");
    assertEquals("Bob <sip:bob@nexcom.fr:5062>", contact.toString());   
  }
View Full Code Here

{
    public static String toCanonical(URI uri)
    {
      if (uri.isSipURI())
      {
        SipURI sipUri = (SipURI) uri;
        return ("sip:" + sipUri.getUser() + "@" + sipUri.getHost()).toLowerCase();
      }
      else
      {
        return uri.toString();
      }
View Full Code Here

  public Object extract(Object input)
  {
    URI uri = (URI) input;
    if (uri.isSipURI())
    {
          SipURI sipuri = (SipURI) uri;
          if ("phone".equals(sipuri.getParameter("user")))
              return stripVisuals(sipuri.getUser());
      }
    else if ("tel".equals(uri.getScheme()))
    {
          return stripVisuals(((TelURL) uri).getPhoneNumber());
      }
View Full Code Here

  {
    _fields.setAddress(SipHeaders.FROM_BUFFER, new NameAddr("sip:foo@bar.com"));
   
    assertEquals("<sip:foo@bar.com>", _fields.getString("from"));
   
    SipURI uri = (SipURI) _fields.getAddress("from").getURI();
    assertEquals("foo", uri.getUser());
    assertEquals("bar.com", uri.getHost());
   
    _fields.addAddress("route", new NameAddr("sip:route1"), false);
    _fields.addAddress(SipHeaders.ROUTE_BUFFER, new NameAddr("sip:route2"), false);
   
    Iterator<Address> it = _fields.getAddressValues("route");
View Full Code Here

 
  private SipURI newProxyURI(boolean applicationId)
  {
    SipConnector connector = _tx.getRequest().getConnection().getConnector();
           
    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;
  }
View Full Code Here

  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();
      }
    }
View Full Code Here

    if (session == null)
      register = createRequest(SipMethods.REGISTER, _localAddress);
    else
      register = createRequest(session, SipMethods.REGISTER);
     
    SipURI registrar = _factory.createSipURI(null, ((SipURI) _localAddress.getURI()).getHost());
    register.setRequestURI(registrar);
    register.setAddressHeader(SipHeaders.CONTACT, _contact);
    register.setExpires(3600);
   
    return register;
View Full Code Here

TOP

Related Classes of javax.servlet.sip.SipURI

Copyright © 2018 www.massapicom. 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.