Class AssetResolutionAssert
The console chrome links its assets at context-root URLs such as /juneau-console/chrome.css, so they only
load if the host mounts something at those paths. Page tests that assert the hrefs cannot see a missing mount;
this helper fetches each URL through whatever client the caller supplies and reports every one that does not
answer 200.
The fetcher is a plain Function from URL to HTTP status, so the class has no dependency on a test
framework or on a particular client. Failures throw AssertionError. Only same-origin URLs are checked:
absolute http(s):, protocol-relative, data: and fragment-only URLs are skipped.
Example:
MockRestClient
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAsserts that every asset the page links answers200, naming the page in the failure message.static voidassertAssetsResolve(String html, Function<String, Integer> statusOf) Asserts that every asset the page links answers200.Returns the same-origin asset URLs a page links, in document order and without duplicates.unresolved(String html, Function<String, Integer> statusOf) Returns a description of every linked asset that does not answer200.
-
Method Details
-
assetUrls
Returns the same-origin asset URLs a page links, in document order and without duplicates.Covers
<script src>,<img src>and<link href>whoserelis a stylesheet, icon, preload or manifest.&is decoded and any fragment is dropped.- Parameters:
html- The rendered page.- Returns:
- The asset URLs. Never
null .
-
unresolved
Returns a description of every linked asset that does not answer200.- Parameters:
html- The rendered page.statusOf- Fetches a URL and returns its HTTP status code.- Returns:
- One
"<status> <url>"entry per failing asset, sorted; empty when every asset resolves.
-
assertAssetsResolve
Asserts that every asset the page links answers200.- Parameters:
html- The rendered page.statusOf- Fetches a URL and returns its HTTP status code.- Throws:
AssertionError- If any linked asset does not resolve; the message lists each one.
-
assertAssetsResolve
Asserts that every asset the page links answers200, naming the page in the failure message.- Parameters:
page- A label for the page (typically its path); can benull .html- The rendered page.statusOf- Fetches a URL and returns its HTTP status code.- Throws:
AssertionError- If any linked asset does not resolve; the message lists each one.
-