X-Git-Url: http://git.osdn.net/view?p=mikutoga%2FTogaGem.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fjp%2Fsfjp%2Fmikutoga%2Fxml%2FXmlResourceResolverTest.java;fp=src%2Ftest%2Fjava%2Fjp%2Fsfjp%2Fmikutoga%2Fxml%2FXmlResourceResolverTest.java;h=4b540309d4ea1aa5a830ae9f8de6946751a91a4d;hp=0000000000000000000000000000000000000000;hb=e9585200f4122a8ab3b6c56a67e5eaadb6bdadb0;hpb=b1fef4ec0adcd1d3b614ef4508123847b4760c06 diff --git a/src/test/java/jp/sfjp/mikutoga/xml/XmlResourceResolverTest.java b/src/test/java/jp/sfjp/mikutoga/xml/XmlResourceResolverTest.java new file mode 100644 index 0000000..4b54030 --- /dev/null +++ b/src/test/java/jp/sfjp/mikutoga/xml/XmlResourceResolverTest.java @@ -0,0 +1,93 @@ +/* + */ + +package jp.sfjp.mikutoga.xml; + +import java.net.URI; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + */ +public class XmlResourceResolverTest { + + public XmlResourceResolverTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of buildBaseRelativeURI method, of class XmlResourceResolver. + */ + @Test + public void testBuildBaseRelativeURI() throws Exception { + System.out.println("buildBaseRelativeURI"); + + URI result; + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com", "/a"); + assertEquals("http://example.com/a", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/", "a"); + assertEquals("http://example.com/a", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/", "/a"); + assertEquals("http://example.com/a", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/a", "/b"); + assertEquals("http://example.com/b", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/a/", "b"); + assertEquals("http://example.com/a/b", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/a/", "/b"); + assertEquals("http://example.com/b", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/a", "http://example.org/b"); + assertEquals("http://example.org/b", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI(null, "http://example.org/b"); + assertEquals("http://example.org/b", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/a", null); + assertEquals("http://example.com/", result.toASCIIString()); + + result = XmlResourceResolver.buildBaseRelativeURI("http://example.com/a/b/", "../c"); + assertEquals("http://example.com/a/c", result.toASCIIString()); + + try{ + XmlResourceResolver.buildBaseRelativeURI("a/b/", "c/d"); + fail(); + }catch(IllegalArgumentException e){ + assert true; + } + + try{ + XmlResourceResolver.buildBaseRelativeURI(null, "c/d"); + fail(); + }catch(IllegalArgumentException e){ + assert true; + } + + return; + } + +}