Examples of ChangeSource


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

    List<CheckpointAndChange> secondBatchAgain = q2.resume(checkpoint);
    assertEquals(secondBatch, secondBatchAgain);
  }

  public void testRepeatedRecoveryAtSameCheckpoint() throws IOException {
    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(null);
    List<CheckpointAndChange> firstBatch = q.resume(null);
View Full Code Here

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

    List<CheckpointAndChange> secondBatchFourthTime = q4.resume(checkpoint);
    assertEquals(secondBatch, secondBatchFourthTime);
  }

  public void testRepeatedResumeAtSameCheckpointOfSameQueue() throws IOException {
    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(null);
    List<CheckpointAndChange> firstBatch = q.resume(null);
View Full Code Here

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

    List<CheckpointAndChange> secondBatchThrice = q2.resume(checkpoint);
    assertEquals(secondBatch, secondBatchThrice);
  }

  public void testPartialRecovery() throws IOException {
    ChangeSource changeSource = new MockChangeSource(10);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(4);
    q.start(null);
    List<CheckpointAndChange> firstBatch = q.resume(null);
View Full Code Here

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

  private static final String EMPTY_RECOVERY_FILE =
      "{\"MON\":{},\"Q\":[]}SENTINAL";

  public void testWriteAndReadJson() throws Exception {
    ChangeSource changeSource = new MockChangeSource(10);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.start(null);
    assertEquals(EMPTY_RECOVERY_FILE, getRecoveryFile(q));
    List<CheckpointAndChange> firstBatch = q.resume(null);
View Full Code Here

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

    assertEquals(original, getRecoveryFile(q2));
  }

  public void testRecoveryStateCleanup() throws IOException {
    final int NUM_RESUME_CALLS = 20;
    ChangeSource changeSource = new MockChangeSource(NUM_RESUME_CALLS * 3);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    String checkpoint = null;
    q.start(checkpoint);
View Full Code Here

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

   * Regression test for NPE being thrown if persistDir does not exist
   * in call to clean().
   */
  public void testCleanPersistDirNotExist() throws Exception {
    final int NUM_RESUME_CALLS = 20;
    ChangeSource changeSource = new MockChangeSource(NUM_RESUME_CALLS * 3);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(null);
    assertTrue(persistDir.exists());
View Full Code Here

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

    q.ensurePersistDirExists();
    assertTrue(persistDir.exists());
  }

  public void testTooManyRecoveryFiles() throws IOException {
    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    {
      File persistFile = new File(persistDir, "recovery.1234");
      FileWriter writer = new FileWriter(persistFile);
View Full Code Here

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

      assertTrue(-1 != e.getMessage().indexOf("Found too many recovery files: "));
    }
  }

  public void testInvalidRecoveryFilename() throws IOException {
    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    File persistFile = new File(persistDir, "recovery.sugar-n-spice");
    FileWriter writer = new FileWriter(persistFile);
    writer.write("oh so not relevent");
View Full Code Here

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

  public void testRecoveryFromTwoCompleteFiles() throws IOException {
    File persistDirA = testDirectoryManager.makeDirectory("queue-A");
    File persistDirB = testDirectoryManager.makeDirectory("queue-B");

    { /* Make recovery file that finishes 2nd batch. */
      ChangeSource changeSource = new MockChangeSource(6);
      CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
          persistDirA, internalFactory, clientFactory);
      q.setMaximumQueueSize(2);
      q.start(null);
      List<CheckpointAndChange> firstBatch = q.resume(null);
      String checkpoint = firstBatch.get(1).getCheckpoint().toString();
      List<CheckpointAndChange> secondBatch = q.resume(checkpoint);
      checkpoint = secondBatch.get(1).getCheckpoint().toString();
      q.resume(checkpoint);
      File recoveryFile = persistDirA.listFiles()[0];
      recoveryFile.renameTo(new File(persistDir, recoveryFile.getName()));
    }

    List<CheckpointAndChange> secondBatch;
    String checkpoint;
    { /* Make recovery file that finishes 1st batch. */
      ChangeSource changeSource = new MockChangeSource(6);
      CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
          persistDirB, internalFactory, clientFactory);
      q.setMaximumQueueSize(2);
      q.start(null);
      List<CheckpointAndChange> firstBatch = q.resume(null);
      checkpoint = firstBatch.get(1).getCheckpoint().toString();
      secondBatch = q.resume(checkpoint);
      File recoveryFile = persistDirB.listFiles()[0];
      recoveryFile.renameTo(new File(persistDir, recoveryFile.getName()));
    }

    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(checkpoint);
    List<CheckpointAndChange> secondBatchAgain = q.resume(checkpoint);
View Full Code Here

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

    File persistDirAux = testDirectoryManager.makeDirectory("queue-aux");

    String checkpoint;
    List<CheckpointAndChange> secondBatch;
    {
      ChangeSource changeSource = new MockChangeSource(6);
      CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
          persistDirAux, internalFactory, clientFactory);
      q.setMaximumQueueSize(2);
      q.start(null);
      List<CheckpointAndChange> firstBatch = q.resume(null);
      checkpoint = firstBatch.get(1).getCheckpoint().toString();
      secondBatch = q.resume(checkpoint);
      File recoveryFile = persistDirAux.listFiles()[0];
      recoveryFile.renameTo(new File(persistDir, recoveryFile.getName()));
    }

    File persistFile = new File(persistDir, "recovery." + System.nanoTime());
    FileWriter writer = new FileWriter(persistFile);
    writer.write("i iZ brokens\nyar\t\t\n?");
    writer.close();

    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(checkpoint);
    List<CheckpointAndChange> secondBatchAgain = q.resume(checkpoint);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.