Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/Configuration.java @ 202:706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 26 Apr 2011 02:50:06 +0200 |
parents | a736f42ed75b |
children | 66fd2c73c56f |
comparison
equal
deleted
inserted
replaced
201:a736f42ed75b | 202:706bcc7cfee4 |
---|---|
17 package org.tmatesoft.hg.test; | 17 package org.tmatesoft.hg.test; |
18 | 18 |
19 import static org.junit.Assert.*; | 19 import static org.junit.Assert.*; |
20 | 20 |
21 import java.io.File; | 21 import java.io.File; |
22 import java.util.ArrayList; | |
23 import java.util.Arrays; | |
22 import java.util.Collections; | 24 import java.util.Collections; |
23 import java.util.List; | 25 import java.util.List; |
24 | 26 |
25 import org.tmatesoft.hg.repo.HgLookup; | 27 import org.tmatesoft.hg.repo.HgLookup; |
26 import org.tmatesoft.hg.repo.HgRemoteRepository; | 28 import org.tmatesoft.hg.repo.HgRemoteRepository; |
34 public class Configuration { | 36 public class Configuration { |
35 | 37 |
36 private static Configuration inst; | 38 private static Configuration inst; |
37 private final File root; | 39 private final File root; |
38 private final HgLookup lookup; | 40 private final HgLookup lookup; |
41 private File tempDir; | |
42 private List<String> remoteServers; | |
39 | 43 |
40 private Configuration(File reposRoot) { | 44 private Configuration(File reposRoot) { |
41 root = reposRoot; | 45 root = reposRoot; |
42 lookup = new HgLookup(); | 46 lookup = new HgLookup(); |
43 } | 47 } |
63 assertNotNull(rv); | 67 assertNotNull(rv); |
64 assertFalse(rv.isInvalid()); | 68 assertFalse(rv.isInvalid()); |
65 return rv; | 69 return rv; |
66 } | 70 } |
67 | 71 |
72 // easy override for manual test runs | |
73 public void remoteServers(String... keys) { | |
74 remoteServers = Arrays.asList(keys); | |
75 } | |
76 | |
68 public List<HgRemoteRepository> allRemote() throws Exception { | 77 public List<HgRemoteRepository> allRemote() throws Exception { |
69 return Collections.singletonList(lookup.detectRemote("hg4j-gc", null)); | 78 if (remoteServers == null) { |
79 remoteServers = Collections.singletonList("hg4j-gc"); // just a default | |
80 } | |
81 ArrayList<HgRemoteRepository> rv = new ArrayList<HgRemoteRepository>(remoteServers.size()); | |
82 for (String key : remoteServers) { | |
83 rv.add(lookup.detectRemote(key, null)); | |
84 } | |
85 return rv; | |
86 } | |
87 | |
88 public File getTempDir() { | |
89 if (tempDir == null) { | |
90 String td = System.getProperty("hg4j.tests.tmpdir", System.getProperty("java.io.tmpdir")); | |
91 tempDir = new File(td); | |
92 } | |
93 return tempDir; | |
70 } | 94 } |
71 } | 95 } |