|
18 | 18 | */
|
19 | 19 |
|
20 | 20 | /*
|
21 |
| - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. |
| 21 | + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. |
22 | 22 | * Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
|
23 | 23 | */
|
24 | 24 | package org.opengrok.indexer.configuration;
|
|
33 | 33 | import java.io.InputStreamReader;
|
34 | 34 | import java.lang.reflect.Field;
|
35 | 35 | import java.lang.reflect.Modifier;
|
| 36 | +import java.nio.file.Files; |
| 37 | +import java.nio.file.Path; |
36 | 38 | import java.util.LinkedList;
|
37 | 39 | import java.util.stream.Collectors;
|
| 40 | +import java.util.stream.Stream; |
38 | 41 | import javax.xml.XMLConstants;
|
39 | 42 | import javax.xml.parsers.SAXParser;
|
40 | 43 | import javax.xml.parsers.SAXParserFactory;
|
41 | 44 |
|
42 | 45 | import org.junit.jupiter.api.Test;
|
43 | 46 | import org.junit.jupiter.params.ParameterizedTest;
|
| 47 | +import org.junit.jupiter.params.provider.Arguments; |
| 48 | +import org.junit.jupiter.params.provider.MethodSource; |
44 | 49 | import org.junit.jupiter.params.provider.ValueSource;
|
45 | 50 | import org.opengrok.indexer.util.ClassUtil;
|
46 | 51 |
|
| 52 | +import org.opengrok.indexer.util.IOUtils; |
47 | 53 | import org.xml.sax.Attributes;
|
48 | 54 | import org.xml.sax.ext.DefaultHandler2;
|
49 | 55 |
|
@@ -234,4 +240,34 @@ void testLoadingValidConfiguration() throws IOException {
|
234 | 240 | }
|
235 | 241 | }
|
236 | 242 |
|
| 243 | + private static Stream<Arguments> getArgsForTestCheckConfigurationBugPage() { |
| 244 | + return Stream.of( |
| 245 | + Arguments.of(true, true), |
| 246 | + Arguments.of(true, false), |
| 247 | + Arguments.of(false, true), |
| 248 | + Arguments.of(false, false) |
| 249 | + ); |
| 250 | + } |
| 251 | + |
| 252 | + @ParameterizedTest |
| 253 | + @MethodSource("getArgsForTestCheckConfigurationBugPage") |
| 254 | + void testCheckConfigurationBugPage(boolean valid, boolean bugPage) throws IOException { |
| 255 | + Configuration cfg = new Configuration(); |
| 256 | + Path tmpSourceRoot = Files.createTempDirectory("sourceRoot"); |
| 257 | + cfg.setSourceRoot(tmpSourceRoot.toString()); |
| 258 | + Path tmpDataRoot = Files.createTempDirectory("dataRoot"); |
| 259 | + cfg.setDataRoot(tmpDataRoot.toString()); |
| 260 | + if (bugPage) { |
| 261 | + cfg.setBugPage("http://example.org/bug?" + (valid ? "" : "\"")); |
| 262 | + } else { |
| 263 | + cfg.setReviewPage("http://example.org/review?" + (valid ? "" : "\"")); |
| 264 | + } |
| 265 | + if (!valid) { |
| 266 | + assertThrows(Configuration.ConfigurationException.class, cfg::checkConfiguration); |
| 267 | + } else { |
| 268 | + assertDoesNotThrow(cfg::checkConfiguration); |
| 269 | + } |
| 270 | + IOUtils.removeRecursive(tmpSourceRoot); |
| 271 | + IOUtils.removeRecursive(tmpDataRoot); |
| 272 | + } |
237 | 273 | }
|
0 commit comments