2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.xml;
18 import junit.framework.TestCase;
20 import org.wamblee.io.ClassPathResource;
21 import org.wamblee.io.FileSystemUtils;
23 import java.io.IOException;
25 import javax.xml.transform.Source;
26 import javax.xml.transform.TransformerException;
27 import javax.xml.transform.URIResolver;
28 import javax.xml.transform.stream.StreamSource;
32 * Tests for {@link org.wamblee.xml.ClasspathUriResolver}.
34 * @author Erik Brakkee
36 public class ClasspathUriResolverTest extends TestCase {
37 private URIResolver resolver;
40 * @see junit.framework.TestCase#setUp()
43 protected void setUp() throws Exception {
44 resolver = new ClasspathUriResolver();
48 * Resolves an existing file. Verifies the file is resolved correctly.
49 * @throws TransformerException
52 public void testResolveExistingFile()
53 throws TransformerException, IOException {
54 Source source = resolver.resolve("org/wamblee/xml/reportToHtml.xsl", "");
55 assertTrue(source instanceof StreamSource);
57 String resolved = FileSystemUtils.read(((StreamSource) source).getInputStream());
59 ClassPathResource resource = new ClassPathResource(
60 "org/wamblee/xml/reportToHtml.xsl");
61 String expected = FileSystemUtils.read(resource.getInputStream());
62 assertEquals(expected, resolved);
66 * Resolves a non-existing file. Verifies that a TransformerException is thrown.
69 public void testResolveNonExistingFile() {
71 Source source = resolver.resolve("org/wamblee/xml/reportToHtml-nonexisting.xsl",
73 } catch (TransformerException e) {