Package javax.servlet.sip

Examples of javax.servlet.sip.SipURI


   
    assertEquals("host-1.com", sipURI("sip:user@host-1.com:3261").getHost());
    assertEquals("[::1]", sipURI("sip:user@[::1]:5060").getHost());
    try {sipURI("sip:user@space here:5060"); fail(); } catch (ServletParseException e) {}
    try {sipURI("sip:user@plus+here:5060"); fail(); } catch (ServletParseException e) {}
    SipURI uri = sipURI("sip:1234@foo.com");
    uri.setHost("::1");
    assertEquals("[::1]", uri.getHost());
    assertEquals("sip:1234@[::1]", uri.toString());
   
    uri = sipURI("sip:vivekg@chair-dnrc.example.com ; transport = TCP");
    assertEquals("chair-dnrc.example.com", uri.getHost());
    assertEquals("TCP", uri.getParameter("transport"));
  }
View Full Code Here


  }

  @Test
  public void testParam() throws Exception
  {
    SipURI uri = sipURI("sip:1234@foo.com;user=phone;lr");
    assertEquals(true, uri.getLrParam());
    assertEquals("phone", uri.getUserParam());
    assertNull(uri.getParameter("unknown"));
    assertNull(uri.getParameter("transport"));
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("user", "phone");
    params.put("lr", "");
    Iterator<String> it = uri.getParameterNames();
    while (it.hasNext())
    {
      String name = (String) it.next();
      assertTrue(params.containsKey(name));
      assertEquals(params.get(name), uri.getParameter(name));
      params.remove(name);
    }
    assertTrue(params.isEmpty());
  }
View Full Code Here

  }

  @Test
  public void testHeader() throws Exception
  {
    SipURI uri = sipURI("sip:1234@foo.com?Subject=nexcom");
    assertEquals("nexcom", uri.getHeader("Subject"));
    assertNull(uri.getHeader("unknown"));
  }
View Full Code Here

  @Test
  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.equals(uri2));
      assertFalse(uri2.equals(uri1));
    }
  }
View Full Code Here

  }

  @Test
  public void testClone() throws Exception
  {
    SipURI uri = sipURI("sip:user@host.com:1234;foo=bar");
    SipURI clone = (SipURI) uri.clone();
   
    assertEquals(uri.toString(), clone.toString());
    uri.setLrParam(true);
    assertFalse(clone.getLrParam());
    assertTrue(uri.getLrParam());
  }
View Full Code Here

  }

  @Test
  public void testEscape() throws Exception
  {
    SipURI uri = sipURI("sip:+1234@example.com;user=phone;f%3Doo=%22bar%22?Subject=hello%20world");   
    assertEquals("\"bar\"", uri.getParameter("f=oo"));
    assertEquals("hello world", uri.getHeader("Subject"));
   
    uri = sipURI("sip:inside@example.com;lr");   
    SipURI uri2 = sipURI("sip:middle@example.com");
    uri2.setHeader("To", uri.toString());
    SipURI uri3 = sipURI("sip:outside@example.com");
    uri3.setHeader("From", uri2.toString());
    // System.out.println(uri3);
   
    SipURI uri3b = sipURI(uri3.toString());
    assertEquals(uri3.toString(), uri3b.toString());
    SipURI uri2b = sipURI(uri3b.getHeader("From"));
    assertEquals(uri2.toString(), uri2b.toString());
    SipURI uri1b = sipURI(uri2b.getHeader("To"));
    assertEquals(uri.toString(), uri1b.toString());

  }
View Full Code Here

  }

  @Test
  public void testNew() throws Exception
  {
    SipURI uri = new SipURIImpl("foo", "bar.com", 5060);
    assertEquals("sip:foo@bar.com:5060", uri.toString());
  }
View Full Code Here

  }

  @Test
  public void testHttp() throws Exception
  {
    SipURI uri = sipURI("sip:mrf;voicexml=http://foo.bar.com/vxml/play.jsp%3Fuser%3Dsip:foo%40bar.com");
    assertEquals("http://foo.bar.com/vxml/play.jsp?user=sip:foo@bar.com", uri.getParameter("voicexml"));
  }
View Full Code Here

      System.out.println("SipURI2 Took: " + time2/1000000 + "ms");
             
      start = System.nanoTime();
      for (int i = 0; i <nbTest; i++)
      {
        SipURI uri;
        if (impl2)
          uri = new SipURIImpl(uris[j]);
        else
          uri = new SipURIImpl(uris[j]);
        parsed[i] = uri;
        uri.setLrParam(true);
        uri.toString();
      }
      time2 = (System.nanoTime() - start);
      System.out.println("SipURI2 Took (with modif): " + time2/1000000 + "ms")

      System.out.println("Total memory: " + r.totalMemory()/1048576 + "Mo");
View Full Code Here

  public boolean equals(Object o)
  {
    if (o == null || !(o instanceof SipURI))
      return false;
   
    SipURI other = (SipURI) o;
    if (!_scheme.equals(other.getScheme()))
      return false;
   
    if (!equalsUser(other))
      return false;
   
    if (!equalsPassword(other))
      return false;
   
    if (!_host.equalsIgnoreCase(other.getHost()))
      return false;
   
    if (_port != other.getPort())
      return false;
   
    Map<String, String> otherParams = new HashMap<String, String>();
    Iterator<String> it = other.getParameterNames();
    while (it.hasNext())
    {
      String key = it.next();
      otherParams.put(key, other.getParameter(key));
     
    }
    if (!equalsParameters(_params, otherParams))
      return false;
   
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.