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.

T0004_PackReaderTest.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C) 2008-2009, Google Inc.
  3. * Copyright (C) 2008, Imran M Yousuf <imyousuf@smartitengineering.com>
  4. * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
  5. * Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org> and others
  6. *
  7. * This program and the accompanying materials are made available under the
  8. * terms of the Eclipse Distribution License v. 1.0 which is available at
  9. * https://www.eclipse.org/org/documents/edl-v10.php.
  10. *
  11. * SPDX-License-Identifier: BSD-3-Clause
  12. */
  13. package org.eclipse.jgit.internal.storage.file;
  14. import static org.junit.Assert.assertEquals;
  15. import static org.junit.Assert.assertNotNull;
  16. import java.io.IOException;
  17. import org.eclipse.jgit.lib.Constants;
  18. import org.eclipse.jgit.lib.ObjectId;
  19. import org.eclipse.jgit.lib.ObjectLoader;
  20. import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
  21. import org.junit.Test;
  22. public class T0004_PackReaderTest extends SampleDataRepositoryTestCase {
  23. private static final String PACK_NAME = "34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
  24. @Test
  25. public void test003_lookupCompressedObject() throws IOException {
  26. final ObjectId id;
  27. final ObjectLoader or;
  28. Pack pr = null;
  29. for (Pack p : db.getObjectDatabase().getPacks()) {
  30. if (PACK_NAME.equals(p.getPackName())) {
  31. pr = p;
  32. break;
  33. }
  34. }
  35. assertNotNull("have pack-" + PACK_NAME, pr);
  36. id = ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327");
  37. or = pr.get(new WindowCursor(null), id);
  38. assertNotNull(or);
  39. assertEquals(Constants.OBJ_TREE, or.getType());
  40. assertEquals(35, or.getSize());
  41. pr.close();
  42. }
  43. @Test
  44. public void test004_lookupDeltifiedObject() throws IOException {
  45. final ObjectId id;
  46. final ObjectLoader or;
  47. id = ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259");
  48. or = db.open(id);
  49. assertNotNull(or);
  50. assertEquals(Constants.OBJ_BLOB, or.getType());
  51. assertEquals(18009, or.getSize());
  52. }
  53. }