18
18
*/
19
19
20
20
/*
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.
22
22
* Portions Copyright (c) 2017, Chris Fraire <[email protected] >.
23
23
*/
24
24
package org .opengrok .indexer .analysis ;
35
35
import java .util .zip .ZipEntry ;
36
36
import java .util .zip .ZipOutputStream ;
37
37
38
- import org .junit .Test ;
38
+ import org .junit .jupiter . api . Test ;
39
39
import org .opengrok .indexer .analysis .archive .ZipAnalyzer ;
40
40
import org .opengrok .indexer .analysis .c .CxxAnalyzerFactory ;
41
41
import org .opengrok .indexer .analysis .document .MandocAnalyzer ;
49
49
import org .opengrok .indexer .analysis .sh .ShAnalyzer ;
50
50
import org .opengrok .indexer .analysis .sh .ShAnalyzerFactory ;
51
51
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 ;
59
59
60
60
/**
61
61
* Tests for the functionality provided by the AnalyzerGuru class.
@@ -98,7 +98,7 @@ public void testUTF8ByteOrderMarkPlusCopyrightSymbol() throws Exception {
98
98
'/' , '/' , ' ' , (byte ) 0xC2 , (byte ) 0xA9 };
99
99
ByteArrayInputStream in = new ByteArrayInputStream (doc );
100
100
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," );
102
102
}
103
103
104
104
@ Test
@@ -118,8 +118,7 @@ public void testUTF16BigByteOrderMarkPlusCopyrightSymbol() throws Exception {
118
118
0 , '#' , 0 , ' ' , (byte ) 0xC2 , (byte ) 0xA9 };
119
119
ByteArrayInputStream in = new ByteArrayInputStream (doc );
120
120
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," );
123
122
}
124
123
125
124
@ Test
@@ -128,7 +127,7 @@ public void testUTF16LittleByteOrderMarkPlusCopyrightSymbol() throws Exception {
128
127
'#' , 0 , ' ' , 0 , (byte ) 0xA9 , (byte ) 0xC2 };
129
128
ByteArrayInputStream in = new ByteArrayInputStream (doc );
130
129
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," );
132
131
}
133
132
134
133
@ Test
@@ -254,49 +253,44 @@ public void getAnalyzerFactoryClass() {
254
253
@ Test
255
254
public void shouldNotThrowGettingCsprojOpening () throws IOException {
256
255
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," );
260
258
}
261
259
262
260
@ Test
263
261
public void shouldMatchPerlHashbang () throws IOException {
264
262
ByteArrayInputStream in = new ByteArrayInputStream (
265
263
"#!/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," );
268
265
}
269
266
270
267
@ Test
271
268
public void shouldMatchPerlHashbangSpaced () throws IOException {
272
269
ByteArrayInputStream in = new ByteArrayInputStream (
273
270
"\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," );
276
272
}
277
273
278
274
@ Test
279
275
public void shouldMatchEnvPerlHashbang () throws IOException {
280
276
ByteArrayInputStream in = new ByteArrayInputStream (
281
277
"#!/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," );
284
279
}
285
280
286
281
@ Test
287
282
public void shouldMatchEnvPerlHashbangSpaced () throws IOException {
288
283
ByteArrayInputStream in = new ByteArrayInputStream (
289
284
"\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," );
292
287
}
293
288
294
289
@ Test
295
290
public void shouldNotMatchEnvLFPerlHashbang () throws IOException {
296
291
ByteArrayInputStream in = new ByteArrayInputStream (
297
292
"#!/usr/bin/env\n perl" .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," );
300
294
}
301
295
302
296
@ Test
@@ -305,37 +299,37 @@ public void shouldMatchELFMagic() throws Exception {
305
299
(byte ) 0x06 };
306
300
ByteArrayInputStream in = new ByteArrayInputStream (elfmt );
307
301
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," );
309
303
}
310
304
311
305
@ Test
312
306
public void shouldMatchJavaClassMagic () throws Exception {
313
307
String oldMagic = "\312 \376 \272 \276 " ; // cafebabe?
314
308
String newMagic = new String (new byte [] {(byte ) 0xCA , (byte ) 0xFE ,
315
309
(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," );
317
311
318
312
// 0xCAFEBABE (4), minor (2), major (2)
319
313
byte [] dotclass = {(byte ) 0xCA , (byte ) 0xFE , (byte ) 0xBA , (byte ) 0xBE ,
320
314
(byte ) 0 , (byte ) 1 , (byte ) 0 , (byte ) 0x34 };
321
315
ByteArrayInputStream in = new ByteArrayInputStream (dotclass );
322
316
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," );
324
318
}
325
319
326
320
@ Test
327
321
public void shouldMatchTroffMagic () throws Exception {
328
322
byte [] mandoc = {' ' , '\n' , '.' , '\"' , '\n' , '.' , 'T' , 'H' , (byte ) 0x20 , '\n' };
329
323
ByteArrayInputStream in = new ByteArrayInputStream (mandoc );
330
324
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," );
332
326
}
333
327
334
328
@ Test
335
329
public void shouldMatchMandocMagic () throws Exception {
336
330
byte [] mandoc = {'\n' , ' ' , '.' , '\"' , '\n' , '.' , 'D' , 'd' , (byte ) 0x20 , '\n' };
337
331
ByteArrayInputStream in = new ByteArrayInputStream (mandoc );
338
332
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," );
340
334
}
341
335
}
0 commit comments