Package org.cipango.kaleo.presence.pidf

Examples of org.cipango.kaleo.presence.pidf.PresenceDocument


    state.setExpirationTime(expirationTime);
  }

  public State getNeutralState()
  {
    PresenceDocument document = PresenceDocument.Factory.newInstance();
    Presence presence = document.addNewPresence();
    presence.setEntity(getUri());
    Tuple tuple = document.getPresence().addNewTuple();
    tuple.setId("123");
    tuple.addNewStatus().setBasic(Basic.CLOSED);
    return new State(PresenceEventPackage.PIDF, document);
  }
View Full Code Here


 
  public void testSimple() throws Exception
  {
    Presentity presentity = new Presentity("sip:alice@cipango.org");
    assertTrue(presentity.isDone());
    PresenceDocument doc = (PresenceDocument) presentity.getState().getContent();
    assertEquals(presentity.getNeutralState().getContent().toString(),
        doc.toString());
   
    PresenceDocument doc1 = PresenceDocument.Factory.newInstance();
    Tuple tuple1 = doc1.addNewPresence().addNewTuple();
    tuple1.setId("tuple1");
    tuple1.addNewStatus().setBasic(Basic.OPEN);
    SoftState state1 = presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
   
    doc = (PresenceDocument) presentity.getState().getContent();
    assertEquals(1, doc.getPresence().getTupleArray().length);
    assertEquals("tuple1",
        doc.getPresence().getTupleArray(0).getId());
    assertEquals(Basic.OPEN,
        doc.getPresence().getTupleArray(0).getStatus().getBasic());
   
    PresenceDocument doc2 = PresenceDocument.Factory.newInstance();
    Tuple tuple2 = doc2.addNewPresence().addNewTuple();
    tuple2.setId("tuple2");
    tuple2.addNewStatus().setBasic(Basic.CLOSED);
    SoftState state2 = presentity.addState(PresenceEventPackage.PIDF, doc2, 60);
   
    doc = (PresenceDocument) presentity.getState().getContent();
    assertEquals(2, doc.getPresence().getTupleArray().length);
    assertEquals("tuple1",
        doc.getPresence().getTupleArray(0).getId());
    assertEquals(Basic.OPEN,
        doc.getPresence().getTupleArray(0).getStatus().getBasic());
    assertEquals("tuple2",
        doc.getPresence().getTupleArray(1).getId());
    assertEquals(Basic.CLOSED,
        doc.getPresence().getTupleArray(1).getStatus().getBasic());
    assertFalse(presentity.isDone());
   
    presentity.removeState(state1.getETag());
    assertNull(presentity.getState(state1.getETag()));
    doc = (PresenceDocument) presentity.getState().getContent();
    assertEquals(1, doc.getPresence().getTupleArray().length);
    assertEquals("tuple2",
        doc.getPresence().getTupleArray(0).getId());
   
    String etag = state2.getETag();
    assertEquals(state2, presentity.getState(etag));
    doc2 = (PresenceDocument) doc2.copy();
    doc2.getPresence().getTupleArray(0).getStatus().setBasic(Basic.OPEN);
    presentity.modifyState(state2, PresenceEventPackage.PIDF, doc2, 30);
    doc = (PresenceDocument) presentity.getState().getContent();
    assertEquals(Basic.OPEN,
        doc.getPresence().getTupleArray(0).getStatus().getBasic());
    assertNotSame(etag, state2.getETag());
View Full Code Here

  public void testGetState() throws Exception
  {   
    Presentity presentity = new Presentity("sip:alice@cipango.org");
    assertEquals(presentity.getNeutralState().getContent().toString(),
        presentity.getState().getContent().toString());
    PresenceDocument doc1 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/org/cipango/kaleo/sipunit/publish1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    PresenceDocument doc2 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/pidf1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc2, 60);
    Presence presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    assertEquals(2, presence.getTupleArray().length);
    assertEquals(doc1.getPresence().getTupleArray(0).getId(), presence.getTupleArray(0).getId());
    assertEquals(doc2.getPresence().getTupleArray(0).getId(), presence.getTupleArray(1).getId());
   
    PresenceDocument doc3 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/org/cipango/kaleo/sipunit/publish2.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc3, 60);
    presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    assertEquals(3, presence.getTupleArray().length);
   
    //System.out.println(presentity.getState().getContent());
View Full Code Here

 
  public void testNamespaceCollision() throws Exception
  {   
    Presentity presentity = new Presentity("sip:alice@cipango.org");
 
    PresenceDocument doc1 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/pidfNamespace.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    PresenceDocument doc2 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/pidf1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc2, 60);
    Presence presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    //System.out.println(presentity.getState().getContent());
  }
View Full Code Here

  }
 
  public void testInsertSameId() throws Exception
  {   
    Presentity presentity = new Presentity("sip:alice@cipango.org");
    PresenceDocument doc1 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/org/cipango/kaleo/sipunit/publish1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    Presence presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    assertEquals(1, presence.getTupleArray().length);
  }
View Full Code Here

TOP

Related Classes of org.cipango.kaleo.presence.pidf.PresenceDocument

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.