View Javadoc
1   /*
2    * Copyright (C) 2009, Google Inc.
3    * Copyright (C) 2008-2009, Jonas Fonseca <fonseca@diku.dk>
4    * Copyright (C) 2007-2009, Robin Rosenberg <robin.rosenberg@dewire.com>
5    * Copyright (C) 2006-2007, 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  
14  package org.eclipse.jgit.test.resources;
15  
16  import java.io.File;
17  import java.io.IOException;
18  
19  import org.eclipse.jgit.internal.storage.file.FileRepository;
20  import org.eclipse.jgit.junit.JGitTestUtil;
21  import org.eclipse.jgit.junit.RepositoryTestCase;
22  
23  
24  /** Test case which includes C Git generated pack files for testing. */
25  public abstract class SampleDataRepositoryTestCase extends RepositoryTestCase {
26  	@Override
27  	public void setUp() throws Exception {
28  		super.setUp();
29  		copyCGitTestPacks(db);
30  	}
31  
32  	/**
33  	 * Copy C Git generated pack files into given repository for testing
34  	 *
35  	 * @param repo
36  	 *            test repository to receive packfile copies
37  	 * @throws IOException
38  	 */
39  	public static void copyCGitTestPacks(FileRepository repo) throws IOException {
40  		final String[] packs = {
41  				"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f",
42  				"pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371",
43  				"pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745",
44  				"pack-546ff360fe3488adb20860ce3436a2d6373d2796",
45  				"pack-cbdeda40019ae0e6e789088ea0f51f164f489d14",
46  				"pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa",
47  				"pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
48  		};
49  		final File packDir = repo.getObjectDatabase().getPackDirectory();
50  		for (String n : packs) {
51  			JGitTestUtil.copyTestResource(n + ".pack", new File(packDir, n + ".pack"));
52  			JGitTestUtil.copyTestResource(n + ".idx", new File(packDir, n + ".idx"));
53  		}
54  
55  		JGitTestUtil.copyTestResource("packed-refs",
56  				new File(repo.getDirectory(), "packed-refs"));
57  	}
58  }