-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package jenkins.bugs; | ||
|
||
import hudson.model.FreeStyleProject; | ||
import org.htmlunit.cssparser.parser.CSSErrorHandler; | ||
import org.htmlunit.cssparser.parser.CSSException; | ||
import org.htmlunit.cssparser.parser.CSSParseException; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ErrorCollector; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class Jenkins14749Test { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Rule | ||
public ErrorCollector errors = new ErrorCollector(); | ||
|
||
@Test | ||
public void dashboard() throws Exception { | ||
JenkinsRule.WebClient webClient = createErrorReportingWebClient(); | ||
webClient.goTo(""); | ||
} | ||
|
||
@Test | ||
public void project() throws Exception { | ||
FreeStyleProject p = j.createFreeStyleProject(); | ||
JenkinsRule.WebClient webClient = createErrorReportingWebClient(); | ||
webClient.getPage(p); | ||
} | ||
|
||
@Test | ||
public void configureProject() throws Exception { | ||
FreeStyleProject p = j.createFreeStyleProject(); | ||
JenkinsRule.WebClient webClient = createErrorReportingWebClient(); | ||
webClient.getPage(p, "configure"); | ||
} | ||
|
||
@Test | ||
public void manage() throws Exception { | ||
JenkinsRule.WebClient webClient = createErrorReportingWebClient(); | ||
webClient.goTo("manage"); | ||
} | ||
|
||
@Test | ||
public void system() throws Exception { | ||
JenkinsRule.WebClient webClient = createErrorReportingWebClient(); | ||
webClient.goTo("manage/configure"); | ||
} | ||
|
||
private JenkinsRule.WebClient createErrorReportingWebClient() { | ||
JenkinsRule.WebClient webClient = j.createWebClient(); | ||
webClient.setCssErrorHandler(new CSSErrorHandler() { | ||
@Override | ||
public void warning(final CSSParseException exception) throws CSSException { | ||
if (!ignore(exception)) { | ||
errors.addError(exception); | ||
} | ||
} | ||
|
||
@Override | ||
public void error(final CSSParseException exception) throws CSSException { | ||
if (!ignore(exception)) { | ||
errors.addError(exception); | ||
} | ||
} | ||
|
||
@Override | ||
public void fatalError(final CSSParseException exception) throws CSSException { | ||
if (!ignore(exception)) { | ||
errors.addError(exception); | ||
} | ||
} | ||
|
||
private boolean ignore(final CSSParseException exception) { | ||
// Keep in sync with HudsonTestCase/JenkinsRule | ||
return exception.getURI().contains("/yui/"); | ||
} | ||
}); | ||
return webClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters