22
33import static org .junit .jupiter .api .Assertions .assertNull ;
44import static org .junit .jupiter .api .Assertions .assertTrue ;
5+ import static org .junit .jupiter .api .Assumptions .assumeFalse ;
56
67import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
78import java .io .File ;
89import java .io .InputStream ;
10+ import java .net .URI ;
911import java .net .URL ;
1012import java .nio .ByteBuffer ;
1113import java .nio .charset .CharacterCodingException ;
1214import java .nio .charset .Charset ;
1315import java .nio .charset .CharsetDecoder ;
1416import java .nio .charset .CodingErrorAction ;
1517import java .nio .charset .StandardCharsets ;
18+ import java .util .Map ;
1619import java .util .Properties ;
1720import java .util .PropertyResourceBundle ;
1821import java .util .stream .Stream ;
@@ -28,14 +31,22 @@ public class PropertiesTest extends InjectedTest {
2831
2932 @ SuppressFBWarnings (value = "PATH_TRAVERSAL_IN" )
3033 static Stream <Arguments > resources () throws Exception {
31- return scan (new File (outputDirectory ), "properties" ).entrySet ().stream ()
32- .map (e -> Arguments .of (Named .of (e .getKey (), e .getValue ())));
34+ Map <String , URL > resources = scan (new File (outputDirectory ), "properties" );
35+ if (resources .isEmpty ()) {
36+ return Stream .of (Arguments .of (Named .of ("empty" , new URI ("file:///empty.properties" ).toURL ())));
37+ } else {
38+ return resources .entrySet ().stream ().map (e -> Arguments .of (Named .of (e .getKey (), e .getValue ())));
39+ }
3340 }
3441
3542 @ ParameterizedTest
3643 @ MethodSource ("resources" )
3744 @ SuppressFBWarnings (value = "URLCONNECTION_SSRF_FD" )
3845 void testProperties (URL resource ) throws Exception {
46+ assumeFalse (
47+ resource .toURI ().equals (new URI ("file:///empty.properties" )),
48+ "No properties file found - skipping test" );
49+
3950 Properties props = new Properties () {
4051 @ Override
4152 public synchronized Object put (Object key , Object value ) {
0 commit comments