2 * Copyright (C) 2006 Shawn Pearce <spearce@spearce.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License, version 2.1, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org
.spearce
.jgit
.lib
;
20 import java
.io
.IOException
;
22 public class T0004_PackReader
extends RepositoryTestCase
{
23 private static final File TEST_PACK
= new File(new File("tst"),
24 "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
26 public void test003_lookupCompressedObject() throws IOException
{
29 final PackedObjectLoader or
;
31 id
= new ObjectId("902d5476fa249b7abc9d84c611577a81381f0327");
32 pr
= new PackFile(db
, TEST_PACK
);
33 or
= pr
.get(id
, new byte[Constants
.OBJECT_ID_LENGTH
]);
35 assertEquals(id
, or
.getId());
36 assertEquals(Constants
.TYPE_TREE
, or
.getType());
37 assertEquals(35, or
.getSize());
38 assertEquals(7738, or
.getDataOffset());
42 public void test004_lookupDeltifiedObject() throws IOException
{
44 final ObjectLoader or
;
46 id
= new ObjectId("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259");
47 or
= db
.openObject(id
);
49 assertTrue(or
instanceof PackedObjectLoader
);
50 assertEquals(id
, or
.getId());
51 assertEquals(Constants
.TYPE_BLOB
, or
.getType());
52 assertEquals(18009, or
.getSize());
53 assertEquals(537, ((PackedObjectLoader
) or
).getDataOffset());
56 public void test005_todopack() throws IOException
{
57 final File todopack
= new File(new File("tst"), "todopack");
58 if (!todopack
.isDirectory()) {
59 System
.err
.println("Skipping " + getName() + ": no " + todopack
);
63 final File packDir
= new File(db
.getObjectsDirectory(), "pack");
64 final String packname
= "pack-2e71952edc41f3ce7921c5e5dd1b64f48204cf35";
65 copyFile(new File(todopack
, packname
+ ".pack"), new File(packDir
,
67 copyFile(new File(todopack
, packname
+ ".idx"), new File(packDir
,
73 .mapTree(new ObjectId(
74 "aac9df07f653dd18b935298deb813e02c32d2e6f"));
79 .mapTree(new ObjectId(
80 "6b9ffbebe7b83ac6a61c9477ab941d999f5d0c96"));