diff --git a/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/collect/Finding.java b/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/collect/Finding.java
index cb9ec9eb..e65dbeb6 100644
--- a/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/collect/Finding.java
+++ b/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/collect/Finding.java
@@ -9,21 +9,18 @@
import java.util.List;
/**
- * A single "finding" from any check, i.e.:
- * A single "finding" from any check, i.e.:
+ * A single "finding" from any check, i.e.,
* - a missing image file
* - a missing label/id/bookmark (== broken link)
* - a duplicate label/id/bookmark
*/
+@Getter
public class Finding {
- @Getter
- String whatIsTheProblem; // i.e. which image is missing, which link/anchor is undefined
- @Getter
+ String whatIsTheProblem; // i.e., which image is missing, which link/anchor is undefined
int nrOfOccurrences;// how often does this specific finding occur in the checked-page
// suggestions are ordered: getAt(0) yields the best, getAt(1) the second and so forth
@Setter
- @Getter
List suggestions;
public Finding() {
@@ -31,17 +28,17 @@ public Finding() {
}
/**
- * no finding should exist without giving an explanation ("whatIsTheProblem")
+ * No finding should exist without giving an explanation ("whatIsTheProblem")
* about what went wrong.
*
- * @param whatIsTheProblem An explanation of what went wrong (i.e. name of missing file)
+ * @param whatIsTheProblem An explanation of what went wrong (i.e., name of the missing file)
*/
public Finding(String whatIsTheProblem) {
this(whatIsTheProblem, 1, new ArrayList<>(3));
}
/**
- * finding with explanation and several occurences
+ * Finding with explanation and several occurrences
*/
public Finding(String whatIsTheProblem, int nrOfOccurrences) {
this(whatIsTheProblem, nrOfOccurrences, new ArrayList<>(3));
@@ -49,7 +46,7 @@ public Finding(String whatIsTheProblem, int nrOfOccurrences) {
/**
- * most general constructor:
+ * Most general constructor:
* create Finding with explanation and nrOfOccurrences
*
* @param whatIsTheProblem An explanation of what went wrong (i.e. name of missing file)
@@ -62,7 +59,7 @@ public Finding(String whatIsTheProblem, int nrOfOccurrences, List sugges
}
/**
- * create Finding with explanation and suggestions
+ * Create Finding with explanation and suggestions
*
* @param whatIsTheProblem explanation what went wrong
* @param suggestions what could have been meant
diff --git a/htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/check/BrokenHttpLinksCheckerSpec.groovy b/htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/check/BrokenHttpLinksCheckerSpec.groovy
index dd8be8b9..0e102db2 100644
--- a/htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/check/BrokenHttpLinksCheckerSpec.groovy
+++ b/htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/check/BrokenHttpLinksCheckerSpec.groovy
@@ -6,14 +6,13 @@ import org.aim42.htmlsanitycheck.html.HtmlConst
import org.aim42.htmlsanitycheck.html.HtmlPage
import org.aim42.htmlsanitycheck.test.dns.CustomHostNameResolver
import org.wiremock.integrations.testcontainers.WireMockContainer
-import spock.lang.Ignore
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
import java.lang.reflect.Field
import java.lang.reflect.Proxy
-// see end-of-file for license information
+// see end-of-file for license information
class BrokenHttpLinksCheckerSpec extends Specification {
@@ -40,9 +39,10 @@ class BrokenHttpLinksCheckerSpec extends Specification {
}
/* executed before every single spec */
+
def setup() {
myConfig = new Configuration()
- brokenHttpLinksChecker = new BrokenHttpLinksChecker( myConfig )
+ brokenHttpLinksChecker = new BrokenHttpLinksChecker(myConfig)
collector = new SingleCheckResults()
}
@@ -57,24 +57,24 @@ class BrokenHttpLinksCheckerSpec extends Specification {
// Custom method to register the DNS resolver
private void registerCustomDnsResolver() {
try {
- Field implField = InetAddress.class.getDeclaredField("impl");
- implField.setAccessible(true);
- Object currentImpl = implField.get(null);
+ Field implField = InetAddress.class.getDeclaredField("impl")
+ implField.setAccessible(true)
+ Object currentImpl = implField.get(null)
Proxy newImpl = (Proxy) Proxy.newProxyInstance(
currentImpl.getClass().getClassLoader(),
currentImpl.getClass().getInterfaces(),
(proxy, method, args) -> {
- if ("lookupAllHostAddr".equals(method.getName()) && args.length == 1 && args[0] instanceof String) {
- return customHostNameResolver.resolve((String) args[0]);
+ if ("lookupAllHostAddr" == method.getName() && args.length == 1 && args[0] instanceof String) {
+ return customHostNameResolver.resolve((String) args[0])
}
- return method.invoke(currentImpl, args);
+ return method.invoke(currentImpl, args)
}
- );
+ )
- implField.set(null, newImpl);
+ implField.set(null, newImpl)
} catch (Exception e) {
- throw new RuntimeException("Failed to register custom DNS resolver", e);
+ throw new RuntimeException("Failed to register custom DNS resolver", e)
}
}
@@ -97,6 +97,7 @@ class BrokenHttpLinksCheckerSpec extends Specification {
def "one syntactically correct http URL is ok"() {
given: "an HTML page with a single correct anchor/link"
+ //noinspection HttpUrlsUsage
String HTML = """$HtmlConst.HTML_HEAD
google
$HtmlConst.HTML_END """
@@ -133,16 +134,18 @@ class BrokenHttpLinksCheckerSpec extends Specification {
collector.nrOfProblems() == 0
where:
- goodUrl << ["http://junit.org:$port/junit4",
- "http://plumelib.org:$port/plume-util",
- "http://people.csail.mit.edu:$port/cpacheco"
- ]
+ //noinspection HttpUrlsUsage
+ goodUrl << ["http://junit.org:$port/junit4",
+ "http://plumelib.org:$port/plume-util",
+ "http://people.csail.mit.edu:$port/cpacheco"
+ ]
}
def "single bad link is identified as problem"() {
given: "an HTML page with a single (bad) link"
+ //noinspection HttpUrlsUsage
String badhref = "http://arc42.org:$port/ui98jfuhenu87djch"
String HTML = """$HtmlConst.HTML_HEAD
nonexisting arc42 link
@@ -166,6 +169,7 @@ class BrokenHttpLinksCheckerSpec extends Specification {
def "amazon does not deliver 405 statuscode for links that really exist"() {
given: "an HTML page with a single (good) amazon link"
+ //noinspection HttpUrlsUsage
String goodAmazonLink = "http://www.amazon.com:$port/dp/B01A2QL9SS"
String HTML = """$HtmlConst.HTML_HEAD
Amazon
@@ -208,6 +212,7 @@ class BrokenHttpLinksCheckerSpec extends Specification {
def 'bad link #badLink is recognized as such'() {
given: "an HTML page with a single (broken) link"
+ //noinspection HttpUrlsUsage
String goodURL = "http://mock.codes$port/${badLink}"
String HTML = """$HtmlConst.HTML_HEAD
${badLink}
@@ -231,6 +236,7 @@ class BrokenHttpLinksCheckerSpec extends Specification {
def 'redirects are recognized and their new location is contained in warning message'() {
given: "the old arc42 (http!) page "
+ //noinspection HttpUrlsUsage
String HTML = """$HtmlConst.HTML_HEAD
$HtmlConst.HTML_END """
diff --git a/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/html/HtmlConst.java b/htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/html/HtmlConst.groovy
similarity index 81%
rename from htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/html/HtmlConst.java
rename to htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/html/HtmlConst.groovy
index 2216105f..04f6b4cf 100644
--- a/htmlSanityCheck-core/src/main/java/org/aim42/htmlsanitycheck/html/HtmlConst.java
+++ b/htmlSanityCheck-core/src/test/groovy/org/aim42/htmlsanitycheck/html/HtmlConst.groovy
@@ -1,10 +1,8 @@
-package org.aim42.htmlsanitycheck.html;
-
+package org.aim42.htmlsanitycheck.html
class HtmlConst {
- public static final String HTML_HEAD = " ";
- public static final String HTML_END = "";
-
+ static final String HTML_HEAD = " "
+ static final String HTML_END = ""
}