### Question:
AlternativeTextForAppletRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlUnknownElement applet : page.findAllAppletTags()) { if (applet.getTextContent() == null || applet.getTextContent().trim().isEmpty()) { violations.add(createViolation(applet, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void alternativeTextPresent() throws Exception { String content = "<html><body><applet code=\"Applet.class\">Displaying current stock prices.</applet></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }
@Test public void alternativeTextMissing() throws Exception { String content = "<html><body><applet code=\"Applet.class\"></applet></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }