41
41
import org .junit .jupiter .api .BeforeAll ;
42
42
import org .junit .jupiter .api .BeforeEach ;
43
43
import org .junit .jupiter .api .Test ;
44
+ import org .opengrok .indexer .configuration .Configuration ;
44
45
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
45
46
import org .opengrok .indexer .history .RepositoryFactory ;
46
47
import org .opengrok .indexer .util .FileUtilities ;
51
52
* Verify index check.
52
53
* @author Vladimír Kotal
53
54
*/
54
- public class IndexCheckTest {
55
+ class IndexCheckTest {
55
56
56
57
private TestRepository repository ;
57
58
private final RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
58
59
private Path oldIndexDataDir ;
60
+ private Configuration configuration ;
59
61
60
62
@ BeforeAll
61
63
public static void setUpClass () {
@@ -68,6 +70,9 @@ public void setUp() throws IOException {
68
70
repository = new TestRepository ();
69
71
repository .create (IndexerTest .class .getResourceAsStream ("/org/opengrok/indexer/history/repositories.zip" ));
70
72
oldIndexDataDir = null ;
73
+ configuration = new Configuration ();
74
+ configuration .setDataRoot (env .getDataRootPath ());
75
+ configuration .setSourceRoot (env .getSourceRootPath ());
71
76
}
72
77
73
78
@ AfterEach
@@ -84,36 +89,38 @@ public void tearDown() throws IOException {
84
89
*/
85
90
private void testIndexVersion (boolean projectsEnabled , List <String > subFiles ) throws Exception {
86
91
env .setHistoryEnabled (false );
92
+ configuration .setHistoryEnabled (false );
87
93
env .setProjectsEnabled (projectsEnabled );
94
+ configuration .setProjectsEnabled (projectsEnabled );
88
95
Indexer .getInstance ().prepareIndexer (env , true , true ,
89
96
false , null , null );
90
97
Indexer .getInstance ().doIndexerExecution (true , null , null );
91
98
92
- IndexCheck .check (subFiles );
99
+ IndexCheck .check (configuration , subFiles );
93
100
}
94
101
95
102
@ Test
96
- public void testIndexVersionNoIndex () throws Exception {
97
- IndexCheck .check (new ArrayList <>());
103
+ void testIndexVersionNoIndex () {
104
+ IndexCheck .check (configuration , new ArrayList <>());
98
105
}
99
106
100
107
@ Test
101
- public void testIndexVersionProjects () throws Exception {
108
+ void testIndexVersionProjects () throws Exception {
102
109
testIndexVersion (true , new ArrayList <>());
103
110
}
104
111
105
112
@ Test
106
- public void testIndexVersionSelectedProjects () throws Exception {
113
+ void testIndexVersionSelectedProjects () throws Exception {
107
114
testIndexVersion (true , Arrays .asList ("mercurial" , "git" ));
108
115
}
109
116
110
117
@ Test
111
- public void testIndexVersionNoProjects () throws Exception {
118
+ void testIndexVersionNoProjects () throws Exception {
112
119
testIndexVersion (false , new ArrayList <>());
113
120
}
114
121
115
122
@ Test
116
- public void testIndexVersionOldIndex () throws Exception {
123
+ void testIndexVersionOldIndex () throws Exception {
117
124
oldIndexDataDir = Files .createTempDirectory ("data" );
118
125
Path indexPath = oldIndexDataDir .resolve ("index" );
119
126
Files .createDirectory (indexPath );
@@ -125,8 +132,10 @@ public void testIndexVersionOldIndex() throws Exception {
125
132
assertTrue (archive .isFile (), "archive exists" );
126
133
FileUtilities .extractArchive (archive , indexDir );
127
134
env .setDataRoot (oldIndexDataDir .toString ());
135
+ configuration .setDataRoot (oldIndexDataDir .toString ());
128
136
env .setProjectsEnabled (false );
129
- assertFalse (IndexCheck .check (new ArrayList <>()));
137
+ configuration .setProjectsEnabled (false );
138
+ assertFalse (IndexCheck .check (configuration , new ArrayList <>()));
130
139
131
140
assertThrows (IndexCheck .IndexVersionException .class , () -> IndexCheck .checkDir (indexDir ));
132
141
}
0 commit comments