@Test
  public void testCssUrls() throws Exception {

    String output = service.externalize(source, serverUrl);

    assertTrue("Output is empty", StringUtils.isNotEmpty(output));

    // check CSS URLs
    assertTrue(
        "CSS URLs were not rewritten correctly",
        output.contains("background: url(\"" + serverUrl + "/css/images"));
  }
  @Test
  public void testJavaScript() throws Exception {

    String output = service.externalize(source, serverUrl);

    assertTrue("Output is empty", StringUtils.isNotEmpty(output));

    Source src = new Source(output);

    // check JavaScript
    List<Element> scriptTags = src.getAllElements(HTMLElementName.SCRIPT);
    assertTrue(
        "Not all script tags were removed. " + scriptTags.size() + " tags remain.",
        scriptTags.isEmpty());
  }
  @Test
  public void testUrls() throws Exception {

    String output = service.externalize(source, serverUrl);

    assertTrue("Output is empty", StringUtils.isNotEmpty(output));

    Source src = new Source(output);

    // check URLs
    List<StartTag> linkStartTags = src.getAllStartTags(HTMLElementName.A);
    for (StartTag startTag : linkStartTags) {
      String href = startTag.getAttributeValue("href");
      assertTrue(
          "The URL was not rewritten correctly: " + href, href == null || !href.startsWith("/"));
    }
  }
  @Test
  public void testCss() throws Exception {

    String output = service.externalize(source, serverUrl);

    assertTrue("Output is empty", StringUtils.isNotEmpty(output));

    Source src = new Source(output);

    // check CSS
    List<StartTag> cssStartTags = src.getAllStartTags(HTMLElementName.LINK);
    for (StartTag startTag : cssStartTags) {
      String rel = startTag.getAttributeValue("rel");
      assertTrue(
          "CSS was not inlined correctly " + startTag.getAttributeValue("href"),
          rel == null || !"stylesheet".equalsIgnoreCase(rel));
    }
  }