38
38
import org .glassfish .jersey .internal .inject .AbstractBinder ;
39
39
import org .glassfish .jersey .server .ResourceConfig ;
40
40
import org .junit .jupiter .api .Test ;
41
+ import org .junit .jupiter .api .extension .ExtendWith ;
41
42
import org .mockito .Mock ;
42
- import org .mockito .MockitoAnnotations ;
43
+ import org .mockito .junit . jupiter . MockitoExtension ;
43
44
import org .opengrok .indexer .configuration .Configuration ;
44
45
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
45
46
import org .opengrok .indexer .web .DummyHttpServletRequest ;
46
47
import org .opengrok .web .PageConfig ;
47
48
import org .opengrok .web .api .v1 .suggester .provider .service .SuggesterService ;
48
49
49
- public class ConfigurationControllerTest extends OGKJerseyTest {
50
+ @ ExtendWith (MockitoExtension .class )
51
+ class ConfigurationControllerTest extends OGKJerseyTest {
50
52
51
53
private final RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
52
54
@@ -55,7 +57,6 @@ public class ConfigurationControllerTest extends OGKJerseyTest {
55
57
56
58
@ Override
57
59
protected Application configure () {
58
- MockitoAnnotations .initMocks (this );
59
60
return new ResourceConfig (ConfigurationController .class )
60
61
.register (new AbstractBinder () {
61
62
@ Override
@@ -66,7 +67,7 @@ protected void configure() {
66
67
}
67
68
68
69
@ Test
69
- public void testApplySetAndGetBasicConfig () {
70
+ void testApplySetAndGetBasicConfig () {
70
71
Configuration config = new Configuration ();
71
72
String srcRoot = "/foo" ;
72
73
config .setSourceRoot (srcRoot );
@@ -87,7 +88,7 @@ public void testApplySetAndGetBasicConfig() {
87
88
}
88
89
89
90
@ Test
90
- public void testApplySetInvalidMethod () {
91
+ void testApplySetInvalidMethod () {
91
92
Response r = setValue ("noMethodExists" , "1000" );
92
93
93
94
assertEquals (Response .Status .BAD_REQUEST .getStatusCode (), r .getStatus ());
@@ -101,7 +102,7 @@ private Response setValue(final String field, final String value) {
101
102
}
102
103
103
104
@ Test
104
- public void testApplyGetInvalidMethod () {
105
+ void testApplyGetInvalidMethod () {
105
106
Response r = target ("configuration" )
106
107
.path ("FooBar" )
107
108
.request ()
@@ -111,14 +112,14 @@ public void testApplyGetInvalidMethod() {
111
112
}
112
113
113
114
@ Test
114
- public void testApplySetInvalidMethodParameter () {
115
+ void testApplySetInvalidMethodParameter () {
115
116
Response r = setValue ("setDefaultProjects" , "1000" ); // expecting Set
116
117
117
118
assertEquals (Response .Status .BAD_REQUEST .getStatusCode (), r .getStatus ());
118
119
}
119
120
120
121
@ Test
121
- public void testApplySetOptionInteger () {
122
+ void testApplySetOptionInteger () {
122
123
assertEquals (25 , env .getHitsPerPage ());
123
124
124
125
setValue ("hitsPerPage" , "1000" );
@@ -129,14 +130,14 @@ public void testApplySetOptionInteger() {
129
130
}
130
131
131
132
@ Test
132
- public void testApplySetOptionInvalidInteger () {
133
+ void testApplySetOptionInvalidInteger () {
133
134
Response r = setValue ("hitsPerPage" , "abcd" );
134
135
135
136
assertEquals (Response .Status .BAD_REQUEST .getStatusCode (), r .getStatus ());
136
137
}
137
138
138
139
@ Test
139
- public void testApplySetOptionBooleanTrue () {
140
+ void testApplySetOptionBooleanTrue () {
140
141
testSetChattyStatusPageTrue ("true" );
141
142
testSetChattyStatusPageTrue ("on" );
142
143
testSetChattyStatusPageTrue ("1" );
@@ -151,7 +152,7 @@ private void testSetChattyStatusPageTrue(final String value) {
151
152
}
152
153
153
154
@ Test
154
- public void testApplySetOptionBooleanFalse () {
155
+ void testApplySetOptionBooleanFalse () {
155
156
testSetChattyStatusPageFalse ("false" );
156
157
testSetChattyStatusPageFalse ("off" );
157
158
testSetChattyStatusPageFalse ("0" );
@@ -166,21 +167,21 @@ private void testSetChattyStatusPageFalse(final String value) {
166
167
}
167
168
168
169
@ Test
169
- public void testApplySetOptionInvalidBoolean1 () {
170
+ void testApplySetOptionInvalidBoolean1 () {
170
171
Response r = setValue ("chattyStatusPage" , "1000" ); // only 1 is accepted as true
171
172
172
173
assertEquals (Response .Status .BAD_REQUEST .getStatusCode (), r .getStatus ());
173
174
}
174
175
175
176
@ Test
176
- public void testApplySetOptionInvalidBoolean2 () {
177
+ void testApplySetOptionInvalidBoolean2 () {
177
178
Response r = setValue ("chattyStatusPage" , "anything" );
178
179
179
180
assertEquals (Response .Status .BAD_REQUEST .getStatusCode (), r .getStatus ());
180
181
}
181
182
182
183
@ Test
183
- public void testApplySetOptionString () {
184
+ void testApplySetOptionString () {
184
185
String old = env .getUserPage ();
185
186
186
187
setValue ("userPage" , "http://users.portal.com?user=" );
@@ -195,7 +196,7 @@ public void testApplySetOptionString() {
195
196
}
196
197
197
198
@ Test
198
- public void testApplyGetOptionString () {
199
+ void testApplyGetOptionString () {
199
200
env .setSourceRoot ("/foo/bar" );
200
201
String response = target ("configuration" )
201
202
.path ("sourceRoot" )
@@ -206,7 +207,7 @@ public void testApplyGetOptionString() {
206
207
}
207
208
208
209
@ Test
209
- public void testApplyGetOptionInteger () {
210
+ void testApplyGetOptionInteger () {
210
211
int hitsPerPage = target ("configuration" )
211
212
.path ("hitsPerPage" )
212
213
.request ()
@@ -216,7 +217,7 @@ public void testApplyGetOptionInteger() {
216
217
}
217
218
218
219
@ Test
219
- public void testApplyGetOptionBoolean () {
220
+ void testApplyGetOptionBoolean () {
220
221
boolean response = target ("configuration" )
221
222
.path ("historyCache" )
222
223
.request ()
@@ -226,14 +227,14 @@ public void testApplyGetOptionBoolean() {
226
227
}
227
228
228
229
@ Test
229
- public void testSuggesterServiceNotifiedOnConfigurationFieldChange () {
230
+ void testSuggesterServiceNotifiedOnConfigurationFieldChange () {
230
231
reset (suggesterService );
231
232
setValue ("sourceRoot" , "test" );
232
233
verify (suggesterService ).refresh ();
233
234
}
234
235
235
236
@ Test
236
- public void testSuggesterServiceNotifiedOnConfigurationChange () {
237
+ void testSuggesterServiceNotifiedOnConfigurationChange () {
237
238
reset (suggesterService );
238
239
target ("configuration" )
239
240
.request ()
@@ -242,7 +243,7 @@ public void testSuggesterServiceNotifiedOnConfigurationChange() {
242
243
}
243
244
244
245
@ Test
245
- public void testConfigValueSetVsThread () throws InterruptedException {
246
+ void testConfigValueSetVsThread () throws InterruptedException {
246
247
int origValue = env .getHitsPerPage ();
247
248
final int [] threadValue = new int [1 ];
248
249
final CountDownLatch startLatch = new CountDownLatch (1 );
0 commit comments