Package javax.sip.message

Examples of javax.sip.message.Request


  }
 
  public void testWilcard() throws Exception
  {
    RegisterSession session =  new RegisterSession(getAlicePhone());
    Request request = session.createRegister(null, 1800);
    ContactHeader contact2 = newContact("<sip:localhost>");
    contact2.setExpires(1500);
    request.addHeader(contact2);
    Response response =
      session.sendRegistrationMessage(request, Response.OK);
   
        request = session.createRegister("*", 0);
    response =   session.sendRegistrationMessage(request, Response.OK);
View Full Code Here


   
  public void testLowerCSeq() throws Exception {
    RegisterSession session =  new RegisterSession(getAlicePhone());
    session.register(1800);
   
    Request request = session.createRegister(null, 0);
    CSeqHeader cseq = (CSeqHeader) request.getHeader(CSeqHeader.NAME);
    cseq.setSeqNumber(cseq.getSeqNumber() - 2);
    Response response = session.sendRegistrationMessage(request, Response.SERVER_INTERNAL_ERROR);
    assertEquals("Lower CSeq", response.getReasonPhrase());
  }
View Full Code Here

  }
 
 
  public void testInvalidWilcard() throws Exception
    RegisterSession session =  new RegisterSession(getAlicePhone());
    Request request = session.createRegister("*", 1800);
    Response response =
      session.sendRegistrationMessage(request, Response.BAD_REQUEST);
    assertEquals("Invalid wildcard", response.getReasonPhrase());
  }
View Full Code Here

    assertEquals("Invalid wildcard", response.getReasonPhrase());
  }
 
  public void testInvalidWilcard2() throws Exception
    RegisterSession session =  new RegisterSession(getAlicePhone());
    Request request = session.createRegister(null, 0);
    ContactHeader contact = __headerFactory.createContactHeader();
    contact.setWildCard();
    request.addHeader(contact);
    Response response =
      session.sendRegistrationMessage(request, Response.BAD_REQUEST);
    assertEquals("Invalid wildcard", response.getReasonPhrase());
  }
View Full Code Here

    assertEquals("Invalid wildcard", response.getReasonPhrase());
  }
 
  public void testMinExpires() throws Exception
    RegisterSession session =  new RegisterSession(getAlicePhone());
    Request request = session.createRegister(null, 2);
    Response response = session.sendRegistrationMessage(request, Response.INTERVAL_TOO_BRIEF);
    MinExpiresHeader minExpiresHeader = (MinExpiresHeader) response.getHeader(MinExpiresHeader.NAME);
        assertNotNull(minExpiresHeader);
  }
View Full Code Here

  }
 

  public void testRequires() throws Exception
    RegisterSession session =  new RegisterSession(getAlicePhone());
    Request request = session.createRegister(null, 1800);
    request.addHeader(__headerFactory.createRequireHeader("ext1"));
    request.addHeader(__headerFactory.createRequireHeader("ext2"));
    Response response =
      session.sendRegistrationMessage(request, Response.BAD_EXTENSION);

    assertHeaderContains(response, UnsupportedHeader.NAME, "ext1");
    assertHeaderContains(response, UnsupportedHeader.NAME, "ext2");
View Full Code Here

  }
 
  @SuppressWarnings("unchecked")
  protected void sendRegisterNoContact(RegisterSession session, List<String> expectedContacts) throws Exception
  {
    Request request = session.createRegister(null, 1800);
    request.removeHeader(ContactHeader.NAME);
    request.removeHeader(ExpiresHeader.NAME);
    Response response =
      session.sendRegistrationMessage(request, Response.OK);
   
    List<String> noParams = new ArrayList<String>();
    Iterator<String> it1 = expectedContacts.iterator();
View Full Code Here

     * </pre>
   */
  public void testSubscription()
  {   
    SubscribeSession winfoSession = new SubscribeSession(getBobPhone(), "presence.winfo"); // 1
    Request subscribe = winfoSession.newInitialSubscribe(100, getBobUri());
    winfoSession.sendRequest(subscribe, Response.OK); // 2
   
    ServerTransaction tx = winfoSession.waitForNotify(); // 3
    Request notify = tx.getRequest();
    //System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 4
    SubscriptionStateHeader subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
    assertEquals(SubscriptionStateHeader.ACTIVE.toLowerCase(), subState.getState().toLowerCase());
    assertBetween(95, 100, subState.getExpires());
    assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
    Watcherinfo watcherinfo = getWatcherinfo(notify);
    assertEquals(0, watcherinfo.getVersion().intValue());
    assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
View Full Code Here

     * </pre>
   */
  public void testSubscription2()
  {   
    SubscribeSession presenceSession = new SubscribeSession(getAlicePhone(), "presence");
    Request subscribe = presenceSession.newInitialSubscribe(100, getBobUri()); // 1
    presenceSession.sendRequest(subscribe, Response.OK); // 2

    ServerTransaction tx = presenceSession.waitForNotify(); // 3
    presenceSession.sendResponse(Response.OK, tx); // 4
   
    SubscribeSession winfoSession = new SubscribeSession(getBobPhone(), "presence.winfo"); // 5
    subscribe = winfoSession.newInitialSubscribe(0, getBobUri());
    winfoSession.sendRequest(subscribe, Response.OK); // 6
   
    tx = winfoSession.waitForNotify(); // 7
    Request notify = tx.getRequest();
    //System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 8
    SubscriptionStateHeader subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
    assertEquals(SubscriptionStateHeader.TERMINATED.toLowerCase(), subState.getState().toLowerCase());
    assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
    Watcherinfo watcherinfo = getWatcherinfo(notify);
    assertEquals(0, watcherinfo.getVersion().intValue());
    assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
View Full Code Here

     * </pre>
   */
  public void testSubscription3() throws Exception
  {
    PublishSession publishSession = new PublishSession(getBobPhone());
        Request publish = publishSession.newPublish(getClass().getResourceAsStream("publish1.xml"), 60); // 1
        publishSession.sendRequest(publish, SipResponse.OK); // 2
   
    SubscribeSession presenceSession = new SubscribeSession(getAlicePhone(), "presence");
    Request subscribe = presenceSession.newInitialSubscribe(100, getBobUri()); // 3
    presenceSession.sendRequest(subscribe, Response.OK); // 4

    ServerTransaction tx = presenceSession.waitForNotify(); // 5
    //System.out.println("3:\n" + tx.getRequest());
    presenceSession.sendResponse(Response.OK, tx); // 6
    Presence presence = getPresence(tx.getRequest());
    assertEquals(Basic.OPEN, presence.getTupleArray()[0].getStatus().getBasic());
   
   
    SubscribeSession winfoSession = new SubscribeSession(getBobPhone(), "presence.winfo"); // 7
    subscribe = winfoSession.newInitialSubscribe(60, getBobUri());
    winfoSession.sendRequest(subscribe, Response.OK); // 8
   
    tx = winfoSession.waitForNotify(); // 9
    Request notify = tx.getRequest();
    //System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 10
    SubscriptionStateHeader subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
    assertEquals(SubscriptionStateHeader.ACTIVE.toLowerCase(), subState.getState().toLowerCase());
    assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
    Watcherinfo watcherinfo = getWatcherinfo(notify);
    assertEquals(0, watcherinfo.getVersion().intValue());
    assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(getBobUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(1, watcherList.getWatcherArray().length);
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.SUBSCRIBE, watcher.getEvent());
    assertEquals(getAliceUri(), watcher.getStringValue());
    assertEquals(Status.ACTIVE, watcher.getStatus());
   
   
    HttpClient httpClient = new HttpClient();
    PutMethod put = new PutMethod(getHttpXcapUri() + BOB_PRES_RULES_URI); // 11
   
    InputStream is = WatcherInfoTest.class.getResourceAsStream("/xcap-root/pres-rules/users/put/elementPoliteBlock.xml");
    RequestEntity entity = new InputStreamRequestEntity(is, "application/xcap-el+xml");
    put.setRequestEntity(entity);
   
    int result = httpClient.executeMethod(put);
    assertEquals(200, result); // 12
    put.releaseConnection();
   
    tx = presenceSession.waitForNotify(); // 13
    //System.out.println("11:\n" + tx.getRequest());
    presenceSession.sendResponse(Response.OK, tx); // 14
    presence = getPresence(tx.getRequest());
    assertEquals(Basic.CLOSED, presence.getTupleArray()[0].getStatus().getBasic());
   
    tx = winfoSession.waitForNotify(); // 15
    notify = tx.getRequest();
    winfoSession.sendResponse(Response.OK, tx); // 16
    System.out.println(notify);
    subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
    assertEquals(SubscriptionStateHeader.ACTIVE.toLowerCase(), subState.getState().toLowerCase());
    assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
    watcherinfo = getWatcherinfo(notify);
    assertEquals(1, watcherinfo.getVersion().intValue());
    assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    watcherList = watcherinfo.getWatcherListArray(0);
View Full Code Here

TOP

Related Classes of javax.sip.message.Request

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.