@Test
  public void transform() throws Exception {
    Resource mainCss = new ClassPathResource("test/main.css", getClass());
    Resource resource = this.transformerChain.transform(this.request, mainCss);
    TransformedResource transformedResource = (TransformedResource) resource;

    String expected =
        "\n"
            + "@import url(\"bar-11e16cf79faee7ac698c805cf28248d2.css\");\n"
            + "@import url('bar-11e16cf79faee7ac698c805cf28248d2.css');\n"
            + "@import url(bar-11e16cf79faee7ac698c805cf28248d2.css);\n\n"
            + "@import \"foo-e36d2e05253c6c7085a91522ce43a0b4.css\";\n"
            + "@import 'foo-e36d2e05253c6c7085a91522ce43a0b4.css';\n\n"
            + "body { background: url(\"images/image-f448cd1d5dba82b774f3202c878230b3.png\") }\n";

    String result = new String(transformedResource.getByteArray(), "UTF-8");
    result = StringUtils.deleteAny(result, "\r");
    assertEquals(expected, result);
  }
  @Test
  public void transformExtLinksNotAllowed() throws Exception {
    ResourceResolverChain resolverChain = Mockito.mock(DefaultResourceResolverChain.class);
    ResourceTransformerChain transformerChain =
        new DefaultResourceTransformerChain(
            resolverChain, Arrays.asList(new CssLinkResourceTransformer()));

    Resource externalCss = new ClassPathResource("test/external.css", getClass());
    Resource resource = transformerChain.transform(this.request, externalCss);
    TransformedResource transformedResource = (TransformedResource) resource;

    String expected =
        "@import url(\"http://example.org/fonts/css\");\n"
            + "body { background: url(\"file:///home/spring/image.png\") }";
    String result = new String(transformedResource.getByteArray(), "UTF-8");
    result = StringUtils.deleteAny(result, "\r");
    assertEquals(expected, result);

    Mockito.verify(resolverChain, Mockito.never())
        .resolveUrlPath("http://example.org/fonts/css", Arrays.asList(externalCss));
    Mockito.verify(resolverChain, Mockito.never())
        .resolveUrlPath("file:///home/spring/image.png", Arrays.asList(externalCss));
  }