60
60
/**
61
61
* Tests for the functionality provided by the AnalyzerGuru class.
62
62
*/
63
- public class AnalyzerGuruTest {
63
+ class AnalyzerGuruTest {
64
64
65
65
@ Test
66
- public void testGetFileTypeDescriptions () {
66
+ void testGetFileTypeDescriptions () {
67
67
Map <String , String > map = AnalyzerGuru .getfileTypeDescriptions ();
68
68
assertTrue (map .size () > 0 );
69
69
}
@@ -73,7 +73,7 @@ public void testGetFileTypeDescriptions() {
73
73
* known extension.
74
74
*/
75
75
@ Test
76
- public void testFileNameSameAsExtension () throws Exception {
76
+ void testFileNameSameAsExtension () throws Exception {
77
77
ByteArrayInputStream in = new ByteArrayInputStream (
78
78
"#!/bin/sh\n exec /usr/bin/zip \" $@\" \n " .getBytes (StandardCharsets .US_ASCII ));
79
79
String file = "/dummy/path/to/source/zip" ;
@@ -82,7 +82,7 @@ public void testFileNameSameAsExtension() throws Exception {
82
82
}
83
83
84
84
@ Test
85
- public void testUTF8ByteOrderMark () throws Exception {
85
+ void testUTF8ByteOrderMark () throws Exception {
86
86
byte [] xml = {(byte ) 0xEF , (byte ) 0xBB , (byte ) 0xBF , // UTF-8 BOM
87
87
'<' , '?' , 'x' , 'm' , 'l' , ' ' ,
88
88
'v' , 'e' , 'r' , 's' , 'i' , 'o' , 'n' , '=' ,
@@ -93,7 +93,7 @@ public void testUTF8ByteOrderMark() throws Exception {
93
93
}
94
94
95
95
@ Test
96
- public void testUTF8ByteOrderMarkPlusCopyrightSymbol () throws Exception {
96
+ void testUTF8ByteOrderMarkPlusCopyrightSymbol () throws Exception {
97
97
byte [] doc = {(byte ) 0xEF , (byte ) 0xBB , (byte ) 0xBF , // UTF-8 BOM
98
98
'/' , '/' , ' ' , (byte ) 0xC2 , (byte ) 0xA9 };
99
99
ByteArrayInputStream in = new ByteArrayInputStream (doc );
@@ -102,7 +102,7 @@ public void testUTF8ByteOrderMarkPlusCopyrightSymbol() throws Exception {
102
102
}
103
103
104
104
@ Test
105
- public void testUTF8ByteOrderMarkPlainFile () throws Exception {
105
+ void testUTF8ByteOrderMarkPlainFile () throws Exception {
106
106
byte [] bytes = {(byte ) 0xEF , (byte ) 0xBB , (byte ) 0xBF , // UTF-8 BOM
107
107
'h' , 'e' , 'l' , 'l' , 'o' , ' ' ,
108
108
'w' , 'o' , 'r' , 'l' , 'd' };
@@ -113,7 +113,7 @@ public void testUTF8ByteOrderMarkPlainFile() throws Exception {
113
113
}
114
114
115
115
@ Test
116
- public void testUTF16BigByteOrderMarkPlusCopyrightSymbol () throws Exception {
116
+ void testUTF16BigByteOrderMarkPlusCopyrightSymbol () throws Exception {
117
117
byte [] doc = {(byte ) 0xFE , (byte ) 0xFF , // UTF-16BE BOM
118
118
0 , '#' , 0 , ' ' , (byte ) 0xC2 , (byte ) 0xA9 };
119
119
ByteArrayInputStream in = new ByteArrayInputStream (doc );
@@ -122,7 +122,7 @@ public void testUTF16BigByteOrderMarkPlusCopyrightSymbol() throws Exception {
122
122
}
123
123
124
124
@ Test
125
- public void testUTF16LittleByteOrderMarkPlusCopyrightSymbol () throws Exception {
125
+ void testUTF16LittleByteOrderMarkPlusCopyrightSymbol () throws Exception {
126
126
byte [] doc = {(byte ) 0xFF , (byte ) 0xFE , // UTF-16BE BOM
127
127
'#' , 0 , ' ' , 0 , (byte ) 0xA9 , (byte ) 0xC2 };
128
128
ByteArrayInputStream in = new ByteArrayInputStream (doc );
@@ -131,7 +131,7 @@ public void testUTF16LittleByteOrderMarkPlusCopyrightSymbol() throws Exception {
131
131
}
132
132
133
133
@ Test
134
- public void addExtension () throws Exception {
134
+ void addExtension () throws Exception {
135
135
// should not find analyzer for this unlikely extension
136
136
assertNull (AnalyzerGuru .find ("file.unlikely_extension" ));
137
137
@@ -150,7 +150,7 @@ public void addExtension() throws Exception {
150
150
}
151
151
152
152
@ Test
153
- public void addPrefix () throws Exception {
153
+ void addPrefix () throws Exception {
154
154
// should not find analyzer for this unlikely extension
155
155
assertNull (AnalyzerGuru .find ("unlikely_prefix.foo" ));
156
156
@@ -169,7 +169,7 @@ public void addPrefix() throws Exception {
169
169
}
170
170
171
171
@ Test
172
- public void testZip () throws IOException {
172
+ void testZip () throws IOException {
173
173
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
174
174
ZipOutputStream zos = new ZipOutputStream (baos );
175
175
zos .putNextEntry (new ZipEntry ("dummy" ));
@@ -181,7 +181,7 @@ public void testZip() throws IOException {
181
181
}
182
182
183
183
@ Test
184
- public void testJar () throws IOException {
184
+ void testJar () throws IOException {
185
185
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
186
186
JarOutputStream jos = new JarOutputStream (baos );
187
187
jos .putNextEntry (new JarEntry ("dummy" ));
@@ -193,21 +193,21 @@ public void testJar() throws IOException {
193
193
}
194
194
195
195
@ Test
196
- public void testPlainText () throws IOException {
196
+ void testPlainText () throws IOException {
197
197
ByteArrayInputStream in = new ByteArrayInputStream (
198
198
"This is a plain text file." .getBytes (StandardCharsets .US_ASCII ));
199
199
assertSame (PlainAnalyzer .class , AnalyzerGuru .getAnalyzer (in , "dummy" ).getClass ());
200
200
}
201
201
202
202
@ Test
203
- public void rfe2969 () {
203
+ void rfe2969 () {
204
204
AnalyzerFactory faf = AnalyzerGuru .find ("foo.hxx" );
205
205
assertNotNull (faf );
206
206
assertSame (CxxAnalyzerFactory .class , faf .getClass ());
207
207
}
208
208
209
209
@ Test
210
- public void rfe3401 () {
210
+ void rfe3401 () {
211
211
AnalyzerFactory f1 = AnalyzerGuru .find ("main.c" );
212
212
assertNotNull (f1 );
213
213
AnalyzerFactory f2 = AnalyzerGuru .find ("main.cc" );
@@ -219,7 +219,7 @@ public void rfe3401() {
219
219
* Test that matching of full names works. Bug #859.
220
220
*/
221
221
@ Test
222
- public void matchesFullName () {
222
+ void matchesFullName () {
223
223
String s = File .separator ; // so test works on Unix and Windows
224
224
String path = s + "path" + s + "to" + s + "Makefile" ;
225
225
AnalyzerFactory faf = AnalyzerGuru .find (path );
@@ -238,7 +238,7 @@ public void matchesFullName() {
238
238
* language + "AnalyzerFactory"
239
239
*/
240
240
@ Test
241
- public void getAnalyzerFactoryClass () {
241
+ void getAnalyzerFactoryClass () {
242
242
Class <?> fcForSh = AnalyzerGuru .getFactoryClass ("Sh" );
243
243
Class <?> fcForShAnalyzer = AnalyzerGuru .getFactoryClass ("ShAnalyzer" );
244
244
Class <?> fcSimpleName = AnalyzerGuru .getFactoryClass ("ShAnalyzerFactory" );
@@ -251,50 +251,50 @@ public void getAnalyzerFactoryClass() {
251
251
}
252
252
253
253
@ Test
254
- public void shouldNotThrowGettingCsprojOpening () throws IOException {
254
+ void shouldNotThrowGettingCsprojOpening () throws IOException {
255
255
InputStream res = getClass ().getClassLoader ().getResourceAsStream ("analysis/a.csproj" );
256
256
assertNotNull (res , "despite embedded a.csproj," );
257
257
assertSame (XMLAnalyzer .class , AnalyzerGuru .getAnalyzer (res , "dummy" ).getClass (), "despite normal a.csproj," );
258
258
}
259
259
260
260
@ Test
261
- public void shouldMatchPerlHashbang () throws IOException {
261
+ void shouldMatchPerlHashbang () throws IOException {
262
262
ByteArrayInputStream in = new ByteArrayInputStream (
263
263
"#!/usr/bin/perl -w" .getBytes (StandardCharsets .US_ASCII ));
264
264
assertSame (PerlAnalyzer .class , AnalyzerGuru .getAnalyzer (in , "dummy" ).getClass (), "despite Perl hashbang," );
265
265
}
266
266
267
267
@ Test
268
- public void shouldMatchPerlHashbangSpaced () throws IOException {
268
+ void shouldMatchPerlHashbangSpaced () throws IOException {
269
269
ByteArrayInputStream in = new ByteArrayInputStream (
270
270
"\n \t #! /usr/bin/perl -w" .getBytes (StandardCharsets .US_ASCII ));
271
271
assertSame (PerlAnalyzer .class , AnalyzerGuru .getAnalyzer (in , "dummy" ).getClass (), "despite Perl hashbang," );
272
272
}
273
273
274
274
@ Test
275
- public void shouldMatchEnvPerlHashbang () throws IOException {
275
+ void shouldMatchEnvPerlHashbang () throws IOException {
276
276
ByteArrayInputStream in = new ByteArrayInputStream (
277
277
"#!/usr/bin/env perl -w" .getBytes (StandardCharsets .US_ASCII ));
278
278
assertSame (PerlAnalyzer .class , AnalyzerGuru .getAnalyzer (in , "dummy" ).getClass (), "despite env hashbang with perl," );
279
279
}
280
280
281
281
@ Test
282
- public void shouldMatchEnvPerlHashbangSpaced () throws IOException {
282
+ void shouldMatchEnvPerlHashbangSpaced () throws IOException {
283
283
ByteArrayInputStream in = new ByteArrayInputStream (
284
284
"\n \t #! /usr/bin/env\t perl -w" .getBytes (StandardCharsets .US_ASCII ));
285
285
assertSame (PerlAnalyzer .class , AnalyzerGuru .getAnalyzer (in , "dummy" ).getClass (),
286
286
"despite env hashbang with perl," );
287
287
}
288
288
289
289
@ Test
290
- public void shouldNotMatchEnvLFPerlHashbang () throws IOException {
290
+ void shouldNotMatchEnvLFPerlHashbang () throws IOException {
291
291
ByteArrayInputStream in = new ByteArrayInputStream (
292
292
"#!/usr/bin/env\n perl" .getBytes (StandardCharsets .US_ASCII ));
293
293
assertNotSame (PerlAnalyzer .class , AnalyzerGuru .getAnalyzer (in , "dummy" ).getClass (), "despite env hashbang LF," );
294
294
}
295
295
296
296
@ Test
297
- public void shouldMatchELFMagic () throws Exception {
297
+ void shouldMatchELFMagic () throws Exception {
298
298
byte [] elfmt = {(byte ) 0x7F , 'E' , 'L' , 'F' , (byte ) 2 , (byte ) 2 , (byte ) 1 ,
299
299
(byte ) 0x06 };
300
300
ByteArrayInputStream in = new ByteArrayInputStream (elfmt );
@@ -303,7 +303,7 @@ public void shouldMatchELFMagic() throws Exception {
303
303
}
304
304
305
305
@ Test
306
- public void shouldMatchJavaClassMagic () throws Exception {
306
+ void shouldMatchJavaClassMagic () throws Exception {
307
307
String oldMagic = "\312 \376 \272 \276 " ; // cafebabe?
308
308
String newMagic = new String (new byte [] {(byte ) 0xCA , (byte ) 0xFE ,
309
309
(byte ) 0xBA , (byte ) 0xBE }, StandardCharsets .UTF_8 );
@@ -318,15 +318,15 @@ public void shouldMatchJavaClassMagic() throws Exception {
318
318
}
319
319
320
320
@ Test
321
- public void shouldMatchTroffMagic () throws Exception {
321
+ void shouldMatchTroffMagic () throws Exception {
322
322
byte [] mandoc = {' ' , '\n' , '.' , '\"' , '\n' , '.' , 'T' , 'H' , (byte ) 0x20 , '\n' };
323
323
ByteArrayInputStream in = new ByteArrayInputStream (mandoc );
324
324
AbstractAnalyzer fa = AnalyzerGuru .getAnalyzer (in , "/dummy/file" );
325
325
assertSame (TroffAnalyzer .class , fa .getClass (), "despite .TH magic," );
326
326
}
327
327
328
328
@ Test
329
- public void shouldMatchMandocMagic () throws Exception {
329
+ void shouldMatchMandocMagic () throws Exception {
330
330
byte [] mandoc = {'\n' , ' ' , '.' , '\"' , '\n' , '.' , 'D' , 'd' , (byte ) 0x20 , '\n' };
331
331
ByteArrayInputStream in = new ByteArrayInputStream (mandoc );
332
332
AbstractAnalyzer fa = AnalyzerGuru .getAnalyzer (in , "/dummy/file" );
0 commit comments