@@ -62,24 +62,16 @@ public class ProjectMessageTest {
62
62
private static TestRepository repository = new TestRepository ();
63
63
private final String ctagsProperty = "org.opensolaris.opengrok.analysis.Ctags" ;
64
64
65
- @ BeforeClass
66
- public static void setUpClass () throws Exception {
67
- repository = new TestRepository ();
68
- repository .create (HistoryGuru .class .getResourceAsStream (
69
- "repositories.zip" ));
70
- }
71
-
72
- @ AfterClass
73
- public static void tearDownClass () throws Exception {
74
- repository .destroy ();
75
- }
76
-
77
65
@ Before
78
66
public void setUp () throws IOException {
79
67
Assume .assumeTrue (new MercurialRepository ().isWorking ());
80
68
Assume .assumeTrue (new SubversionRepository ().isWorking ());
81
69
Assume .assumeTrue (new GitRepository ().isWorking ());
82
70
71
+ repository = new TestRepository ();
72
+ repository .create (HistoryGuru .class .getResourceAsStream (
73
+ "repositories.zip" ));
74
+
83
75
env = RuntimeEnvironment .getInstance ();
84
76
env .removeAllMessages ();
85
77
env .setSourceRoot (repository .getSourceRoot ());
@@ -96,6 +88,8 @@ public void tearDown() {
96
88
env .setProjects (new ConcurrentHashMap <>());
97
89
env .setRepositories (new ArrayList <RepositoryInfo >());
98
90
env .getProjectRepositoriesMap ().clear ();
91
+
92
+ repository .destroy ();
99
93
}
100
94
101
95
@ Test
@@ -145,10 +139,20 @@ public void testAdd() throws Exception {
145
139
m .addTag ("mercurial" );
146
140
Assert .assertTrue (env .getRepositories ().isEmpty ());
147
141
Assert .assertTrue (env .getProjects ().isEmpty ());
142
+
143
+ // Add a sub-repository.
144
+ File mercurialRoot = new File (repository .getSourceRoot () + File .separator + "mercurial" );
145
+ File subDir = new File (mercurialRoot , "usr" );
146
+ Assert .assertTrue (subDir .mkdir ());
147
+ MercurialRepositoryTest .runHgCommand (mercurialRoot ,
148
+ "clone" , mercurialRoot .getAbsolutePath (),
149
+ mercurialRoot .getAbsolutePath () + File .separator + "usr" + File .separator + "closed" );
150
+
151
+ env .setScanningDepth (3 );
148
152
m .apply (env );
149
153
Assert .assertTrue (env .getProjects ().containsKey ("mercurial" ));
150
154
Assert .assertEquals (1 , env .getProjects ().size ());
151
- Assert .assertEquals (1 , env .getRepositories ().size ());
155
+ Assert .assertEquals (2 , env .getRepositories ().size ());
152
156
153
157
// Add more projects and check that they have been added incrementally.
154
158
// At the same time, it checks that multiple projects can be added
@@ -158,7 +162,7 @@ public void testAdd() throws Exception {
158
162
m .addTag ("svn" );
159
163
m .apply (env );
160
164
Assert .assertEquals (3 , env .getProjects ().size ());
161
- Assert .assertEquals (3 , env .getRepositories ().size ());
165
+ Assert .assertEquals (4 , env .getRepositories ().size ());
162
166
Assert .assertTrue (env .getProjects ().containsKey ("git" ));
163
167
Assert .assertTrue (env .getProjects ().containsKey ("svn" ));
164
168
}
0 commit comments