1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
9
* This library is free software; you can redistribute it and/or modify it
10
* under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2.1 of the License, or
12
* (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
30
* (C)opyright 2003-2005, by Thomas Morgner and Contributors.
32
* Original Author: Thomas Morgner;
33
* Contributor(s): David Gilbert (for Object Refinery Limited);
35
* $Id: IOUtilsTests.java,v 1.4 2005/10/18 13:16:15 mungady Exp $
39
* 05-Jan-2004 : Initial version
43
package org.jfree.io.junit;
45
import java.io.IOException;
48
import junit.framework.Test;
49
import junit.framework.TestCase;
50
import junit.framework.TestSuite;
52
import org.jfree.io.IOUtils;
55
* Creates a new test case.
57
public class IOUtilsTests extends TestCase {
60
* Returns the tests as a test suite.
62
* @return The test suite.
64
public static Test suite() {
65
return new TestSuite(IOUtilsTests.class);
69
* Constructs a new set of tests.
71
public IOUtilsTests() {
76
* Constructs a new set of tests.
78
* @param name the name of the tests.
80
public IOUtilsTests(final String name) {
85
* A test for the createRelativeURL() method.
87
* @throws IOException if there is an I/O problem.
89
public void testCreateRelativeURL() throws IOException {
90
final URL baseurl = new URL
91
("http://test.com:80/test/a/funny/directory/basefile.xml");
93
final URL testInput1 = new URL ("http://test.com:80/test/a/funny/directory/datafile.jpg");
94
String result = IOUtils.getInstance().createRelativeURL(testInput1, baseurl);
95
assertEquals("datafile.jpg", result);
96
assertEquals(testInput1, new URL (baseurl, result));
98
final URL testInput2 = new URL ("http://test.com:80/test/adatafile.jpg");
99
result = IOUtils.getInstance().createRelativeURL(testInput2, baseurl);
100
assertEquals("../../../adatafile.jpg", result);
101
assertEquals(testInput2, new URL (baseurl, result));
103
final URL testInput3 = new URL ("http://test.com:80/test/adatafile.jpg?query=test");
104
result = IOUtils.getInstance().createRelativeURL(testInput3, baseurl);
105
assertEquals("../../../adatafile.jpg?query=test", result);
106
assertEquals(testInput3, new URL (baseurl, result));