tests/libjava-mauve/src/gnu/testlet/java/net/URI/ToStringTest.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.4
       
     2 
       
     3 /*
       
     4    Copyright (C) 2005 Andrew John Hughes (gnu_andrew@member.fsf.org)
       
     5 
       
     6    This file is part of Mauve.
       
     7 
       
     8    Mauve is free software; you can redistribute it and/or modify
       
     9    it under the terms of the GNU General Public License as published by
       
    10    the Free Software Foundation; either version 2, or (at your option)
       
    11    any later version.
       
    12 
       
    13    Mauve is distributed in the hope that it will be useful,
       
    14    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16    GNU General Public License for more details.
       
    17 
       
    18    You should have received a copy of the GNU General Public License
       
    19    along with Mauve; see the file COPYING.  If not, write to
       
    20    the Free Software Foundation, 59 Temple Place - Suite 330,
       
    21    Boston, MA 02111-1307, USA.
       
    22 */
       
    23 
       
    24 package gnu.testlet.java.net.URI;
       
    25 
       
    26 import gnu.testlet.Testlet;
       
    27 import gnu.testlet.TestHarness;
       
    28 
       
    29 import java.net.URI;
       
    30 import java.net.URISyntaxException;
       
    31 
       
    32 public class ToStringTest 
       
    33   implements Testlet
       
    34 {
       
    35 
       
    36   private static final String TEST_URI_1 = "http://example.com/examples?name=Fred#";
       
    37   private static final String TEST_URI_2 = "http://example.com/examples?name=Fred";
       
    38   private static final String TEST_URI_3 = "http://example.com/examples?";
       
    39   private static final String TEST_URI_4 = "http://example.com/examples";
       
    40   private static final String TEST_URI_5 = "://example.com/examples";
       
    41   private static final String TEST_URI_6 = "//example.com/examples";
       
    42   private static final String TEST_URI_7 = "http:///examples";
       
    43   private static final String TEST_URI_8 = "http:/examples";
       
    44 
       
    45   public void test(TestHarness h)
       
    46   {
       
    47     try
       
    48       {
       
    49 	URI test1 = new URI(TEST_URI_1);
       
    50 	h.check(test1.toString(), TEST_URI_1);
       
    51 	h.check(test1.getRawFragment(), "");
       
    52 	URI test2 = new URI(TEST_URI_2);
       
    53 	h.check(test2.toString(), TEST_URI_2);
       
    54 	h.check(test2.getRawFragment(), null);
       
    55 	URI test3 = new URI(TEST_URI_3);
       
    56 	h.check(test3.toString(), TEST_URI_3);
       
    57 	h.check(test3.getRawQuery(), "");
       
    58 	URI test4 = new URI(TEST_URI_4);
       
    59 	h.check(test4.toString(), TEST_URI_4);
       
    60 	h.check(test4.getRawQuery(), null);
       
    61 	URI test5 = new URI(TEST_URI_5);
       
    62 	h.check(test5.toString(), TEST_URI_5);
       
    63 	h.check(test5.getScheme(), null); // Scheme is different and can't be "".
       
    64 	URI test6 = new URI(TEST_URI_6);
       
    65 	h.check(test6.toString(), TEST_URI_6);
       
    66 	h.check(test6.getScheme(), null);
       
    67 	URI test7 = new URI(TEST_URI_7);
       
    68 	h.check(test7.toString(), TEST_URI_7);
       
    69 	h.check(test7.getRawAuthority(), "");
       
    70 	URI test8 = new URI(TEST_URI_8);
       
    71 	h.check(test8.toString(), TEST_URI_8);
       
    72 	h.check(test8.getRawAuthority(), null);
       
    73       }
       
    74     catch (URISyntaxException e)
       
    75       {
       
    76 	h.debug(e);
       
    77 	h.fail("Unexpected exception");
       
    78       }
       
    79   }
       
    80 }