1818 */
1919
2020/*
21- * Copyright (c) 2010, 2023 , Oracle and/or its affiliates. All rights reserved.
21+ * Copyright (c) 2010, 2026 , Oracle and/or its affiliates. All rights reserved.
2222 * Portions Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>.
2323 */
2424package org .opengrok .indexer .analysis ;
2525
2626import java .io .File ;
27+ import java .net .URL ;
2728import java .util .List ;
2829
2930import org .junit .jupiter .api .AfterAll ;
3334import org .junit .jupiter .api .condition .OS ;
3435import org .junit .jupiter .params .ParameterizedTest ;
3536import org .junit .jupiter .params .provider .MethodSource ;
37+ import org .junit .jupiter .params .provider .ValueSource ;
3638import org .opengrok .indexer .util .TestRepository ;
3739
3840import static org .junit .jupiter .api .Assertions .assertAll ;
3941import static org .junit .jupiter .api .Assertions .assertEquals ;
42+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
43+ import static org .junit .jupiter .api .Assertions .assertNull ;
4044import static org .junit .jupiter .api .Assertions .assertTrue ;
4145
4246/**
@@ -53,7 +57,9 @@ static void setUpClass() throws Exception {
5357 ctags = new Ctags ();
5458
5559 repository = new TestRepository ();
56- repository .create (CtagsTest .class .getClassLoader ().getResource ("sources" ));
60+ URL repositoryURL = CtagsTest .class .getClassLoader ().getResource ("sources" );
61+ assertNotNull (repositoryURL );
62+ repository .create (repositoryURL );
5763
5864 /*
5965 * This setting is only needed for bug19195 but it does not seem
@@ -84,6 +90,12 @@ private static Definitions getDefs(String fileName) throws Exception {
8490 return ctags .doCtags (new File (path ).getAbsolutePath ());
8591 }
8692
93+ @ ParameterizedTest
94+ @ ValueSource (strings = {"" , "\n " })
95+ void testEmptyFile (String filePath ) throws Exception {
96+ assertNull (ctags .doCtags (filePath ));
97+ }
98+
8799 /**
88100 * Test of doCtags method, of class Ctags.
89101 */
@@ -150,8 +162,8 @@ void testTfTags(final SingleTagTestData data) throws Exception {
150162 var defs = getDefs ("terraform/" + data .file + ".tf" );
151163 assertAll (
152164 () -> assertEquals (1 , defs .getTags ().size ()),
153- () -> assertEquals (data .symbol , defs .getTags ().get ( 0 ).symbol ),
154- () -> assertEquals (data .type , defs .getTags ().get ( 0 ).type )
165+ () -> assertEquals (data .symbol , defs .getTags ().getFirst ( ).symbol ),
166+ () -> assertEquals (data .type , defs .getTags ().getFirst ( ).type )
155167 );
156168 }
157169
@@ -166,16 +178,6 @@ private static List<SingleTagTestData> terraformTestParams() {
166178 );
167179 }
168180
169- private static class SingleTagTestData {
170- private final String file ;
171- private final String symbol ;
172- private final String type ;
173-
174- SingleTagTestData (final String file , final String symbol , final String type ) {
175- this .file = file ;
176- this .symbol = symbol ;
177- this .type = type ;
178- }
181+ private record SingleTagTestData (String file , String symbol , String type ) {
179182 }
180-
181183}
0 commit comments