4141import org .junit .jupiter .api .BeforeAll ;
4242import org .junit .jupiter .api .BeforeEach ;
4343import org .junit .jupiter .api .Test ;
44+ import org .opengrok .indexer .configuration .Configuration ;
4445import org .opengrok .indexer .configuration .RuntimeEnvironment ;
4546import org .opengrok .indexer .history .RepositoryFactory ;
4647import org .opengrok .indexer .util .FileUtilities ;
5152 * Verify index check.
5253 * @author Vladimír Kotal
5354 */
54- public class IndexCheckTest {
55+ class IndexCheckTest {
5556
5657 private TestRepository repository ;
5758 private final RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
5859 private Path oldIndexDataDir ;
60+ private Configuration configuration ;
5961
6062 @ BeforeAll
6163 public static void setUpClass () {
@@ -68,6 +70,9 @@ public void setUp() throws IOException {
6870 repository = new TestRepository ();
6971 repository .create (IndexerTest .class .getResourceAsStream ("/org/opengrok/indexer/history/repositories.zip" ));
7072 oldIndexDataDir = null ;
73+ configuration = new Configuration ();
74+ configuration .setDataRoot (env .getDataRootPath ());
75+ configuration .setSourceRoot (env .getSourceRootPath ());
7176 }
7277
7378 @ AfterEach
@@ -84,36 +89,38 @@ public void tearDown() throws IOException {
8489 */
8590 private void testIndexVersion (boolean projectsEnabled , List <String > subFiles ) throws Exception {
8691 env .setHistoryEnabled (false );
92+ configuration .setHistoryEnabled (false );
8793 env .setProjectsEnabled (projectsEnabled );
94+ configuration .setProjectsEnabled (projectsEnabled );
8895 Indexer .getInstance ().prepareIndexer (env , true , true ,
8996 false , null , null );
9097 Indexer .getInstance ().doIndexerExecution (true , null , null );
9198
92- IndexCheck .check (subFiles );
99+ IndexCheck .check (configuration , subFiles );
93100 }
94101
95102 @ Test
96- public void testIndexVersionNoIndex () throws Exception {
97- IndexCheck .check (new ArrayList <>());
103+ void testIndexVersionNoIndex () {
104+ IndexCheck .check (configuration , new ArrayList <>());
98105 }
99106
100107 @ Test
101- public void testIndexVersionProjects () throws Exception {
108+ void testIndexVersionProjects () throws Exception {
102109 testIndexVersion (true , new ArrayList <>());
103110 }
104111
105112 @ Test
106- public void testIndexVersionSelectedProjects () throws Exception {
113+ void testIndexVersionSelectedProjects () throws Exception {
107114 testIndexVersion (true , Arrays .asList ("mercurial" , "git" ));
108115 }
109116
110117 @ Test
111- public void testIndexVersionNoProjects () throws Exception {
118+ void testIndexVersionNoProjects () throws Exception {
112119 testIndexVersion (false , new ArrayList <>());
113120 }
114121
115122 @ Test
116- public void testIndexVersionOldIndex () throws Exception {
123+ void testIndexVersionOldIndex () throws Exception {
117124 oldIndexDataDir = Files .createTempDirectory ("data" );
118125 Path indexPath = oldIndexDataDir .resolve ("index" );
119126 Files .createDirectory (indexPath );
@@ -125,8 +132,10 @@ public void testIndexVersionOldIndex() throws Exception {
125132 assertTrue (archive .isFile (), "archive exists" );
126133 FileUtilities .extractArchive (archive , indexDir );
127134 env .setDataRoot (oldIndexDataDir .toString ());
135+ configuration .setDataRoot (oldIndexDataDir .toString ());
128136 env .setProjectsEnabled (false );
129- assertFalse (IndexCheck .check (new ArrayList <>()));
137+ configuration .setProjectsEnabled (false );
138+ assertFalse (IndexCheck .check (configuration , new ArrayList <>()));
130139
131140 assertThrows (IndexCheck .IndexVersionException .class , () -> IndexCheck .checkDir (indexDir ));
132141 }
0 commit comments