Package net.sourceforge.syncyoursecrets.xmlmapping

Examples of net.sourceforge.syncyoursecrets.xmlmapping.ListElement


   * @throws Exception
   *             the exception
   */
  @Test
  public void testMerge() throws Exception {
    ListElement left = listFromProperties(leftNames, leftTimes);
    ListElement right = listFromProperties(rightNames, rightTimes);

    // deletion is handled programatically here:
    MappingElement rightDelete = right.getElements().get(6L);
    right.remove(rightDelete);
    rightDelete.setLastModified(NEWEST_TIME_STAMP);

    MappingElement leftDelete = left.getElements().get(7L);
    left.remove(leftDelete);
    leftDelete.setLastModified(NEWEST_TIME_STAMP);

    // actually do the merge
    ListElement merged = (ListElement) left.merge(right);

    // check deletion
    assertTrue("Entry 6 should be deleted", merged.getElements().get(6L)
        .isDeleted());
    assertTrue("Entry 7 should be deleted", merged.getElements().get(7L)
        .isDeleted());

    // check all properties
    checkProperties(expectedNames, expectedTimes, merged);

View Full Code Here


   *             the exception
   */
  public ListElement listFromProperties(Map<Long, String> names,
      Map<Long, DateTime> times) throws Exception {

    ListElement list = new ListElement("list", null);

    for (Long key : names.keySet()) {
      StringElement entry = new StringElement(CHILD_NODE);
      entry.setContent(names.get(key));
      entry.setLastModified(times.get(key));
      entry.setId(key);
      list.add(entry);
    }
    return list;

  }
View Full Code Here

   *             the exception
   */
  public Document toXml() throws Exception {
    Document doc = XmlSerializeTool.createDocument();

    ListElement list = new ListElement(LIST_ELEMENT_NAME, null);

    StringElement stringElement = new StringElement(FIRST_ELEMENT_NAME);
    stringElement.setContent(FIRST_CONTENT);
    list.add(stringElement);

    StringElement otherElement = new StringElement(SECOND_ELEMENT_NAME);
    otherElement.setContent(SECOND_CONTENT);
    list.add(otherElement);

    Element root = list.toXml(doc);

    doc.appendChild(root);

    return doc;

View Full Code Here

   *             the exception
   */
  public void fillFromXml(Document doc) throws Exception {

    Element root = doc.getDocumentElement();
    ListElement list = new ListElement(root);
    assertEquals("Name on list checked", LIST_ELEMENT_NAME, list
        .getElementName());

    Iterator<MappingElement> it = list.iterator();

    int foundcount = 0;
    while (it.hasNext()) {
      StringElement current = (StringElement) it.next();
      if (current.getElementName().equals(FIRST_ELEMENT_NAME)) {
View Full Code Here

TOP

Related Classes of net.sourceforge.syncyoursecrets.xmlmapping.ListElement

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.