2 * Copyright 2005-2010 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;
31 * Tests for {@link org.wamblee.xml.ClasspathUriResolver}.
33 * @author Erik Brakkee
35 public class ClasspathUriResolverTest extends TestCase {
36 private URIResolver resolver;
41 * @see junit.framework.TestCase#setUp()
44 protected void setUp() throws Exception {
45 resolver = new ClasspathUriResolver();
49 * Resolves an existing file. Verifies the file is resolved correctly.
51 * @throws TransformerException
54 public void testResolveExistingFile() throws TransformerException,
56 Source source = resolver
57 .resolve("org/wamblee/xml/reportToHtml.xsl", "");
58 assertTrue(source instanceof StreamSource);
60 String resolved = FileSystemUtils.read(((StreamSource) source)
63 ClassPathResource resource = new ClassPathResource(
64 "org/wamblee/xml/reportToHtml.xsl");
65 String expected = FileSystemUtils.read(resource.getInputStream());
66 assertEquals(expected, resolved);
70 * Resolves a non-existing file. Verifies that a TransformerException is
74 public void testResolveNonExistingFile() {
77 "org/wamblee/xml/reportToHtml-nonexisting.xsl", "");
78 } catch (TransformerException e) {