Skip to content

Commit

Permalink
[error-prone] fix error: "ParserTest.java:[75,34] [CheckReturnValue] …
Browse files Browse the repository at this point in the history
…The result of `parseStylesheet(...)` must be used"
  • Loading branch information
asolntsev committed Oct 23, 2024
1 parent 4706487 commit 181e348
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import org.xhtmlrenderer.css.sheet.PropertyDeclaration;
import org.xhtmlrenderer.css.sheet.Ruleset;
import org.xhtmlrenderer.css.sheet.Stylesheet;
import org.xhtmlrenderer.css.sheet.StylesheetInfo.Origin;

import java.io.IOException;
import java.io.StringReader;

import static org.assertj.core.api.Assertions.assertThat;
import static org.xhtmlrenderer.css.sheet.StylesheetInfo.Origin.USER_AGENT;

public class ParserTest {
private final String test = String.format("div { background-image: url('something') }%n");
Expand All @@ -45,7 +45,7 @@ public void cssParsingPerformance() throws IOException {
for (int i = 0; i < 40; i++) {
long start = System.currentTimeMillis();
CSSParser p = new CSSParser(errorHandler);
Stylesheet stylesheet = p.parseStylesheet(null, Origin.USER_AGENT, new StringReader(longTest));
Stylesheet stylesheet = p.parseStylesheet(null, USER_AGENT, new StringReader(longTest));
long end = System.currentTimeMillis();
// System.out.println("Took " + (end-start) + " ms");
total += (end-start);
Expand All @@ -58,7 +58,7 @@ public void cssParsingPerformance() throws IOException {
for (int i = 0; i < 10; i++) {
long start = System.currentTimeMillis();
CSSParser p = new CSSParser(errorHandler);
Stylesheet stylesheet = p.parseStylesheet(null, Origin.USER_AGENT, new StringReader(longTest));
Stylesheet stylesheet = p.parseStylesheet(null, USER_AGENT, new StringReader(longTest));
long end = System.currentTimeMillis();
// System.out.println("Took " + (end-start) + " ms");
total += (end-start);
Expand All @@ -72,7 +72,10 @@ public void cssParsingPerformance() throws IOException {
for (int i = 0; i < 10; i++) {
long start = System.currentTimeMillis();
for (int j = 0; j < 10000; j++) {
p.parseStylesheet(null, Origin.USER_AGENT, new StringReader(test));
Stylesheet stylesheet = p.parseStylesheet(null, USER_AGENT, new StringReader(test));
assertThat(stylesheet.getURI()).isNull();
assertThat(stylesheet.getOrigin()).isEqualTo(USER_AGENT);
assertThat(stylesheet.getContents()).hasSize(1);
}
long end = System.currentTimeMillis();
// System.out.println("Took " + (end-start) + " ms");
Expand All @@ -85,7 +88,7 @@ public void cssParsingPerformance() throws IOException {
public void parseCss() throws IOException {
CSSParser p = new CSSParser(errorHandler);

Stylesheet stylesheet = p.parseStylesheet(null, Origin.USER_AGENT, new StringReader(test));
Stylesheet stylesheet = p.parseStylesheet(null, USER_AGENT, new StringReader(test));
assertThat(stylesheet.getContents()).hasSize(1);
Ruleset ruleset = (Ruleset) stylesheet.getContents().get(0);
org.assertj.core.api.Assertions.assertThat(ruleset.getFSSelectors()).hasSize(1);
Expand Down

0 comments on commit 181e348

Please sign in to comment.