You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GcDirCacheSavesObjectsTest.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2012, Christian Halstrick <christian.halstrick@sap.com> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.internal.storage.file;
  11. import static org.junit.Assert.assertEquals;
  12. import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
  13. import org.junit.Test;
  14. public class GcDirCacheSavesObjectsTest extends GcTestCase {
  15. @Test
  16. public void testDirCacheSavesObjects() throws Exception {
  17. BranchBuilder bb = tr.branch("refs/heads/master");
  18. bb.commit().add("A", "A").add("B", "B").create();
  19. bb.commit().add("A", "A2").add("B", "B2").create();
  20. bb.commit().add("A", "A3"); // this new content in index should survive
  21. stats = gc.getStatistics();
  22. assertEquals(9, stats.numberOfLooseObjects);
  23. assertEquals(0, stats.numberOfPackedObjects);
  24. gc.gc();
  25. stats = gc.getStatistics();
  26. assertEquals(1, stats.numberOfLooseObjects);
  27. assertEquals(8, stats.numberOfPackedObjects);
  28. assertEquals(1, stats.numberOfPackFiles);
  29. }
  30. @Test
  31. public void testDirCacheSavesObjectsWithPruneNow() throws Exception {
  32. BranchBuilder bb = tr.branch("refs/heads/master");
  33. bb.commit().add("A", "A").add("B", "B").create();
  34. bb.commit().add("A", "A2").add("B", "B2").create();
  35. bb.commit().add("A", "A3"); // this new content in index should survive
  36. stats = gc.getStatistics();
  37. assertEquals(9, stats.numberOfLooseObjects);
  38. assertEquals(0, stats.numberOfPackedObjects);
  39. gc.setExpireAgeMillis(0);
  40. fsTick();
  41. gc.gc();
  42. stats = gc.getStatistics();
  43. assertEquals(0, stats.numberOfLooseObjects);
  44. assertEquals(8, stats.numberOfPackedObjects);
  45. assertEquals(1, stats.numberOfPackFiles);
  46. }
  47. }