Skip to content
Permalink
Browse files
Silence warnings in test code and use correct parameter when calling …
…chained constructor

When chaining the constructor to add a default UA, we lost one parameter (replaced it
with another). That seems wrong, so I changed it back to the (hopefully) correct one.

While we are here, suppress a few other warnings from error prone, that can't be
fixed in a quick way. Feel free, to fix them.
  • Loading branch information
FSchumacher committed Apr 18, 2022
1 parent bcb2f22 commit 14ab8da63b820feb66ab1539cdab4976b77ae4e1
Showing 1 changed file with 9 additions and 7 deletions.
@@ -90,6 +90,7 @@ private StaticTestClass() {
}
}

@SuppressWarnings("ClassCanBeStatic")
private class TestClass // Can't instantiate
{
private TestClass() {
@@ -99,7 +100,7 @@ private TestClass() {
private static class TestData {
private String fileName;

private String baseURL;
private String baseUrl;

private String expectedSet;

@@ -113,10 +114,9 @@ private static class TestData {
* @param baseUrl Base URL
* @param expectedSet Set of expected URLs
* @param expectedList List of expected URLs
* @param userAgent User Agent
*/
private TestData(String htmlFileName, String baseUrl, String expectedSet, String expectedList) {
this(htmlFileName, baseUrl, expectedList, expectedList, DEFAULT_UA);
this(htmlFileName, baseUrl, expectedSet, expectedList, DEFAULT_UA);
}
/**
*
@@ -128,7 +128,7 @@ private TestData(String htmlFileName, String baseUrl, String expectedSet, String
*/
private TestData(String htmlFileName, String baseUrl, String expectedSet, String expectedList, String userAgent) {
this.fileName = htmlFileName;
this.baseURL = baseUrl;
this.baseUrl = baseUrl;
this.expectedSet = expectedSet;
this.expectedList = expectedList;
this.userAgent = userAgent;
@@ -359,26 +359,28 @@ public void testNotCreatableStatic() throws Exception {

public void testParserSet() throws Exception {
HTMLParser p = (HTMLParser) BaseParser.getParser(parserName);
filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseURL, TESTS[testNumber].expectedSet, null,
filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseUrl, TESTS[testNumber].expectedSet, null,
false, TESTS[testNumber].userAgent);
}

@SuppressWarnings("JdkObsolete")
public void testParserList() throws Exception {
HTMLParser p = (HTMLParser) BaseParser.getParser(parserName);
filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseURL, TESTS[testNumber].expectedList,
filetest(p, TESTS[testNumber].fileName, TESTS[testNumber].baseUrl, TESTS[testNumber].expectedList,
new Vector<URLString>(), true, TESTS[testNumber].userAgent);
}

public void testSpecificParserList() throws Exception {
HTMLParser p = (HTMLParser) BaseParser.getParser(parserName);
filetest(p, SPECIFIC_PARSER_TESTS[testNumber].fileName,
SPECIFIC_PARSER_TESTS[testNumber].baseURL,
SPECIFIC_PARSER_TESTS[testNumber].baseUrl,
SPECIFIC_PARSER_TESTS[testNumber].expectedList,
new ArrayList<URLString>(), true,
SPECIFIC_PARSER_TESTS[testNumber].userAgent);
}


@SuppressWarnings("URLEqualsHashCode")
private static void filetest(HTMLParser p, String file, String url, String resultFile, Collection<URLString> c,
boolean orderMatters, // Does the order matter?
String userAgent)

0 comments on commit 14ab8da

Please sign in to comment.