Package org.cipango.kaleo.presence.watcherinfo.WatcherinfoDocument

Examples of org.cipango.kaleo.presence.watcherinfo.WatcherinfoDocument.Watcherinfo


    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);
    assertEquals(getBobUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(0, watcherList.getWatcherArray().length);
   
   
    SubscribeSession presenceSession = new SubscribeSession(getAlicePhone(), "presence");
    subscribe = presenceSession.newInitialSubscribe(100, getBobUri()); // 5
    presenceSession.sendRequest(subscribe, Response.OK); // 6
   
    tx = winfoSession.waitForNotify(); // 7
    notify = tx.getRequest();
    //System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 8
    watcherinfo = getWatcherinfo(notify);
    assertEquals(1, watcherinfo.getVersion().intValue());
    watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(1, watcherList.sizeOfWatcherArray());
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.SUBSCRIBE, watcher.getEvent());
    assertEquals(getAliceUri(), watcher.getStringValue());
    assertEquals(Status.ACTIVE, watcher.getStatus());
   
   
    tx = presenceSession.waitForNotify(); // 9
    presenceSession.sendResponse(Response.OK, tx); // 10
   
   
    subscribe = presenceSession.newSubsequentSubscribe(0); // 11
    presenceSession.sendRequest(subscribe, Response.OK); // 12
   
    tx = winfoSession.waitForNotify(); // 13
    notify = tx.getRequest();
    // System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 14
    watcherinfo = getWatcherinfo(notify);
    assertEquals(2, watcherinfo.getVersion().intValue());
    watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(1, watcherList.sizeOfWatcherArray());
    watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.TIMEOUT, watcher.getEvent());
    assertEquals(getAliceUri(), watcher.getStringValue());
    assertEquals(Status.TERMINATED, watcher.getStatus());
   
    tx = presenceSession.waitForNotify(); // 15
    presenceSession.sendResponse(Response.OK, tx); // 16
   
    subscribe = winfoSession.newSubsequentSubscribe(0); // 17
    winfoSession.sendRequest(subscribe, Response.OK); //18
   
    tx = winfoSession.waitForNotify(); // 19
    notify = tx.getRequest();
    // System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 20
    watcherinfo = getWatcherinfo(notify);
    assertEquals(3, watcherinfo.getVersion().intValue());
    watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(0, watcherList.sizeOfWatcherArray());
   
  }
View Full Code Here


    //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);
    assertEquals(getBobUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(1, watcherList.getWatcherArray().length);
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.SUBSCRIBE, watcher.getEvent());
View Full Code Here

    //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);
    assertEquals(getBobUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(1, watcherList.getWatcherArray().length);
    watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.SUBSCRIBE, watcher.getEvent());
View Full Code Here

    System.out.println("9:\n" +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(getAliceUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(1, watcherList.getWatcherArray().length);
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.TIMEOUT, watcher.getEvent());
View Full Code Here

  public WatcherResource(String uri, Presentity presentity)
  {
    super(uri);
    _content = WatcherinfoDocument.Factory.newInstance();
    Watcherinfo watcherinfo = _content.addNewWatcherinfo();
    watcherinfo.setState(org.cipango.kaleo.presence.watcherinfo.WatcherinfoDocument.Watcherinfo.State.FULL);
    watcherinfo.setVersion(BigInteger.ZERO);
    WatcherList list = watcherinfo.addNewWatcherList();
    list.setResource(uri);
    list.setPackage(PresenceEventPackage.NAME);
   
    if (presentity != null)
    {
View Full Code Here

  }

  public State getNeutralState()
  {
    WatcherinfoDocument document = WatcherinfoDocument.Factory.newInstance();
    Watcherinfo watcherinfo = document.addNewWatcherinfo();
    watcherinfo.setState(org.cipango.kaleo.presence.watcherinfo.WatcherinfoDocument.Watcherinfo.State.FULL);
    watcherinfo.setVersion(BigInteger.ZERO);
    WatcherList list = watcherinfo.addNewWatcherList();
    list.setResource(getUri());
    list.setPackage(PresenceEventPackage.NAME);
   
    return new State(WatcherInfoEventPackage.WATCHERINFO, document);
  }
View Full Code Here

    BigInteger version = (BigInteger) session.getAttribute(Constants.VERSION_ATTRIBUTE);
    if (version == null)
      version = BigInteger.ZERO;
    else
      version = version.add(BigInteger.ONE);
    Watcherinfo watcherinfo = ((WatcherinfoDocument) state.getContent()).getWatcherinfo();
   
    watcherinfo.setVersion(version);
    session.setAttribute(Constants.VERSION_ATTRIBUTE, version);
  }
View Full Code Here

    private int _nbNotif = 0;

    public void stateChanged(EventResource resource)
    {
      _nbNotif++;
      Watcherinfo watcherinfo = ((WatcherinfoDocument) resource.getState().getContent()).getWatcherinfo();
      WatcherList watcherList = watcherinfo.getWatcherListArray(0);
      if (_nbNotif == 1)
      {
        assertEquals(1, watcherList.getWatcherArray().length);
        Watcher watcher1 = watcherList.getWatcherArray(0);
        assertEquals(SUBSCRIBER_AOR, watcher1.getStringValue());
View Full Code Here

    Presentity presentity = new Presentity(AOR);
    WatcherResource resource = new WatcherResource(AOR, presentity);
    EventListener eventListener = new EventListener();
    resource.addListener(eventListener);
    //System.out.println(resource.getState().getContent());
    Watcherinfo watcherinfo = ((WatcherinfoDocument) resource.getState().getContent()).getWatcherinfo();
    assertEquals(State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(AOR, watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(0, watcherList.getWatcherArray().length);
   
    Subscription subscription = new Subscription(presentity, null, 100, SUBSCRIBER_AOR);
View Full Code Here

TOP

Related Classes of org.cipango.kaleo.presence.watcherinfo.WatcherinfoDocument.Watcherinfo

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.