tests/libjava-mauve/src/gnu/testlet/java/net/URLConnection/getRequestProperties.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 // Copyright (C) 2006 Free Software Foundation, Inc.
       
     4 // Contributed by David Daney (ddaney@avtrex.com)
       
     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, 51 Franklin Street, Fifth Floor,
       
    21 // Boston, MA  02110-1301  USA
       
    22 
       
    23 package gnu.testlet.java.net.URLConnection;
       
    24 
       
    25 import gnu.testlet.Testlet;
       
    26 import gnu.testlet.TestHarness;
       
    27 
       
    28 
       
    29 import java.io.IOException;
       
    30 import java.net.URL;
       
    31 import java.net.URLConnection;
       
    32 import java.util.Map;
       
    33 import java.util.List;
       
    34 
       
    35 public class getRequestProperties implements Testlet
       
    36 {
       
    37   public void test (TestHarness harness)
       
    38   {
       
    39     try
       
    40       {
       
    41         harness.checkPoint("getRequestProperties");
       
    42         URL url = new URL("http://foo.bar/blah/blah");
       
    43         URLConnection c = url.openConnection();
       
    44         
       
    45         c.addRequestProperty("mauve", "p1");
       
    46         c.addRequestProperty("mauve", "p2");
       
    47         
       
    48         Map m = c.getRequestProperties();
       
    49         
       
    50         List l = (List)m.get("mauve");
       
    51         
       
    52         harness.check(l.contains("p1"));
       
    53         harness.check(l.contains("p2"));
       
    54 
       
    55       }
       
    56     catch (ClassCastException cce)
       
    57       {
       
    58 	harness.debug(cce);
       
    59 	harness.fail("ClassCastException");
       
    60       }
       
    61     catch (IOException ioe)
       
    62       {
       
    63 	harness.debug(ioe);
       
    64 	harness.fail("IOException");
       
    65       }
       
    66     catch (Exception e)
       
    67       {
       
    68 	harness.debug(e);
       
    69 	harness.fail("Unexpected Exception");
       
    70       }
       
    71   }
       
    72 }