Package org.apache.abdera.ext.sharing

Examples of org.apache.abdera.ext.sharing.Sync


 
  @Test
  public void testCreateOperation() throws Exception  {
    Abdera abdera = new Abdera();
    Entry entry = SharingHelper.createEntry(abdera, "jms");
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertNotNull(sync.getId());
    assertEquals(sync.getUpdates(),1);
    assertEquals(sync.getHistory().size(),1);
    History history = sync.getTopmostHistory();
    assertEquals(history.getSequence(),1);
    assertEquals(history.getBy(),"jms");
  }
View Full Code Here


  @Test
  public void testUpdateOperation() throws Exception {
    Abdera abdera = new Abdera();
    Entry entry = SharingHelper.createEntry(abdera, "jms");
    SharingHelper.updateEntry(entry, "jms");
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertNotNull(sync.getId());
    assertEquals(sync.getUpdates(),2);
    assertEquals(sync.getHistory().size(),2);
    History history = sync.getTopmostHistory();
    assertEquals(history.getSequence(),2);
    assertEquals(history.getBy(),"jms");
  }
View Full Code Here

 
  @Test
  public void testDeleteOperation() throws Exception {
    Abdera abdera = new Abdera();
    Entry entry = SharingHelper.createEntry(abdera, "jms");
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertFalse(sync.isDeleted());
    SharingHelper.deleteEntry(entry, "jms");
    sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertTrue(sync.isDeleted());
    assertNotNull(sync.getId());
    assertEquals(sync.getUpdates(),2);
    assertEquals(sync.getHistory().size(),2);
    History history = sync.getTopmostHistory();
    assertEquals(history.getSequence(),2);
    assertEquals(history.getBy(),"jms");
  }
View Full Code Here

    Abdera abdera = new Abdera();
    Feed f1 = abdera.newFeed();
    Feed f2 = abdera.newFeed();
    Entry e1 = SharingHelper.createEntry(abdera, "jms", f1);
    Entry e2 = SharingHelper.createEntry(abdera, "jms", f2);
    Sync s1 = SharingHelper.getSync(e1, false);
    Sync s2 = SharingHelper.getSync(e2, false);
    s2.setId(s1.getId());
    SharingHelper.updateEntry(e1, "bob");
    SharingHelper.updateEntry(e2, "jms");
   
    SharingHelper.mergeFeeds(f1, f2);
   
    assertEquals(f2.getEntries().size(),1);
    Entry entry = f2.getEntries().get(0);
    Sync sync = SharingHelper.getSync(entry);
    Conflicts conflicts = sync.getConflicts();
    assertNotNull(conflicts);
    assertEquals(conflicts.getEntries().size(),1);
    Entry conflict = conflicts.getEntries().get(0);
    assertNotNull(conflict);
   
    ConflictResolver r = new ConflictResolver() {
      public Entry resolve(Entry entry, List<Entry> conflicts) {
        Sync sync = SharingHelper.getSync(entry,false);
        Conflicts c = sync.getConflicts(false);
        if (c != null) c.discard();
        return entry; // take the latest
      }
    };
   
    entry = SharingHelper.resolveConflicts(entry, r, "jms");
    sync = SharingHelper.getSync(entry);
    conflicts = sync.getConflicts();
    assertNull(conflicts);
    assertEquals(sync.getHistory().size(),4);
   
  }
View Full Code Here

  }
 
  public void testDeleteOperation() throws Exception {
    Abdera abdera = new Abdera();
    Entry entry = SharingHelper.createEntry(abdera, "jms");
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertFalse(sync.isDeleted());
    SharingHelper.deleteEntry(entry, "jms");
    sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertTrue(sync.isDeleted());
    assertNotNull(sync.getId());
    assertEquals(sync.getUpdates(),2);
    assertEquals(sync.getHistory().size(),2);
    History history = sync.getTopmostHistory();
    assertEquals(history.getSequence(),2);
    assertEquals(history.getBy(),"jms");
  }
View Full Code Here

    Abdera abdera = new Abdera();
    Feed f1 = abdera.newFeed();
    Feed f2 = abdera.newFeed();
    Entry e1 = SharingHelper.createEntry(abdera, "jms", f1);
    Entry e2 = SharingHelper.createEntry(abdera, "jms", f2);
    Sync s1 = SharingHelper.getSync(e1, false);
    Sync s2 = SharingHelper.getSync(e2, false);
    s2.setId(s1.getId());
    SharingHelper.updateEntry(e1, "bob");
    SharingHelper.updateEntry(e2, "jms");
   
    SharingHelper.mergeFeeds(f1, f2);
   
    assertEquals(f2.getEntries().size(),1);
    Entry entry = f2.getEntries().get(0);
    Sync sync = SharingHelper.getSync(entry);
    Conflicts conflicts = sync.getConflicts();
    assertNotNull(conflicts);
    assertEquals(conflicts.getEntries().size(),1);
    Entry conflict = conflicts.getEntries().get(0);
    assertNotNull(conflict);
   
    ConflictResolver r = new ConflictResolver() {
      public Entry resolve(Entry entry, List<Entry> conflicts) {
        Sync sync = SharingHelper.getSync(entry,false);
        Conflicts c = sync.getConflicts(false);
        if (c != null) c.discard();
        return entry; // take the latest
      }
    };
    entry = SharingHelper.resolveConflicts(entry, r, "jms");
    sync = SharingHelper.getSync(entry);
    conflicts = sync.getConflicts();
    assertNull(conflicts);
    assertEquals(sync.getHistory().size(),4);
  }
View Full Code Here

    assertNotNull(history);
    Related related = factory.newElement(SharingHelper.SSE_RELATED);
    assertNotNull(related);
    Sharing sharing = factory.newElement(SharingHelper.SSE_SHARING);
    assertNotNull(sharing);
    Sync sync = factory.newElement(SharingHelper.SSE_SYNC);
    assertNotNull(sync);
    Unpublished unpub = factory.newElement(SharingHelper.SSE_UNPUBLISHED);
    assertNotNull(unpub);
  }
View Full Code Here

    rel = sharing.getRelated().get(1);
    assertEquals(rel.getLink().toString(),"http://example.com/B.xml");
    assertEquals(rel.getType(),Related.Type.AGGREGATED);
   
    Entry entry = feed.getEntries().get(0);
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertEquals(sync.getId(),"item 1_myapp_2005-05-21T11:43:33Z");
    assertEquals(sync.getUpdates(),3);
   
    assertEquals(sync.getHistory().size(),3);
   
    Date d1 = AtomDate.parse("2005-05-21T11:43:33Z");
    Date d2 = AtomDate.parse("2005-05-21T10:43:33Z");
    Date d3 = AtomDate.parse("2005-05-21T09:43:33Z");
   
    History history = sync.getHistory().get(0);
    assertEquals(history.getSequence(),3);
    assertEquals(history.getWhen(),d1);
    assertEquals(history.getBy(),"JEO2000");
   
    history = sync.getHistory().get(1);
    assertEquals(history.getSequence(),2);
    assertEquals(history.getWhen(),d2);
    assertEquals(history.getBy(),"REO1750");
   
    history = sync.getHistory().get(2);
    assertEquals(history.getSequence(),1);
    assertEquals(history.getWhen(),d3);
    assertEquals(history.getBy(),"REO1750");
  }
View Full Code Here

  }
 
  public void testCreateOperation() throws Exception  {
    Abdera abdera = new Abdera();
    Entry entry = SharingHelper.createEntry(abdera, "jms");
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertNotNull(sync.getId());
    assertEquals(sync.getUpdates(),1);
    assertEquals(sync.getHistory().size(),1);
    History history = sync.getTopmostHistory();
    assertEquals(history.getSequence(),1);
    assertEquals(history.getBy(),"jms");
  }
View Full Code Here

 
  public void testUpdateOperation() throws Exception {
    Abdera abdera = new Abdera();
    Entry entry = SharingHelper.createEntry(abdera, "jms");
    SharingHelper.updateEntry(entry, "jms");
    Sync sync = SharingHelper.getSync(entry, false);
    assertNotNull(sync);
    assertNotNull(sync.getId());
    assertEquals(sync.getUpdates(),2);
    assertEquals(sync.getHistory().size(),2);
    History history = sync.getTopmostHistory();
    assertEquals(history.getSequence(),2);
    assertEquals(history.getBy(),"jms");
  }
View Full Code Here

TOP

Related Classes of org.apache.abdera.ext.sharing.Sync

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.