@@ -0,0 +1,3331 @@
+// Copyright 2009 Google Inc.%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//      http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.enterprise.connector.util.diffing;%0A%0Aimport com.google.enterprise.connector.spi.TraversalSchedule;%0Aimport com.google.enterprise.connector.util.diffing.ChangeQueue;%0Aimport com.google.enterprise.connector.util.diffing.ChangeQueue.DefaultCrawlActivityLogger;%0A%0Aimport java.sql.Timestamp;%0Aimport java.util.ArrayList;%0Aimport junit.framework.TestCase;%0A%0A/**%0A * Tests for %7B@link DocumentSnapshotRepositoryMonitorManagerImpl%7D.%0A */%0Apublic class DocumentSnapshotRepositoryMonitorManagerImplTest extends TestCase %7B%0A%0A  // Borrowed from filesystem connector's  MockTraversalSchedule.java%0A  public class MockTraversalSchedule implements TraversalSchedule %7B%0A    private final int load;%0A    private final int retryDelay;%0A    private final boolean isDisabled;%0A    private final boolean inInterval;%0A  %0A    public MockTraversalSchedule() %7B%0A      this(500, -1, false, true);%0A    %7D%0A  %0A    public MockTraversalSchedule(int load, int retryDelay, boolean isDisabled,%0A                                 boolean inInterval) %7B%0A      this.load = load;%0A      this.retryDelay = retryDelay;%0A      this.isDisabled = isDisabled;%0A      this.inInterval = inInterval;%0A    %7D%0A  %0A    /** Returns the target traversal rate in documents per minute. */%0A    /* @Override */%0A    public int getTraversalRate() %7B%0A      return load;%0A    %7D%0A  %0A    /** Returns the number of seconds to delay after finding no new content. */%0A    /* @Override */%0A    public int getRetryDelay() %7B%0A      return retryDelay;%0A    %7D%0A  %0A    /** Returns %7B@code true%7D if the traversal schedule is disabled. */%0A    /* @Override */%0A    public boolean isDisabled() %7B%0A      return isDisabled;%0A    %7D%0A  %0A    /**%0A     * Returns %7B@code true%7D if the current time is within a scheduled travesal%0A     * interval.%0A     */%0A    /* @Override */%0A    public boolean inScheduledInterval() %7B%0A      return inInterval;%0A    %7D%0A  %0A    /* @Override */%0A    public int nextScheduledInterval() %7B%0A      return -1;%0A    %7D%0A%0A    /**%0A     * Returns %7B@code true%7D if traversals could run at this time,%0A     * equivalent to %3Cpre%3E!isDisabled() && inScheduledInterval()%3C/pre%3E.%0A     */%0A    /* @Override */%0A    public boolean shouldRun() %7B%0A      return !isDisabled() && inScheduledInterval();%0A    %7D%0A  %7D%0A%0A  public void testSetTraversalSchedule() %7B%0A    ChangeQueue queue;%0A    queue = new ChangeQueue(10, 0L, null);%0A%0A    DocumentSnapshotRepositoryMonitorManagerImpl manager =%0A        new DocumentSnapshotRepositoryMonitorManagerImpl(%0A            new ArrayList%3CSnapshotRepository%3C? extends DocumentSnapshot%3E%3E(), null, null, null,%0A            queue, null);%0A%0A    assertEquals(0, queue.getSleepInterval());%0A    manager.setTraversalSchedule(new MockTraversalSchedule(500, 8074, false, false));%0A    assertEquals(8074000, queue.getSleepInterval());%0A  %7D%0A%7D%0A

Add a new test for DocumentSnapshotRepositoryMonitorManagerImpl