Skip to content

Commit 52d1076

Browse files
ahornaceVladimir Kotal
authored andcommitted
Use junit5 in indexer
1 parent 2f7dccc commit 52d1076

File tree

221 files changed

+2553
-3703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+2553
-3703
lines changed

opengrok-indexer/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ Portions Copyright (c) 2020-2020, Lubos Kosco <[email protected]>.
133133
<scope>test</scope>
134134
</dependency>
135135
<dependency>
136-
<groupId>org.junit.vintage</groupId>
137-
<artifactId>junit-vintage-engine</artifactId>
136+
<groupId>org.junit.jupiter</groupId>
137+
<artifactId>junit-jupiter-params</artifactId>
138138
<scope>test</scope>
139139
</dependency>
140140
<dependency>
@@ -149,12 +149,12 @@ Portions Copyright (c) 2020-2020, Lubos Kosco <[email protected]>.
149149
<version>3.1.6</version>
150150
<scope>test</scope>
151151
</dependency>
152-
<dependency>
152+
<!--<dependency>
153153
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
154154
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
155155
<version>${jersey.version}</version>
156156
<scope>test</scope>
157-
</dependency>
157+
</dependency>-->
158158
<dependency>
159159
<groupId>org.mockito</groupId>
160160
<artifactId>mockito-core</artifactId>

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/AnalyzerGuruHelpTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
*/
2323
package org.opengrok.indexer.analysis;
2424

25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

27-
import static org.junit.Assert.assertFalse;
28-
import static org.junit.Assert.assertTrue;
27+
import static org.junit.jupiter.api.Assertions.assertFalse;
28+
import static org.junit.jupiter.api.Assertions.assertTrue;
2929

3030
/**
3131
* Represents a container for tests of {@link AnalyzerGuruHelp}.
@@ -34,8 +34,8 @@ public class AnalyzerGuruHelpTest {
3434
@Test
3535
public void shouldCreateReadableUsage() {
3636
String usage = AnalyzerGuruHelp.getUsage();
37-
assertFalse("usage is not empty", usage.isEmpty());
38-
assertTrue("usage contains \"*.\"", usage.contains("*."));
39-
assertTrue("usage contains \"#!\"", usage.contains("#!"));
37+
assertFalse(usage.isEmpty(), "usage is not empty");
38+
assertTrue(usage.contains("*."), "usage contains \"*.\"");
39+
assertTrue(usage.contains("#!"), "usage contains \"#!\"");
4040
}
4141
}

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/AnalyzerGuruTest.java

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis;
@@ -35,7 +35,7 @@
3535
import java.util.zip.ZipEntry;
3636
import java.util.zip.ZipOutputStream;
3737

38-
import org.junit.Test;
38+
import org.junit.jupiter.api.Test;
3939
import org.opengrok.indexer.analysis.archive.ZipAnalyzer;
4040
import org.opengrok.indexer.analysis.c.CxxAnalyzerFactory;
4141
import org.opengrok.indexer.analysis.document.MandocAnalyzer;
@@ -49,13 +49,13 @@
4949
import org.opengrok.indexer.analysis.sh.ShAnalyzer;
5050
import org.opengrok.indexer.analysis.sh.ShAnalyzerFactory;
5151

52-
import static org.junit.Assert.assertEquals;
53-
import static org.junit.Assert.assertNotEquals;
54-
import static org.junit.Assert.assertNotNull;
55-
import static org.junit.Assert.assertNotSame;
56-
import static org.junit.Assert.assertNull;
57-
import static org.junit.Assert.assertSame;
58-
import static org.junit.Assert.assertTrue;
52+
import static org.junit.jupiter.api.Assertions.assertEquals;
53+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
54+
import static org.junit.jupiter.api.Assertions.assertNotNull;
55+
import static org.junit.jupiter.api.Assertions.assertNotSame;
56+
import static org.junit.jupiter.api.Assertions.assertNull;
57+
import static org.junit.jupiter.api.Assertions.assertSame;
58+
import static org.junit.jupiter.api.Assertions.assertTrue;
5959

6060
/**
6161
* Tests for the functionality provided by the AnalyzerGuru class.
@@ -98,7 +98,7 @@ public void testUTF8ByteOrderMarkPlusCopyrightSymbol() throws Exception {
9898
'/', '/', ' ', (byte) 0xC2, (byte) 0xA9};
9999
ByteArrayInputStream in = new ByteArrayInputStream(doc);
100100
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
101-
assertSame("despite BOM as precise match,", PlainAnalyzer.class, fa.getClass());
101+
assertSame(PlainAnalyzer.class, fa.getClass(), "despite BOM as precise match,");
102102
}
103103

104104
@Test
@@ -118,8 +118,7 @@ public void testUTF16BigByteOrderMarkPlusCopyrightSymbol() throws Exception {
118118
0, '#', 0, ' ', (byte) 0xC2, (byte) 0xA9};
119119
ByteArrayInputStream in = new ByteArrayInputStream(doc);
120120
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
121-
assertSame("despite BOM as precise match,", PlainAnalyzer.class,
122-
fa.getClass());
121+
assertSame(PlainAnalyzer.class, fa.getClass(), "despite BOM as precise match,");
123122
}
124123

125124
@Test
@@ -128,7 +127,7 @@ public void testUTF16LittleByteOrderMarkPlusCopyrightSymbol() throws Exception {
128127
'#', 0, ' ', 0, (byte) 0xA9, (byte) 0xC2};
129128
ByteArrayInputStream in = new ByteArrayInputStream(doc);
130129
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
131-
assertSame("despite BOM as precise match,", PlainAnalyzer.class, fa.getClass());
130+
assertSame(PlainAnalyzer.class, fa.getClass(), "despite BOM as precise match,");
132131
}
133132

134133
@Test
@@ -254,49 +253,44 @@ public void getAnalyzerFactoryClass() {
254253
@Test
255254
public void shouldNotThrowGettingCsprojOpening() throws IOException {
256255
InputStream res = getClass().getClassLoader().getResourceAsStream("analysis/a.csproj");
257-
assertNotNull("despite embedded a.csproj,", res);
258-
assertSame("despite normal a.csproj,", XMLAnalyzer.class,
259-
AnalyzerGuru.getAnalyzer(res, "dummy").getClass());
256+
assertNotNull(res, "despite embedded a.csproj,");
257+
assertSame(XMLAnalyzer.class, AnalyzerGuru.getAnalyzer(res, "dummy").getClass(), "despite normal a.csproj,");
260258
}
261259

262260
@Test
263261
public void shouldMatchPerlHashbang() throws IOException {
264262
ByteArrayInputStream in = new ByteArrayInputStream(
265263
"#!/usr/bin/perl -w".getBytes(StandardCharsets.US_ASCII));
266-
assertSame("despite Perl hashbang,", PerlAnalyzer.class,
267-
AnalyzerGuru.getAnalyzer(in, "dummy").getClass());
264+
assertSame(PerlAnalyzer.class, AnalyzerGuru.getAnalyzer(in, "dummy").getClass(), "despite Perl hashbang,");
268265
}
269266

270267
@Test
271268
public void shouldMatchPerlHashbangSpaced() throws IOException {
272269
ByteArrayInputStream in = new ByteArrayInputStream(
273270
"\n\t #! /usr/bin/perl -w".getBytes(StandardCharsets.US_ASCII));
274-
assertSame("despite Perl hashbang,", PerlAnalyzer.class,
275-
AnalyzerGuru.getAnalyzer(in, "dummy").getClass());
271+
assertSame(PerlAnalyzer.class, AnalyzerGuru.getAnalyzer(in, "dummy").getClass(), "despite Perl hashbang,");
276272
}
277273

278274
@Test
279275
public void shouldMatchEnvPerlHashbang() throws IOException {
280276
ByteArrayInputStream in = new ByteArrayInputStream(
281277
"#!/usr/bin/env perl -w".getBytes(StandardCharsets.US_ASCII));
282-
assertSame("despite env hashbang with perl,", PerlAnalyzer.class,
283-
AnalyzerGuru.getAnalyzer(in, "dummy").getClass());
278+
assertSame(PerlAnalyzer.class, AnalyzerGuru.getAnalyzer(in, "dummy").getClass(), "despite env hashbang with perl,");
284279
}
285280

286281
@Test
287282
public void shouldMatchEnvPerlHashbangSpaced() throws IOException {
288283
ByteArrayInputStream in = new ByteArrayInputStream(
289284
"\n\t #! /usr/bin/env\t perl -w".getBytes(StandardCharsets.US_ASCII));
290-
assertSame("despite env hashbang with perl,", PerlAnalyzer.class,
291-
AnalyzerGuru.getAnalyzer(in, "dummy").getClass());
285+
assertSame(PerlAnalyzer.class, AnalyzerGuru.getAnalyzer(in, "dummy").getClass(),
286+
"despite env hashbang with perl,");
292287
}
293288

294289
@Test
295290
public void shouldNotMatchEnvLFPerlHashbang() throws IOException {
296291
ByteArrayInputStream in = new ByteArrayInputStream(
297292
"#!/usr/bin/env\nperl".getBytes(StandardCharsets.US_ASCII));
298-
assertNotSame("despite env hashbang LF,", PerlAnalyzer.class,
299-
AnalyzerGuru.getAnalyzer(in, "dummy").getClass());
293+
assertNotSame(PerlAnalyzer.class, AnalyzerGuru.getAnalyzer(in, "dummy").getClass(), "despite env hashbang LF,");
300294
}
301295

302296
@Test
@@ -305,37 +299,37 @@ public void shouldMatchELFMagic() throws Exception {
305299
(byte) 0x06};
306300
ByteArrayInputStream in = new ByteArrayInputStream(elfmt);
307301
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
308-
assertSame("despite \\177ELF magic,", ELFAnalyzer.class, fa.getClass());
302+
assertSame(ELFAnalyzer.class, fa.getClass(), "despite \\177ELF magic,");
309303
}
310304

311305
@Test
312306
public void shouldMatchJavaClassMagic() throws Exception {
313307
String oldMagic = "\312\376\272\276"; // cafebabe?
314308
String newMagic = new String(new byte[] {(byte) 0xCA, (byte) 0xFE,
315309
(byte) 0xBA, (byte) 0xBE}, StandardCharsets.UTF_8);
316-
assertNotEquals("despite octal string, escape it as unicode,", oldMagic, newMagic);
310+
assertNotEquals(oldMagic, newMagic, "despite octal string, escape it as unicode,");
317311

318312
// 0xCAFEBABE (4), minor (2), major (2)
319313
byte[] dotclass = {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE,
320314
(byte) 0, (byte) 1, (byte) 0, (byte) 0x34};
321315
ByteArrayInputStream in = new ByteArrayInputStream(dotclass);
322316
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
323-
assertSame("despite 0xCAFEBABE magic,", JavaClassAnalyzer.class, fa.getClass());
317+
assertSame(JavaClassAnalyzer.class, fa.getClass(), "despite 0xCAFEBABE magic,");
324318
}
325319

326320
@Test
327321
public void shouldMatchTroffMagic() throws Exception {
328322
byte[] mandoc = {' ', '\n', '.', '\"', '\n', '.', 'T', 'H', (byte) 0x20, '\n'};
329323
ByteArrayInputStream in = new ByteArrayInputStream(mandoc);
330324
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
331-
assertSame("despite .TH magic,", TroffAnalyzer.class, fa.getClass());
325+
assertSame(TroffAnalyzer.class, fa.getClass(), "despite .TH magic,");
332326
}
333327

334328
@Test
335329
public void shouldMatchMandocMagic() throws Exception {
336330
byte[] mandoc = {'\n', ' ', '.', '\"', '\n', '.', 'D', 'd', (byte) 0x20, '\n'};
337331
ByteArrayInputStream in = new ByteArrayInputStream(mandoc);
338332
AbstractAnalyzer fa = AnalyzerGuru.getAnalyzer(in, "/dummy/file");
339-
assertSame("despite .Dd magic,", MandocAnalyzer.class, fa.getClass());
333+
assertSame(MandocAnalyzer.class, fa.getClass(), "despite .Dd magic,");
340334
}
341335
}

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/CtagsParserTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis;
2525

26-
import static org.junit.Assert.assertEquals;
27-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
27+
28+
import static org.junit.jupiter.api.Assertions.assertEquals;
2829

2930
/**
3031
*

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/CtagsTest.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis;
2525

2626
import java.io.File;
27-
import org.junit.AfterClass;
28-
import static org.junit.Assert.assertEquals;
29-
import static org.junit.Assert.assertTrue;
30-
import org.junit.BeforeClass;
31-
import org.junit.Test;
27+
28+
import org.junit.jupiter.api.AfterAll;
29+
import org.junit.jupiter.api.BeforeAll;
30+
import org.junit.jupiter.api.Test;
3231
import org.opengrok.indexer.util.TestRepository;
3332

33+
import static org.junit.jupiter.api.Assertions.assertEquals;
34+
import static org.junit.jupiter.api.Assertions.assertTrue;
35+
3436
/**
3537
*
3638
* @author Lubos Kosco
@@ -40,7 +42,7 @@ public class CtagsTest {
4042
private static Ctags ctags;
4143
private static TestRepository repository;
4244

43-
@BeforeClass
45+
@BeforeAll
4446
public static void setUpClass() throws Exception {
4547
ctags = new Ctags();
4648

@@ -59,7 +61,7 @@ public static void setUpClass() throws Exception {
5961
ctags.setCTagsExtraOptionsFile(extraOptionsFile);
6062
}
6163

62-
@AfterClass
64+
@AfterAll
6365
public static void tearDownClass() {
6466
ctags.close();
6567
ctags = null;
@@ -83,8 +85,8 @@ private static Definitions getDefs(String fileName) throws Exception {
8385
*/
8486
@Test
8587
public void testDoCtags() throws Exception {
86-
Definitions result = getDefs("bug16070/arguments.c");
87-
assertEquals(13, result.numberOfSymbols());
88+
Definitions result = getDefs("bug16070/arguments.c");
89+
assertEquals(13, result.numberOfSymbols());
8890
}
8991

9092
/**
@@ -102,13 +104,13 @@ public void bug14924() throws Exception {
102104
int count = 0;
103105
for (Definitions.Tag tag : result.getTags()) {
104106
if (tag.type.startsWith("method")) {
105-
assertTrue("too many methods", count < names.length);
106-
assertEquals("method name", names[count], tag.symbol);
107-
assertEquals("method line", lines[count], tag.line);
107+
assertTrue(count < names.length, "too many methods");
108+
assertEquals(names[count], tag.symbol, "method name");
109+
assertEquals(lines[count], tag.line, "method line");
108110
count++;
109111
}
110112
}
111-
assertEquals("method count", names.length, count);
113+
assertEquals(names.length, count, "method count");
112114
}
113115

114116
/**
@@ -127,12 +129,12 @@ public void bug19195() throws Exception {
127129
int count = 0;
128130
for (Definitions.Tag tag : result.getTags()) {
129131
if (tag.type.startsWith("function")) {
130-
assertTrue("too many functions", count < names.length);
131-
assertEquals("function name", names[count], tag.symbol);
132-
assertEquals("function line", lines[count], tag.line);
132+
assertTrue(count < names.length, "too many functions");
133+
assertEquals(names[count], tag.symbol, "function name");
134+
assertEquals(lines[count], tag.line, "function line");
133135
count++;
134136
}
135137
}
136-
assertEquals("function count", names.length, count);
138+
assertEquals(names.length, count, "function count");
137139
}
138140
}

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/DefinitionsTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
*/
2424
package org.opengrok.indexer.analysis;
2525

26-
import java.util.Set;
26+
import org.junit.jupiter.api.Test;
2727

28-
import org.junit.Test;
28+
import java.util.Set;
2929

30-
import static org.junit.Assert.assertEquals;
31-
import static org.junit.Assert.assertFalse;
32-
import static org.junit.Assert.assertNotNull;
33-
import static org.junit.Assert.assertTrue;
30+
import static org.junit.jupiter.api.Assertions.assertEquals;
31+
import static org.junit.jupiter.api.Assertions.assertFalse;
32+
import static org.junit.jupiter.api.Assertions.assertNotNull;
33+
import static org.junit.jupiter.api.Assertions.assertTrue;
3434

3535
/**
3636
* @author austvik

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/ExpandTabsReaderTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
*/
2424
package org.opengrok.indexer.analysis;
2525

26+
import org.junit.jupiter.api.Test;
27+
2628
import java.io.BufferedReader;
2729
import java.io.IOException;
2830
import java.io.Reader;
2931
import java.io.StringReader;
30-
import static org.junit.Assert.assertEquals;
31-
import static org.junit.Assert.assertNull;
32-
import static org.junit.Assert.assertTrue;
33-
import org.junit.Test;
32+
33+
import static org.junit.jupiter.api.Assertions.assertEquals;
34+
import static org.junit.jupiter.api.Assertions.assertNull;
35+
import static org.junit.jupiter.api.Assertions.assertTrue;
3436

3537
/**
3638
* Unit tests for the ExpandTabsReader class.

0 commit comments

Comments
 (0)