Package com.google.enterprise.connector.util.diffing

Examples of com.google.enterprise.connector.util.diffing.DocumentHandle


    jsonDocument = new JsonDocument(jsonObjectUtil.getProperties(),
                                    jsonObjectUtil.getJsonObject());
  }

  public void testGetDocument() throws Exception {
    DocumentHandle handle = new DBHandle(jsonDocument);
    Document doc = handle.getDocument();
    assertNotNull(doc);
    assertEquals(properties.keySet(), doc.getPropertyNames());

    for (Map.Entry<String, String>  entry : properties.entrySet()) {
      Property property = doc.findProperty(entry.getKey());
View Full Code Here


  /**
   * Tests that the JSON object handle string includes all of the
   * document properties.
   */
  public void testToString() {
    DocumentHandle handle = new DBHandle(jsonDocument);
    Object expected = "{\"google:ispublic\":\"false\",\"google:docid\":\"1\","
        + "\"google:mimetype\":\"text/plain\","
        + "\"google:lastmodified\":\"" + lastModified + "\"}";
    assertEquals(expected, handle.toString());
  }
View Full Code Here

   * lifecycle tests are, or in JsonDocumentTest, since the date
   * handling is in JsonDocument at the moment, but we're
   * fundamentally testing the behavior of the document handle.
   */
  public void testDeserializedDate() throws RepositoryException {
    DocumentHandle handle = new DBHandle(jsonDocument);
    Document document = handle.getDocument();
    DocumentHandle deserialHandle = new DBHandle(handle.toString());
    Document deserialDocument = deserialHandle.getDocument();

    Value value = Value.getSingleValue(document,
        SpiConstants.PROPNAME_LASTMODIFIED);
    Value deserialValue = Value.getSingleValue(deserialDocument,
        SpiConstants.PROPNAME_LASTMODIFIED);
View Full Code Here

    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);
    DocumentSnapshot deserialSnapshot = getDeserializedSnapshot(snapshot);

    // This is the core assertion, that a deserialized snapshot
    // compares as identical to the repository source snapshot.
    DocumentHandle update = snapshot.getUpdate(deserialSnapshot);
    if (update != null) {
      fail(update.toString());
    }

    assertEquals(snapshot.getDocumentId(), deserialSnapshot.getDocumentId());
    assertEquals(snapshot.toString(), deserialSnapshot.toString());
  }
View Full Code Here

      throws Exception {
    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);
    DocumentSnapshot deserialSnapshot = getDeserializedSnapshot(snapshot);

    try {
      DocumentHandle update = deserialSnapshot.getUpdate(snapshot);
      fail("Expected an UnsupportedOperationException exception");
    } catch (UnsupportedOperationException expected) {
    }
  }
View Full Code Here

  public void testHandleLifecycle(Map<String, String> configMap)
      throws Exception {
    DocumentSnapshot snapshot = getSnapshotUnderTest(configMap);

    DocumentHandle handle = snapshot.getUpdate(null);
    assertNotNull(handle);

    Document doc = handle.getDocument();
    assertNotNull(doc);
    Set<String> propertyNames = doc.getPropertyNames();

    String serialHandle = handle.toString();
    DocumentHandle deserialHandle =
        new DBHandleFactory().fromString(serialHandle);
    assertNotNull(deserialHandle);
    assertEquals("document ID",
        handle.getDocumentId(), deserialHandle.getDocumentId());
    assertJsonEquals("serialization not value preserving",
        serialHandle, deserialHandle.toString());

    Document recoveryDoc = deserialHandle.getDocument();
    assertNotNull(recoveryDoc);
    // This is the core assertion, that a document from a deserialized
    // handle has the same properties as the original handle from the
    // SnapshotRepository.
    assertEquals("document from deserialized handle",
View Full Code Here

    // The diffing framework sends in a null to indicate that it has not
    // seen this snapshot before.
    // Assert that our DocumentHolder is used to create the DocumentHandle.
    expect(builder.getDocumentHandle(same(holder))).andReturn(null);
    replay(builder);
    DocumentHandle actual = documentSnapshot.getUpdate(null);
    verify(builder);
  }
View Full Code Here

        builder.getJsonString(documentSnapshot.getDocumentId(), "9999"));

    // Assert that our DocumentHolder is used to create the DocumentHandle.
    expect(builder.getDocumentHandle(same(holder))).andReturn(null);
    replay(builder);
    DocumentHandle update = documentSnapshot.getUpdate(onGsa);
    verify(builder);
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.util.diffing.DocumentHandle

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.