comparison test/org/tmatesoft/hg/test/Configuration.java @ 147:a05145db4d0c

Bring test repos along with us to recreate testbench
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 22 Feb 2011 15:49:26 +0100
parents
children a736f42ed75b
comparison
equal deleted inserted replaced
146:8c9f729f4dfa 147:a05145db4d0c
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program 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
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.test;
18
19 import static org.junit.Assert.*;
20
21 import java.io.File;
22
23 import org.tmatesoft.hg.repo.HgLookup;
24 import org.tmatesoft.hg.repo.HgRepository;
25
26 /**
27 *
28 * @author Artem Tikhomirov
29 * @author TMate Software Ltd.
30 */
31 public class Configuration {
32
33 private static Configuration inst;
34 private final File root;
35 private final HgLookup lookup;
36
37 private Configuration(File reposRoot) {
38 root = reposRoot;
39 lookup = new HgLookup();
40 }
41
42 public static Configuration get() {
43 if (inst == null) {
44 String repo2 = System.getProperty("hg4j.tests.repos");
45 assertNotNull(repo2);
46 File rr = new File(repo2);
47 assertTrue(rr.exists());
48 inst = new Configuration(rr);
49 }
50 return inst;
51 }
52
53 public HgRepository own() throws Exception {
54 return lookup.detectFromWorkingDir();
55 }
56
57 // fails if repo not found
58 public HgRepository find(String key) throws Exception {
59 HgRepository rv = lookup.detect(new File(root, key));
60 assertNotNull(rv);
61 assertFalse(rv.isInvalid());
62 return rv;
63 }
64 }