- public void testResolveExistingFile() throws TransformerException,
- IOException {
- Source source = resolver
- .resolve("org/wamblee/xml/reportToHtml.xsl", "");
- assertTrue(source instanceof StreamSource);
+ public void testResolveExistingFileLSResourceResolver()
+ throws TransformerException, IOException {
+ LSInput source = resolver.resolveResource(null, null, "kees",
+ EXISTING_RESOURCE, null);
+ assertNotNull(source);
+
+ assertEquals("kees", source.getPublicId());
+ assertEquals(EXISTING_RESOURCE, source.getSystemId());
+
+ String resolved = FileSystemUtils.read(source.getByteStream());
+
+ ClassPathResource resource = new ClassPathResource(
+ EXISTING_RESOURCE);
+ String expected = FileSystemUtils.read(resource.getInputStream());
+ assertEquals(expected, resolved);
+ }
+
+ /**
+ * Resolves an existing file using a base path. Verifies the file is resolved correctly.
+ *
+ * @throws TransformerException
+ * @throws IOException
+ */
+ public void testResolveExistingFileLSResourceResolverUsingBasePath()
+ throws TransformerException, IOException {
+
+ resolver = new ClasspathUriResolver(PREFIX);
+ LSInput source = resolver.resolveResource(null, null, "kees",
+ REPORT_TO_HTML_XSL, null);
+ assertNotNull(source);
+
+ assertEquals("kees", source.getPublicId());
+ assertEquals(REPORT_TO_HTML_XSL, source.getSystemId());