~ubuntu-branches/ubuntu/lucid/libjcommon-java/lucid

« back to all changes in this revision

Viewing changes to source/org/jfree/io/junit/IOUtilsTests.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2006-02-09 15:58:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060209155813-fzi9zwh2rzedbllq
Tags: 1.0.0-1
* New stable upstream release (closes: #328574)
* Move to main - build with kaffe
* Use cdbs build system - added cdbs build-dependency
* Move package to pkg-java-maintainers for comaintenance, 
  added Christian Bayle and myself as uploaders
* Removed unneeded README.Debian
* Added README.Debian-source how the upstream tarball was cleaned
* Move big documentation in an own -doc package
* Register javadoc api with doc-base
* Standards-Version 3.6.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================
 
2
 * JCommon : a free general purpose class library for the Java(tm) platform
 
3
 * ========================================================================
 
4
 *
 
5
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 
6
 * 
 
7
 * Project Info:  http://www.jfree.org/jcommon/index.html
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 *
 
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, 
 
22
 * USA.  
 
23
 *
 
24
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 
25
 * in the United States and other countries.]
 
26
 * 
 
27
 * -----------------
 
28
 * IOUtilsTests.java
 
29
 * -----------------
 
30
 * (C)opyright 2003-2005, by Thomas Morgner and Contributors.
 
31
 *
 
32
 * Original Author:  Thomas Morgner;
 
33
 * Contributor(s):   David Gilbert (for Object Refinery Limited);
 
34
 *
 
35
 * $Id: IOUtilsTests.java,v 1.4 2005/10/18 13:16:15 mungady Exp $
 
36
 *
 
37
 * Changes 
 
38
 * -------
 
39
 * 05-Jan-2004 : Initial version
 
40
 *  
 
41
 */
 
42
 
 
43
package org.jfree.io.junit;
 
44
 
 
45
import java.io.IOException;
 
46
import java.net.URL;
 
47
 
 
48
import junit.framework.Test;
 
49
import junit.framework.TestCase;
 
50
import junit.framework.TestSuite;
 
51
 
 
52
import org.jfree.io.IOUtils;
 
53
 
 
54
/**
 
55
 * Creates a new test case.
 
56
 */
 
57
public class IOUtilsTests extends TestCase {
 
58
 
 
59
    /**
 
60
     * Returns the tests as a test suite.
 
61
     *
 
62
     * @return The test suite.
 
63
     */
 
64
    public static Test suite() {
 
65
        return new TestSuite(IOUtilsTests.class);
 
66
    }
 
67
 
 
68
    /**
 
69
     * Constructs a new set of tests.
 
70
     */
 
71
    public IOUtilsTests() {
 
72
        super();
 
73
    }
 
74
 
 
75
    /**
 
76
     * Constructs a new set of tests.
 
77
     *
 
78
     * @param name  the name of the tests.
 
79
     */
 
80
    public IOUtilsTests(final String name) {
 
81
        super(name);
 
82
    }
 
83
 
 
84
    /**
 
85
     * A test for the createRelativeURL() method.
 
86
     * 
 
87
     * @throws IOException if there is an I/O problem.
 
88
     */
 
89
    public void testCreateRelativeURL() throws IOException {
 
90
        final URL baseurl = new URL
 
91
            ("http://test.com:80/test/a/funny/directory/basefile.xml");
 
92
 
 
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));
 
97
 
 
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));
 
102
 
 
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));
 
107
    }
 
108
    
 
109
}