42
42
import org .opengrok .indexer .history .RepositoryInfo ;
43
43
import org .opengrok .indexer .index .IndexDatabase ;
44
44
import org .opengrok .indexer .index .Indexer ;
45
+ import org .opengrok .indexer .util .IOUtils ;
45
46
import org .opengrok .indexer .util .TestRepository ;
46
47
47
48
import javax .ws .rs .client .Entity ;
48
49
import javax .ws .rs .core .Application ;
49
50
import javax .ws .rs .core .GenericType ;
50
51
import java .io .File ;
52
+ import java .io .IOException ;
53
+ import java .nio .file .CopyOption ;
54
+ import java .nio .file .Files ;
55
+ import java .nio .file .Path ;
56
+ import java .nio .file .StandardCopyOption ;
51
57
import java .util .ArrayList ;
52
58
import java .util .Arrays ;
53
59
import java .util .Collections ;
@@ -337,7 +343,7 @@ private void delete(final String project) {
337
343
}
338
344
339
345
@ Test
340
- public void testIndexed () {
346
+ public void testIndexed () throws IOException {
341
347
String projectName = "mercurial" ;
342
348
343
349
// When a project is added, it should be marked as not indexed.
@@ -357,9 +363,15 @@ public void testIndexed() {
357
363
358
364
// Add some changes to the repository.
359
365
File mercurialRoot = new File (repository .getSourceRoot () + File .separator + "mercurial" );
360
- MercurialRepositoryTest .runHgCommand (mercurialRoot ,
361
- "import" , HistoryGuru .getInstance ().getClass ().
362
- getResource ("/history/hg-export-subdir.txt" ).getPath ());
366
+
367
+ // copy file from jar to a temp file
368
+ Path temp = Files .createTempFile ("opengrok" , "temp" );
369
+ Files .copy (HistoryGuru .getInstance ().getClass ().getResourceAsStream ("/history/hg-export-subdir.txt" ),
370
+ temp , StandardCopyOption .REPLACE_EXISTING );
371
+
372
+ MercurialRepositoryTest .runHgCommand (mercurialRoot , "import" , temp .toString ());
373
+
374
+ temp .toFile ().delete ();
363
375
364
376
// Test that the project's indexed flag becomes true only after
365
377
// the message is applied.
0 commit comments