コード例 #1
0
 public void testGetAndAdd() throws Exception {
   final ObjectCache cache = createMemoryCache();
   final RevisionCacheImpl revisionCache = new RevisionCacheImpl(cache);
   try {
     assertNull(revisionCache.get(123));
     revisionCache.add(TestUtils.getLogEntryStub());
     final SVNLogEntry result = revisionCache.get(123);
     assertNotNull(result);
     assertEquals(123, result.getRevision());
     assertEquals("TestAuthor", result.getAuthor());
     assertNotNull(result.getDate());
     assertEquals("TestMessage", result.getMessage());
   } finally {
     cache.shutdown();
   }
 }
コード例 #2
0
  @Test
  public void testUpdate() throws Exception {
    final ConfigDirectory configDirectory = TestUtils.getTestConfigDirectory();
    configDirectory.setCreateDirectories(false);
    final MockServletContext servletContext = new MockServletContext();
    servletContext.setContextPath("sventon-test");
    configDirectory.setServletContext(servletContext);

    final Application application = new Application(configDirectory);

    final RepositoryConfiguration configuration = new RepositoryConfiguration("name");
    configuration.setCacheUsed(true);
    application.addConfiguration(configuration);
    application.setConfigured(true);

    final ObjectCache cache = createMemoryCache();

    try {
      final List<RepositoryChangeListener> listeners = new ArrayList<RepositoryChangeListener>();
      listeners.add(repositoryChangeListenerMock);
      final DefaultRepositoryChangeMonitor changeMonitor = new DefaultRepositoryChangeMonitor();
      changeMonitor.setListeners(listeners);
      changeMonitor.setMaxRevisionCountPerUpdate(3);
      changeMonitor.setApplication(application);

      changeMonitor.setRepositoryService(repositoryServiceMock);
      assertFalse(application.isUpdating(configuration.getName()));

      expect(repositoryServiceMock.getLatestRevision(null)).andReturn(6L);
      expect(repositoryServiceMock.getLogEntriesFromRepositoryRoot(null, 1L, 3L))
          .andReturn(firstBatchOfRevisions);
      repositoryChangeListenerMock.update(isA(RevisionUpdate.class));
      expect(repositoryServiceMock.getLogEntriesFromRepositoryRoot(null, 4L, 6L))
          .andReturn(secondBatchOfRevisions);
      repositoryChangeListenerMock.update(isA(RevisionUpdate.class));

      replay(repositoryServiceMock);
      replay(repositoryChangeListenerMock);
      changeMonitor.update(configuration.getName(), null, cache);
      verify(repositoryServiceMock);
      verify(repositoryChangeListenerMock);

      assertFalse(application.isUpdating(configuration.getName()));
    } finally {
      cache.shutdown();
    }
  }